1 line
43 KiB
JavaScript
1 line
43 KiB
JavaScript
(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[54],{855:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var i=n(7208),r=n(76475),s=n(44414);function o(e){var t,n;let o,a,{children:l,type:c="scale",direction:d="right",offset:h=10,scale:p={hover:1.05,tap:.95}}=e;switch(d){case"up":case"left":o=h,a=0;break;default:o=0,a=h}const[u,x]=(0,i.Y)(o,a),[m,f]=(0,i.Y)(o,a);switch(c){case"rotate":return(0,s.jsx)(r.P.div,{animate:{rotate:360},transition:{repeat:1/0,repeatType:"loop",duration:2,repeatDelay:0},children:l});case"slide":return"up"===d||"down"===d?(0,s.jsx)(r.P.div,{animate:{y:void 0!==m?m:""},onHoverEnd:()=>f(),onHoverStart:()=>f(),children:l}):(0,s.jsx)(r.P.div,{animate:{x:void 0!==u?u:""},onHoverEnd:()=>x(),onHoverStart:()=>x(),children:l});default:return"number"===typeof p&&(p={hover:p,tap:p}),(0,s.jsx)(r.P.div,{whileHover:{scale:null===(t=p)||void 0===t?void 0:t.hover},whileTap:{scale:null===(n=p)||void 0===n?void 0:n.tap},children:l})}}},39009:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>xe});var i=n(89379),r=n(9950),s=n(26910),o=n(50847),a=n.n(o),l=n(55271),c=n(4159),d=n.n(c),h=n(28429),p=n(14857),u=n(8881),x=n(55158),m=n(16491),f=n(93230),g=n(82053),A=n(25277),v=n(60899),j=n(48089),b=n(77922),y=n(29925),S=n(2046),w=n(82223),k=n(46639),Y=n(1320),C=n(2235),z=n(15769),W=n(69780),M=n(9213),D=n(21671),P=n(34075),I=n(83274),N=n(25333),R=n(96583),H=n(40033),L=n(25979),T=n(2660),E=n(74745),O=n(28170),F=n(96557),B=n(16497),J=n(93038),V=n(79739),q=n(30633),G=n(81831),K=n(95359),Z=n(7762),U=n(87942),Q=n(81419),X=n(3911),_=n(47738),$=n(27379),ee=n(90421),te=n(94118),ne=n(88349),ie=n(60767),re=n(13838),se=n(54826),oe=n(43302),ae=n(31222),le=n(52351),ce=n(94826),de=(n(855),n(42041),n(44414)),he=n(36220);d().extend(he);const pe={fontSize:11.5,fontWeight:700,color:"#475569",py:.75,px:1},ue={fontSize:12,py:.6,px:1},xe=()=>{const e=(0,h.Zp)(),t=(0,p.A)(),n=(0,r.useRef)(null),o=(0,r.useRef)(null),c=localStorage.getItem("userid"),[he,xe]=(0,r.useState)([]),[me,fe]=(0,r.useState)([]),[ge,Ae]=(0,r.useState)([]),[ve,je]=(0,r.useState)(!1),[be,ye]=(0,r.useState)(!1),[Se,we]=(0,r.useState)(0),[ke,Ye]=(0,r.useState)(0),[Ce,ze]=(0,r.useState)(0),[We,Me]=(0,r.useState)(null),[De,Pe]=(0,r.useState)(null),[Ie,Ne]=(0,r.useState)(0),[Re,He]=(0,r.useState)(0),[Le,Te]=(0,r.useState)(0),[Ee,Oe]=(0,r.useState)(null),[Fe,Be]=(0,r.useState)([]),[Je,Ve]=(0,r.useState)([]),[qe,Ge]=(0,r.useState)(!1),[Ke,Ze]=(0,r.useState)(""),[Ue,Qe]=(0,r.useState)(d()().format("MM-DD-YYYY")),[Xe,_e]=(0,r.useState)(""),[$e,et]=(0,r.useState)(null),[tt,nt]=(0,r.useState)(null),[it,rt]=(0,r.useState)(""),[st,ot]=(0,r.useState)(),[at,lt]=(0,r.useState)(0),[ct,dt]=(0,r.useState)(0),[ht,pt]=(0,r.useState)(0),[ut,xt]=(0,r.useState)(0),[mt,ft]=(0,r.useState)(null),[gt,At]=(0,r.useState)([]),[vt,jt]=(0,r.useState)(""),bt=(0,r.useRef)({}),yt=(e,t,n)=>{(0,u.M8)(e,{variant:t,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:n||1500})},St=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e3;const i="".concat(t,"-").concat(e);bt.current[i]||(yt(e,t,n),bt.current[i]=!0,setTimeout((()=>delete bt.current[i]),3e3))};(0,r.useEffect)((()=>{Ye(0),Me(null),ze(0),Pe(null),Ae([]),Oe(null),Be([]),At([]),ft(null),jt(""),et(null),nt(null),_e("")}),[Se]),(0,r.useEffect)((()=>{ze(0),Pe(null),Be([]),At([]),ft(null),jt("")}),[ke]);(0,r.useEffect)((()=>{(async()=>{je(!0);try{const e=await s.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/partners/getlocations/?userid=").concat(c));xe(e.data.details||[])}catch(e){St(e.message,"error",5e3)}finally{je(!1)}})()}),[]);(0,r.useEffect)((()=>{Se&&(async()=>{je(!0);try{const e=await s.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenants/?applocationid=").concat(Se,"&status=active"));if(e.data.status){const t=(e.data.details||[]).map((e=>(0,i.A)((0,i.A)({},e),{},{label:"".concat(e.tenantname)})));fe(t)}}catch(e){St("Failed to load clients","warning",3e3)}finally{je(!1)}})()}),[Se]);(0,r.useEffect)((()=>{if(!ke)return;const e=setTimeout((()=>{(""===Ke||Ke.length>2)&&(async()=>{try{const e=""===Ke?"".concat("https://jupiter.nearle.app/live/api/v1","/customers/gettenantcustomers/?tenantid=").concat(ke,"&pageno=1&pagesize=30"):"".concat("https://jupiter.nearle.app/live/api/v1","/customers/search/?tenantid=").concat(ke,"&keyword=").concat(Ke),t=await s.A.get(e);t.data.status&&Ve(t.data.details||[])}catch(e){console.log(e),yt("server error","warning")}})()}),250);return()=>clearTimeout(e)}),[Ke,ke]),(0,r.useEffect)((()=>{let e=0,t=0,n=0,i=0;Fe.forEach((r=>{e+=Number(r.distance)||0,t+=Number(r.totalcharge)||0,n+=Number(r.quantity)||0,i+=Number(r.collectionamt)||0})),lt(e),dt(t),pt(n),xt(i)}),[Fe]);const wt=async e=>{var t,n;if("undefined"===typeof window||null===(t=window.google)||void 0===t||null===(n=t.maps)||void 0===n||!n.DistanceMatrixService)throw new Error("Google Maps not loaded");const i=new window.google.maps.DistanceMatrixService;try{var r,s,o,a,l;if(!e||"object"!==typeof e)throw new Error("Invalid customer data.");if(!Ee||"object"!==typeof Ee)throw new Error("Origin (pickCust) data missing or invalid.");const t=await(c=Ee,d=e,new Promise(((e,t)=>{try{if(!c||!d)return t(new Error("Origin or destination data missing."));i.getDistanceMatrix({origins:[new window.google.maps.LatLng(c.latitude,c.longitude)],destinations:[new window.google.maps.LatLng(d.latitude,d.longitude)],travelMode:"DRIVING",unitSystem:window.google.maps.UnitSystem.METRIC},((n,i)=>{"OK"===i?e(n):t(new Error("Google API error: ".concat(i)))}))}catch(n){t(new Error("Unexpected error inside DistanceMatrixService: ".concat(n.message)))}}))),n=null===t||void 0===t||null===(r=t.rows)||void 0===r||null===(s=r[0])||void 0===s||null===(o=s.elements)||void 0===o||null===(a=o[0])||void 0===a||null===(l=a.distance)||void 0===l?void 0:l.value;if(null==n)throw new Error("Malformed Distance Matrix response: missing distance value.");const h=n/1e3,p=Math.round(h);return{roundedDistance:p,totalcharge:p<Le?Ie:(p-Le)*Re+Ie}}catch(h){throw h.message.includes("Google API")?St("Invalid coordinates or Google API error.","error",3e3):h.message.includes("Malformed Distance Matrix")?St("Google Distance Matrix returned invalid data.","error",3e3):h.message.includes("Origin")||h.message.includes("customer")?St("Missing or invalid input data for distance calculation.","warning",3e3):St("Unexpected error during distance calculation.","error",3e3),h}var c,d},kt=async e=>{let t=!1;if(Be((n=>(t=n.some((t=>t.firstname===e.firstname)),t?n.filter((t=>t.firstname!==e.firstname)):n))),!t){je(!0);try{const{roundedDistance:t,totalcharge:n}=await wt(e);Be((r=>r.some((t=>t.firstname===e.firstname))?r:[...r,(0,i.A)((0,i.A)({},e),{},{distance:t,totalcharge:n})]))}catch(n){console.error("Failed to calculate distance:",n)}finally{je(!1)}}};(0,r.useEffect)((()=>{Se&&(async()=>{try{const e=await s.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocationconfig/?applocationid=").concat(Se));if(e.data.status){const t=e.data.details.applocationadmins.map((e=>e.userfcmtokem));ot(t)}}catch(e){console.log(e)}})()}),[Se]);const Yt=e=>null===e||void 0===e?void 0:e.toString().trim().toLowerCase().replace(/\s+/g,""),Ct={"pickupdate(yyyy-mmm-dd)":"date","sendername*":"locationname","senderphone*":"locationcontact","senderaddress*":"locationaddress","receivername*":"firstname","receiverphone*":"contactno","receiveralternatephone*":"altcontactno",receiverfulladdress:"address",receiverlatitude:"latitude",receiverlongitude:"longitude","itemdescription*":"description",Quantity:"quantity"," Collect Cash":"collectionamt"},zt={location:!!Se,client:!!ke,business:!!Ce,schedule:!!tt,drops:Fe.length>0},Wt=zt.location&&zt.client&&zt.business&&zt.schedule&&zt.drops,Mt=Fe.length>0?"drops":gt.length>0?"preview":"empty";return(0,de.jsxs)(de.Fragment,{children:[ve&&(0,de.jsx)(le.A,{}),(0,de.jsx)(x.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:be,children:(0,de.jsx)(ce.A,{color:"inherit"})}),(0,de.jsxs)(m.A,{className:"orders-workspace-bg",sx:{height:"calc(100vh - 64px)",display:"flex",flexDirection:"column",overflow:"hidden",p:{xs:1,sm:1.25},gap:1},children:[(0,de.jsxs)(f.A,{direction:"row",alignItems:"center",gap:1,flexWrap:"wrap",sx:{flexShrink:0,px:.5},children:[(0,de.jsx)(g.A,{sx:{fontWeight:700,fontSize:{xs:16,sm:17},color:"#1e293b",lineHeight:1.2},children:"Create Multiple Orders"}),(0,de.jsx)(A.A,{size:"small",label:"".concat(Fe.length," drop").concat(1===Fe.length?"":"s"),sx:{height:20,fontSize:10.5,fontWeight:700,bgcolor:Fe.length?"rgba(24,144,255,0.10)":"#f1f5f9",color:Fe.length?"#1890ff":"#94a3b8",border:"1px solid ".concat(Fe.length?"rgba(24,144,255,0.25)":"#e2e8f0")}}),(0,de.jsx)(m.A,{sx:{flex:1}}),(0,de.jsx)(g.A,{sx:{fontSize:11,color:"#94a3b8",display:{xs:"none",md:"block"}},children:"Bulk-create deliveries from CSV/Excel or saved customers."})]}),(0,de.jsxs)(v.Ay,{container:!0,spacing:1.25,sx:{flex:1,minHeight:0,overflow:"hidden"},children:[(0,de.jsxs)(v.Ay,{item:!0,xs:12,md:6,sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",gap:2.25,overflowY:"auto",pr:.75},children:[(0,de.jsxs)(j.A,{className:"orders-card",sx:{p:2,flexShrink:0},children:[(0,de.jsx)(m.A,{className:"section-title-bar",sx:{mb:1.5},children:(0,de.jsx)(g.A,{sx:{fontWeight:700,color:"#1e293b",fontSize:13.5,letterSpacing:"-0.01em"},children:"Setup"})}),(0,de.jsxs)(v.Ay,{container:!0,spacing:1.75,children:[(0,de.jsx)(v.Ay,{item:!0,xs:12,sm:4,children:(0,de.jsx)(b.A,{fullWidth:!0,size:"small",ref:n,className:"header-compact-input",options:he||[],getOptionLabel:e=>"".concat(e.locationname),onChange:(e,t,n)=>{"clear"===n?we(0):t&&we(t.applocationid)},renderInput:e=>(0,de.jsx)(y.A,(0,i.A)((0,i.A)({},e),{},{size:"small",placeholder:"Choose Location",label:"Location",InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:(0,i.A)((0,i.A)({},e.InputProps),{},{startAdornment:(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(oe.sIY,{style:{color:"#94a3b8",fontSize:12,marginRight:6,flexShrink:0}}),e.InputProps.startAdornment]})})}))})}),(0,de.jsx)(v.Ay,{item:!0,xs:12,sm:4,children:(0,de.jsx)(b.A,{fullWidth:!0,size:"small",className:"header-compact-input",options:me||[],value:We,getOptionLabel:e=>(null===e||void 0===e?void 0:e.tenantname)||"",isOptionEqualToValue:(e,t)=>e.tenantid===t.tenantid,onOpen:e=>{Se||(e.preventDefault(),St("Please select Location first!","warning",3e3),setTimeout((()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.focus()}),0))},onChange:(e,t,n)=>{"clear"===n?(Ye(0),Me(null)):t&&(Ye(t.tenantid),Me(t),(async e=>{try{const t=(await s.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantpricing/?tenantid=").concat(e))).data.details||{};Ne(t.baseprice||0),He(t.priceperkm||0),Te(t.minkm||0)}catch(t){console.log("fetchTenantPricing error",t)}})(t.tenantid),(async e=>{try{const t=(await s.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantlocations/?tenantid=").concat(e))).data.details||[];1===t.length?(Ae(t),Oe(t[0]),ze(t[0].locationid),Pe(t[0]),et(t[0].slots)):Ae(t)}catch(t){console.log("gettenantlocations",t)}})(t.tenantid))},renderInput:e=>(0,de.jsx)(y.A,(0,i.A)((0,i.A)({},e),{},{size:"small",placeholder:"Choose Client",label:"Client",inputRef:o,InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:(0,i.A)((0,i.A)({},e.InputProps),{},{startAdornment:(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(se.x$1,{style:{color:"#94a3b8",fontSize:11,marginRight:6,flexShrink:0}}),e.InputProps.startAdornment]})})}))})}),(0,de.jsx)(v.Ay,{item:!0,xs:12,sm:4,children:1===ge.length?(0,de.jsx)(y.A,{variant:"outlined",fullWidth:!0,size:"small",label:"Business Location",value:ge[0].locationname,InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:{style:{color:t.palette.primary.main},startAdornment:(0,de.jsx)(U.A,{style:{color:"#94a3b8",fontSize:14,marginRight:6,flexShrink:0}})}}):(0,de.jsx)(b.A,{fullWidth:!0,size:"small",className:"header-compact-input",value:De,options:ge||[],getOptionLabel:e=>null!==e&&void 0!==e&&e.locationname?"".concat(e.locationname," (").concat(e.suburb||"",")"):"",onOpen:e=>{Se||ke?ke||(e.preventDefault(),St("Please select Client first!","warning",3e3),setTimeout((()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.focus()}),0)):(e.preventDefault(),St("Please select Location and Client first!","warning",3e3),setTimeout((()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.focus()}),0))},onChange:(e,t,n)=>{"clear"!==n&&t?(ze(t.locationid||0),Pe(t),Oe(t),et(null===t||void 0===t?void 0:t.slots)):(ze(0),Pe(null),Oe(null),et(null))},renderInput:e=>(0,de.jsx)(y.A,(0,i.A)((0,i.A)({},e),{},{size:"small",placeholder:"Business Location",label:"Business Location",InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:(0,i.A)((0,i.A)({},e.InputProps),{},{startAdornment:(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(U.A,{style:{color:"#94a3b8",fontSize:14,marginRight:6,flexShrink:0}}),e.InputProps.startAdornment]})})}))})})]})]}),(0,de.jsxs)(j.A,{className:"orders-card",sx:{p:2,flexShrink:0},children:[(0,de.jsx)(m.A,{className:"section-title-bar section-title-bar--accent",sx:{mb:1.5},children:(0,de.jsx)(g.A,{sx:{fontWeight:700,color:"#1e293b",fontSize:13.5,letterSpacing:"-0.01em"},children:"Schedule & Pickup"})}),(0,de.jsxs)(v.Ay,{container:!0,spacing:1.75,children:[(0,de.jsx)(v.Ay,{item:!0,xs:12,sm:6,children:(0,de.jsx)(G.$,{dateAdapter:K.R,children:(0,de.jsx)(q.l,{label:"Pickup Date",format:"DD-MM-YYYY",value:Ue?d()(Ue):null,onChange:e=>{if(!e||!d()(e).isValid())return void Qe(d()().format("MM-DD-YYYY"));d()().diff(d()("".concat(d()(e).format("YYYY-MM-DD"))),"d")<=0?(Qe(d()(e).format("MM-DD-YYYY")),_e(""),nt(null)):(yt("Choose an upcoming date","warning"),Qe(d()().format("MM-DD-YYYY")))},disablePast:!0,slotProps:{textField:{size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},InputProps:{startAdornment:(0,de.jsx)(S.A,{position:"start",children:(0,de.jsx)(Q.A,{style:{color:"#94a3b8",fontSize:"13px"}})})},sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",height:"36px",paddingLeft:"10px"}}}}})})}),(0,de.jsx)(v.Ay,{item:!0,xs:12,sm:6,children:(0,de.jsx)(b.A,{size:"small",fullWidth:!0,options:$e||[],sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",height:"36px"}},onChange:(e,t,n)=>{if("clear"===n||!t)return _e(null),void nt(null);if(!t.time)return void St("This slot has no time configured.","warning",3e3);const i=d()(t.time,"HH:mm").format("hh:mm A");_e(i);const r=d()("".concat(Ue," ").concat(i),"MM-DD-YYYY hh:mm A").format("YYYY-MM-DD hh:mm A");nt(r)},getOptionLabel:e=>e?"".concat(e.name," (").concat(d()(e.time,"HH:mm").format("hh:mm A"),")"):"",renderInput:e=>(0,de.jsx)(y.A,(0,i.A)((0,i.A)({},e),{},{label:"Pickup Slot",placeholder:"Select Pickup Slot",fullWidth:!0,InputLabelProps:{shrink:!0},sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",height:"36px"}},InputProps:(0,i.A)((0,i.A)({},e.InputProps),{},{startAdornment:(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(X.A,{style:{color:"#94a3b8",fontSize:"13px",marginRight:"6px",marginLeft:"2px",flexShrink:0}}),e.InputProps.startAdornment]})})}))})}),(0,de.jsx)(v.Ay,{item:!0,xs:12,children:Ee?(0,de.jsxs)(f.A,{direction:"row",spacing:1.25,alignItems:"center",sx:{border:"1px solid #eef2f6",borderLeft:"3px solid #1890ff",borderRadius:"10px",px:1.25,py:.75,bgcolor:"#fbfcff"},children:[(0,de.jsx)(m.A,{sx:{width:28,height:28,borderRadius:"8px",background:"linear-gradient(135deg,#1890ff,#096dd9)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontSize:12,boxShadow:"0 4px 10px rgba(24,144,255,0.30)"},children:(0,de.jsx)(oe.sIY,{})}),(0,de.jsxs)(m.A,{sx:{minWidth:0,flex:1},children:[(0,de.jsx)(g.A,{sx:{fontSize:12.5,fontWeight:700,color:"#1e293b",lineHeight:1.2},noWrap:!0,children:Ee.locationname||"\u2014"}),(0,de.jsx)(g.A,{sx:{fontSize:11,color:"#64748b",lineHeight:1.3},noWrap:!0,children:Ee.address||"\u2014"})]})]}):(0,de.jsx)(g.A,{sx:{color:"#94a3b8",fontSize:12},children:"Pickup auto-fills once a Business Location is selected."})})]})]}),(0,de.jsxs)(j.A,{className:"orders-card delivery-prefs-card",sx:{p:2,flexShrink:0},children:[(0,de.jsxs)(m.A,{className:"delivery-prefs-header",sx:{mb:1},children:[(0,de.jsx)(g.A,{className:"delivery-prefs-title",children:"Order Notes"}),(0,de.jsx)(g.A,{className:"delivery-prefs-sub",children:"Applied to every order"})]}),(0,de.jsx)(m.A,{className:"delivery-prefs-row",children:(0,de.jsxs)(m.A,{className:"delivery-prefs-field",sx:{width:"100%"},children:[(0,de.jsxs)("label",{className:"delivery-prefs-label",htmlFor:"bulk-dispatch-notes-input",children:[(0,de.jsx)(_.A,{style:{fontSize:11,color:"#65387a"}}),"Special Dispatch Notes"]}),(0,de.jsx)(y.A,{id:"bulk-dispatch-notes-input",size:"small",fullWidth:!0,placeholder:"Gate codes, call instructions, special cargo care\u2026",value:it,onChange:e=>rt(e.target.value),sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",padding:"0 10px",alignItems:"center",fontSize:"12px",background:"#ffffff",height:"32px"},"& .MuiOutlinedInput-input":{padding:"0 !important",fontSize:"12px !important",lineHeight:"32px"}}})]})})]}),(0,de.jsxs)(j.A,{className:"orders-card pricing-summary-card",sx:{flexShrink:0,p:"16px 18px !important"},children:[(0,de.jsxs)(m.A,{className:"pricing-header",sx:{mb:1.5,pb:1},children:[(0,de.jsx)(g.A,{className:"pricing-title",sx:{fontSize:"13px !important"},children:"Bulk Summary"}),(0,de.jsx)(g.A,{className:"pricing-subtitle",sx:{fontSize:"10px !important"},children:"Live totals"})]}),(()=>{const e=e=>{let{icon:t,label:n,value:r,accent:s,active:o}=e;return(0,de.jsxs)(m.A,{sx:(0,i.A)({bgcolor:"#fff",border:"1px solid #eef2f6",borderRadius:"10px",px:1,py:.75,display:"flex",alignItems:"center",gap:.85,minWidth:0,transition:"border-color 0.2s, box-shadow 0.2s"},o&&{borderColor:"".concat(s,"55"),boxShadow:"0 2px 6px -2px ".concat(s,"33")}),children:[(0,de.jsx)(m.A,{sx:{width:26,height:26,borderRadius:"8px",bgcolor:"".concat(s,"18"),color:s,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,flexShrink:0},children:(0,de.jsx)(t,{})}),(0,de.jsxs)(m.A,{sx:{minWidth:0,flex:1},children:[(0,de.jsx)(g.A,{sx:{fontSize:9.5,fontWeight:600,color:"#94a3b8",letterSpacing:.4,textTransform:"uppercase",lineHeight:1},children:n}),(0,de.jsx)(g.A,{sx:{fontSize:13.5,fontWeight:800,color:o?"#1e293b":"#94a3b8",lineHeight:1.2,mt:.25},noWrap:!0,children:r})]})]})};return(0,de.jsxs)(v.Ay,{container:!0,spacing:1.25,children:[(0,de.jsx)(v.Ay,{item:!0,xs:6,children:e({icon:se.$Fg,label:"Distance",value:at?"".concat(at," km"):"\u2014",accent:"#1890ff",active:!!at})}),(0,de.jsx)(v.Ay,{item:!0,xs:6,children:e({icon:se.H5e,label:"Quantity",value:ht||0,accent:"#16a34a",active:!!ht})}),(0,de.jsx)(v.Ay,{item:!0,xs:6,children:e({icon:se.MxO,label:"Cash Collect",value:"\u20b9".concat(Number(ut).toFixed(2)),accent:"#d97706",active:!!ut})}),(0,de.jsx)(v.Ay,{item:!0,xs:6,children:e({icon:se.dv1,label:"Deliveries",value:Fe.length,accent:"#65387a",active:Fe.length>0})})]})})(),Fe.length>0&&(0,de.jsxs)("div",{className:"total-charge-badge",style:{marginTop:14,padding:"10px 14px"},children:[(0,de.jsxs)("div",{className:"total-charge-left",children:[(0,de.jsx)(se.wTh,{className:"total-charge-icon"}),(0,de.jsx)("div",{className:"total-charge-label",children:"Total Charge"})]}),(0,de.jsxs)("div",{className:"total-charge-val",style:{fontSize:17},children:["\u20b9",Number(ct).toFixed(2)]})]}),(0,de.jsx)(m.A,{sx:{mt:1.75},children:(0,de.jsx)(w.A,{fullWidth:!0,className:"gradient-btn-create",disabled:!Wt||be,startIcon:!be&&(0,de.jsx)(se.Cer,{style:{fontSize:11}}),onClick:async()=>{if(!ke)return void yt("Choose Client","warning");if(!Ee)return void yt("Pickup location required","warning");if(!tt)return void yt("Select a pickup slot","warning");if(!Fe.length)return void yt("Add at least one drop customer","warning");const t=(()=>{if(tt){const e=d()(tt,["YYYY-MM-DD hh:mm A","YYYY-MM-DD HH:mm:ss"]);if(e.isValid())return e.format("YYYY-MM-DD HH:mm:ss")}if(Ue&&Xe){const e=d()("".concat(d()(Ue).format("YYYY-MM-DD")," ").concat(Xe),["YYYY-MM-DD hh:mm A","YYYY-MM-DD HH:mm:ss"]);if(e.isValid())return e.format("YYYY-MM-DD HH:mm:ss")}return d()().format("YYYY-MM-DD HH:mm:ss")})(),n=Fe.map((e=>{var n,i,r,s;return{applocationid:Ee.applocationid,configid:9,partnerid:Ee.partnerid,partneruserid:+c,paymentstatus:1,paymenttype:42,pickupaddress:Ee.address||"",pickupcity:Ee.city||"",pickupcontactno:Ee.contactno||"",pickupcustomer:Ee.locationname||"",pickuplandmark:Ee.landmark||"",pickuplat:Ee.latitude,pickuplocation:Ee.suburb||"",pickuplocationid:Ee.locationid||0,pickuplong:Ee.longitude,tenantid:Ee.tenantid,customerid:+(null===e||void 0===e?void 0:e.customerid),deliveryaddress:e.address||"",deliverycharge:+e.totalcharge||0,deliverycity:e.city||"",deliverycontactno:(null===(n=e.contactno)||void 0===n?void 0:n.toString())||"",deliverycustomer:e.firstname||"",deliveryid:+e.customerid,deliverylandmark:e.landmark||"",deliverylat:(null===(i=e.latitude)||void 0===i?void 0:i.toString())||"",deliverylocation:e.suburb||"",deliverylocationid:e.deliverylocationid||0,deliverylong:(null===(r=e.longitude)||void 0===r?void 0:r.toString())||"",deliverytime:t,deliverytype:"B",itemcount:1,quantity:e.quantity,collectionamt:e.collectionamt,kms:(null===(s=e.distance)||void 0===s?void 0:s.toString())||"0",locationid:+Ee.locationid,moduleid:+Ee.moduleid,orderamount:+e.totalcharge||0,ordercharges:0,orderdate:d()().format("YYYY-MM-DD HH:mm:ss"),ordernotes:it,orderstatus:"created",ordervalue:+e.totalcharge||0,pickupSlot:tt}}));je(!0),ye(!0);try{const t=await s.A.post("".concat("https://jupiter.nearle.app/live/api/v1","/orders/createorders"),n);var i;if(t.data.status)yt("Orders Created Successfully","success",2e3),st&&(async()=>{try{"Success"===(await s.A.post("".concat("https://jupiter.nearle.app/live/api/v1","/utils/sendnotifications"),{priority:"high",registration_ids:st,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"}})).data.message&&yt("Notification sent Successfully","success",1e3)}catch(e){yt(e.message,"error",1e3)}})(),e("/nearle/orders");else yt((null===t||void 0===t||null===(i=t.data)||void 0===i?void 0:i.message)||"Order creation failed. Please try again.","warning",3e3)}catch(o){let e="Something went wrong. Please try again.";var r;if(o.response)e=(null===(r=o.response.data)||void 0===r?void 0:r.message)||"Server error (".concat(o.response.status,")");else o.request&&(e="Network error. Check your internet connection.");yt(e,"error",3e3)}finally{je(!1),ye(!1)}},sx:{minHeight:"36px !important"},children:be?(0,de.jsx)(k.A,{color:"inherit",size:16,thickness:5}):"Dispatch ".concat(Fe.length||""," ").concat(1===Fe.length?"Order":"Orders").trim()})})]})]}),(0,de.jsx)(v.Ay,{item:!0,xs:12,md:6,sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column"},children:(0,de.jsxs)(j.A,{className:"orders-card",sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:1.25,maxHeight:685},children:[(0,de.jsxs)(f.A,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,sx:{mb:.75,flexShrink:0},children:[(0,de.jsxs)(m.A,{className:"section-title-bar",sx:{mb:0},children:[(0,de.jsx)(g.A,{sx:{fontWeight:700,color:"#1e293b",fontSize:13.5,letterSpacing:"-0.01em"},children:"drops"===Mt?"Drop List":"preview"===Mt?"File Preview":"Preview"}),(0,de.jsx)(A.A,{size:"small",label:"drops"===Mt?Fe.length:"preview"===Mt?gt.length:0,sx:{height:20,fontSize:10.5,fontWeight:700,ml:1,bgcolor:"rgba(168,85,247,0.10)",color:"#65387a",border:"1px solid rgba(168,85,247,0.25)"}})]}),"drops"===Mt&&(0,de.jsx)(A.A,{size:"small",label:"\u20b9".concat(Number(ct).toFixed(2)," total"),sx:{height:22,fontWeight:700,fontSize:11,bgcolor:"rgba(101,56,122,0.10)",color:"#65387a",border:"1px solid rgba(101,56,122,0.25)"}}),"preview"===Mt&&(0,de.jsx)(A.A,{size:"small",label:"Awaiting Continue",icon:(0,de.jsx)($.A,{style:{fontSize:11}}),sx:{height:22,fontWeight:700,fontSize:11,bgcolor:"rgba(245,158,11,0.12)",color:"#b45309",border:"1px solid rgba(245,158,11,0.30)","& .MuiChip-icon":{color:"#b45309"}}}),"empty"!==Mt&&(()=>{const e=Se&&ke&&Ce,t=t=>{var n;e?(ft(t),0===t?null===(n=document.getElementById("upload-file"))||void 0===n||n.click():1===t&&(Ge(!0),Ze(""))):St("Please select Location, Client, and Business Location first.","warning",3e3)};return(0,de.jsxs)(f.A,{direction:"row",gap:.75,alignItems:"center",children:[(0,de.jsx)(w.A,{size:"small",variant:"outlined",onClick:()=>t(0),startIcon:(0,de.jsx)(ae.CtR,{}),sx:{height:24,py:0,textTransform:"none",borderRadius:"6px",fontSize:10.5,fontWeight:600,borderColor:"#cbd5e1",color:"#475569","&:hover":{borderColor:"#1890ff",color:"#1890ff"}},children:"Excel / CSV"}),(0,de.jsx)(w.A,{size:"small",variant:"outlined",onClick:()=>t(1),startIcon:(0,de.jsx)(se.YXz,{}),sx:{height:24,py:0,textTransform:"none",borderRadius:"6px",fontSize:10.5,fontWeight:600,borderColor:"#cbd5e1",color:"#475569","&:hover":{borderColor:"#65387a",color:"#65387a"}},children:"Selection"})]})})()]}),vt&&(0,de.jsxs)(f.A,{direction:"row",gap:.75,alignItems:"center",sx:{mb:.75,color:"#64748b",flexShrink:0},children:[(0,de.jsx)(ee.A,{style:{fontSize:12}}),(0,de.jsx)(g.A,{sx:{fontSize:11.5},noWrap:!0,children:vt})]}),"preview"===Mt&>.length>=1&&(0,de.jsxs)(m.A,{sx:{mb:1,p:1.25,bgcolor:"rgba(245,158,11,0.06)",border:"1.5px solid rgba(245,158,11,0.25)",borderRadius:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,animation:"blink 1.5s infinite","@keyframes blink":{"0%":{borderColor:"rgba(245,158,11,0.25)"},"50%":{borderColor:"rgba(245,158,11,0.6)"},"100%":{borderColor:"rgba(245,158,11,0.25)"}}},children:[(0,de.jsxs)(m.A,{sx:{textAlign:"left"},children:[(0,de.jsx)(g.A,{sx:{fontWeight:700,fontSize:12,color:"#b45309",lineHeight:1.2},children:"Process & Calculate Distances"}),(0,de.jsx)(g.A,{sx:{color:"#b45309",opacity:.8,fontSize:10.5,lineHeight:1.25},children:"Click continue to import spreadsheet rows and calculate drop charges."})]}),(0,de.jsx)(w.A,{variant:"contained",size:"small",color:"warning",onClick:()=>gt.forEach((e=>kt(e))),sx:{textTransform:"none",borderRadius:"8px",fontWeight:700,fontSize:11,height:28,px:1.5,bgcolor:"#d97706",boxShadow:"none","&:hover":{bgcolor:"#b45309",boxShadow:"none"}},children:"Continue"})]}),(0,de.jsxs)(m.A,{sx:{flex:1,minHeight:0,overflow:"auto"},children:["drops"===Mt&&(0,de.jsx)(Y.A,{component:C.A,sx:{borderRadius:"10px",border:"1px solid #eef2f6",boxShadow:"none"},children:(0,de.jsxs)(z.A,{size:"small",stickyHeader:!0,children:[(0,de.jsx)(W.A,{sx:{bgcolor:"#f8fafc"},children:(0,de.jsxs)(M.A,{children:[(0,de.jsx)(D.A,{sx:pe,children:"#"}),(0,de.jsx)(D.A,{sx:pe,children:"Customer"}),(0,de.jsx)(D.A,{sx:pe,children:"Address"}),(0,de.jsx)(D.A,{sx:pe,align:"center",children:"Qty"}),(0,de.jsx)(D.A,{sx:pe,align:"center",children:"Cash"}),(0,de.jsx)(D.A,{sx:pe,children:"Km"}),(0,de.jsx)(D.A,{sx:pe,align:"right",children:"Charge"}),(0,de.jsx)(D.A,{sx:pe,align:"center",children:" "})]})}),(0,de.jsxs)(P.A,{children:[Fe.map(((e,t)=>(0,de.jsxs)(M.A,{hover:!0,children:[(0,de.jsx)(D.A,{sx:ue,children:t+1}),(0,de.jsx)(D.A,{sx:(0,i.A)((0,i.A)({},ue),{},{whiteSpace:"nowrap",color:"#1e293b",fontWeight:600}),children:e.firstname}),(0,de.jsx)(D.A,{sx:(0,i.A)((0,i.A)({},ue),{},{color:"#64748b",maxWidth:220}),children:(0,de.jsx)(I.A,{title:e.address||"",children:(0,de.jsx)("span",{style:{display:"inline-block",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"middle"},children:e.address})})}),(0,de.jsx)(D.A,{align:"center",sx:ue,children:0===mt?e.quantity:(0,de.jsx)(y.A,{size:"small",type:"number",value:e.quantity||"",onChange:t=>{return n=e.customerid,r=t.target.value,void Be((e=>e.map((e=>e.customerid===n?(0,i.A)((0,i.A)({},e),{},{quantity:Number(r)||0}):e))));var n,r},inputProps:{min:0},sx:{width:64,"& .MuiOutlinedInput-root":{borderRadius:"8px",height:30}}})}),(0,de.jsx)(D.A,{align:"center",sx:ue,children:0===mt?"\u20b9".concat(Number(e.collectionamt||0).toFixed(2)):(0,de.jsx)(y.A,{size:"small",type:"number",value:e.collectionamt?e.collectionamt:"",placeholder:"0",onChange:t=>{const n=Number(t.target.value);var r,s;r=e.customerid,s=n>0?n:0,Be((e=>e.map((e=>e.customerid===r?(0,i.A)((0,i.A)({},e),{},{collectionamt:Number(s)||0}):e))))},inputProps:{min:0},InputProps:{startAdornment:(0,de.jsx)(S.A,{position:"start",children:"\u20b9"})},sx:{width:90,"& .MuiOutlinedInput-root":{borderRadius:"8px",height:30}}})}),(0,de.jsx)(D.A,{sx:ue,children:e.distance}),(0,de.jsxs)(D.A,{align:"right",sx:(0,i.A)((0,i.A)({},ue),{},{fontWeight:700,color:"#1e293b"}),children:["\u20b9",Number((null===e||void 0===e?void 0:e.totalcharge)||0).toFixed(2)]}),(0,de.jsx)(D.A,{align:"center",sx:ue,children:(0,de.jsx)(I.A,{title:"Remove",children:(0,de.jsx)(N.A,{size:"small",onClick:()=>kt(e),sx:{color:"#ef4444",p:.5},children:(0,de.jsx)(te.A,{style:{fontSize:13}})})})})]},e.customerid||e.firstname||t))),(0,de.jsxs)(M.A,{sx:{bgcolor:"#fafbfc"},children:[(0,de.jsx)(D.A,{sx:(0,i.A)((0,i.A)({},ue),{},{fontWeight:800}),children:"Total"}),(0,de.jsx)(D.A,{colSpan:2,sx:ue}),(0,de.jsx)(D.A,{align:"center",sx:(0,i.A)((0,i.A)({},ue),{},{fontWeight:800}),children:ht}),(0,de.jsxs)(D.A,{align:"center",sx:(0,i.A)((0,i.A)({},ue),{},{fontWeight:800}),children:["\u20b9",Number(ut).toFixed(2)]}),(0,de.jsx)(D.A,{sx:(0,i.A)((0,i.A)({},ue),{},{fontWeight:800}),children:at}),(0,de.jsxs)(D.A,{align:"right",sx:(0,i.A)((0,i.A)({},ue),{},{fontWeight:800,color:"#65387a"}),children:["\u20b9",Number(ct).toFixed(2)]}),(0,de.jsx)(D.A,{sx:ue})]})]})]})}),"preview"===Mt&&(0,de.jsx)(Y.A,{component:C.A,sx:{borderRadius:"10px",border:"1px solid #eef2f6",boxShadow:"none"},children:(0,de.jsxs)(z.A,{size:"small",stickyHeader:!0,children:[(0,de.jsx)(W.A,{sx:{bgcolor:"#f8fafc"},children:(0,de.jsxs)(M.A,{children:[(0,de.jsx)(D.A,{sx:pe,children:"#"}),(0,de.jsx)(D.A,{sx:pe,children:"Name"}),(0,de.jsx)(D.A,{sx:pe,children:"Contact"}),(0,de.jsx)(D.A,{sx:pe,children:"Address"}),(0,de.jsx)(D.A,{sx:pe,align:"center",children:"Qty"}),(0,de.jsx)(D.A,{sx:pe,align:"center",children:"Cash"})]})}),(0,de.jsx)(P.A,{children:gt.map(((e,t)=>{var n;return(0,de.jsxs)(M.A,{hover:!0,children:[(0,de.jsx)(D.A,{sx:ue,children:t+1}),(0,de.jsx)(D.A,{sx:(0,i.A)((0,i.A)({},ue),{},{whiteSpace:"nowrap",color:"#1e293b",fontWeight:600}),children:e.firstname||"\u2014"}),(0,de.jsx)(D.A,{sx:ue,children:e.contactno||"\u2014"}),(0,de.jsx)(D.A,{sx:(0,i.A)((0,i.A)({},ue),{},{color:"#64748b",maxWidth:240}),children:(0,de.jsx)(I.A,{title:e.address||"",children:(0,de.jsx)("span",{style:{display:"inline-block",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"middle"},children:e.address||"\u2014"})})}),(0,de.jsx)(D.A,{align:"center",sx:ue,children:null!==(n=e.quantity)&&void 0!==n?n:"\u2014"}),(0,de.jsx)(D.A,{align:"center",sx:ue,children:null!=e.collectionamt?"\u20b9".concat(Number(e.collectionamt).toFixed(2)):"\u2014"})]},t)}))})]})}),"empty"===Mt&&(()=>{const e=Se&&ke&&Ce,t=t=>{var n;e?(ft(t),Be([]),At([]),jt(""),0===t?null===(n=document.getElementById("upload-file"))||void 0===n||n.click():1===t&&(Ge(!0),Ze(""))):St("Please select Location, Client, and Business Location first.","warning",3e3)},n=n=>{let{value:i,icon:r,title:s,sub:o,accent:a}=n;return(0,de.jsxs)(m.A,{role:"button",tabIndex:0,onClick:()=>t(i),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),t(i))},sx:{flex:1,minWidth:0,display:"flex",alignItems:"center",textAlign:"left",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",border:"1.5px solid #eef2f6",bgcolor:"#fff",opacity:e?1:.6,cursor:e?"pointer":"not-allowed",transition:"all 0.18s ease","&:hover":e?{borderColor:a,boxShadow:"0 4px 12px -4px ".concat(a,"40"),transform:"translateY(-1px)"}:void 0},children:[(0,de.jsx)(m.A,{sx:{width:32,height:32,borderRadius:"8px",background:"".concat(a,"15"),color:a,display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,flexShrink:0},children:(0,de.jsx)(r,{})}),(0,de.jsxs)(m.A,{sx:{minWidth:0,flex:1},children:[(0,de.jsx)(g.A,{sx:{fontWeight:700,fontSize:13,color:"#1e293b",lineHeight:1.15},children:s}),(0,de.jsx)(g.A,{sx:{fontSize:11,color:"#94a3b8",lineHeight:1.25},noWrap:!0,children:o})]})]})};return(0,de.jsxs)(f.A,{alignItems:"center",justifyContent:"center",spacing:1.5,sx:{height:"100%",minHeight:240,bgcolor:"rgba(24,144,255,0.03)",border:"1px dashed rgba(24,144,255,0.25)",borderRadius:"12px",p:3,textAlign:"center"},children:[(0,de.jsx)(m.A,{sx:{width:56,height:56,borderRadius:"14px",bgcolor:"rgba(24,144,255,0.08)",color:"#1890ff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:28},children:(0,de.jsx)(ne.A,{})}),(0,de.jsx)(g.A,{sx:{fontWeight:700,color:"#1e293b",fontSize:14},children:"Choose a Drop Source to begin"}),(0,de.jsx)(g.A,{sx:{color:"#64748b",fontSize:12,maxWidth:360,mb:1},children:"Select a source from below or the left panel to import or pick your delivery customers."}),(0,de.jsxs)(f.A,{direction:{xs:"column",sm:"row"},gap:1.5,sx:{width:"100%",maxWidth:480,mt:1},children:[n({value:0,icon:ae.CtR,title:"Excel / CSV",sub:"Bulk upload a sheet",accent:"#1890ff"}),n({value:1,icon:se.YXz,title:"Selection",sub:"Pick saved customers",accent:"#65387a"})]})]})})()]})]})})]})]}),(0,de.jsx)("input",{accept:".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",id:"upload-file",type:"file",hidden:!0,onChange:e=>{const t=e.target.files[0];if(!t)return;const n=t.name.replace(/\.[^/.]+$/,"");jt((e=>e?"".concat(e,", ").concat(n):n)),(e=>{try{var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!n)return void yt("No file selected.","warning");const i=n.name.toLowerCase(),r=i.endsWith(".csv"),s=i.endsWith(".xls")||i.endsWith(".xlsx");if(!r&&!s)return void yt("Invalid file type. Please upload a CSV or Excel file.","warning");const o=(e,t)=>{const n={};for(const s in Ct)n[Yt(s)]=Ct[s];const i=e.map((e=>{const t={};for(const r in e){const s=Yt(r),o=n[s]||s;let a=e[r];"firstname"===o&&(a="string"===typeof(i=a)?i.replace(/^[\d.\s]+/,"").trim():i),t[o]=a}var i;return t})),r=Object.keys(Ct).filter((e=>!t.includes(Yt(e))));r.length>0&&yt("Missing columns: ".concat(r.join(", ")),"warning"),At(i),yt("File uploaded successfully","success",2e3),yt("Press Continue to add as drop customers","info",2500)};if(r&&a().parse(n,{header:!0,dynamicTyping:!0,skipEmptyLines:!0,complete:e=>{var t;if(null===(t=e.data)||void 0===t||!t.length)return yt("CSV file is empty or has no valid rows.","warning"),void At([]);const n=e.meta.fields.map(Yt);o(e.data,n)},error:e=>yt("CSV parsing failed: ".concat(e.message),"warning")}),s){const e=new FileReader;e.onload=e=>{try{const t=e.target.result,n=l.LF(t,{type:"binary"}),i=n.SheetNames[0],r=n.Sheets[i],s=l.Wp.sheet_to_json(r,{defval:""});if(null===s||void 0===s||!s.length)return yt("Excel file is empty or invalid.","warning"),void At([]);const a=Object.keys(s[0]).map(Yt);o(s,a)}catch(t){yt("Error reading Excel: ".concat(t.message),"warning")}},e.readAsBinaryString(n)}}catch(n){yt("Unexpected error: ".concat(n.message),"warning")}})(e)}}),(0,de.jsxs)(R.A,{open:qe,onClose:()=>Ge(!1),fullWidth:!0,sx:{"& .MuiDialog-paper":{borderRadius:"16px",overflow:"hidden"}},children:[(0,de.jsx)(H.A,{sx:{bgcolor:t.palette.primary.main,color:"white",py:2.5},children:(0,de.jsxs)(f.A,{spacing:1.5,children:[(0,de.jsx)(g.A,{variant:"h4",sx:{fontWeight:600,color:"white"},children:"Select Drop Customers (".concat(Fe.length||0,")")}),(0,de.jsx)(L.A,{sx:{width:"100%"},children:(0,de.jsx)(T.A,{autoFocus:!0,fullWidth:!0,id:"input-search-header",placeholder:"Search by name, contact, or address\u2026",value:Ke,onChange:e=>Ze(e.target.value),sx:{bgcolor:"white",borderRadius:"10px","& .MuiOutlinedInput-input":{p:"10px 14px"}},startAdornment:(0,de.jsx)(S.A,{position:"start",children:(0,de.jsx)(ie.A,{style:{fontSize:"small",color:"#64748b"}})}),endAdornment:(0,de.jsx)(N.A,{sx:{visibility:Ke?"visible":"hidden",p:.5},onClick:()=>Ze(""),children:(0,de.jsx)(Z.A,{style:{fontSize:"18px"}})}),autoComplete:"off"})})]})}),(0,de.jsx)(E.A,{}),(0,de.jsx)(O.A,{sx:{p:2.5,bgcolor:"#fafbfc",minHeight:400,maxHeight:600},children:0===(null===Je||void 0===Je?void 0:Je.length)?(0,de.jsx)(f.A,{alignItems:"center",justifyContent:"center",sx:{minHeight:300},children:(0,de.jsx)(re.A,{description:"No saved customers found for this client"})}):(0,de.jsx)(f.A,{spacing:0,children:null===Je||void 0===Je?void 0:Je.map(((e,t)=>{const n=Fe.some((t=>t.customerid===e.customerid));return(0,de.jsx)(F.A,{children:(0,de.jsx)(B.A,{sx:{m:0,py:1,px:1.25,borderRadius:"10px","&:hover":{bgcolor:"rgba(24,144,255,0.04)"}},control:(0,de.jsx)(J.A,{checked:n,onChange:t=>(async(e,t)=>{je(!0);try{if(e.target.checked){const{roundedDistance:e,totalcharge:n}=await wt(t);Be((r=>[...r,(0,i.A)((0,i.A)({},t),{},{distance:e,totalcharge:n})]))}else Be((e=>e.filter((e=>e.customerid!==t.customerid))))}catch(n){console.error("Failed to calculate distance:",n)}finally{je(!1)}})(t,e)}),label:(0,de.jsxs)(m.A,{sx:{width:"100%"},children:[(0,de.jsxs)(g.A,{sx:{fontWeight:600,color:"#1e293b",fontSize:13.5},children:[e.firstname," (",e.contactno,")"]}),(0,de.jsx)(g.A,{sx:{color:"#64748b",fontSize:12,mt:.25},children:e.address})]})})},e.customerid||t)}))})}),(0,de.jsx)(E.A,{}),(0,de.jsx)(V.A,{sx:{p:2,bgcolor:"#fafbfc"},children:(0,de.jsx)(w.A,{variant:"outlined",color:0===Fe.length?"error":"primary",onClick:()=>Ge(!1),sx:{borderRadius:"10px",textTransform:"none",fontWeight:600,px:3},children:0===Fe.length?"Close":"Continue"})})]})]})}},42041:()=>{},62217:e=>{"use strict";e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAA+CAYAAABzwahEAAAPnUlEQVR4AdVae3AU9R3/7d4jdyGQQKAhECBAJBSmEAtFSQUjqPgAHGlhRm0lDkWY6Tg+O9qiErR26h8WR8ZWqTMN1ur4qMpDrTyjtDwDJloeCYiBvAgkaZ53l7vb3X4/v9vfZS/Zu9uFwLSfmb3d293f7u/z+z5/399K7CphdW5JrupgBZosZ0ialmu8pklSjUOTamRJbvvjqTUV7CpAYlcIj+SWZHQ55WJZlm7UNK2IXpRhpZ3GWJskSWXUZrPD4Sp77eSva9gVwIATXz35+SJNYWs1phWxAYDEpDKVaZv+fOrZUjaAGDDiK695rpgetpYOc82upw72sMycdJbz/SzmHeKl/ynRay31bbS1s7rjTczXGYj3ihrShnUDNQCXTXzlNS8UyExdbybhSdeNYwXz81nBzflE2pKms7oT51ntiSa276NKVn3wrNktNcGQelNpTUkNuwxcFvFV+S88rKnKy8ZzkOz84uvYvOJZ/PhyAE3Y/+HXbN+HFVwjjJAlR8lr1WueY9wt2MclEYfj8rnkj+nwRnHOLuGWhnbmpfuMKh/3Xn0Atm74IuY8OcGPFYk99kbVM98xm7BFnDyttHLyb3MlRdsjSWycOA+VLv79YpY5Ork6V5efY59s/JJVHznH/+dMymLz7v0Rm71oWtK2GIDSJ7ew6kMxJlCjytI8u+Qddm4+93bPBIfqiiG96KG5RPouljokuZT3b/2avf7EB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XfrGkwsiJRIMLF1i76MBEue7qE0XqTPadYiNnFen3j6Ad5HGYSDwTcslkQYGamVULLrLpH7y6dOnuY1TGctFFR0hcYfhvujinQ6eaNBgYc6sEHm+0WAKqatEWJkwYYI6depUjYhbtuWrBW775GGd1FEXFQA8FFsR8+HRMdFBKocgPrTvRkgnh4l70ijPxtwAzpLnCLpDvSztvFqQ9C8PuAPEINDeTdpgjADYjOFQhESn3s6hP+OKr9dfSUhCaiIcYjNIMur52f850f95/BfoYlARf1CQvwAAAABJRU5ErkJggg=="},83686:()=>{},94826:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var i=n(59254),r=n(46639),s=n(62217),o=n(44414);const a=(0,i.Ay)("div")((()=>({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:2001,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255, 255, 255, 0.7)",padding:"20px",borderRadius:"10px"}))),l=(0,i.Ay)("div")((()=>({position:"absolute",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center"}))),c=()=>(0,o.jsxs)(a,{children:[(0,o.jsx)(r.A,{color:"primary",size:80,thickness:6}),(0,o.jsx)(l,{children:(0,o.jsx)("img",{src:s,alt:"Logo",style:{width:"100%",height:"100%"}})})]})}}]); |