1 line
7.4 KiB
JavaScript
1 line
7.4 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[238],{40238:(e,t,a)=>{a.r(t),a.d(t,{default:()=>b});var s=a(9950),l=a(14857),n=a(47223),o=a(16491),i=a(60899),r=a(93230),c=a(82053),d=a(19647),h=a(29925),m=a(70006),u=a(23266),p=a(82223),g=a(50027),x=a(26910),A=a(56713),f=a(52351),j=a(99459),y=a(8881),v=a(28429),C=a(44414);const b=()=>{const[e,t]=(0,s.useState)(""),[a,b]=(0,s.useState)(""),[S,_]=(0,s.useState)(""),[F,k]=(0,s.useState)(""),[I,w]=(0,s.useState)(""),[z,W]=(0,s.useState)(""),[H,M]=(0,s.useState)(""),[N,D]=(0,s.useState)({}),[O,E]=(0,s.useState)(""),[K,L]=(0,s.useState)(""),[P,R]=(0,s.useState)(""),[Y,q]=(0,s.useState)({}),T=(0,v.Zp)(),U=(0,l.A)(),Z=(0,n.A)(U.breakpoints.down("md"));j.A.setApiKey("AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8");const[V,B]=(0,s.useState)(!1);(0,s.useEffect)((()=>{localStorage.getItem("tenantid")&&J(localStorage.getItem("tenantid"))}),[]),(0,s.useEffect)((()=>{try{j.A.fromAddress(I).then((e=>{if("OK"==e.status){const{lat:t,lng:a}=e.results[0].geometry.location;D({lat:t,lng:a}),console.log(e)}}),(e=>{console.log(e)}))}catch(e){console.log(e)}}),[I]);const G=e=>{(0,y.M8)(e,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3})},J=async e=>{B(!0),await x.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantinfo/?tenantid=").concat(e)).then((e=>{console.log(e),e.data.status&&q(e.data.details),B(!1)})).catch((e=>{console.log(e),B(!1)}))};(0,s.useEffect)((()=>{selectedImage&&setAvatar(URL.createObjectURL(selectedImage))}),[selectedImage]);const{ref:Q}=(0,A.usePlacesWidget)({apiKey:"AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8",onPlaceSelected:e=>{let t,a,s,l;console.log(e),w(e.formatted_address);for(let n=0;n<e.address_components.length;n++)for(let o=0;o<e.address_components[n].types.length;o++)switch(e.address_components[n].types[o]){case"locality":t=e.address_components[n].long_name;break;case"administrative_area_level_1":s=e.address_components[n].long_name;break;case"postal_code":a=e.address_components[n].long_name;break;case"sublocality":l=e.address_components[n].long_name}_(t||""),W(s||""),k(a||""),M(l||"")},options:{types:["address"]}});return(0,C.jsxs)(C.Fragment,{children:[V&&(0,C.jsx)(f.A,{}),(0,C.jsxs)(o.A,{sx:{p:{xs:1.5,md:3}},children:[(0,C.jsx)(i.Ay,{item:!0,xs:12,sx:{mb:2},children:(0,C.jsx)(r.A,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{xs:"flex-start",sm:"center"},spacing:1,children:(0,C.jsx)(c.A,{variant:"h3",children:"Create Rider"})})}),(0,C.jsx)(g.A,{children:(0,C.jsxs)(i.Ay,{container:!0,spacing:3,children:[(0,C.jsx)(i.Ay,{item:!0,xs:12,children:(0,C.jsx)(g.A,{sx:{height:"100%"},children:(0,C.jsxs)(i.Ay,{container:!0,spacing:3,children:[(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-last-name",children:"Admin Name"}),(0,C.jsx)(h.A,{fullWidth:!0,id:"personal-last-name",placeholder:"Name",onChange:e=>E(e.target.value),value:O,autoComplete:"off"})]})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6}),(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-phone",children:"Phone Number"}),(0,C.jsxs)(r.A,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[(0,C.jsx)(m.A,{defaultValue:"+1",disabled:!0,sx:{cursor:"not-allowed"},children:(0,C.jsx)(u.A,{value:"+1",children:"+91"})}),(0,C.jsx)(h.A,{type:"number",id:"personal-phone",fullWidth:!0,placeholder:"Phone Number",onChange:e=>{e.target.value.toString().length<=10&&t(e.target.value)},value:e,autoComplete:"off",sx:{cursor:"not-allowed"}})]})]})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-email",children:"Email Address"}),(0,C.jsx)(h.A,{type:"email",fullWidth:!0,id:"personal-email",placeholder:"Email Address",onChange:e=>b(e.target.value),value:a,autoComplete:"off"})]})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-address",children:"Address"}),(0,C.jsx)(h.A,{fullWidth:!0,id:"personal-address",placeholder:"Address",value:I,onChange:e=>w(e.target.value),inputRef:Q})]})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-location",children:"Suburb"}),(0,C.jsx)(h.A,{fullWidth:!0,id:"personal-location",placeholder:"Location",onChange:e=>M(e.target.value),value:H,autoComplete:"off"})]})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-zipcode",children:"City"}),(0,C.jsx)(h.A,{fullWidth:!0,id:"personal-zipcode",placeholder:"City",onChange:e=>_(e.target.value),value:S,autoComplete:"off"})]})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-location",children:"State"}),(0,C.jsx)(h.A,{fullWidth:!0,id:"personal-location",placeholder:"State",onChange:e=>W(e.target.value),value:z,autoComplete:"off"})]})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-zipcode",children:"Post Code"}),(0,C.jsx)(h.A,{fullWidth:!0,type:"number",id:"personal-zipcode",placeholder:"Zipcode",onChange:e=>k(e.target.value),value:F,autoComplete:"off"})]})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-location",children:"Door No"}),(0,C.jsx)(h.A,{fullWidth:!0,id:"personal-location",placeholder:"Door No",onChange:e=>L(e.target.value),value:K,autoComplete:"off"})]})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(r.A,{spacing:1.25,children:[(0,C.jsx)(d.A,{htmlFor:"personal-email",children:"Landmark"}),(0,C.jsx)(h.A,{type:"email",fullWidth:!0,id:"personal-email",placeholder:"Landmark",onChange:e=>R(e.target.value),value:P,autoComplete:"off"})]})})]})})}),(0,C.jsx)(i.Ay,{item:!0,xs:12,children:(0,C.jsx)(r.A,{direction:{xs:"column",sm:"row"},justifyContent:"flex-end",alignItems:{xs:"stretch",sm:"center"},spacing:2,children:(0,C.jsx)(p.A,{variant:"contained",onClick:()=>(async()=>{if(console.log("res",businessname,businessno,e,a,I,S,F),O)if(e)if(a)if(I)if(S)if(F)if(H)if(N.lat&&N.lng){let s={customerid:0,configid:1,firstname:O,applocationid:Y.applolcationid,profileimage:"",dialcode:"+91",contactno:e,devicetype:"",deviceid:"",customertoken:"",address:I,suburb:H,city:S,state:z,postcode:F,landmark:P,doorno:K,latitude:N.lat.toString(),longitude:N.lng.toString(),tenantid:parseInt(localStorage.getItem("tenantid")),email:a};console.log(s),B(!0);try{await x.A.post("".concat("https://jupiter.nearle.app/live/api/v1","/customers/create"),s).then((e=>{console.log(e),e.data.status?((0,y.M8)(" Created Successfully ",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3}),T("/clients")):"Customer Already available"==e.data.message&&(0,y.M8)("Customer Already available",{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3}),B(!1)})).catch((e=>{console.log(e),B(!1),(0,y.M8)(e.message,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3})}))}catch(t){console.log(t),B(!1)}}else G("Choose valid address");else G("Fill suburb");else G("Fill post code");else G("Fill City");else G("Fill Address");else G("Fill emailaddress");else G("Fill Mobile Number");else G("Fill Full name")})(),fullWidth:Z,children:"Create"})})})]})})]})]})}}}]); |