Files
Express_console_build/build/static/js/2638.f4999b6b.chunk.js
2026-05-25 16:32:21 +05:30

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