1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[9336],{29336:function(e,t,a){a.r(t);var n=a(74165),o=a(15861),r=a(1413),s=a(29439),i=a(47313),l=a(19860),c=a(69099),u=a(9019),d=a(42832),p=a(15103),m=a(16783),h=a(88797),g=a(51405),Z=a(47131),f=(a(72495),a(97316)),v=a(56573),x=(a(47168),a(11577)),j=a(17530),_=a(90842),y=a(58467),S=a(11198),b=a(7266),C=a(46417);t.default=function(){var e=localStorage.getItem("applocationid"),t=((0,l.Z)(),(0,i.useState)(void 0)),a=(0,s.Z)(t,2),k=a[0],w=(a[1],(0,i.useState)()),P=(0,s.Z)(w,2),E=(P[0],P[1]),A=(0,i.useState)(""),I=(0,s.Z)(A,2),L=(I[0],I[1],(0,i.useState)("")),z=(0,s.Z)(L,2),F=(z[0],z[1],(0,i.useState)("")),W=(0,s.Z)(F,2),N=W[0],D=W[1],H=(0,i.useState)(""),O=(0,s.Z)(H,2),B=O[0],M=O[1],R=(0,i.useState)(""),K=(0,s.Z)(R,2),T=(K[0],K[1],(0,i.useState)("")),U=(0,s.Z)(T,2),Y=(U[0],U[1],(0,i.useState)("")),q=(0,s.Z)(Y,2),V=q[0],G=q[1],J=(0,i.useState)(""),Q=(0,s.Z)(J,2),X=(Q[0],Q[1],(0,i.useState)({})),$=(0,s.Z)(X,2),ee=($[0],$[1],(0,i.useState)("")),te=(0,s.Z)(ee,2),ae=te[0],ne=te[1],oe=(0,i.useState)(""),re=(0,s.Z)(oe,2),se=re[0],ie=re[1],le=(0,i.useState)(""),ce=(0,s.Z)(le,2),ue=ce[0],de=ce[1],pe=(0,i.useState)({}),me=(0,s.Z)(pe,2),he=(me[0],me[1]),ge=(0,i.useState)(""),Ze=(0,s.Z)(ge,2),fe=Ze[0],ve=Ze[1],xe=(0,i.useState)(),je=(0,s.Z)(xe,2),_e=je[0],ye=je[1],Se=(0,i.useState)(),be=(0,s.Z)(Se,2),Ce=be[0],ke=be[1],we=(0,i.useState)(),Pe=(0,s.Z)(we,2),Ee=Pe[0],Ae=Pe[1],Ie=(0,i.useState)("Select Location"),Le=(0,s.Z)(Ie,2),ze=(Le[0],Le[1],(0,i.useState)("Select Location")),Fe=(0,s.Z)(ze,2),We=(Fe[0],Fe[1]),Ne=(0,i.useState)([]),De=(0,s.Z)(Ne,2),He=(De[0],De[1],localStorage.getItem("userid")),Oe=(0,i.useState)(!1),Be=(0,s.Z)(Oe,2),Me=(Be[0],Be[1],(0,i.useState)([])),Re=(0,s.Z)(Me,2),Ke=(Re[0],Re[1],(0,i.useState)(!1)),Te=(0,s.Z)(Ke,2),Ue=(Te[0],Te[1],(0,i.useState)(0)),Ye=(0,s.Z)(Ue,2),qe=Ye[0],Ve=(Ye[1],(0,i.useState)(!1)),Ge=(0,s.Z)(Ve,2),Je=(Ge[0],Ge[1],(0,i.useState)(localStorage.getItem("locationid"))),Qe=(0,s.Z)(Je,2),Xe=(Qe[0],Qe[1],(0,i.useState)("")),$e=(0,s.Z)(Xe,2),et=($e[0],$e[1],(0,i.useState)(!1)),tt=(0,s.Z)(et,2),at=(tt[0],tt[1],(0,i.useState)({})),nt=(0,s.Z)(at,2),ot=nt[0],rt=nt[1],st=(0,i.useState)({latitude:0,longitude:0}),it=(0,s.Z)(st,2),lt=it[0],ct=it[1],ut=(0,y.s0)();j.Z.setApiKey("AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8");var dt=(0,i.useState)(!1),pt=(0,s.Z)(dt,2),mt=pt[0],ht=pt[1];(0,i.useEffect)((function(){localStorage.getItem("tenantid")&&vt(localStorage.getItem("tenantid"))}),[]),(0,i.useEffect)((function(){if(fe){var 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(_e,Ce),radius:1e3*Ee}).getBounds()});t.addListener("place_changed",(function(){var e=t.getPlace();ve("".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()}),ct({latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()}),G("".concat(e.name," ").concat(e.formatted_address)),rt((0,r.Z)((0,r.Z)({},ot),{},{address:"".concat(e.name," ").concat(e.formatted_address)}));var 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((function(e){e.types.forEach((function(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}}))})),rt((0,r.Z)((0,r.Z)({},ot),{},{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)}))}}),[fe]);var gt=function(){var t=(0,o.Z)((0,n.Z)().mark((function t(){return(0,n.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return ht(!0),t.next=3,v.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocations/?applocationid=").concat(e)).then((function(e){console.log("getapplocations",e);var t=e.data.details[0],a=(t.opentime,t.closetime,t.latitude),n=t.longitude,o=t.radius;e.data.status&&(ye(a),ke(n),Ae(o),console.log("radius",o)),ht(!1)})).catch((function(e){console.log(e),ht(!1)}));case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();(0,i.useEffect)((function(){gt()}),[e]);var Zt=function(){var e=(0,o.Z)((0,n.Z)().mark((function e(){var t;return(0,n.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,v.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/partners/getlocations/?userid=").concat(He));case 3:t=e.sent,console.log("fetchAppLocations",t.data.details),We(t.data.details),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),console.log("locationRes",e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(){return e.apply(this,arguments)}}();(0,i.useEffect)((function(){Zt()}),[]);var ft=function(e){(0,_.yv)(e,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3})},vt=function(){var e=(0,o.Z)((0,n.Z)().mark((function e(t){return(0,n.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ht(!0),e.next=3,v.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantinfo/?tenantid=").concat(t)).then((function(e){console.log("fetchtenantinfo",e.data.details),e.data.status&&he(e.data.details),ht(!1)})).catch((function(e){console.log(e),ht(!1)}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();(0,i.useEffect)((function(){k&&E(URL.createObjectURL(k))}),[k]);var xt=function(){var t=(0,o.Z)((0,n.Z)().mark((function t(){var a;return(0,n.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a={applocationid:+e,tenantid:+localStorage.getItem("tenantid"),customerid:0,configid:1,firstname:ae,dialcode:"+91",contactno:N,email:B,doorno:se,address:ot.address,suburb:ot.suburb,city:ot.city,state:ot.state,postcode:ot.postcode,landmark:ue,latitude:lt.latitude.toString(),longitude:lt.longitude.toString(),profileimage:"",devicetype:"",deviceid:"",customertoken:"",primaryaddress:1},console.log(a),ht(!0),t.prev=3,t.next=6,v.Z.post("".concat("https://jupiter.nearle.app/live/api/v1","/customers/create"),a).then((function(e){console.log(e),e.data.status?((0,_.yv)(" Created Successfully ",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3}),ut("/customers")):"Customer Already available"==e.data.message&&(0,_.yv)("Customer Already available",{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3}),ht(!1)})).catch((function(e){console.log(e),ht(!1),(0,_.yv)(e.message,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3})}));case 6:t.next=12;break;case 8:t.prev=8,t.t0=t.catch(3),console.log(t.t0),ht(!1);case 12:case"end":return t.stop()}}),t,null,[[3,8]])})));return function(){return t.apply(this,arguments)}}();return(0,C.jsxs)(C.Fragment,{children:[mt&&(0,C.jsx)(x.Z,{}),(0,C.jsx)(b.Z,{title:"Create Customer",secondary:(0,C.jsx)(c.Z,{variant:"contained",color:"secondary",onClick:function(){return ut("/nearle/customers")},children:"Back"})}),(0,C.jsx)(f.Z,{children:(0,C.jsxs)(u.ZP,{container:!0,spacing:3,children:[(0,C.jsx)(u.ZP,{item:!0,xs:12,children:(0,C.jsxs)(u.ZP,{container:!0,spacing:3,children:[(0,C.jsx)(u.ZP,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-last-name",children:"Name"}),(0,C.jsx)(m.Z,{fullWidth:!0,id:"personal-last-name",placeholder:"Name",onChange:function(e){return ne(e.target.value)},value:ae,autoComplete:"off"})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-phone",children:"Phone Number"}),(0,C.jsxs)(d.Z,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[(0,C.jsx)(h.Z,{defaultValue:"+1",disabled:!0,sx:{cursor:"not-allowed"},children:(0,C.jsx)(g.Z,{value:"+1",children:"+91"})}),(0,C.jsx)(m.Z,{type:"number",id:"personal-phone",fullWidth:!0,placeholder:"Phone Number",onChange:function(e){e.target.value.toString().length<=10&&D(e.target.value)},value:N,autoComplete:"off",sx:{cursor:"not-allowed"}})]})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-email",children:"Email Address"}),(0,C.jsx)(m.Z,{type:"email",fullWidth:!0,id:"personal-email",placeholder:"Email Address",onChange:function(e){return M(e.target.value)},value:B,autoComplete:"off"})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-location",children:"Door No"}),(0,C.jsx)(m.Z,{fullWidth:!0,id:"personal-location",placeholder:"Door No",onChange:function(e){return ie(e.target.value)},value:se,autoComplete:"off"})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-email",children:" Address"}),(0,C.jsx)(m.Z,{variant:"outlined",id:"addressAuto1",fullWidth:!0,value:fe,onChange:function(e){return ve(e.target.value)},InputProps:{endAdornment:(0,C.jsx)(Z.Z,{onClick:function(){ve(""),rt((0,r.Z)((0,r.Z)({},ot),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),ct({latitude:0,longitude:0})},size:"small",children:(0,C.jsx)(S.Z,{})})}})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-location",children:"Location"}),(0,C.jsx)(m.Z,{fullWidth:!0,id:"personal-location",placeholder:"Location",onChange:function(e){return rt((0,r.Z)((0,r.Z)({},ot),{},{suburb:e.target.value}))},value:ot.suburb,autoComplete:"off"})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-zipcode",children:"City"}),(0,C.jsx)(m.Z,{fullWidth:!0,id:"personal-zipcode",placeholder:"City",onChange:function(e){return rt((0,r.Z)((0,r.Z)({},ot),{},{city:e.target.value}))},value:ot.city,autoComplete:"off"})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-location",children:"State"}),(0,C.jsx)(m.Z,{fullWidth:!0,id:"personal-location",placeholder:"State",onChange:function(e){return rt((0,r.Z)((0,r.Z)({},ot),{},{state:e.target.value}))},value:ot.state,autoComplete:"off"})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,sm:6,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-zipcode",children:"Post Code"}),(0,C.jsx)(m.Z,{fullWidth:!0,type:"number",id:"personal-zipcode",placeholder:"Zipcode",onChange:function(e){return rt((0,r.Z)((0,r.Z)({},ot),{},{postcode:e.target.value}))},value:ot.postcode,autoComplete:"off"})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,children:(0,C.jsxs)(d.Z,{spacing:1.25,children:[(0,C.jsx)(p.Z,{htmlFor:"personal-email",children:"Landmark"}),(0,C.jsx)(m.Z,{type:"email",fullWidth:!0,id:"personal-email",placeholder:"Landmark",onChange:function(e){return de(e.target.value)},value:ue,autoComplete:"off"})]})})]})}),(0,C.jsx)(u.ZP,{item:!0,xs:12,children:(0,C.jsx)(d.Z,{direction:"row",justifyContent:"flex-end",alignItems:"center",spacing:2,children:(0,C.jsx)(c.Z,{variant:"contained",onClick:function(){""===e?ft("Select Applocation "):""===qe?ft("Select Tenant"):""===ae?ft("Enter Name"):""===N?ft("Enter Mobile Number "):""===V?ft("Enter Address "):""===ot.city?ft("Enter City "):""===ot.state?ft("Enter State "):""===ot.suburb?ft("Enter location "):""===ot.postcode?ft("Enter Post Code "):""===ue?ft("Enter Land Mark "):""===ot.latitude?ft("Invalid latitude "):""===ot.longitude?ft("Invaiid Longitude "):xt()},children:"Create"})})})]})})]})}},7266:function(e,t,a){var n=a(1413),o=(a(47313),a(19860)),r=a(9019),s=a(56104),i=a(42832),l=a(61113),c=a(46417);t.Z=function(e){var t=e.title,a=e.secondary,u=e.sx,d=(0,o.Z)();return(0,c.jsx)(r.ZP,{container:!0,spacing:2,children:(0,c.jsx)(s.Z,{sx:(0,n.Z)({position:"sticky",top:"60px",bgcolor:d.palette.background.default,zIndex:1,width:"100%"},u),children:(0,c.jsx)(r.ZP,{item:!0,xs:12,children:(0,c.jsxs)(i.Z,{direction:"row",justifyContent:"space-between",sx:{p:1,flexWrap:"wrap"},children:[(0,c.jsx)(l.Z,{variant:"h3",children:t}),a&&a]})})})})}}}]); |