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

1 line
34 KiB
JavaScript

"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[987],{20466:(e,t,a)=>{a.d(t,{k:()=>o});var n=a(8881);const o=(e,t,a)=>(0,n.M8)(e,{variant:t,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:a||2e3})},80987:(e,t,a)=>{a.r(t),a.d(t,{default:()=>Z});var n=a(89379),o=a(9950),s=a(60899),i=a(93230),l=a(82053),r=a(77922),c=a(29925),d=a(2046),u=a(82223),m=a(25333),p=a(96557),g=a(16497),h=a(93038),x=a(25277),A=a(37324),v=a(46639),y=a(40033),j=a(25979),f=a(2660),b=a(74745),k=a(28170),S=a(79739),C=a(96319),_=a(13838),w=a(54826),Y=a(85527),D=a(43302),P=a(7762),M=a(28429),I=a(63057),L=a(26910),E=a(14857),H=a(99459),W=a(52351),N=(a(172),a(50027)),z=a(30633),R=a(81831),T=a(95359),B=a(96583),O=a(4159),F=a.n(O),q=a(8881),U=a(60767),K=a(87942),V=a(76746),$=a(20466),Q=a(44414),X=a(36220);F().extend(X);const Z=()=>{H.A.setApiKey("AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8");const e=o.useRef(!1),t=(0,M.Zp)(),a=(0,E.A)(),O=(0,o.useRef)(null),X=(0,o.useRef)(null),[Z,G]=o.useState(""),[J,ee]=o.useState(""),[te,ae]=(0,o.useState)(localStorage.getItem("locationid")),[ne,oe]=(0,o.useState)(!1),se=(0,o.useRef)(null),ie=(0,o.useRef)(null),le=(0,o.useRef)(null),[re,ce]=(0,o.useState)(0),[de,ue]=(0,o.useState)(!1),[me,pe]=(0,o.useState)([]),[ge,he]=(0,o.useState)(F()().format("MM-DD-YYYY")),[xe,Ae]=(0,o.useState)(),[ve,ye]=(0,o.useState)(),[je,fe]=(0,o.useState)([]),[be,ke]=(0,o.useState)(""),[Se,Ce]=(0,o.useState)(!1),[_e,we]=(0,o.useState)(!1),[Ye,De]=(0,o.useState)(!1),[Pe,Me]=(0,o.useState)(""),[Ie,Le]=(0,o.useState)(),[Ee,He]=(0,o.useState)({}),[We,Ne]=(0,o.useState)(""),[ze,Re]=(0,o.useState)([]),[Te,Be]=(0,o.useState)({latitude:0,longitude:0}),[Oe,Fe]=(0,o.useState)({latitude:0,longitude:0}),[qe,Ue]=(0,o.useState)(!1),[Ke,Ve]=(0,o.useState)(0),[$e,Qe]=(0,o.useState)(0),[Xe,Ze]=(0,o.useState)(0),[Ge,Je]=(0,o.useState)(0),[et,tt]=(0,o.useState)(0),[at,nt]=(0,o.useState)([]),[ot,st]=(0,o.useState)("Select "),[it,lt]=(0,o.useState)(0),[rt,ct]=(0,o.useState)(""),[dt,ut]=(0,o.useState)(0),[mt,pt]=(0,o.useState)(0),[gt,ht]=(0,o.useState)(null),[xt,At]=(0,o.useState)(!1),[vt,yt]=(0,o.useState)(""),[jt,ft]=(0,o.useState)([]),[bt,kt]=(0,o.useState)(null),[St,Ct]=(0,o.useState)(null),[_t,wt]=(0,o.useState)(null),[Yt,Dt]=(0,o.useState)(0),[Pt,Mt]=(0,o.useState)(0),[It,Lt]=(0,o.useState)(0),[Et,Ht]=(0,o.useState)([]),[Wt,Nt]=(0,o.useState)(),[zt,Rt]=(0,o.useState)(),[Tt,Bt]=(0,o.useState)(),[Ot,Ft]=(0,o.useState)("Select Location"),qt=localStorage.getItem("userid"),[Ut,Kt]=(0,o.useState)(0),[Vt,$t]=(0,o.useState)(0),[Qt,Xt]=(0,o.useState)(0),[Zt,Gt]=(0,o.useState)(0),[Jt,ea]=(0,o.useState)(),[ta,aa]=(0,o.useState)(),[na,oa]=(0,o.useState)(!1),[sa,ia]=(0,o.useState)(!1),[la,ra]=(0,o.useState)(0),[ca,da]=(0,o.useState)(0),[ua,ma]=(0,o.useState)(1),[pa,ga]=(0,o.useState)(null),[ha,xa]=(0,o.useState)(null),[Aa,va]=(0,o.useState)(null),[ya,ja]=(0,o.useState)(null);(0,o.useEffect)((()=>{console.log("pickupSlotsList",Aa),console.log("pickupSlot",ya)}),[Aa,ya]),"undefined"===typeof window||e.current||(document.querySelector("#google-maps")||function(e,t,a){if(!t)return;const n=document.createElement("script");n.setAttribute("async",""),n.setAttribute("id",a),n.src=e,t.appendChild(n)}("https://maps.googleapis.com/maps/api/js?key=".concat("AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8","&libraries=places&location=10.3656,77.9690&radius=50000&components=country:IN&strictbounds=true"),document.querySelector("head"),"google-maps"),e.current=!0);(0,o.useEffect)((()=>{(async()=>{try{const e=await L.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/partners/getlocations/?userid=").concat(qt));console.log("fetchAppLocations",e.data.details),Ft(e.data.details)}catch(e){console.log("locationRes",e)}})()}),[]);(0,o.useEffect)((()=>{re&&(async()=>{we(!0),await L.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenants/?applocationid=").concat(re,"&status=active")).then((e=>{if(console.log(e),e.data.status){let t=[];e.data.details.map((e=>{t.push((0,n.A)((0,n.A)({},e),{},{label:"".concat(e.tenantname)}))})),Re(t)}we(!1)})).catch((e=>{console.log(e),we(!1)}))})()}),[re]);const fa=e=>{ht(e)},ba=e=>({cursor:"pointer",backgroundColor:gt===e?a.palette.primary.main:"default",color:gt===e?"#fff":"","&:hover":{backgroundColor:gt===e?a.palette.primary.main:a.palette.primary.light,color:"#fff"}});(0,o.useEffect)((()=>{console.log("startPoint",Te),console.log("endPoint",Oe),0!=Te.latitude&&0!=Te.longitude&&0!=Oe.latitude&&0!=Oe.longitude&&ka(Te,Oe)}),[Te,Oe]);const ka=async(e,t)=>{try{const a=(1.3*((e,t,a,n)=>{const o=e=>e*Math.PI/180,s=o(a-e),i=o(n-t),l=Math.sin(s/2)*Math.sin(s/2)+Math.cos(o(e))*Math.cos(o(a))*Math.sin(i/2)*Math.sin(i/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371})(e.latitude,e.longitude,t.latitude,t.longitude)).toFixed(2);console.log("distance in km ",a);const n=Math.round(a);if(console.log("roundedDistance",n),Ve(n),n<Ge)tt($e);else{console.log("minKm",Ge),console.log("pricePerKm",Xe),console.log("basePrice",$e);const e=(n-Ge)*Xe+$e;console.log("total",e),tt(e)}Ue(!0),n>Tt&&(Ue(!0),ue(!0));const o=40,s=Math.round(n/o*60);console.log("Distance: ".concat(n,", Duration: ").concat(s))}catch(a){console.error("Error calculating distance:",a)}};(0,o.useEffect)((()=>{dt&&_a()}),[(null===vt||void 0===vt?void 0:vt.length)>3,""==vt,dt]),(0,o.useEffect)((()=>{if(je[0]){let e=[];je.map((t=>{F()().diff(F()("".concat(F()(ge).format("MM-DD-YYYY")," ").concat(F()(t).format("HH:mm:ss"))),"m")<=0&&e.push(t)}))}}),[je]);(0,o.useEffect)((()=>{dt&&(async()=>{we(!0),console.log("tenantid",dt),await L.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantinfo/?tenantid=").concat(dt)).then((e=>{console.log("fetchtenantinfo",e),e.data.status&&(He(e.data.details),Sa(),st(e.data.details.subcategoryname),lt(e.data.details.subcategoryid)),we(!1)})).catch((e=>{console.log(e),we(!1)}))})()}),[dt]);(0,o.useEffect)((()=>{(async()=>{await L.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getsubcategories/?moduleid=6")).then((e=>{console.log("subcateRes",e.data.details),e.data.status&&nt(e.data.details)})).catch((e=>{console.log(e)}))})()}),[]);(0,o.useEffect)((()=>{re&&(async()=>{we(!0),await L.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocations/?applocationid=").concat(re)).then((e=>{console.log("fetchTiming",e);const{opentime:t,closetime:a,latitude:n,longitude:o,radius:s}=e.data.details[0];if(e.data.status){Nt(n),Rt(o),Bt(s),console.log("radius",s),Ae("".concat(F()().format("MM-DD-YYYY")," ").concat(t)),ye("".concat(F()().format("MM-DD-YYYY")," ").concat(a)),console.log("starttime","".concat(F()().format("MM-DD-YYYY")," ").concat(t)),console.log("endtime","".concat(F()().format("MM-DD-YYYY")," ").concat(a," "));let e=[];for(let n="".concat(F()().format("MM-DD-YYYY")," ").concat(t),o=0;F()("".concat(F()().format("MM-DD-YYYY")," ").concat(a," ")).diff(n,"m")>=0;o++,n=F()(n).add(30,"m"))e.push(n);console.log("setTimeslotarr",e),fe(e)}we(!1)})).catch((e=>{console.log(e),we(!1)}))})()}),[re]);const Sa=async()=>{we(!0),await L.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocationconfig/?applocationid=").concat(re)).then((e=>{const t=e.data.details.applocationadmins.map((e=>e.userfcmtokem));e.data.status&&Le(t),we(!1)})).catch((e=>{console.log(e),we(!1)}))};(0,o.useEffect)((()=>{xe&&ve&&Sa()}),[xe,ve]);const Ca=(e,t,a)=>{(0,q.M8)(e,{variant:t,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:a||1500}),console.log(Pe)},_a=async()=>{Ce(!0);try{let e=""==vt?"".concat("https://jupiter.nearle.app/live/api/v1","/customers/gettenantcustomers/?tenantid=").concat(dt,"&pageno=1&pagesize=30"):"".concat("https://jupiter.nearle.app/live/api/v1","/customers/search/?tenantid=").concat(dt,"&keyword=").concat(vt);await L.A.get(e).then((e=>{e.data.status&&(console.log("clientdetails",e.data.details),pe(e.data.details),ft(e.data.details)),Ce(!1)})).catch((e=>{console.log(e),Ce(!1),Ca("server error","warning")}))}catch(e){console.log(e),Ce(!1)}},wa=async()=>{we(!0),await L.A.post("".concat("https://jupiter.nearle.app/live/api/v1","/utils/sendnotifications"),{priority:"high",registration_ids:Ie,data:{accessid:"AAAAILMpCEU:APA91bEavuOllBI6sFgYtxXAgNmAVwNA-MnCMHLGlR4_t7UqpLajAkdn3T0CZr_zaLBknLyim9ytFLMZgbeXmKqTad_PKCbqlYjHpaizVrLXtecxqyEy4UktIacK2UvHVUATHL-7VQQk"},notification:{title:"Nearle Merchant",body:"An Order has been placed successfully,kindly process the same",sound:"ring"}}).then((e=>{console.log(e),"Success"==e.data.message&&(0,q.M8)("Notification sent Successfully",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:1e3}),we(!1)})).catch((e=>{console.log(e),(0,q.M8)(e.message,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:1e3}),we(!1)}))};(0,o.useEffect)((()=>{if(Z){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(Wt,zt),radius:1e3*Tt}).getBounds()});t.addListener("place_changed",(()=>{const e=t.getPlace();G("".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()}),Be({latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()}),Ct((0,n.A)((0,n.A)({},St),{},{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}}))})),Ct((0,n.A)((0,n.A)({},St),{},{address:a.address,doorno:"".concat(a.street_number," ").concat(a.route),suburb:a.sublocality_level_1,city:a.locality,postcode:a.postal_code,latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()})),console.log("Pick Address:",a)}))}}),[Z]),(0,o.useEffect)((()=>{if(J){const e=document.getElementById("addressAuto2"),t=new window.google.maps.places.Autocomplete(e,{strictBounds:!0,bounds:new window.google.maps.Circle({center:new window.google.maps.LatLng(Wt,zt),radius:1e3*Tt}).getBounds()});t.addListener("place_changed",(()=>{const e=t.getPlace();ee("".concat(e.name,", ").concat(e.formatted_address)),console.log("new place",e),console.log("drop (new place) lat lng",{lat:e.geometry.location.lat(),lng:e.geometry.location.lng()}),Fe({latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()}),wt((0,n.A)((0,n.A)({},_t),{},{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}}))})),wt((0,n.A)((0,n.A)({},_t),{},{address:a.address,doorno:"".concat(a.street_number," ").concat(a.route),suburb:a.sublocality_level_1,city:a.locality,postcode:a.postal_code,latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()})),console.log("Drop Address:",a)}))}}),[J]);return(0,Q.jsxs)(Q.Fragment,{children:[_e&&(0,Q.jsx)(W.A,{}),Se&&(0,Q.jsx)(W.A,{}),(0,Q.jsxs)(s.Ay,{container:!0,spacing:3,sx:{position:"sticky",top:"60px",bgcolor:a.palette.background.default,zIndex:100,display:"flex",flexDirection:"column",justifyContent:"start",alignItems:"center",spacing:5},children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,sx:{width:"100%",mt:-1},children:(0,Q.jsx)(i.A,{children:(0,Q.jsx)(l.A,{variant:"h3",children:"Create Order"})})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sx:{width:"100%",mt:-2},children:(0,Q.jsx)(N.A,{sx:{height:"100%"},children:(0,Q.jsxs)(s.Ay,{container:!0,spacing:3,sx:{},children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:4,children:(0,Q.jsx)(r.A,{fullWidth:!0,autoFocus:!0,ref:O,options:Ot||[],getOptionLabel:e=>"".concat(e.locationname),onChange:(e,t,a)=>{"clear"===a?(ce(0),ut(0),ga(null),Re([]),pt(0),xa(null),Ht([]),Ct(null),wt(null)):(ce(t.applocationid),Ct(null),wt(null),ut(0),ga(null),pt(0),xa(null),Ht([]))},renderInput:e=>(0,Q.jsx)(c.A,(0,n.A)((0,n.A)({},e),{},{placeholder:"Choose Location",label:"Location"}))})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:4,children:(0,Q.jsx)(r.A,{fullWidth:!0,options:ze||[],value:pa,onOpen:e=>{re||(e.preventDefault(),(0,$.k)("Please select a your location first!","warning",3e3),setTimeout((()=>{var e;null===(e=O.current)||void 0===e||e.focus()}),0))},onChange:(e,t,a)=>{"clear"==a?(ut(0),ga(null),pt(0),xa(null),Ht([]),Ct(null),wt(null)):(ut((null===t||void 0===t?void 0:t.tenantid)||0),ga(t),pt(0),xa(null),(async e=>{try{const t=await L.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantpricing/?tenantid=").concat(e));console.log("pricingResponse",t.data.details),Qe(t.data.details.baseprice),Ze(t.data.details.priceperkm),Je(t.data.details.minkm)}catch(t){console.log("fetchTenantPricing error",t)}})(t.tenantid),(async e=>{try{const t=await L.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantlocations/?tenantid=").concat(e));console.log("gettenantlocations",t.data.details),1==t.data.details.length?(Ht(t.data.details),kt(t.data.details[0]),pt(t.data.details[0].locationid),xa(t.data.details[0].locationid),va(t.data.details[0].slots)):Ht(t.data.details)}catch(t){console.log("gettenantlocations",t)}})(t.tenantid),wt(null))},renderInput:e=>(0,Q.jsx)(c.A,(0,n.A)((0,n.A)({},e),{},{placeholder:"Choose Client",label:"Client",inputRef:X}))})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:4,children:1==Et.length?(0,Q.jsx)(c.A,{variant:"outlined",fullWidth:!0,label:"Business Location",value:Et[0].locationname,InputProps:{style:{color:a.palette.primary.main},startAdornment:(0,Q.jsx)(d.A,{position:"start",children:(0,Q.jsx)(K.A,{color:"primary"})})}}):(0,Q.jsx)(r.A,{fullWidth:!0,value:ha,options:Et||[],getOptionLabel:e=>"".concat(e.locationname," (").concat(e.suburb,")")||0,onOpen:e=>{re||dt?dt||(e.preventDefault(),(0,$.k)("Please select a your Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=X.current)||void 0===e||e.focus()}),0)):(e.preventDefault(),(0,$.k)("Please select Location and Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=O.current)||void 0===e||e.focus()}),0))},onChange:(e,t,a)=>{"clear"===a?(pt(0),xa(null),Ct(null)):(pt(t.locationid||0),xa(t),kt(t),va(null===t||void 0===t?void 0:t.slots))},renderInput:e=>(0,Q.jsx)(c.A,(0,n.A)((0,n.A)({},e),{},{placeholder:"Select Business Locations",label:"Business Location",color:"primary"}))})})]})})})]}),(0,Q.jsxs)(s.Ay,{container:!0,sx:{},children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,sx:{mt:2},children:(0,Q.jsxs)(s.Ay,{container:!0,spacing:1,children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,children:(0,Q.jsxs)(s.Ay,{container:!0,spacing:2,sx:{height:"100%"},children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(N.A,{sx:{height:"100%"},children:(0,Q.jsxs)(s.Ay,{container:!0,spacing:2,children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,children:(0,Q.jsxs)(i.A,{direction:"row",justifyContent:"space-between",children:[(0,Q.jsx)(l.A,{variant:"h5",sx:{mb:2},children:"Pickup Details"}),(0,Q.jsx)(i.A,{display:"flex",direction:"row",children:(0,Q.jsx)(u.A,{variant:"contained",size:"small",disabled:!mt,onClick:()=>{re||dt||mt?re||dt?re?(At(!0),Dt(1),Ct(null),G(""),yt("")):(0,$.k)("Please select Location!","warning",3e3):(0,$.k)("Please select Location and Tenant!","warning",3e3):(0,$.k)("Please select Location, Tenant and Business!","warning",3e3)},children:"Select Pickup"})})]})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sx:{},children:(0,Q.jsxs)(s.Ay,{container:!0,spacing:4,children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{inputRef:se,fullWidth:!0,InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(D.x$1,{})})},variant:"outlined",label:"Contact Name",value:(null===St||void 0===St?void 0:St.firstname)||"",onChange:e=>{Ct((0,n.A)((0,n.A)({},St),{},{firstname:e.target.value}))}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{error:na,inputRef:ie,fullWidth:!0,type:"number",InputProps:{inputProps:{maxLength:10},startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(w.dRU,{color:na&&"red"})})},variant:"outlined",label:"Contact Number",value:(null===St||void 0===St?void 0:St.contactno)||"",onChange:e=>{e.target.value.length<=10&&Ct((0,n.A)((0,n.A)({},St),{},{contactno:e.target.value})),Jt==e.target.value?Xt(0):Xt(1),e.target.value.length<10?oa(!0):oa(!1)}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,children:(0,Q.jsx)(i.A,{spacing:1.25,sx:{mt:0},children:0==Pt?(0,Q.jsx)("div",{children:(0,Q.jsx)(c.A,{id:"addressAuto1",fullWidth:!0,label:"Address",variant:"outlined",value:Z||"",onChange:e=>G(e.target.value),InputProps:{endAdornment:(0,Q.jsx)(m.A,{onClick:()=>{G(""),Ct((0,n.A)((0,n.A)({},St),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Ue(!1),Be({latitude:0,longitude:0})},size:"small",children:(0,Q.jsx)(C.A,{})})}})}):(0,Q.jsx)(c.A,{variant:"outlined",InputProps:{endAdornment:(0,Q.jsx)(m.A,{onClick:()=>{Mt(0),Ct((0,n.A)((0,n.A)({},St),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Ue(!1),Be({latitude:0,longitude:0})},children:(0,Q.jsx)(P.A,{})})},value:(null===St||void 0===St?void 0:St.address)||"",onChange:e=>{Ct((0,n.A)((0,n.A)({},St),{},{address:e.target.value})),""==e.target.value&&(Mt(0),Ue(!1),Be({latitude:0,longitude:0}))}})})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{fullWidth:!0,InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(Y.V92,{})})},variant:"outlined",label:"Door No / Street",value:(null===St||void 0===St?void 0:St.doorno)||"",onChange:e=>{Ct((0,n.A)((0,n.A)({},St),{},{doorno:e.target.value}))}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{fullWidth:!0,InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(D.sIY,{})})},variant:"outlined",label:"Location",value:(null===St||void 0===St?void 0:St.suburb)||"",onChange:e=>{Ct((0,n.A)((0,n.A)({},St),{},{suburb:e.target.value}))}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{fullWidth:!0,InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(I.BND,{})})},variant:"outlined",label:"Postcode",value:(null===St||void 0===St?void 0:St.postcode)||"",onChange:e=>{Ct((0,n.A)((0,n.A)({},St),{},{postcode:e.target.value}))}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{fullWidth:!0,InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(D.Ndh,{})})},variant:"outlined",label:"Landmark",value:(null===St||void 0===St?void 0:St.landmark)||"",onChange:e=>{Ct((0,n.A)((0,n.A)({},St),{},{landmark:e.target.value}))}})}),1==Qt&&(0,Q.jsx)(s.Ay,{item:!0,xs:12,sx:{display:"flex",justifyContent:"end"},children:(0,Q.jsx)(p.A,{children:(0,Q.jsx)(g.A,{control:(0,Q.jsx)(h.A,{checked:1===Ut,onChange:e=>{Kt(e.target.checked?1:0)}}),label:"Save For Later"})})})]})})]})})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(N.A,{sx:{height:"100%"},children:(0,Q.jsxs)(s.Ay,{container:!0,spacing:2,sx:{height:"100%"},children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,sx:{height:"100%"},children:(0,Q.jsxs)(i.A,{direction:"row",justifyContent:"space-between",children:[(0,Q.jsx)(l.A,{variant:"h5",sx:{mb:2},children:"Drop Details"})," ",(0,Q.jsx)(u.A,{variant:"contained",disabled:!mt,size:"small",onClick:()=>{re||dt||mt?re||dt?re?(At(!0),Dt(2),ee("")):(0,$.k)("Please select Location!","warning",3e3):(0,$.k)("Please select Location and Tenant!","warning",3e3):(0,$.k)("Please select Location, Tenant and Business!","warning",3e3)},children:"Select Drop"})]})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,children:(0,Q.jsxs)(s.Ay,{container:!0,spacing:4,children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{inputRef:le,fullWidth:!0,variant:"outlined",label:"Contact Name",InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(D.x$1,{})})},value:(null===_t||void 0===_t?void 0:_t.firstname)||"",onChange:e=>{wt((0,n.A)((0,n.A)({},_t),{},{firstname:e.target.value}))}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{error:sa,fullWidth:!0,type:"number",variant:"outlined",label:"Contact Number",InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(w.dRU,{color:sa&&"red"})})},value:(null===_t||void 0===_t?void 0:_t.contactno)||"",onChange:e=>{e.target.value.length<=10&&wt((0,n.A)((0,n.A)({},_t),{},{contactno:e.target.value})),ta==e.target.value?Gt(0):Gt(1),e.target.value.length<10?ia(!0):ia(!1)},sx:{color:sa?"red":"inherit"}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,children:(0,Q.jsx)(i.A,{spacing:1.25,sx:{mt:0},children:0==It?(0,Q.jsx)("div",{children:(0,Q.jsx)(c.A,{id:"addressAuto2",label:"Address ",variant:"outlined",fullWidth:!0,value:J||"",onChange:e=>ee(e.target.value),InputProps:{endAdornment:(0,Q.jsx)(m.A,{onClick:()=>{ee(""),wt((0,n.A)((0,n.A)({},_t),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Ue(!1),Fe({latitude:0,longitude:0})},size:"small",children:(0,Q.jsx)(C.A,{})})}})}):(0,Q.jsx)(c.A,{variant:"outlined",InputProps:{endAdornment:(0,Q.jsx)(m.A,{onClick:()=>{Lt(0),wt((0,n.A)((0,n.A)({},_t),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Ue(!1),Fe({latitude:0,longitude:0})},children:(0,Q.jsx)(P.A,{})})},value:(null===_t||void 0===_t?void 0:_t.address)||"",onChange:e=>{Ct((0,n.A)((0,n.A)({},_t),{},{address:e.target.value})),""==e.target.value&&(Lt(0),Ue(!1),Fe({latitude:0,longitude:0}))}})})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{fullWidth:!0,variant:"outlined",label:"Door No / Street",InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(Y.V92,{})})},value:(null===_t||void 0===_t?void 0:_t.doorno)||"",onChange:e=>{wt((0,n.A)((0,n.A)({},_t),{},{doorno:e.target.value}))}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{fullWidth:!0,variant:"outlined",label:"Location",InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(D.sIY,{})})},value:(null===_t||void 0===_t?void 0:_t.suburb)||"",onChange:e=>{wt((0,n.A)((0,n.A)({},_t),{},{suburb:e.target.value}))}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{fullWidth:!0,variant:"outlined",label:"Postcode",InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(I.BND,{})})},value:(null===_t||void 0===_t?void 0:_t.postcode)||"",onChange:e=>{wt((0,n.A)((0,n.A)({},_t),{},{postcode:e.target.value}))}})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(c.A,{fullWidth:!0,variant:"outlined",label:"Landmark",InputProps:{startAdornment:(0,Q.jsx)(m.A,{children:(0,Q.jsx)(D.Ndh,{})})},value:(null===_t||void 0===_t?void 0:_t.landmark)||"",onChange:e=>{wt((0,n.A)((0,n.A)({},_t),{},{landmark:e.target.value}))}})}),1==Zt&&(0,Q.jsx)(s.Ay,{item:!0,xs:12,sx:{display:"flex",justifyContent:"end"},children:(0,Q.jsx)(p.A,{children:(0,Q.jsx)(g.A,{control:(0,Q.jsx)(h.A,{checked:1===Vt,onChange:e=>{$t(e.target.checked?1:0)}}),label:"Save For Later"})})})]})})]})})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sx:{},children:(0,Q.jsx)(N.A,{sx:{height:"100%"},children:(0,Q.jsxs)(s.Ay,{container:!0,spacing:2,children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:4,children:(0,Q.jsx)(i.A,{children:(0,Q.jsx)(r.A,{id:"combo-box-demo",options:at,getOptionLabel:e=>"".concat(e.subcategoryname)||"",fullWidth:!0,renderInput:e=>(0,Q.jsx)(c.A,(0,n.A)((0,n.A)({},e),{},{label:"Category"})),onChange:(e,t,a)=>{t?(console.log(t),st(t.subcategoryname||""),lt(t.subcategoryid||0)):a&&(st(null),lt(null))}})})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:4,children:(0,Q.jsx)(i.A,{children:(0,Q.jsx)(c.A,{type:"number",value:ca,fullWidth:!0,label:"Cash Collect",onChange:e=>{da(e.target.value)},inputProps:{min:0}})})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:4,children:(0,Q.jsx)(i.A,{children:(0,Q.jsx)(c.A,{type:"number",value:ua,fullWidth:!0,label:"Quantity",onChange:e=>{ma(e.target.value)},inputProps:{min:1}})})})]})})}),(0,Q.jsxs)(o.Fragment,{children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsx)(N.A,{sx:{mt:2,height:"auto"},children:(0,Q.jsx)(s.Ay,{container:!0,children:(0,Q.jsxs)(s.Ay,{item:!0,xs:12,children:[(0,Q.jsx)(l.A,{variant:"h5",children:"Pickup Slots "}),(0,Q.jsx)(l.A,{variant:"h6",sx:{marginTop:2},children:"Date"}),(0,Q.jsx)(R.$,{dateAdapter:T.R,sx:{},children:(0,Q.jsx)(z.l,{format:"DD-MM-YYYY",onChange:e=>{let t=F()().diff(F()("".concat(F()(e).format("YYYY-MM-DD"))),"d");if(console.log("dateres11"),console.log(t),Ne(""),t<=0){console.log("startdate",e),he(e);let t=[];je.map((a=>{F()().diff(F()("".concat(F()(e).format("MM-DD-YYYY")," ").concat(F()(a).format("HH:mm:ss"))),"m")<=0&&t.push(a)}))}else Me("choose Upcoming Date"),Ca("choose Upcoming Date","warning"),he(NaN)},value:F()(ge),sx:{width:"100%",mt:2},disablePast:!0})}),(0,Q.jsx)(l.A,{variant:"h6",sx:{my:2},children:"Pickup Time Slot"}),(0,Q.jsx)(r.A,{options:Aa||[],onChange:(e,t,a)=>{if("clear"===a)Ne(null),ja(null);else{const e=F()(t.time,"HH:mm").format("hh:mm A");Ne(e);const a=F()("".concat(ge," ").concat(e),"MM-DD-YYYY hh:mm A").format("YYYY-MM-DD hh:mm A");ja(a)}},getOptionLabel:e=>"".concat(e.name," (").concat(F()(e.time,"HH:mm").format("hh:mm A"),")"),renderInput:e=>(0,Q.jsx)(c.A,(0,n.A)((0,n.A)({},e),{},{placeholder:"Select Pickup Slot"}))})]})})})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,sm:6,children:(0,Q.jsxs)(N.A,{sx:{mt:2},children:[qe&&(0,Q.jsxs)(i.A,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",mb:3},children:[(0,Q.jsx)(i.A,{spacing:1.5,children:(0,Q.jsx)(x.A,{label:"Distance: ".concat(Ke," km"),size:"medium",variant:"contained",color:"primary"})}),(0,Q.jsx)(i.A,{spacing:1.5,children:(0,Q.jsx)(x.A,{label:"Charge: \u20b9".concat(et.toFixed(2)),size:"medium",variant:"contained",color:"primary"})})]}),(0,Q.jsx)(l.A,{variant:"h5",children:"Weight"}),(0,Q.jsxs)(i.A,{direction:"row",justifyContent:"space-evenly",sx:{border:"1px solid #eee",my:2,py:2},children:[(0,Q.jsx)(x.A,{variant:"contained",color:"default",label:"1-10kgs",sx:ba("1-10kgs"),onClick:()=>{fa("1-10kgs"),ct("1-10kgs")}}),(0,Q.jsx)(x.A,{variant:"contained",color:"default",label:"11-20kgs",sx:ba("11-20kgs"),onClick:()=>{fa("11-20kgs"),ct("11-20kgs")}}),(0,Q.jsx)(x.A,{variant:"contained",color:"default",label:"21-30kgs",sx:ba("21-30kgs"),onClick:()=>{fa("21-30kgs"),ct("21-30kgs")}})]}),(0,Q.jsxs)(i.A,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{},children:[(0,Q.jsx)(l.A,{variant:"h5",noWrap:!0,children:"SMS Delivery"}),(0,Q.jsx)(A.A,{checked:1===la,onChange:e=>{ra(e.target.checked?1:0)}})]})]})})]})]})}),(0,Q.jsx)(s.Ay,{item:!0,xs:12,children:(0,Q.jsx)(N.A,{sx:{mt:2},children:(0,Q.jsxs)(s.Ay,{container:!0,children:[(0,Q.jsx)(s.Ay,{item:!0,xs:12,children:(0,Q.jsxs)(i.A,{sx:{mt:3},gap:1,children:[(0,Q.jsx)(l.A,{variant:"h5",noWrap:!0,children:"Notes"}),(0,Q.jsx)(c.A,{focused:!0,id:"outlined-multiline-static",sx:{width:"100%",height:"100%",mb:2},multiline:!0,rows:1,placeholder:"Notes",value:be,onChange:e=>ke(e.target.value)})]})}),(0,Q.jsx)(i.A,{direction:"row",justifyContent:"end",sx:{mt:2,width:"100%"},children:(0,Q.jsx)(u.A,{size:"medium",disabled:!qe||!We||!ya,variant:"outlined",onClick:()=>{we(!0),De(!0),(async()=>{let e={};if(e={orders:{applocationid:Ee.applolcationid,cancellled:"",categoryid:+Ee.categoryid,configid:9,customerid:0==Ut&&+St.customerid||0,deliveryaddress:_t.address||"",deliverycharge:+et.toFixed(2)||0,deliverycity:_t.city||"",deliverycontactno:_t.contactno||"",deliverycustomer:_t.firstname||"",deliveryid:0==Vt&&+_t.customerid||0,deliverylandmark:_t.landmark||"",deliverylat:_t.latitude.toString(),deliverylocation:_t.suburb||"",deliverylocationid:_t.deliverylocationid||0,deliverylong:_t.longitude.toString(),deliverytime:"".concat(F()(ge).format("YYYY-MM-DD")," ").concat(F()(We.$d).format("HH:mm:ss")),deliverytype:"B",delivered:"",itemcount:1,kms:Ke.toString()||0,locationid:+mt,moduleid:+Ee.moduleid,orderamount:+et.toFixed(2)||0,ordercharges:0,orderdate:F()().format("YYYY-MM-DD HH:mm:ss"),ordernotes:be,orderstatus:"created",ordervalue:+et.toFixed(2)||0,partnerid:Ee.partnerid,partneruserid:+qt,paymentstatus:1,paymenttype:42,pickupaddress:St.address||"",pickupcity:St.city||"",pickupcontactno:St.contactno||"",pickupcustomer:St.firstname||"",pickuplandmark:St.landmark||"",pickuplat:St.latitude.toString()||"",pickuplocation:St.suburb||"",pickuplocationid:St.deliverylocationid||0,pickuplong:St.longitude.toString()||"",smsdelivery:la,subcategoryid:+it,tenantid:Ee.tenantid,collectionamt:+ca,quantity:+ua,weight:rt,pickupSlot:ya},pickup:{address:St.address||"",applocationid:Ee.applolcationid,city:St.city||"",configid:1,contactno:St.contactno||"",customertoken:"",customerid:0==Ut&&St.customerid||0,devicetype:"",deviceid:"",dialcode:"+91",doorno:St.doorno||"",email:St.email||"",firstname:St.firstname||"",landmark:St.landmark||"",latitude:St.latitude.toString()||"",longitude:St.longitude.toString()||"",postcode:St.postcode||"",primaryaddress:1,locationid:St.deliverylocationid||0,profileimage:"",state:St.state||"",suburb:St.suburb||"",tenantid:Ee.tenantid},drop:{address:_t.address||"",applocationid:Ee.applolcationid,city:_t.city||"",configid:1,contactno:_t.contactno||"",customertoken:"",customerid:0==Vt&&_t.customerid||0,devicetype:"",deviceid:"",locationid:_t.deliverylocationid||0,dialcode:"+91",doorno:_t.doorno||"",email:_t.email||"",firstname:_t.firstname||"",landmark:_t.landmark||"",latitude:_t.latitude.toString(),longitude:_t.longitude.toString(),postcode:_t.postcode||"",primaryaddress:1,profileimage:"",state:_t.state||"",suburb:_t.suburb||"",tenantid:Ee.tenantid}},console.log("createsubmitobj2",e),St.firstname)if(St.contactno)if(10!=St.contactno.length)Ca("Check Pickup Contact Number ","error",2e3);else if(St.suburb)if(St.city)if(St.postcode)if(St.landmark)if(_t.firstname)if(_t.contactno)if(10!==_t.contactno.length)Ca("Check Drop Contact Number ","error",2e3);else if(_t.suburb)if(_t.city)if(_t.postcode)if(_t.landmark)if(We)if(lt)try{const a=await L.A.post("".concat("https://jupiter.nearle.app/live/api/v2","/orders/createorder"),e);a.data.status?(console.log("createRes",a),(0,q.M8)("Order Created Successfully",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:1e3}),Ie&&wa(),t("/nearle/orders")):Ca("Error in creating orders","warning"),we(!1)}catch(a){Ca(a.message,"warning"),console.log("createResErr",a)}else Ca("Choose SubCategory ","warning",2e3);else Ca("Choose deliverytime ","warning",2e3);else Ca("Enter Drop Landmark ","warning",2e3);else Ca("Enter Drop postcode ","warning",2e3);else Ca("Enter Drop City ","warning",2e3);else Ca("Enter Drop Suburb ","warning",2e3);else Ca("Enter Drop Contact Number","warning",2e3);else Ca("Enter Drop Contact Name ","warning",2e3);else Ca("Enter Pickup Landmark ","warning",2e3);else Ca("Enter Pickup Postcode ","warning",2e3);else Ca("Enter Pickup City ","warning",2e3);else Ca("Enter Pickup Location ","warning",2e3);else Ca("Enter Pickup Contact Number ","warning",2e3);else Ca("Enter Pickup Contact Name ","warning",2e3)})(),setTimeout((()=>{we(!1),De(!1)}),2e3)},sx:{"&:hover":{transform:"scale(1.05)",transition:"transform 0.3s ease"}},children:Ye?(0,Q.jsx)(v.A,{color:"primary",size:20,thickness:10}):"Create"})})]})})})]})}),(0,Q.jsxs)(B.A,{open:xt,onClose:()=>{At(!1),yt("")},fullWidth:!0,sx:{minWidth:"lg"},children:[(0,Q.jsx)(y.A,{sx:{bgcolor:a.palette.primary.main,color:"white"},children:(0,Q.jsxs)(i.A,{children:[(0,Q.jsxs)(l.A,{variant:"h4",children:[" ","Select Address (".concat(1===Yt?"Pickup":"Drop",")")]}),(0,Q.jsx)(j.A,{sx:{width:"100%",mt:1},children:(0,Q.jsx)(i.A,{spacing:2,sx:{py:.2},children:(0,Q.jsx)(f.A,{autoFocus:!0,fullWidth:!0,id:"input-search-header",placeholder:"Search",value:vt,onChange:e=>yt(e.target.value),sx:{"& .MuiOutlinedInput-input":{p:"10.5px 0px 12px"},bgcolor:"white"},startAdornment:(0,Q.jsx)(d.A,{position:"start",children:(0,Q.jsx)(U.A,{style:{fontSize:"small"}})}),endAdornment:(0,Q.jsx)(m.A,{sx:{visibility:vt?"visible":"hidden"},onClick:()=>{yt("")},children:(0,Q.jsx)(P.A,{})}),autoComplete:"off"})})})]})}),(0,Q.jsx)(b.A,{}),(0,Q.jsx)(k.A,{sx:{p:2.5},children:0==(null===jt||void 0===jt?void 0:jt.length)?(0,Q.jsx)(i.A,{spacing:2,direction:"row",alignItems:"center",justifyContent:"center",sx:{minHeight:600,maxHeight:600},children:(0,Q.jsx)(_.A,{})}):(0,Q.jsx)(i.A,{spacing:2,sx:{minHeight:600,maxHeight:600},children:jt&&(null===jt||void 0===jt?void 0:jt.map(((e,t)=>(0,Q.jsx)(u.A,{onClick:()=>{At(!1),yt(""),1===Yt?(console.log("PickupClient",e),Mt(1),Be({latitude:e.latitude,longitude:e.longitude}),Ct(e),ea(e.contactno)):(console.log("DropClient",e),Lt(1),Fe({latitude:e.latitude,longitude:e.longitude}),wt(e),aa(e.contactno))},disabled:(null===St||void 0===St?void 0:St.customerid)===e.customerid,sx:{width:"100%",border:"1px solid",borderColor:"grey.200",borderRadius:1,p:1.25},children:(0,Q.jsxs)("div",{style:{width:"100%"},children:[(0,Q.jsx)(l.A,{variant:"subtitle1",sx:{textAlign:"left"},children:"".concat(e.firstname," (").concat(e.contactno,")")}),(0,Q.jsx)(l.A,{variant:"body2",color:"secondary",sx:{textAlign:"left"},children:e.address})]})},t))))})}),(0,Q.jsx)(b.A,{}),(0,Q.jsx)(S.A,{sx:{p:2.5},children:(0,Q.jsx)(u.A,{color:"error",variant:"outlined",sx:{"&:hover":{bgcolor:"red",color:"white"}},onClick:()=>{At(!1),yt("")},children:"Cancel"})})]}),(0,Q.jsxs)(B.A,{open:de,onClose:()=>{ue(!1)},children:[(0,Q.jsxs)(y.A,{sx:{textAlign:"center"},children:[(0,Q.jsx)(V.A,{sx:{fontSize:60,color:a.palette.error.main}}),(0,Q.jsx)(l.A,{variant:"h3",sx:{color:a.palette.error.main},children:"Error"})]}),(0,Q.jsx)(k.A,{children:(0,Q.jsx)(l.A,{variant:"h4",color:"secondary",children:"Service not available at this location"})}),(0,Q.jsx)(S.A,{sx:{bgcolor:a.palette.error.main,display:"flex",alignItems:"center",justifyContent:"center",fontSize:20,color:"white",cursor:"pointer"},onClick:()=>{ue(!1)},children:"Close"})]})]})]})}}}]);