1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[4793],{20466:(e,t,a)=>{a.d(t,{k:()=>n});var o=a(8881);const n=(e,t,a)=>(0,o.M8)(e,{variant:t,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:a||2e3})},23266:(e,t,a)=>{a.d(t,{A:()=>w});var o=a(98587),n=a(58168),s=a(9950),i=a(72004),l=a(3484),r=a(99269),c=a(59254),d=a(19608),u=a(18463),p=a(13372),m=a(24184),g=a(79044),h=a(31506),A=a(40777),v=a(92455),x=a(88543),f=a(45558),b=a(1614);function y(e){return(0,b.Ay)("MuiMenuItem",e)}const j=(0,f.A)("MuiMenuItem",["root","focusVisible","dense","disabled","divider","gutters","selected"]);var C=a(44414);const _=["autoFocus","component","dense","divider","disableGutters","focusVisibleClassName","role","tabIndex","className"],S=(0,c.Ay)(m.A,{shouldForwardProp:e=>(0,d.A)(e)||"classes"===e,name:"MuiMenuItem",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:a}=e;return[t.root,a.dense&&t.dense,a.divider&&t.divider,!a.disableGutters&&t.gutters]}})((e=>{let{theme:t,ownerState:a}=e;return(0,n.A)({},t.typography.body1,{display:"flex",justifyContent:"flex-start",alignItems:"center",position:"relative",textDecoration:"none",minHeight:48,paddingTop:6,paddingBottom:6,boxSizing:"border-box",whiteSpace:"nowrap"},!a.disableGutters&&{paddingLeft:16,paddingRight:16},a.divider&&{borderBottom:"1px solid ".concat((t.vars||t).palette.divider),backgroundClip:"padding-box"},{"&:hover":{textDecoration:"none",backgroundColor:(t.vars||t).palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}},["&.".concat(j.selected)]:{backgroundColor:t.vars?"rgba(".concat(t.vars.palette.primary.mainChannel," / ").concat(t.vars.palette.action.selectedOpacity,")"):(0,r.X4)(t.palette.primary.main,t.palette.action.selectedOpacity),["&.".concat(j.focusVisible)]:{backgroundColor:t.vars?"rgba(".concat(t.vars.palette.primary.mainChannel," / calc(").concat(t.vars.palette.action.selectedOpacity," + ").concat(t.vars.palette.action.focusOpacity,"))"):(0,r.X4)(t.palette.primary.main,t.palette.action.selectedOpacity+t.palette.action.focusOpacity)}},["&.".concat(j.selected,":hover")]:{backgroundColor:t.vars?"rgba(".concat(t.vars.palette.primary.mainChannel," / calc(").concat(t.vars.palette.action.selectedOpacity," + ").concat(t.vars.palette.action.hoverOpacity,"))"):(0,r.X4)(t.palette.primary.main,t.palette.action.selectedOpacity+t.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:t.vars?"rgba(".concat(t.vars.palette.primary.mainChannel," / ").concat(t.vars.palette.action.selectedOpacity,")"):(0,r.X4)(t.palette.primary.main,t.palette.action.selectedOpacity)}},["&.".concat(j.focusVisible)]:{backgroundColor:(t.vars||t).palette.action.focus},["&.".concat(j.disabled)]:{opacity:(t.vars||t).palette.action.disabledOpacity},["& + .".concat(A.A.root)]:{marginTop:t.spacing(1),marginBottom:t.spacing(1)},["& + .".concat(A.A.inset)]:{marginLeft:52},["& .".concat(x.A.root)]:{marginTop:0,marginBottom:0},["& .".concat(x.A.inset)]:{paddingLeft:36},["& .".concat(v.A.root)]:{minWidth:36}},!a.dense&&{[t.breakpoints.up("sm")]:{minHeight:"auto"}},a.dense&&(0,n.A)({minHeight:32,paddingTop:4,paddingBottom:4},t.typography.body2,{["& .".concat(v.A.root," svg")]:{fontSize:"1.25rem"}}))})),w=s.forwardRef((function(e,t){const a=(0,u.b)({props:e,name:"MuiMenuItem"}),{autoFocus:r=!1,component:c="li",dense:d=!1,divider:m=!1,disableGutters:A=!1,focusVisibleClassName:v,role:x="menuitem",tabIndex:f,className:b}=a,j=(0,o.A)(a,_),w=s.useContext(p.A),k=s.useMemo((()=>({dense:d||w.dense||!1,disableGutters:A})),[w.dense,d,A]),I=s.useRef(null);(0,g.A)((()=>{r&&I.current&&I.current.focus()}),[r]);const M=(0,n.A)({},a,{dense:k.dense,divider:m,disableGutters:A}),O=(e=>{const{disabled:t,dense:a,divider:o,disableGutters:s,selected:i,classes:r}=e,c={root:["root",a&&"dense",t&&"disabled",!s&&"gutters",o&&"divider",i&&"selected"]},d=(0,l.A)(c,y,r);return(0,n.A)({},r,d)})(a),N=(0,h.A)(I,t);let E;return a.disabled||(E=void 0!==f?f:-1),(0,C.jsx)(p.A.Provider,{value:k,children:(0,C.jsx)(S,(0,n.A)({ref:N,role:x,tabIndex:E,component:c,focusVisibleClassName:(0,i.A)(O.focusVisible,v),className:(0,i.A)(O.root,b)},j,{ownerState:M,classes:O}))})}))},59212:(e,t,a)=>{a.d(t,{A:()=>p});var o=a(89379),n=a(9950),s=a(93230),i=a(41413),l=a(77922),r=a(29925),c=a(26910),d=a(31222),u=a(44414);const p=(0,n.forwardRef)(((e,t)=>{let{setAppId:a,setLocoName:p,setPage:m,sx:g,textfeildSx:h,textfieldSx:A,pill:v=!1,accentColor:x="#6366f1",icon:f,placeholder:b="Select Zone",paperComponent:y}=e;const[j,C]=(0,n.useState)(JSON.parse(localStorage.getItem("applocations")||"[]"));(0,n.useEffect)((()=>{0===j.length&&(async()=>{try{const e=localStorage.getItem("userid");if(!e)return;const t=await c.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/partners/getlocations/?userid=").concat(e));if(t.data.status){const e=[...t.data.details,{locationname:"All",applocationid:0}];localStorage.setItem("applocations",JSON.stringify(e)),C(e)}}catch(e){console.error("Error fetching locations in LocationAutocomplete:",e)}})()}),[j.length]);const _=e=>"".concat(x).concat(e),S=_("08"),w=_("26"),k=_("55"),I=_("18"),M=v?{cursor:"pointer","& .MuiOutlinedInput-root":{borderRadius:"999px",bgcolor:S,fontWeight:600,color:"#0f172a",paddingRight:"8px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s, background-color 0.2s","& fieldset":{borderColor:k,borderWidth:1.5},"&:hover fieldset":{borderColor:x},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(w)},"&.Mui-focused fieldset":{borderColor:x,borderWidth:2}},"& .MuiAutocomplete-endAdornment .MuiSvgIcon-root":{color:x}}:{},O=v&&(0,u.jsx)(s.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25,flexShrink:0},children:(0,u.jsx)(i.A,{sx:{width:24,height:24,bgcolor:I,color:x,transition:"background-color 0.15s, color 0.15s"},children:f||(0,u.jsx)(d.HPi,{size:14})})});return(0,u.jsx)(l.A,{id:"location-autocomplete",options:j||[],getOptionLabel:e=>{var t;return null!==(t=null===e||void 0===e?void 0:e.locationname)&&void 0!==t?t:""},PaperComponent:y,sx:(0,o.A)({},g),onChange:(e,t,o)=>{"clear"===o?(null===a||void 0===a||a(0),null===p||void 0===p||p(""),null===m||void 0===m||m(0)):t&&(null===a||void 0===a||a(t.applocationid),null===p||void 0===p||p(t.locationname),null===m||void 0===m||m(0))},renderInput:e=>v?(0,u.jsx)(r.A,(0,o.A)((0,o.A)({},e),{},{inputRef:t,placeholder:b,InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:O}),sx:(0,o.A)((0,o.A)({},M),A||h||{})})):(0,u.jsx)(r.A,(0,o.A)((0,o.A)({},e),{},{inputRef:t,label:"Select Zones",sx:(0,o.A)({},A||h||{})}))})}))},94793:(e,t,a)=>{a.r(t),a.d(t,{default:()=>k});var o=a(89379),n=a(9950),s=a(14857),i=a(47223),l=a(60899),r=a(93230),c=a(82053),d=a(77922),u=a(29925),p=a(19647),m=a(70006),g=a(23266),h=a(25333),A=a(82223),v=a(50027),x=a(26910),f=a(52351),b=a(99459),y=a(8881),j=a(28429),C=a(96319),_=a(59212),S=a(20466),w=a(44414);const k=()=>{const e=(0,s.A)(),t=(0,i.A)(e.breakpoints.down("md")),[a,k]=(0,n.useState)(0),I=(0,n.useRef)(null),[M,O]=(0,n.useState)(""),[N,E]=(0,n.useState)(""),[L,F]=(0,n.useState)(""),[W,z]=(0,n.useState)(""),[P,H]=(0,n.useState)(""),[R,D]=(0,n.useState)(""),[B,V]=(0,n.useState)(""),[G,T]=(0,n.useState)(),[X,Z]=(0,n.useState)(),[J,K]=(0,n.useState)(),[Y,q]=(0,n.useState)("Select Location"),[Q,U]=(0,n.useState)([]),[$,ee]=(0,n.useState)(0),[te,ae]=(0,n.useState)({}),[oe,ne]=(0,n.useState)({latitude:0,longitude:0}),[se,ie]=(0,n.useState)(!1),le=(0,j.Zp)();b.A.setApiKey("AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8"),(0,n.useEffect)((()=>{if(B){const e=document.getElementById("addressAuto1"),t=new window.google.maps.places.Autocomplete(e,{strictBounds:!0,bounds:new window.google.maps.Circle({center:new window.google.maps.LatLng(G,X),radius:1e3*J}).getBounds()});t.addListener("place_changed",(()=>{const e=t.getPlace();V("".concat(e.name,", ").concat(e.formatted_address)),console.log("new place",e),console.log(" pick (new place) lat lng",{lat:e.geometry.location.lat(),lng:e.geometry.location.lng()}),ne({latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()}),F("".concat(e.name," ").concat(e.formatted_address)),ae((0,o.A)((0,o.A)({},te),{},{address:"".concat(e.name," ").concat(e.formatted_address)}));const a={address:"".concat(e.name," ").concat(e.formatted_address),street_number:"",route:"",locality:"",sublocality_level_1:"",administrative_area_level_3:"",administrative_area_level_1:"",country:"",postal_code:""};e.address_components.forEach((e=>{e.types.forEach((t=>{switch(t){case"street_number":a.street_number=e.long_name;break;case"route":a.route=e.long_name;break;case"locality":a.locality=e.long_name;break;case"sublocality_level_1":a.sublocality_level_1=e.long_name;break;case"administrative_area_level_3":a.administrative_area_level_3=e.long_name;break;case"administrative_area_level_1":a.administrative_area_level_1=e.long_name;break;case"country":a.country=e.long_name;break;case"postal_code":a.postal_code=e.long_name}}))})),ae((0,o.A)((0,o.A)({},te),{},{address:a.address,doorno:"".concat(a.street_number," ").concat(a.route),suburb:a.administrative_area_level_3,city:a.locality,state:a.administrative_area_level_1,postcode:a.postal_code,latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()})),console.log("Pick Address:",a)}))}}),[B]);(0,n.useEffect)((()=>{a&&(async()=>{ie(!0),await x.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocations/?applocationid=").concat(a)).then((e=>{console.log("getapplocations",e);const{latitude:t,longitude:a,radius:o}=e.data.details[0];e.data.status&&(T(t),Z(a),K(o),console.log("radius",o)),ie(!1)})).catch((e=>{console.log(e),ie(!1)}))})()}),[a]);(0,n.useEffect)((()=>{a&&(async e=>{ie(!0),await x.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenants/?applocationid=").concat(e,"&status=active")).then((e=>{if(console.log(e),e.data.status){let t=[];e.data.details.map((e=>{t.push((0,o.A)((0,o.A)({},e),{},{label:"".concat(e.tenantname)}))})),U(t)}ie(!1)})).catch((e=>{console.log(e),ie(!1)}))})(a)}),[a]);const re=e=>{(0,y.M8)(e,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3})};return(0,w.jsxs)(w.Fragment,{children:[se&&(0,w.jsx)(f.A,{}),(0,w.jsx)(l.Ay,{item:!0,xs:12,sx:{mb:2},children:(0,w.jsx)(r.A,{direction:"row",justifyContent:"space-between",alignItems:"center",children:(0,w.jsx)(c.A,{variant:"h3",children:"Create Customer"})})}),(0,w.jsx)(v.A,{sx:{p:{xs:1.5,md:3}},children:(0,w.jsxs)(l.Ay,{container:!0,spacing:{xs:2,md:3},children:[(0,w.jsx)(l.Ay,{item:!0,xs:12,children:(0,w.jsxs)(l.Ay,{container:!0,spacing:{xs:2,md:3},children:[(0,w.jsx)(l.Ay,{item:!0,xs:12,md:6,children:(0,w.jsx)(_.A,{ref:I,locaName:Y,setAppId:k,setLocoName:q,sx:{}})}),(0,w.jsxs)(l.Ay,{item:!0,xs:12,md:6,children:[(0,w.jsx)(d.A,{fullWidth:!0,disabled:0==a,id:"free-solo-demo",sx:{},options:Q||[],renderInput:e=>(0,w.jsx)(u.A,(0,o.A)((0,o.A)({},e),{},{label:"Choose Client",focused:!0})),onChange:(e,t,a)=>{t?(console.log("Client",t),(async e=>{try{const t=await x.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantlocations/?tenantid=").concat(e));console.log("gettenantlocations",t.data.details),t.data.details.length}catch(t){console.log("gettenantlocations",t)}})(t.tenantid),ee(t.tenantid)):(setClientinfo({}),setTenantid(""))}})," "]}),(0,w.jsx)(l.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-last-name",children:"Name"}),(0,w.jsx)(u.A,{fullWidth:!0,id:"personal-last-name",placeholder:"Name",onChange:e=>z(e.target.value),value:W,autoComplete:"off"})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-phone",children:"Phone Number"}),(0,w.jsxs)(r.A,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[(0,w.jsx)(m.A,{defaultValue:"+1",disabled:!0,sx:{cursor:"not-allowed"},children:(0,w.jsx)(g.A,{value:"+1",children:"+91"})}),(0,w.jsx)(u.A,{type:"number",id:"personal-phone",fullWidth:!0,placeholder:"Phone Number",onChange:e=>{e.target.value.toString().length<=10&&O(e.target.value)},value:M,autoComplete:"off",sx:{cursor:"not-allowed"}})]})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-email",children:"Email "}),(0,w.jsx)(u.A,{type:"email",fullWidth:!0,id:"personal-email",placeholder:"Email ",onChange:e=>E(e.target.value),value:N,autoComplete:"off"})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-location",children:"Door No"}),(0,w.jsx)(u.A,{fullWidth:!0,id:"personal-location",placeholder:"Door No",onChange:e=>H(e.target.value),value:P,autoComplete:"off"})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-email",children:" Address"}),(0,w.jsx)(u.A,{variant:"outlined",id:"addressAuto1",fullWidth:!0,value:B,onChange:e=>{a?a&&V(e.target.value):(0,S.k)("Select Location First","warning",3e3)},InputProps:{endAdornment:(0,w.jsx)(h.A,{onClick:()=>{V(""),ae((0,o.A)((0,o.A)({},te),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),ne({latitude:0,longitude:0})},size:"small",children:(0,w.jsx)(C.A,{})})}})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-location",children:"Location"}),(0,w.jsx)(u.A,{fullWidth:!0,id:"personal-location",placeholder:"Location",onChange:e=>ae((0,o.A)((0,o.A)({},te),{},{suburb:e.target.value})),value:te.suburb,autoComplete:"off"})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-zipcode",children:"City"}),(0,w.jsx)(u.A,{fullWidth:!0,id:"personal-zipcode",placeholder:"City",onChange:e=>ae((0,o.A)((0,o.A)({},te),{},{city:e.target.value})),value:te.city,autoComplete:"off"})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-location",children:"State"}),(0,w.jsx)(u.A,{fullWidth:!0,id:"personal-location",placeholder:"State",onChange:e=>ae((0,o.A)((0,o.A)({},te),{},{state:e.target.value})),value:te.state,autoComplete:"off"})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-zipcode",children:"Post Code"}),(0,w.jsx)(u.A,{fullWidth:!0,type:"number",id:"personal-zipcode",placeholder:"Zipcode",onChange:e=>ae((0,o.A)((0,o.A)({},te),{},{postcode:e.target.value})),value:te.postcode,autoComplete:"off"})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,children:(0,w.jsxs)(r.A,{spacing:1.25,children:[(0,w.jsx)(p.A,{htmlFor:"personal-email",children:"Landmark"}),(0,w.jsx)(u.A,{type:"email",fullWidth:!0,id:"personal-email",placeholder:"Landmark",onChange:e=>D(e.target.value),value:R,autoComplete:"off"})]})})]})}),(0,w.jsx)(l.Ay,{item:!0,xs:12,children:(0,w.jsx)(r.A,{direction:{xs:"column",sm:"row"},justifyContent:"flex-end",alignItems:{xs:"stretch",sm:"center"},spacing:2,children:(0,w.jsx)(A.A,{variant:"contained",fullWidth:t,onClick:()=>{""===a?re("Select Applocation "):""===$?re("Select Tenant"):""===W?re("Enter Name"):""===M?re("Enter Mobile Number "):""===L?re("Enter Address "):""===te.city?re("Enter City "):""===te.state?re("Enter State "):""===te.suburb?re("Enter location "):""===te.postcode?re("Enter Post Code "):""===R?re("Enter Land Mark "):""===te.latitude?re("Invalid latitude "):""===te.longitude?re("Invaiid Longitude "):(async()=>{let e={applocationid:+a,tenantid:+$,customerid:0,configid:1,firstname:W,dialcode:"+91",contactno:M,email:N,doorno:P,address:te.address,suburb:te.suburb,city:te.city,state:te.state,postcode:te.postcode,landmark:R,latitude:oe.latitude.toString(),longitude:oe.longitude.toString(),profileimage:"",devicetype:"",deviceid:"",customertoken:"",primaryaddress:1};console.log(e),ie(!0);try{await x.A.post("".concat("https://jupiter.nearle.app/live/api/v1","/customers/create"),e).then((e=>{console.log(e),e.data.status?((0,y.M8)(" Created Successfully ",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3}),le("/nearle/customers")):"Customer Already available"==e.data.message&&(0,y.M8)("Customer Already available",{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3}),ie(!1)})).catch((e=>{console.log(e),ie(!1),(0,y.M8)(e.message,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3})}))}catch(t){console.log(t),ie(!1)}})()},children:"Create"})})})]})})]})}}}]); |