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