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