1 line
61 KiB
JavaScript
1 line
61 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[4947],{13968:(e,r,t)=>{t.r(r),t.d(r,{default:()=>ze});var o=t(89379),n=t(9950),i=t(47965),l=t(44070),s=t(36256),a=t(13838),c=t(4159),d=t.n(c),x=t(36150),h=t(60010),u=t(51778),p=(t(47659),t(14857)),A=t(94118),g=t(37476),f=t(94826),m=t(52351),j=t(67562),b=t(49883),v=t(31222),y=t(35678),k=t(56311),S=t(44414);var w=t(50027),C=t(20466),W=t(96646),D=t(59212),I=t(27001),z=t(36803);const M=t.p+"static/media/aiImage.89c2ccb91a41d85031e3.png";var Y=t(63189),P=t(99324),R=t(6604),O=t(2235),F=t(41413),T=t(47223),L=t(55158),E=t(59382),N=t(28810),q=t(79046),H=t(33092),K=t(60899),_=t(77922),B=t(29925),U=t(93230),Z=t(83274),Q=t(16491),V=t(82053),X=t(1320),G=t(93038),J=t(25333),$=t(15769),ee=t(69780),re=t(9213),te=t(21671),oe=t(34075),ne=t(96583),ie=t(40033),le=t(25277),se=t(28170),ae=t(79739),ce=t(82223),de=t(74745),xe=t(81425),he=t(58691),ue=t(23787),pe=t(28429),Ae=t(90376),ge=t(54413),fe=t(36220);d().extend(fe);const me={radiusPill:999,radiusCard:14,shadowSoft:"0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.05)",shadowMd:"0 1px 3px rgba(15, 23, 42, 0.06)",shadowPop:"0 12px 32px rgba(15, 23, 42, 0.12)",textPrimary:"#0f172a",textSecondary:"#64748b",textMuted:"#94a3b8",borderSubtle:"#e2e8f0",divider:"#f1f5f9",surface:"#ffffff",surfaceAlt:"#f8fafc"},je=(e,r)=>"".concat(e).concat(r),be=e=>je(e,"08"),ve=e=>je(e,"18"),ye=e=>je(e,"26"),ke=e=>je(e,"55"),Se="#662582",we=e=>(0,S.jsx)(O.A,(0,o.A)((0,o.A)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:me.shadowPop,border:"1px solid",borderColor:"divider",overflow:"hidden"}})),Ce=e=>{let{color:r,selected:t,size:o=24,children:n}=e;return(0,S.jsx)(F.A,{sx:{width:o,height:o,bgcolor:t?r:ve(r),color:t?"#fff":r,transition:"background-color 0.15s, color 0.15s"},children:n})},We=()=>({"& .MuiOutlinedInput-root":{borderRadius:"10px",bgcolor:"#ffffff",fontWeight:600,"& fieldset":{borderColor:"#e2e8f0",borderWidth:1},"&:hover fieldset":{borderColor:"#cbd5e1"},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(ye("#662582"))},"&.Mui-focused fieldset":{borderColor:"#662582",borderWidth:1.5}}}),De={created:{label:"Created",color:"#0ea5e9",icon:v.F6S},pending:{label:"Pending",color:"#f59e0b",icon:v.tX0},processing:{label:"Processing",color:"#0ea5e9",icon:v.bfP},modified:{label:"Modified",color:"#06b6d4",icon:v.bfP},confirmed:{label:"Confirmed",color:"#10b981",icon:v.mU9},accepted:{label:"Accepted",color:"#6366f1",icon:v.mU9},delivered:{label:"Delivered",color:"#10b981",icon:v.mU9},cancelled:{label:"Cancelled",color:"#ef4444",icon:v.uDv}},Ie=[{idx:0,status:"created",label:"Created",color:Se,icon:v.F6S,countKey:"created"},{idx:1,status:"pending",label:"Pending",color:"#f59e0b",icon:v.tX0,countKey:"pending"},{idx:2,status:"delivered",label:"Delivered",color:"#10b981",icon:v.mU9,countKey:"delivered"},{idx:3,status:"cancelled",label:"Cancelled",color:"#ef4444",icon:v.uDv,countKey:"cancelled"}],ze=()=>{const e=(0,p.A)(),r=(0,T.A)(e.breakpoints.down("md")),t=(0,pe.Zp)(),c=(0,n.useRef)(),fe=(0,n.useRef)(),je=(0,n.useRef)(null),ze=(0,n.useRef)(null),[Me,Ye]=(0,n.useState)(0),[Pe,Re]=(0,n.useState)("All"),[Oe,Fe]=(0,n.useState)(!1),[Te,Le]=(0,n.useState)(d()().format("YYYY-MM-DD")),[Ee,Ne]=(0,n.useState)(d()().format("YYYY-MM-DD")),[qe,He]=(0,n.useState)("Today"),[Ke,_e]=(0,n.useState)(!1),[Be,Ue]=(0,n.useState)(0),[Ze,Qe]=(0,n.useState)("created"),[Ve,Xe]=(0,n.useState)(!1),[Ge,Je]=(0,n.useState)(!1),[$e,er]=(0,n.useState)(!1),[rr,tr]=(0,n.useState)(null),[or,nr]=(0,n.useState)(null),[ir,lr]=(0,n.useState)(""),[sr,ar]=(0,n.useState)(0),[cr,dr]=(0,n.useState)(null),[xr,hr]=(0,n.useState)(0),[ur,pr]=(0,n.useState)(0),[Ar,gr]=(0,n.useState)(""),[fr,mr]=(0,n.useState)(""),[jr,br]=(0,n.useState)(!1),[vr,yr]=(0,n.useState)(!1),[kr,Sr]=(0,n.useState)(null),[wr,Cr]=(0,n.useState)(null),[Wr,Dr]=(0,n.useState)(!1),[Ir,zr]=(0,n.useState)(!1),[Mr,Yr]=(0,n.useState)(!1),[Pr,Rr]=(0,n.useState)(null),[Or,Fr]=(0,n.useState)([]),[Tr,Lr]=(0,n.useState)([]),[Er,Nr]=(0,n.useState)(null),[qr,Hr]=(0,n.useState)(null),[Kr]=(0,n.useState)(0),[_r,Br]=(0,n.useState)([]),[Ur,Zr]=(0,n.useState)([]),Qr=(0,n.useRef)(0),Vr=(0,n.useRef)(null),[Xr,Gr]=(0,n.useState)(null),[Jr,$r]=(0,n.useState)([]);(0,n.useEffect)((()=>{hr(0),Sr(null),pr(0),Cr(null)}),[Me]),(0,n.useEffect)((()=>{pr(0),Cr(null)}),[xr]),(0,n.useEffect)((()=>{const e=Ur.map((e=>({zone_name:e.zone_name,ordernotes:e.ordernotes,rider:e.rider,step:e.step,ordertype:e.ordertype,orderamount:e.orderamount,riderkms:e.riderkms,cumulativekms:e.cumulativekms,baseprice:e.baseprice,minkm:e.minkm,priceperkm:e.priceperkm,kms:e.kms,actualkms:e.actualkms,rider_charge:e.rider_charge,deliveryamt:e.deliveryamt,deliverycharges:e.deliverycharges,profit:e.profit})));Br(e),console.log("csvExportData",e)}),[Ur]),(0,n.useEffect)((()=>{if(null===Tr||void 0===Tr||!Tr.length)return;const e=Tr.map((e=>{const r=Number(e.cumulativekms||0),t=Number(e.minkm||0),n=Number(e.baseprice||0),i=Number(e.priceperkm||0);return r<=t?(0,o.A)((0,o.A)({},e),{},{deliveryamt:n}):(0,o.A)((0,o.A)({},e),{},{deliveryamt:(r-t)*i+n})}));Zr(e),console.log("finaldeliveryList",e)}),[Tr]);const{data:et,isLoading:rt,isError:tt,error:ot,refetch:nt}=(0,x.I)({queryKey:["percentageData",Me],queryFn:()=>(0,xe.jy)(Me),enabled:!0}),{data:it,isLoading:lt,isError:st,error:at}=(0,x.I)({queryKey:["tenantlist",Me],queryFn:()=>(0,xe.Mn)(Me),enabled:0!==Me}),{data:ct,isLoading:dt,isError:xt,error:ht}=(0,x.I)({queryKey:["gettenantlocations",xr],queryFn:()=>(0,xe.DL)(xr),enabled:0!==xr}),{data:ut=[],isLoading:pt}=(0,x.I)({queryKey:["paymentmodes"],queryFn:xe.HY}),{data:At=[],isLoading:gt}=(0,x.I)({queryKey:["ridersList",Me],queryFn:xe.Sd,enabled:0!==Me}),{data:ft,isLoading:mt,isError:jt,error:bt,refetch:vt}=(0,x.I)({queryKey:["ordersCount",Me,Te,Ee,Ze,xr,ur],queryFn:xe.Hh,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:yt}=(0,x.I)({queryKey:["getallriders"],queryFn:xe.Xw,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:kt,isLoading:St,isError:wt,error:Ct,fetchNextPage:Wt,hasNextPage:Dt,isFetchingNextPage:It,refetch:zt}=(0,h.q)({queryKey:["fetchOrders",Me,Ze,fr,Te,Ee,100,xr,ur],queryFn:xe.nQ,getNextPageParam:e=>{var r;return null!==(r=e.nextPage)&&void 0!==r?r:void 0},refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,staleTime:0}),Mt=(null===kt||void 0===kt?void 0:kt.pages.flatMap((e=>e.rows)))||[];(0,n.useEffect)((()=>{if(!Dt)return;const e=new IntersectionObserver((e=>{e[0].isIntersecting&&Wt()}),{root:document.querySelector(".MuiTableContainer-root"),rootMargin:"0px",threshold:1});return c.current&&e.observe(c.current),()=>{c.current&&e.unobserve(c.current)}}),[Dt,Wt]);const Yt=(0,u.n)({mutationFn:0==Qr.current?xe.FC:xe.Yk,onSuccess:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(console.log("data",e),console.log("varialbles",r),(0,C.k)("Orders Optimised Successfully","success",2e3),vt(),zt(),Fe(!1),br(!1),0==Qr.current)Lr(null===e||void 0===e?void 0:e.details),Nr(null===e||void 0===e?void 0:e.zones),Hr(null===e||void 0===e?void 0:e.meta),Yr(!0);else{var o,n,i;Lr(null===e||void 0===e?void 0:e.details),Nr(null===e||void 0===e?void 0:e.zones),Hr(null===e||void 0===e?void 0:e.meta),Rr(e);const r=Vr.current||{};t("/nearle/dispatch/preview",{state:{dispatchPreviewData:e,aiMode:null!==(o=r.aiMode)&&void 0!==o?o:Qr.current,selectedMode:r.selectedMode||Xr,deliveryData:r.deliveryData||[],autoRiders:r.autoRiders||yt||[],absentRidersPayload:r.absentRidersPayload||[],rider:r.rider||rr,appId:null!==(n=r.appId)&&void 0!==n?n:Me,tenantId:null!==(i=r.tenantid)&&void 0!==i?i:xr,startdate:Te}})}},onError:e=>{(0,C.k)(e.message,"error",4e3),br(!1),Fe(!1)},onSettled:()=>{Et(),Fe(!1),br(!1),yr(!1)}}),Pt=(0,u.n)({mutationFn:xe.H2,onMutate:()=>{yr(!0)},onSuccess:e=>{console.log("create data",e),(0,C.k)("Delivery Created Successfully","success",2e3),t("/nearle/deliveries"),Ft.mutate(null===rr||void 0===rr?void 0:rr.userfcmtoken)},onError:e=>{(0,C.k)(e.message,"error",4e3)},onSettled:()=>{yr(!1)}}),Rt=(0,u.n)({mutationFn:xe.N4,onSuccess:e=>{e.status&&(Xe(!1),(0,C.k)("Order Cancelled Successfully","success",2e3),vt(),nt())},onError:e=>{(0,C.k)(e.message,"error",2e3)}}),Ot=(0,u.n)({mutationFn:xe.zR,onSuccess:e=>{e.status&&(er(!1),(0,C.k)("Order Cancelled Successfully","success",2e3),zt(),vt(),nt(),Fr([]))},onError:e=>{(0,C.k)(e.message,"error",2e3)}}),Ft=(0,u.n)({mutationFn:xe.k3,onSuccess:()=>{(0,C.k)("Notification sent Successfully","success",2e3)},onError:e=>{(0,C.k)(e.message,"error",2e3)}}),Tt=async e=>{yr(!0),Fe(!0);const r=Or.map((e=>(0,o.A)((0,o.A)({},e),{},{deliveryid:0,deliverydate:d()(e.deliverydate).utc().format("YYYY-MM-DD HH:mm:ss"),assigntime:d()().format("YYYY-MM-DD HH:mm:ss"),orderstatus:"pending",orderamount:e.deliverycharge,droplat:e.deliverylat,droplon:e.deliverylong,pickuplat:e.pickuplat,pickuplon:e.pickuplong,ordernotes:e.ordernotes,deliverycharges:e.deliverycharge,pickuplocation:e.pickupsuburb,deliverylocation:e.deliverysuburb})));console.log("deliveryData",r);const t=(Jr||[]).map((e=>({userid:e.userid,username:"".concat(e.firstname||""," ").concat(e.lastname||"").trim()||e.username||"Rider ".concat(e.userid)})));Vr.current={deliveryData:r,absentRidersPayload:t,autoRiders:yt,selectedMode:Xr,aiMode:Qr.current,rider:rr,appId:Me,tenantid:xr},0==Qr.current?Yt.mutate({deliveries:r}):Xr&&1==(null===Xr||void 0===Xr?void 0:Xr.value)?Yt.mutate({deliveries:1==Xr.value?r:{body:r},hypertuning_params:e||null,selectedMode:Xr,absent_riders:t}):Yt.mutate({data:{orders:r,riders:yt,config:{pay_type:"hourly",base_pay:300,strategy:"multi_trip"},absent_riders:t},selectedMode:Xr})},Lt=(0,u.n)({mutationFn:xe.H2,onSuccess:(e,r)=>{console.log("data",e),console.log("varialbles",r),(0,C.k)("Delivery Created Successfully","success",2e3),yr(!1),t("/nearle/deliveries")},onError:e=>{(0,C.k)(e.message,"error",4e3)},onSettled:()=>{yr(!1)}}),Et=()=>{Je(!1),tr(null),nr(null),Gr(null),$r([])},Nt=tt?"Error fetching percentages: ".concat(null===ot||void 0===ot?void 0:ot.message):jt?"Error fetching orders Count: ".concat(null===bt||void 0===bt?void 0:bt.message):wt?"Error fetching orders : ".concat(null===Ct||void 0===Ct?void 0:Ct.message):st?"Error Fetching on Tenants:".concat(null===at||void 0===at?void 0:at.message," "):xt?"Error Fetching on Tenants Locations:".concat(null===ht||void 0===ht?void 0:ht.message," "):null;return(0,n.useEffect)((()=>{Nt&&(console.log(Nt),(0,C.k)(Nt,"error",3e3))}),[Nt]),(0,S.jsxs)(n.Fragment,{children:[(rt||mt||St||lt||dt||jr)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(m.A,{}),(0,S.jsx)(f.A,{})]}),(0,S.jsx)(L.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:jr||St,children:(0,S.jsx)(f.A,{color:"inherit"})}),(0,S.jsx)(L.A,{sx:{zIndex:1e3},open:Wr}),Or.length>0&&(0,S.jsxs)(E.A,{ariaLabel:"Actions",icon:(0,S.jsx)(N.A,{badgeContent:(null===Or||void 0===Or?void 0:Or.length)||"",color:"secondary",children:(0,S.jsx)(q.A,{})}),open:Wr,onOpen:()=>Dr(!0),onClose:()=>Dr(!1),sx:{position:"fixed",bottom:52,right:16,"& .MuiFab-primary":{bgcolor:"#7b1fa2",color:"#fff","&:hover":{bgcolor:"#6a1b9a"},width:64,height:64}},children:[(0,S.jsx)(H.A,{icon:(0,S.jsx)("img",{src:M,alt:"Assign",style:{width:38,height:38,objectFit:"contain",borderRadius:50}}),tooltipTitle:" Optimisation",FabProps:{sx:{bgcolor:"primary.main",color:"#fff","&:hover":{bgcolor:"primary.dark"},width:64,height:64}},onClick:()=>{Qr.current=1,Dr(!1),Je(!0)}}),(0,S.jsx)(H.A,{icon:(0,S.jsx)(i.A,{style:{fontSize:22}}),tooltipTitle:"Manual Assign",FabProps:{sx:{bgcolor:"success.600",color:"#fff","&:hover":{bgcolor:"success.dark"},width:64,height:64}},onClick:()=>{Qr.current=0,Dr(!1),Je(!0)}}),(0,S.jsx)(H.A,{icon:(0,S.jsx)(l.A,{style:{fontSize:22}}),tooltipTitle:"Delete",FabProps:{sx:{bgcolor:"#d32f2f",color:"#fff","&:hover":{bgcolor:"#9a0007"},width:64,height:64}},onClick:()=>{Dr(!1),er(!0)}})]}),(0,S.jsx)(I.A,{title:"Orders",subtitle:"Live \xb7 ".concat(Pe||"All Zones"," \xb7 ").concat(qe),live:!0,action:(0,S.jsx)(D.A,{ref:je,locaName:Pe,setAppId:Ye,setLocoName:Re,setPage:ar,pill:!0,accentColor:Se,icon:(0,S.jsx)(v.HPi,{size:14}),placeholder:"Select Zone",paperComponent:we,sx:{width:{xs:"100%",sm:280},zIndex:100}})}),(0,S.jsx)(K.Ay,{container:!0,spacing:{xs:2,md:2.5},sx:{mb:{xs:1.5,md:2}},children:[{key:"created",label:"Created Orders",color:"#662582",icon:v.AdO,value:null===et||void 0===et?void 0:et.created,percentage:null===et||void 0===et?void 0:et.percentage1},{key:"pending",label:"Pending Orders",color:"#f59e0b",icon:v.G6c,value:null===et||void 0===et?void 0:et.uncoveredOrders,percentage:null===et||void 0===et?void 0:et.percentage2},{key:"delivered",label:"Delivered Orders",color:"#10b981",icon:v.cAP,value:null===et||void 0===et?void 0:et.coveredOrders,percentage:null===et||void 0===et?void 0:et.percentage3},{key:"cancelled",label:"Cancelled Orders",color:"#ef4444",icon:v.qiG,value:null===et||void 0===et?void 0:et.cancelled,percentage:null===et||void 0===et?void 0:et.percentage4}].map((e=>{var r;const t=e.icon;return(0,S.jsx)(K.Ay,{item:!0,xs:6,sm:6,md:3,children:(0,S.jsx)(z.A,{title:e.label,value:null!==(r=e.value)&&void 0!==r?r:0,icon:(0,S.jsx)(t,{size:20}),color:e.color,loading:rt,caption:null!=e.percentage?"".concat(e.percentage,"% of total"):void 0})},e.key)}))}),(0,S.jsxs)(O.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1.25,md:1.75},borderRadius:me.radiusCard/8,border:"1px solid",borderColor:me.borderSubtle,background:"#fff",boxShadow:me.shadowSoft},children:[(0,S.jsxs)(K.Ay,{container:!0,spacing:1.25,alignItems:"center",children:[(0,S.jsx)(K.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,S.jsx)(_.A,{options:it||[],value:kr,getOptionLabel:e=>(null===e||void 0===e?void 0:e.tenantname)||"",PaperComponent:we,onOpen:e=>{Me||(e.preventDefault(),(0,C.k)("Please select location first!","warning",3e3),setTimeout((()=>{var e;null===(e=je.current)||void 0===e||e.focus()}),0))},onChange:(e,r,t)=>{"clear"===t?(hr(0),Sr(null),pr(0),Cr(null)):(hr((null===r||void 0===r?void 0:r.tenantid)||0),Sr(r),pr(0),Cr(null))},renderInput:e=>(0,S.jsx)(B.A,(0,o.A)((0,o.A)({},e),{},{inputRef:ze,placeholder:"Select Tenant",size:"small",sx:We(),InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:(0,S.jsx)(U.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:(0,S.jsx)(Ce,{color:"#94a3b8",size:22,children:(0,S.jsx)(v.Itr,{size:13})})})})}))})}),(0,S.jsx)(K.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,S.jsx)(_.A,{options:ct||[],getOptionLabel:e=>e?"".concat(e.locationname," (").concat(e.suburb,")"):"",value:wr,PaperComponent:we,onOpen:e=>{Me||xr?xr||(e.preventDefault(),(0,C.k)("Please select Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=ze.current)||void 0===e||e.focus()}),0)):(e.preventDefault(),(0,C.k)("Please select a your Location and Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=je.current)||void 0===e||e.focus()}),0))},onChange:(e,r,t)=>{"clear"===t?(pr(0),Cr(null)):(pr(r.locationid||0),Cr(r))},renderInput:e=>(0,S.jsx)(B.A,(0,o.A)((0,o.A)({},e),{},{placeholder:"Select Location",size:"small",sx:We(),InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:(0,S.jsx)(U.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:(0,S.jsx)(Ce,{color:"#94a3b8",size:22,children:(0,S.jsx)(v.JFD,{size:13})})})})}))})}),(0,S.jsx)(K.Ay,{item:!0,xs:12,sm:12,md:4,children:(0,S.jsxs)(U.A,{direction:"row",spacing:1,alignItems:"center",justifyContent:{xs:"flex-start",md:"flex-end"},flexWrap:"wrap",children:[(0,S.jsx)(Z.A,{title:"Date Filter",placement:"top",children:(0,S.jsxs)(Q.A,{onClick:()=>_e(!0),sx:{display:"inline-flex",alignItems:"center",gap:.75,px:1.5,py:.875,borderRadius:"10px",cursor:"pointer",bgcolor:"#ffffff",border:"1px solid #e2e8f0",color:"#475569",fontWeight:600,fontSize:12,transition:"border-color 0.15s, box-shadow 0.15s","&:hover":{borderColor:"#cbd5e1"},"& svg":{color:"#94a3b8"}},children:[(0,S.jsx)(v.Ki0,{size:15}),d()(Te).format("DD/MM/YY")," \u2013 ",d()(Ee).format("DD/MM/YY")]})}),(0,S.jsx)(Q.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.5,borderRadius:"8px",bgcolor:"#f1f5f9",color:"#64748b",fontSize:11,fontWeight:600},children:qe})]})})]}),(0,S.jsx)(y.A,{open:Ke,onClose:()=>_e(!1),onSelect:e=>{Le(e.startDate),Ne(e.endDate),He(e.label),console.log("Selected Date Range:",e)}})]}),(0,S.jsx)(O.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1,md:1.5},borderTopLeftRadius:me.radiusCard/8,borderTopRightRadius:me.radiusCard/8,borderBottomLeftRadius:0,borderBottomRightRadius:0,border:"1px solid",borderColor:me.borderSubtle,borderBottom:0,background:"#fff"},children:(0,S.jsxs)(U.A,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{flexWrap:"wrap-reverse"},children:[(0,S.jsx)(U.A,{direction:"row",spacing:.75,sx:{flex:1,overflowX:"auto",py:.5,px:.25,"&::-webkit-scrollbar":{height:6},"&::-webkit-scrollbar-thumb":{backgroundColor:me.borderSubtle,borderRadius:4}},children:Ie.map((e=>{var r;const t=e.icon,o=Be===e.idx,n=null!==(r=null===ft||void 0===ft?void 0:ft[e.countKey])&&void 0!==r?r:0;return(0,S.jsxs)(Q.A,{onClick:r=>{return t=e.idx,ar(0),Ue(t),0===t&&Qe("created"),1===t&&Qe("pending"),2===t&&Qe("delivered"),3===t&&Qe("cancelled"),void gr("");var t},sx:{display:"inline-flex",alignItems:"center",gap:{xs:.625,md:.875},pl:.5,pr:{xs:1,md:1.25},py:.5,flexShrink:0,cursor:"pointer",borderRadius:me.radiusField+"px",border:"1px solid ".concat(o?e.color:me.borderSubtle),bgcolor:o?e.color:me.surface,color:o?"#fff":me.textSecondary,fontWeight:600,boxShadow:"none",transition:"background-color 0.15s, border-color 0.15s, color 0.15s","&:hover":{borderColor:o?e.color:me.borderHover,bgcolor:o?e.color:me.surfaceAlt}},children:[(0,S.jsx)(F.A,{sx:{width:{xs:20,md:22},height:{xs:20,md:22},bgcolor:o?"rgba(255,255,255,0.22)":ve(e.color),color:o?"#fff":e.color},children:(0,S.jsx)(t,{size:12})}),(0,S.jsx)(V.A,{variant:"caption",sx:{fontWeight:600,fontSize:{xs:11.5,md:13},lineHeight:1},children:e.label}),(0,S.jsx)(Q.A,{sx:{minWidth:{xs:20,md:24},height:{xs:18,md:20},px:.625,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:999,fontSize:{xs:10,md:11},fontWeight:700,bgcolor:o?"rgba(255,255,255,0.22)":me.surfaceAlt,color:o?"#fff":me.textSecondary,border:"none"},children:n})]},e.status)}))}),(0,S.jsx)(Q.A,{sx:{width:{xs:"100%",sm:240,lg:280},flex:{xs:"1 1 100%",sm:"0 0 auto"}},children:(0,S.jsx)(k.A,{value:Ar,onChange:gr,onDebouncedChange:mr,placeholder:"Search orders (ctrl+k)",sx:{m:0,width:"100%",borderRadius:999,bgcolor:be(Se),"& fieldset":{borderColor:ke(Se),borderWidth:1.5},"&:hover fieldset":{borderColor:"#cbd5e1"},"&.Mui-focused fieldset":{borderColor:"#662582",borderWidth:1.5},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(ye(Se))}}})})]})}),(0,S.jsx)(O.A,{elevation:0,sx:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:me.radiusCard/8,borderBottomRightRadius:me.radiusCard/8,border:"1px solid",borderColor:me.borderSubtle,overflow:"hidden",background:"#fff"},children:(0,S.jsx)(X.A,{ref:fe,onScroll:e=>{const{scrollTop:r,scrollHeight:t,clientHeight:o}=e.currentTarget;r+o>=t-50&&Dt&&!It&&Wt()},sx:{maxHeight:{xs:"calc(100vh - 220px)",md:"calc(100vh - 190px)"},overflow:"auto","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:ke(Se),borderRadius:8,"&:hover":{backgroundColor:Se}},"&::-webkit-scrollbar-track":{backgroundColor:me.surfaceAlt}},children:r?(0,S.jsxs)(ue.nV,{sx:{p:1.25},children:[0===(null===Mt||void 0===Mt?void 0:Mt.length)&&!St&&(0,S.jsxs)(U.A,{alignItems:"center",spacing:1.5,sx:{py:6},children:[(0,S.jsx)(F.A,{sx:{width:64,height:64,bgcolor:ve("#94a3b8"),color:me.textMuted},children:(0,S.jsx)(v.F6S,{size:28})}),(0,S.jsxs)(V.A,{variant:"subtitle1",sx:{fontWeight:700,color:me.textPrimary},children:["No ",Ze," orders"]}),(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textSecondary,textAlign:"center",px:2},children:Ar?"Try a different keyword.":"Adjust the filters above to load orders."})]}),St&&(0,S.jsxs)(U.A,{alignItems:"center",sx:{py:6},children:[(0,S.jsx)(he.A,{}),(0,S.jsx)(V.A,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Loading orders\u2026"})]}),null===Mt||void 0===Mt?void 0:Mt.map(((r,t)=>{const n=!!Or.find((e=>e.orderheaderid===r.orderheaderid)),i=De[String(r.orderstatus||"").toLowerCase()]||{label:r.orderstatus||"\u2014",color:Se,icon:v.bfP},l=i.icon;return(0,S.jsx)(ue.pg,{accent:i.color,selected:n,header:(0,S.jsxs)(U.A,{spacing:1.25,children:[(0,S.jsxs)(U.A,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,children:[(0,S.jsxs)(U.A,{direction:"row",alignItems:"center",spacing:.75,sx:{minWidth:0},children:["created"===Ze&&(0,S.jsx)(G.A,{size:"small",sx:{p:.25,color:ke(Se),"&.Mui-checked":{color:Se}},onChange:e=>{var t;if(!Me)return(0,C.k)("Please select a location first!","warning",2e3),void(null===(t=je.current)||void 0===t||t.focus());e.target.checked?Fr((e=>[...e,(0,o.A)((0,o.A)({},r),{},{sno:e.length+1})])):Fr((e=>e.filter((e=>e.orderheaderid!==r.orderheaderid)).map(((e,r)=>(0,o.A)((0,o.A)({},e),{},{sno:r+1})))))},checked:n}),(0,S.jsx)(V.A,{variant:"caption",sx:{fontWeight:700,color:me.textMuted},children:String(100*sr+t+1).padStart(2,"0")}),(0,S.jsxs)(Q.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:be(i.color),border:"1px solid ".concat(ke(i.color)),color:i.color,fontSize:10.5,fontWeight:800,whiteSpace:"nowrap"},children:[(0,S.jsx)(l,{size:11})," ",i.label]})]}),"created"===r.orderstatus&&(0,S.jsxs)(U.A,{direction:"row",spacing:.75,sx:{flexShrink:0},children:["C"===r.deliverytype&&(0,S.jsx)(J.A,{size:"small",onClick:()=>{(null===cr||void 0===cr?void 0:cr.orderid)===r.orderid?dr(null):dr(r)},sx:{borderRadius:999,bgcolor:be("#06b6d4"),color:"#06b6d4",border:"1px solid ".concat(ke("#06b6d4")),"&:hover":{bgcolor:ve("#06b6d4")}},children:(null===cr||void 0===cr?void 0:cr.orderid)===r.orderid?(0,S.jsx)(j.A,{fontSize:"small"}):(0,S.jsx)(b.A,{fontSize:"small"})}),(0,S.jsx)(J.A,{size:"small",disabled:n,onClick:()=>{Xe(!0),lr(r.orderheaderid)},sx:{borderRadius:999,bgcolor:be("#ef4444"),color:"#ef4444",border:"1px solid ".concat(ke("#ef4444")),"&:hover":{bgcolor:ve("#ef4444")},"&.Mui-disabled":{color:e.palette.secondary.main}},children:(0,S.jsx)(A.A,{})})]})]}),(0,S.jsxs)(Q.A,{sx:{minWidth:0},children:[(0,S.jsx)(V.A,{sx:{fontWeight:800,color:me.textPrimary,fontSize:15},noWrap:!0,children:r.tenantname}),(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textSecondary},noWrap:!0,children:[r.tenantsuburb,r.applocation].filter(Boolean).join(" \xb7 ")||"\u2014"})]})]}),children:(0,S.jsxs)(ue.FG,{children:[(0,S.jsxs)(ue.pY,{label:"Order / Location",full:!0,children:[(0,S.jsx)(V.A,{sx:{fontSize:13,fontWeight:600,color:me.textPrimary},noWrap:!0,children:"".concat(r.locationname,"-(").concat(r.locationsuburb,")")}),(0,S.jsxs)(V.A,{variant:"caption",sx:{color:me.textSecondary},children:[r.orderid," \xb7 ",d()(r.pickupslot).utc().format("DD/MM/YYYY")," ",d()(r.pickupslot).format("hh:mm A")]})]}),(0,S.jsxs)(ue.pY,{label:"Pickup",children:[(0,S.jsx)(V.A,{sx:{fontSize:13,fontWeight:600,color:me.textPrimary},noWrap:!0,children:r.pickupcustomer||"\u2014"}),(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textSecondary},noWrap:!0,children:r.pickupcontactno}),(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textSecondary},noWrap:!0,children:r.pickupsuburb||r.pickupaddress})]}),(0,S.jsxs)(ue.pY,{label:"Drop",children:[(0,S.jsx)(V.A,{sx:{fontSize:13,fontWeight:600,color:me.textPrimary},noWrap:!0,children:r.deliverycustomer||"\u2014"}),(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textSecondary},noWrap:!0,children:r.deliverycontactno}),(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textSecondary},noWrap:!0,children:r.deliverysuburb||r.deliveryaddress})]}),(0,S.jsx)(ue.pY,{label:"Qty",value:r.quantity||"\u2014"}),(0,S.jsx)(ue.pY,{label:"KMS",children:(0,S.jsxs)(Q.A,{sx:(s="#06b6d4",{display:"inline-flex",alignItems:"center",justifyContent:"center",px:1,py:.25,borderRadius:999,bgcolor:be(s),color:s,fontWeight:700,fontSize:11,border:"1px solid ".concat(ke(s)),whiteSpace:"nowrap"}),children:[r.kms||0," km"]})}),(0,S.jsx)(ue.pY,{label:"COD",children:(0,S.jsx)(V.A,{sx:{fontSize:13,fontWeight:800,color:r.collectionamt?"#ef4444":me.textMuted},children:r.collectionamt?"\u20b9 ".concat(r.collectionamt.toFixed(2)):"\u2014"})}),(0,S.jsx)(ue.pY,{label:"Charges",children:(0,S.jsx)(V.A,{sx:{fontSize:13,fontWeight:800,color:r.deliverycharge?"#ef4444":me.textMuted},children:r.deliverycharge?"\u20b9 ".concat(r.deliverycharge.toFixed(2)):"\u2014"})}),r.ordernotes&&(0,S.jsx)(ue.pY,{label:"Notes",full:!0,children:(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textSecondary},children:r.ordernotes})})]})},r.sno);var s})),0!=(null===Mt||void 0===Mt?void 0:Mt.length)&&(0,S.jsx)("div",{ref:c,style:{height:40,textAlign:"center"},children:It||Dt?(0,S.jsx)(he.A,{}):(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textMuted,fontWeight:600},children:"No more orders"})})]}):(0,S.jsxs)($.A,{stickyHeader:!0,sx:{minWidth:{xs:960,md:1180}},children:[(0,S.jsx)(ee.A,{children:(0,S.jsxs)(re.A,{sx:{"& th":{backgroundColor:me.surfaceAlt,color:me.textSecondary,fontSize:{xs:10,md:11},fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(me.borderSubtle),py:{xs:1,md:1.25},px:{xs:1,md:1.5}}},children:["created"==Ze&&(0,S.jsx)(te.A,{sx:{position:"sticky !important"},children:(0,S.jsx)(G.A,{size:"small",sx:{p:.5,color:ke(Se),"&.Mui-checked, &.MuiCheckbox-indeterminate":{color:Se}},indeterminate:Or.length>0&&Or.length!==(null===Mt||void 0===Mt?void 0:Mt.length),checked:Or.length===(null===Mt||void 0===Mt?void 0:Mt.length),onChange:e=>{var r;if(!Me)return(0,C.k)("Please select a location first!","warning",2e3),void(null===(r=je.current)||void 0===r||r.focus());if(e.target.checked){const e=null===Mt||void 0===Mt?void 0:Mt.map(((e,r)=>(0,o.A)((0,o.A)({},e),{},{sno:r+1})));Fr(e)}else Fr([])}})}),(0,S.jsx)(te.A,{children:"#"}),(0,S.jsx)(te.A,{children:"Tenant"}),(0,S.jsx)(te.A,{children:"Location"}),(0,S.jsx)(te.A,{children:"Pickup"}),(0,S.jsx)(te.A,{children:"Drop"}),(0,S.jsx)(te.A,{align:"center",children:"QTY"}),(0,S.jsx)(te.A,{align:"right",children:"COD"}),(0,S.jsx)(te.A,{align:"center",children:"KMS"}),(0,S.jsx)(te.A,{align:"right",children:"Charges"}),(0,S.jsx)(te.A,{children:"Notes"}),(0,S.jsx)(te.A,{children:"Status"}),"created"==Ze&&(0,S.jsx)(te.A,{align:"right",children:"Actions"})]})}),(0,S.jsxs)(oe.A,{children:[0===(null===Mt||void 0===Mt?void 0:Mt.length)&&!St&&(0,S.jsx)(re.A,{children:(0,S.jsx)(te.A,{colSpan:13,sx:{py:6},children:(0,S.jsxs)(U.A,{alignItems:"center",spacing:1.5,children:[(0,S.jsx)(F.A,{sx:{width:64,height:64,bgcolor:ve("#94a3b8"),color:me.textMuted},children:(0,S.jsx)(v.F6S,{size:28})}),(0,S.jsxs)(V.A,{variant:"subtitle1",sx:{fontWeight:700,color:me.textPrimary},children:["No ",Ze," orders"]}),(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textSecondary},children:Ar?"Try a different keyword.":"Adjust the filters above to load orders."})]})})}),St&&(0,S.jsx)(W.r,{col:8}),null===Mt||void 0===Mt?void 0:Mt.map(((r,t)=>{const n=!!Or.find((e=>e.orderheaderid===r.orderheaderid));return(0,S.jsxs)(re.A,{role:"checkbox",tabIndex:-1,sx:{cursor:"pointer",transition:"background-color 0.15s",backgroundColor:n?be(Se):"transparent","& td":{borderBottom:"1px solid ".concat(me.divider),py:{xs:1,md:1.25},px:{xs:1,md:1.5}},"&:hover":{backgroundColor:n?ve(Se)+" !important":me.surfaceAlt}},children:["created"===Ze&&(0,S.jsx)(te.A,{children:(0,S.jsx)(G.A,{size:"small",sx:{p:.5,color:ke(Se),"&.Mui-checked":{color:Se}},onChange:e=>{var t;if(!Me)return(0,C.k)("Please select a location first!","warning",2e3),void(null===(t=je.current)||void 0===t||t.focus());e.target.checked?Fr((e=>[...e,(0,o.A)((0,o.A)({},r),{},{sno:e.length+1})])):Fr((e=>e.filter((e=>e.orderheaderid!==r.orderheaderid)).map(((e,r)=>(0,o.A)((0,o.A)({},e),{},{sno:r+1})))))},checked:n})}),(0,S.jsx)(te.A,{children:(0,S.jsx)(V.A,{children:100*sr+t+1})}),(0,S.jsx)(te.A,{children:(0,S.jsxs)(Z.A,{title:r.tenantaddress,children:[(0,S.jsx)(V.A,{variant:"subtitle1",noWrap:!0,children:r.tenantname}),(0,S.jsxs)(V.A,{noWrap:!0,variant:"body2",children:[r.tenantsuburb,(0,S.jsx)("br",{})]}),(0,S.jsx)(V.A,{noWrap:!0,variant:"body2",children:r.applocation})]})}),(0,S.jsxs)(te.A,{align:"left",children:[(0,S.jsx)(V.A,{variant:"subtitle1",noWrap:!0,children:"".concat(r.locationname,"-(").concat(r.locationsuburb,")")}),(0,S.jsx)(Z.A,{title:"TenantId - OrderId",children:(0,S.jsx)(V.A,{variant:"body2",noWrap:!0,children:r.orderid})}),(0,S.jsx)(Z.A,{title:"Pickup Slot",children:(0,S.jsxs)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:[d()(r.pickupslot).utc().format("DD/MM/YYYY")," ",d()(r.pickupslot).format("hh:mm A")]})})]}),(0,S.jsx)(te.A,{align:"left",children:(0,S.jsxs)(U.A,{direction:"column",children:[(0,S.jsx)(V.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:r.pickupcustomer}),(0,S.jsx)(V.A,{variant:"caption",children:r.pickupcontactno}),(0,S.jsx)(Z.A,{title:r.pickupaddress,children:(0,S.jsx)(V.A,{variant:"caption",children:"".concat(r.pickupsuburb||r.pickupaddress.slice(0,12)+".....")})})]})}),(0,S.jsx)(te.A,{align:"left",children:(0,S.jsxs)(U.A,{direction:"column",children:[(0,S.jsx)(V.A,{variant:"subtitle1",sx:{maxWidth:120,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.deliverycustomer}),(0,S.jsx)(V.A,{variant:"caption",children:r.deliverycontactno}),(0,S.jsx)(Z.A,{title:r.deliveryaddress,sx:{whiteSpace:"nowrap"},children:(0,S.jsx)(V.A,{variant:"caption",children:"".concat(r.deliverysuburb||r.deliveryaddress.slice(0,12)+".....")})})]})}),(0,S.jsx)(te.A,{align:"center",children:r.quantity?(0,S.jsx)(V.A,{variant:"subtitle1",color:"error",sx:{whiteSpace:"nowrap"},children:r.quantity}):(0,S.jsx)(V.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:r.quantity})}),(0,S.jsx)(te.A,{align:"right",children:r.collectionamt?(0,S.jsxs)(V.A,{variant:"subtitle1",color:r.collectionamt?"error":null,sx:{whiteSpace:"nowrap"},children:["\u20b9",r.collectionamt.toFixed(2)]}):(0,S.jsxs)(V.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:["\u20b9",r.collectionamt.toFixed(2)]})}),(0,S.jsx)(te.A,{align:"center",children:(0,S.jsx)(V.A,{variant:"subtitle1",color:r.kms?"error":null,children:r.kms})}),(0,S.jsx)(te.A,{align:"right",children:r.deliverycharge?(0,S.jsxs)(V.A,{variant:"subtitle1",color:r.deliverycharge?"error":null,sx:{whiteSpace:"nowrap"},children:["\u20b9",r.deliverycharge.toFixed(2)]}):(0,S.jsxs)(V.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:["\u20b9",r.deliverycharge.toFixed(2)]})}),(0,S.jsx)(te.A,{align:"left",children:(0,S.jsx)(V.A,{variant:"body1",fontSize:"12px",sx:{maxWidth:120,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.ordernotes})}),(0,S.jsx)(te.A,{align:"left",children:(()=>{const e=De[String(r.orderstatus||"").toLowerCase()]||{label:r.orderstatus||"\u2014",color:Se,icon:v.bfP},t=e.icon;return(0,S.jsxs)(Q.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:be(e.color),border:"1px solid ".concat(ke(e.color)),color:e.color,fontSize:11,fontWeight:800,whiteSpace:"nowrap"},children:[(0,S.jsx)(t,{size:12})," ",e.label]})})()}),"created"===r.orderstatus&&(0,S.jsx)(te.A,{align:"center",children:(0,S.jsxs)(U.A,{flexDirection:"row",justifyContent:"end",children:["C"===r.deliverytype&&(0,S.jsx)(Z.A,{title:"Product details",children:(0,S.jsx)(J.A,{color:"primary",onClick:()=>{(null===cr||void 0===cr?void 0:cr.orderid)===r.orderid?dr(null):dr(r)},children:(null===cr||void 0===cr?void 0:cr.orderid)===r.orderid?(0,S.jsx)(j.A,{}):(0,S.jsx)(b.A,{})})}),(0,S.jsx)(Z.A,{title:"To Cancel",children:(0,S.jsx)(J.A,{"aria-describedby":"aria-".concat(r.sno),disabled:n,onClick:()=>{Xe(!0),lr(r.orderheaderid)},children:(0,S.jsx)(A.A,{style:{color:n?e.palette.secondary.main:e.palette.error.main}})})})]})})]},r.sno)})),0!=(null===Mt||void 0===Mt?void 0:Mt.length)&&(0,S.jsx)(re.A,{children:(0,S.jsx)(te.A,{colSpan:15,rowSpan:3,sx:{borderBottom:"none"},children:(0,S.jsx)("div",{ref:c,style:{height:40,textAlign:"center"},children:It||Dt?(0,S.jsx)(he.A,{}):(0,S.jsx)(V.A,{variant:"caption",sx:{color:me.textMuted,fontWeight:600},children:"No more orders"})})})})]})]})})}),(0,S.jsxs)(ne.A,{fullScreen:!0,open:Ge,TransitionComponent:g.s,children:[(0,S.jsx)(L.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:jr,children:(0,S.jsx)(f.A,{color:"inherit",text:"Optimising ... .."})}),(0,S.jsx)(ie.A,{sx:{bgcolor:e.palette.primary.lighter},children:(0,S.jsx)(N.A,{badgeContent:null===Or||void 0===Or?void 0:Or.length,color:"primary",children:(0,S.jsx)(le.A,{label:(0,S.jsx)(V.A,{variant:"h3",children:"Preview Orders "}),variant:"contained"})})}),(0,S.jsx)(se.A,{dividers:!0,children:(0,S.jsx)(w.A,{content:!1,children:(0,S.jsx)(X.A,{children:(0,S.jsxs)($.A,{stickyHeader:!0,children:[(0,S.jsx)(ee.A,{children:(0,S.jsxs)(re.A,{children:[(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"#"}),(0,S.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Tenant"," "]}),(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"order Location"}),(0,S.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Pickup"," "]}),(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Delivery"}),(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Notes"}),(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Charges"}),(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"KMS"})]})}),(0,S.jsx)(oe.A,{children:Or.map(((e,r)=>(0,S.jsx)(n.Fragment,{children:(0,S.jsxs)(re.A,{sx:{},children:[(0,S.jsx)(te.A,{children:(0,S.jsxs)(V.A,{children:[" ",e.sno]})}),(0,S.jsx)(te.A,{children:(0,S.jsxs)(Z.A,{title:e.tenantaddress,children:[(0,S.jsx)(V.A,{variant:"body1",noWrap:!0,children:e.tenantname}),(0,S.jsxs)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:[e.tenantsuburb,(0,S.jsx)("br",{})]}),(0,S.jsx)(V.A,{noWrap:!0,variant:"body2",children:e.applocation})]})}),(0,S.jsxs)(te.A,{align:"left",children:[(0,S.jsx)(Z.A,{title:e.locationaddress,placement:"top",children:(0,S.jsx)(V.A,{variant:"body1",noWrap:!0,children:"".concat(e.locationname,"-(").concat(e.locationsuburb,")")})}),(0,S.jsx)(Z.A,{title:"Order Id",children:(0,S.jsx)(V.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,S.jsxs)(U.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,S.jsxs)(Z.A,{title:"Ordered date",children:[(0,S.jsx)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.orderdate).utc().format("DD/MM/YYYY")}),(0,S.jsx)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.orderdate).utc().format("hh:mm A")})]}),"-",(0,S.jsxs)(Z.A,{title:"Delivery date",children:[(0,S.jsx)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.deliverydate).utc().format("DD/MM/YYYY")}),(0,S.jsx)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.deliverydate).utc().format("hh:mm A")})]})]})]}),(0,S.jsx)(te.A,{align:"left",children:(0,S.jsx)(U.A,{direction:"row",spacing:1,children:(0,S.jsxs)(U.A,{direction:"column",children:[(0,S.jsx)(V.A,{variant:"caption",children:e.pickupcustomer}),(0,S.jsx)(V.A,{variant:"caption",children:e.pickupcontactno}),(0,S.jsx)(Z.A,{title:e.pickupaddress,children:(0,S.jsx)(V.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,S.jsx)(te.A,{align:"left",children:(0,S.jsx)(U.A,{direction:"row",spacing:1,children:(0,S.jsxs)(U.A,{direction:"column",children:[(0,S.jsx)(V.A,{variant:"caption",children:e.deliverycustomer}),(0,S.jsx)(V.A,{variant:"caption",children:e.deliverycontactno}),(0,S.jsx)(Z.A,{title:e.deliveryaddress,children:(0,S.jsx)(V.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,S.jsx)(te.A,{align:"left",children:e.ordernotes}),(0,S.jsxs)(te.A,{align:"left",children:["\u20b9 ",e.deliverycharge.toFixed(2)]}),(0,S.jsx)(te.A,{align:"left",children:e.kms})]})},r)))})]})})})}),(0,S.jsx)(ae.A,{sx:{bgcolor:e.palette.secondary.light},children:(0,S.jsx)(K.Ay,{container:!0,sx:{},children:(0,S.jsx)(K.Ay,{item:!0,xs:12,children:(0,S.jsxs)(U.A,{sx:{mt:2,mr:2},direction:"row",justifyContent:"flex-end",flexWrap:"wrap",gap:2,spacing:5,children:[(0,S.jsx)(ce.A,{sx:{width:"130px"},color:"secondary",variant:"contained",onClick:()=>{Et()},startIcon:(0,S.jsx)(A.A,{}),children:"Close"}),1==Qr.current&&(0,S.jsx)(_.A,{options:[{label:"Bike",value:1},{label:"Auto",value:2}],getOptionLabel:e=>e.label,value:Xr,onChange:(e,r)=>{Gr(r),console.log("Selected value:",null===r||void 0===r?void 0:r.value)},renderInput:e=>(0,S.jsx)(B.A,(0,o.A)((0,o.A)({sx:{width:200,border:"1px solid ",borderColor:"primary.main"}},e),{},{placeholder:"Select Transport"})),isOptionEqualToValue:(e,r)=>e.value===r.value}),1==Qr.current&&(0,S.jsx)(_.A,{multiple:!0,fullWidth:!1,options:At||[],loading:gt,disableCloseOnSelect:!0,limitTags:2,value:Jr,onChange:(e,r)=>$r(r),getOptionLabel:e=>"".concat(e.firstname||""," ").concat(e.lastname||"").trim()||"Rider #".concat(e.userid),isOptionEqualToValue:(e,r)=>e.userid===r.userid,PaperComponent:e=>(0,S.jsx)(O.A,(0,o.A)((0,o.A)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:"0 14px 40px rgba(15, 23, 42, 0.18)",border:"1px solid",borderColor:"divider",overflow:"hidden"}})),ListboxProps:{sx:{py:0,maxHeight:340}},noOptionsText:(0,S.jsxs)(U.A,{alignItems:"center",py:2,spacing:1,children:[(0,S.jsx)(v.vbW,{size:26,color:"#94a3b8"}),(0,S.jsx)(V.A,{variant:"caption",color:"text.secondary",children:"No riders to show for this location"})]}),renderTags:(e,r)=>e.map(((e,t)=>{const i="".concat(e.firstname||""," ").concat(e.lastname||"").trim()||"Rider #".concat(e.userid),l=(i.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()||"?",s=r({index:t});return(0,n.createElement)(le.A,(0,o.A)((0,o.A)({},s),{},{key:e.userid,size:"small",avatar:(0,S.jsx)(F.A,{sx:{bgcolor:"#fed7aa",color:"#9a3412",fontSize:10,fontWeight:800},children:l}),label:i,sx:{height:26,bgcolor:"#fff7ed",color:"#9a3412",border:"1px solid",borderColor:"#fdba74",fontWeight:600,fontSize:12,"& .MuiChip-label":{px:.75},"& .MuiChip-deleteIcon":{color:"#c2410c",fontSize:16,"&:hover":{color:"#7c2d12"}}}}))})),renderOption:(e,r,t)=>{let{selected:i}=t;const l="".concat(r.firstname||""," ").concat(r.lastname||"").trim(),s=(l.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()||"?";return(0,n.createElement)("li",(0,o.A)((0,o.A)({},e),{},{key:r.userid,style:{display:"flex",alignItems:"center",gap:12,padding:"8px 12px",borderBottom:"1px solid #f1f5f9",backgroundColor:i?"#fff7ed":"transparent"}}),(0,S.jsx)(G.A,{size:"small",checked:i,sx:{p:.5,color:"#fb923c","&.Mui-checked":{color:"#ea580c"}}}),(0,S.jsx)(F.A,{sx:{width:34,height:34,bgcolor:i?"#fb923c":"#f1f5f9",color:i?"#fff":"#475569",fontSize:12,fontWeight:800,transition:"background-color 0.15s, color 0.15s"},children:s}),(0,S.jsxs)(U.A,{direction:"column",spacing:0,flex:1,minWidth:0,children:[(0,S.jsx)(V.A,{variant:"body2",fontWeight:700,color:"#0f172a",noWrap:!0,children:l||"Rider #".concat(r.userid)}),(0,S.jsxs)(V.A,{variant:"caption",color:"text.secondary",noWrap:!0,children:["ID #",r.userid,r.contactno?" \xb7 ".concat(r.contactno):""]})]}),i&&(0,S.jsx)(le.A,{size:"small",label:"Absent",sx:{height:18,fontSize:9,fontWeight:800,letterSpacing:.3,bgcolor:"#ea580c",color:"#fff","& .MuiChip-label":{px:.75}}}))},renderInput:e=>(0,S.jsx)(B.A,(0,o.A)((0,o.A)({},e),{},{label:"Absent Riders",placeholder:Jr.length?"":"Pick riders unavailable today",InputLabelProps:{shrink:!0},InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:(0,S.jsxs)(U.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25},children:[(0,S.jsx)(v.ihY,{size:18,color:"#ea580c"}),Jr.length>0&&(0,S.jsx)(le.A,{size:"small",label:Jr.length,sx:{height:18,minWidth:22,fontSize:10,fontWeight:800,bgcolor:"#ea580c",color:"#fff","& .MuiChip-label":{px:.5}}}),e.InputProps.startAdornment]})}),sx:{minWidth:300,maxWidth:440,"& .MuiOutlinedInput-root":{borderRadius:2,bgcolor:"#fffbf5",transition:"border-color 0.15s, box-shadow 0.15s","& fieldset":{borderColor:"#fdba74",borderWidth:1.5},"&:hover fieldset":{borderColor:"#fb923c"},"&.Mui-focused":{boxShadow:"0 0 0 3px rgba(251, 146, 60, 0.18)"},"&.Mui-focused fieldset":{borderColor:"#ea580c",borderWidth:2}},"& .MuiInputLabel-root":{fontWeight:700,fontSize:13,color:"#9a3412","&.Mui-focused":{color:"#9a3412"}}}})),sx:{"& .MuiAutocomplete-tag":{my:.25},"& .MuiAutocomplete-endAdornment":{right:8}}}),(0,S.jsx)(ce.A,{color:"primary",disabled:!Xr&&1==Qr.current,variant:"contained",startIcon:1==Qr.current&&(0,S.jsx)("img",{src:M,alt:"Assign",style:{width:32,height:32,objectFit:"contain",borderRadius:50}}),onClick:()=>{br(!0),Tt()},children:Oe?"Optimising...":0==Qr.current?"Optimise Orders":"AI Optimise Orders"})]})})})})]}),(0,S.jsxs)(ne.A,{fullScreen:!0,open:Mr,TransitionComponent:g.s,children:[(0,S.jsx)(ie.A,{children:(0,S.jsx)(U.A,{children:(0,S.jsxs)(U.A,{direction:"row",alignItems:"center",spacing:1,sx:{ml:1},children:[(0,S.jsx)(Z.A,{title:"Back to orders",placement:"top",children:(0,S.jsx)(J.A,{onClick:()=>Yr(!1),sx:{backgroundColor:"action.hover",color:"text.primary","&:hover":{backgroundColor:"action.selected"}},children:(0,S.jsx)(P.eQE,{size:22})})}),(0,S.jsx)(V.A,{sx:{m:2},variant:"h3",children:"Assign Orders"})]})})}),(0,S.jsx)(de.A,{}),(0,S.jsx)(se.A,{children:(0,S.jsxs)(w.A,{content:!1,children:[(pt||gt||vr)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(m.A,{}),(0,S.jsx)(f.A,{})]}),(0,S.jsx)(L.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:pt||gt||vr,children:(0,S.jsx)(f.A,{color:"inherit"})}),(0,S.jsx)(X.A,{children:(0,S.jsxs)($.A,{stickyHeader:!0,children:[(0,S.jsx)(ee.A,{children:(0,S.jsxs)(re.A,{sx:{backgroundColor:"red"},children:[(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"#"}),1==Kr&&(0,S.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Zone"," "]}),(0,S.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Tenant"," "]}),(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"order Location"}),(0,S.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Pickup"," "]}),(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Delivery"}),(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Notes"}),1==Kr&&(0,S.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Rider"}),(0,S.jsx)(te.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Type"}),(0,S.jsx)(te.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Charges"}),(0,S.jsx)(te.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"KMS"})]})}),(0,S.jsxs)(oe.A,{children:[0==(null===Ur||void 0===Ur?void 0:Ur.length)&&(0,S.jsx)(re.A,{children:(0,S.jsx)(te.A,{colSpan:10,children:(0,S.jsx)(a.A,{})})}),null===Ur||void 0===Ur?void 0:Ur.map(((e,r)=>(0,S.jsxs)(re.A,{sx:{},children:[(0,S.jsx)(te.A,{children:(0,S.jsxs)(V.A,{children:[" ",r+1]})}),(0,S.jsx)(te.A,{children:(0,S.jsxs)(Z.A,{title:e.tenantaddress,children:[(0,S.jsx)(V.A,{variant:"body1",noWrap:!0,children:e.tenantname}),(0,S.jsxs)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:[e.tenantsuburb,(0,S.jsx)("br",{})]}),(0,S.jsx)(V.A,{noWrap:!0,variant:"body2",children:e.applocation})]})}),(0,S.jsxs)(te.A,{align:"left",children:[(0,S.jsx)(Z.A,{title:e.locationaddress,placement:"top",children:(0,S.jsx)(V.A,{variant:"body1",noWrap:!0,children:"".concat(e.locationname,"-(").concat(e.locationsuburb,")")})}),(0,S.jsx)(Z.A,{title:"Order Id",children:(0,S.jsx)(V.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,S.jsxs)(U.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,S.jsxs)(Z.A,{title:"Ordered date",children:[(0,S.jsx)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.orderdate).utc().format("DD/MM/YYYY")}),(0,S.jsx)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.orderdate).utc().format("hh:mm A")})]}),"-",(0,S.jsxs)(Z.A,{title:"Delivery date",children:[(0,S.jsx)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.deliverydate).utc().format("DD/MM/YYYY")}),(0,S.jsx)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.deliverydate).utc().format("hh:mm A")})]})]})]}),(0,S.jsx)(te.A,{align:"left",children:(0,S.jsx)(U.A,{direction:"row",spacing:1,children:(0,S.jsxs)(U.A,{direction:"column",children:[(0,S.jsx)(V.A,{variant:"caption",children:e.pickupcustomer}),(0,S.jsx)(V.A,{variant:"caption",children:e.pickupcontactno}),(0,S.jsx)(Z.A,{title:e.pickupaddress,children:(0,S.jsx)(V.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,S.jsx)(te.A,{align:"left",children:(0,S.jsx)(U.A,{direction:"row",spacing:1,children:(0,S.jsxs)(U.A,{direction:"column",children:[(0,S.jsx)(V.A,{variant:"caption",children:e.deliverycustomer}),(0,S.jsx)(V.A,{variant:"caption",children:e.deliverycontactno}),(0,S.jsx)(Z.A,{title:e.deliveryaddress,children:(0,S.jsx)(V.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,S.jsx)(te.A,{align:"left",children:e.ordernotes}),(0,S.jsx)(te.A,{align:"center",children:(0,S.jsx)(le.A,{size:"small",label:e.ordertype,color:"Economy"==e.ordertype?"success":"Risky"==e.ordertype?"error":"primary",variant:"light"})}),(0,S.jsx)(te.A,{align:"center",children:(0,S.jsxs)(U.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,S.jsx)(Z.A,{title:"Charges",placement:"top",children:(0,S.jsx)(le.A,{size:"small",label:"\u20b9 ".concat(e.deliverycharge.toFixed(2)," "),color:"error",variant:"light"})}),(0,S.jsx)(Z.A,{title:"Amount",placement:"left",children:(0,S.jsx)(le.A,{size:"small",label:"\u20b9 ".concat(e.deliveryamt.toFixed(2)," "),color:"success",variant:"light"})})]})}),(0,S.jsx)(te.A,{align:"center",children:(0,S.jsxs)(U.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,S.jsx)(Z.A,{title:"KMS",placement:"top",children:(0,S.jsx)(le.A,{size:"small",label:"".concat(e.kms," km"),color:"error",variant:"light"})}),(0,S.jsx)(Z.A,{title:"Cumulative Kms",placement:"right",children:(0,S.jsx)(le.A,{size:"small",label:"".concat(e.cumulativekms," km"),color:"success",variant:"light"})})]})})]},r)))]})]})}),(0,S.jsx)(de.A,{})]})}),(0,S.jsx)(de.A,{}),(0,S.jsxs)(ae.A,{sx:{flexDirection:"column",alignItems:"stretch",p:2,gap:2},children:[(0,S.jsxs)(K.Ay,{container:!0,spacing:2,children:[(0,S.jsx)(K.Ay,{item:!0,xs:12,sm:6,children:(0,S.jsx)(_.A,{options:ut,fullWidth:!0,renderInput:e=>(0,S.jsx)(B.A,(0,o.A)((0,o.A)({},e),{},{label:"Choose Payment"})),onChange:(e,r,t)=>{if("clear"!==t){if(r){nr(r);const e=null===Ur||void 0===Ur?void 0:Ur.map((e=>(0,o.A)((0,o.A)({},e),{},{paymenttype:r.apptypeid||42})));Zr(e)}}else nr(null)}})}),(0,S.jsx)(K.Ay,{item:!0,xs:12,sm:6,children:(0,S.jsx)(_.A,{options:At,fullWidth:!0,renderInput:e=>(0,S.jsx)(B.A,(0,o.A)((0,o.A)({},e),{},{label:"Choose Rider"})),onChange:(e,r,t)=>{if("clear"!==t){if(r){tr(r);const e=null===Ur||void 0===Ur?void 0:Ur.map((e=>(0,o.A)((0,o.A)({},e),{},{userid:r.userid,fuelcharge:r.fuelcharge||0,userfcmtoken:r.userfcmtoken})));Zr(e)}}else tr(null)}})})]}),(0,S.jsxs)(U.A,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{pt:1,my:2},children:[(0,S.jsx)(ce.A,{variant:"outlined",color:"secondary",startIcon:(0,S.jsx)(Y.A,{}),onClick:()=>Yr(!1),children:"Back"}),(0,S.jsx)(ce.A,{variant:"contained",disabled:!rr||!or,onClick:()=>{null!==Ur&&void 0!==Ur&&Ur.length?Pt.mutate({deliveries:Ur}):(0,C.k)("No deliveries selected","error",3e3)},children:"Assign Orders"})]})]})]}),(0,S.jsxs)(ne.A,{open:Ir,fullScreen:!0,TransitionComponent:g.s,PaperProps:{sx:{display:"flex",flexDirection:"column",overflow:"hidden"}},children:[(0,S.jsx)(L.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:vr,children:(0,S.jsx)(f.A,{color:"inherit"})}),(0,S.jsx)(ie.A,{sx:{py:1.25},children:(0,S.jsxs)(U.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{},children:[(0,S.jsxs)(U.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,S.jsx)(Z.A,{title:"Back to orders",placement:"top",children:(0,S.jsx)(J.A,{onClick:()=>t("/nearle/orders"),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},children:(0,S.jsx)(P.eQE,{size:20})})}),(0,S.jsx)(V.A,{variant:"h3",fontWeight:600,children:"Assign Orders"})]}),(0,S.jsxs)(U.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,S.jsx)(_.A,{options:[{tuneid:1,type:"Balanced",value:"balanced"},{tuneid:2,type:"Aggressive Speed",value:"aggressive_speed"},{tuneid:3,type:"Fuel Saver",value:"fuel_saver"},{tuneid:4,type:"Zone Strict",value:"zone_strict"}]||[],getOptionLabel:e=>e.type,sx:{minWidth:250,maxWidth:600,flex:1},renderInput:e=>(0,S.jsx)(B.A,(0,o.A)((0,o.A)({},e),{},{label:"Hyper Tuning"})),onChange:(e,r,t)=>{"clear"===t?Tt(null):(console.log("val",r),Tt(r.value))}}),(0,S.jsx)(ce.A,{variant:"contained",color:"primary",startIcon:(0,S.jsx)(R.UF6,{}),onClick:()=>{yr(!0),Tt("reshuffle")},children:"Re-Assign"}),(0,S.jsx)(Ae.Ay,{data:_r,filename:"Orders_Detail_".concat(d()().format("YYYY-MM-DD_HHmmss"),".csv"),label:" CSV",style:{m:1}})]})]})}),(0,S.jsx)(se.A,{sx:{p:0,display:"flex",flexDirection:"column",overflow:"hidden",flex:1},children:Pr&&(0,S.jsx)(ge.default,{data:Pr,embedded:!0})}),(0,S.jsx)(ae.A,{sx:{px:2,py:1.25},children:(0,S.jsxs)(U.A,{direction:"row",gap:2,alignItems:"center",justifyContent:"end",children:[(0,S.jsx)(ce.A,{variant:"contained",color:"secondary",startIcon:(0,S.jsx)(Y.A,{}),onClick:()=>{zr(!1)},children:"Back"}),(0,S.jsx)(ce.A,{variant:"contained",onClick:async()=>{yr(!0),Lt.mutate({deliveries:Ur})},children:"Assign Orders"})]})})]}),(0,S.jsx)(ne.A,{open:Ve,onClose:()=>handleClose(),maxWidth:"xs",children:(0,S.jsx)(se.A,{sx:{mt:2,my:1},children:(0,S.jsxs)(U.A,{alignItems:"center",spacing:3.5,children:[(0,S.jsx)(F.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,S.jsx)(s.A,{})}),(0,S.jsx)(U.A,{spacing:2,children:(0,S.jsx)(V.A,{variant:"h4",align:"center",children:"Are you sure you want to cancel this order?"})}),(0,S.jsxs)(U.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,S.jsx)(ce.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{Rt.mutate(ir)},autoFocus:!0,children:"Yes, Cancel"}),(0,S.jsx)(ce.A,{fullWidth:!0,onClick:()=>{Xe(!1)},color:"secondary",variant:"outlined",children:"No"})]})]})})}),(0,S.jsx)(ne.A,{open:$e,onClose:()=>er(!1),maxWidth:"xs",children:(0,S.jsx)(se.A,{sx:{mt:2,my:1},children:(0,S.jsxs)(U.A,{alignItems:"center",spacing:3.5,children:[(0,S.jsx)(F.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,S.jsx)(s.A,{})}),(0,S.jsx)(U.A,{spacing:2,children:(0,S.jsx)(V.A,{variant:"h4",align:"center",children:"Are you sure, you want to cancel multiple orders?"})}),(0,S.jsxs)(U.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,S.jsx)(ce.A,{fullWidth:!0,onClick:()=>{er(!1)},color:"secondary",variant:"outlined",children:"No"}),(0,S.jsx)(ce.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{Ot.mutate(Or)},autoFocus:!0,children:"Yes, Cancel"})]})]})})})]})}},23787:(e,r,t)=>{t.d(r,{FG:()=>u,nV:()=>x,pY:()=>p,pg:()=>h});var o=t(89379),n=t(80045),i=t(93230),l=t(2235),s=t(16491),a=t(82053),c=t(44414);const d=["children","scroll","onScroll","sx"],x=e=>{let{children:r,scroll:t=!1,onScroll:l,sx:s}=e,a=(0,n.A)(e,d);return(0,c.jsx)(i.A,(0,o.A)((0,o.A)({spacing:1.25,onScroll:l,sx:(0,o.A)((0,o.A)({p:1.5},t&&{maxHeight:"calc(100vh - 220px)",overflowY:"auto",overflowX:"hidden"}),s)},a),{},{children:r}))},h=e=>{let{accent:r="#662582",header:t,footer:n,selected:i=!1,onClick:a,children:d,sx:x}=e;return(0,c.jsxs)(l.A,{elevation:0,onClick:a,sx:(0,o.A)({position:"relative",overflow:"hidden",flexShrink:0,borderRadius:2.5,border:"1px solid",borderColor:i?r:"#e2e8f0",background:i?"".concat(r,"0a"):"#fff",boxShadow:"0 4px 14px rgba(15,23,42,0.05)",transition:"border-color 0.15s, box-shadow 0.15s"},x),children:[(0,c.jsx)(s.A,{sx:{position:"absolute",left:0,top:0,bottom:0,width:3,bgcolor:r}}),(0,c.jsxs)(s.A,{sx:{p:1.5,pl:2},children:[t,d,n]})]})},u=e=>{let{children:r,columns:t=2,sx:n}=e;return(0,c.jsx)(s.A,{sx:(0,o.A)({display:"grid",gridTemplateColumns:"repeat(".concat(t,", minmax(0, 1fr))"),gap:1,mt:1.25},n),children:r})},p=e=>{let{label:r,value:t,children:o,full:n=!1,align:i="left"}=e;return(0,c.jsxs)(s.A,{sx:{gridColumn:n?"1 / -1":"auto",minWidth:0,textAlign:i},children:[(0,c.jsx)(a.A,{sx:{fontSize:9.5,fontWeight:800,letterSpacing:.5,textTransform:"uppercase",color:"#94a3b8",lineHeight:1.4},children:r}),(0,c.jsx)(s.A,{sx:{mt:.25,minWidth:0},children:void 0!==o?o:(0,c.jsx)(a.A,{sx:{fontSize:13,fontWeight:600,color:"#0f172a"},noWrap:!0,children:null!==t&&void 0!==t?t:"\u2014"})})]})}},27001:(e,r,t)=>{t.d(r,{A:()=>s});var o=t(93230),n=t(16491),i=t(82053),l=t(44414);function s(e){let{title:r,subtitle:t,live:s=!1,action:a}=e;return(0,l.jsxs)(o.A,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{xs:"flex-start",sm:"center"},spacing:1.5,sx:{mb:{xs:2,md:2.5}},children:[(0,l.jsxs)(n.A,{sx:{minWidth:0},children:[(0,l.jsx)(i.A,{variant:"h3",sx:{fontWeight:700,letterSpacing:"-0.02em",color:"grey.800"},children:r}),t&&(0,l.jsxs)(o.A,{direction:"row",alignItems:"center",spacing:.75,sx:{mt:.5},children:[s&&(0,l.jsx)(n.A,{sx:{width:7,height:7,borderRadius:"50%",bgcolor:"success.main",boxShadow:"0 0 0 3px rgba(16,185,129,0.18)"}}),(0,l.jsx)(i.A,{variant:"caption",sx:{color:"text.secondary",fontWeight:500},children:t})]})]}),a&&(0,l.jsx)(n.A,{sx:{flexShrink:0,width:{xs:"100%",sm:"auto"}},children:a})]})}},35678:(e,r,t)=>{t.d(r,{A:()=>v});var o=t(9950),n=t(96583),i=t(40033),l=t(82053),s=t(28170),a=t(93230),c=t(82223),d=t(55916),x=t(4159),h=t.n(x),u=t(56712),p=t(81417),A=t(96600),g=t(53132),f=t(94289),m=t(57326),j=t(50624),b=t(44414);const v=e=>{let{open:r,onClose:t,onSelect:x}=e;const[v,y]=(0,o.useState)(null);return(0,b.jsxs)(n.A,{open:r,onClose:t,children:[(0,b.jsx)(i.A,{align:"left",children:(0,b.jsx)(l.A,{variant:"h4",children:"Select Filter Options"})}),(0,b.jsx)(s.A,{sx:{width:"100%"},className:"datedialog",children:(0,b.jsx)(d.U,{open:r,toggle:t,id:"daterange1",onChange:e=>{y({startDate:h()(e.startDate).format("YYYY-MM-DD"),endDate:h()(e.endDate).format("YYYY-MM-DD"),label:e.label||"custom"})},definedRanges:[{label:"Today",startDate:new Date,endDate:new Date},{label:"Yesterday",startDate:(0,u.A)(new Date,-1),endDate:(0,u.A)(new Date,-1)},{label:"Tomorrow",startDate:(0,u.A)(new Date,1),endDate:(0,u.A)(new Date,1)},{label:"This Week",startDate:(0,p.A)(new Date),endDate:(0,A.A)(new Date)},{label:"Last Week",startDate:(0,p.A)((0,g.A)(new Date,-1)),endDate:(0,A.A)((0,g.A)(new Date,-1))},{label:"Last 7 Days",startDate:(0,g.A)(new Date,-1),endDate:new Date},{label:"This Month",startDate:(0,f.A)(new Date),endDate:(0,m.A)(new Date)},{label:"Last Month",startDate:(0,f.A)((0,j.A)(new Date,-1)),endDate:(0,m.A)((0,j.A)(new Date,-1))}]})}),(0,b.jsx)(a.A,{direction:"row",justifyContent:"flex-end",sx:{width:"100%",p:2},children:(0,b.jsx)(c.A,{variant:"contained",size:"small",onClick:()=>{v?(x(v),t()):t()},children:"OK"})})]})}},36803:(e,r,t)=>{t.d(r,{A:()=>x});var o=t(48089),n=t(50704),i=t(93230),l=t(16491),s=t(82053),a=t(82917),c=t(41413),d=t(44414);function x(e){let{title:r,value:t,icon:x,color:h="#662582",caption:u,loading:p=!1}=e;return(0,d.jsx)(o.A,{sx:{height:"100%"},children:(0,d.jsx)(n.A,{sx:{p:{xs:1.75,md:2},"&:last-child":{pb:{xs:1.75,md:2}}},children:(0,d.jsxs)(i.A,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:1,children:[(0,d.jsxs)(l.A,{sx:{minWidth:0,flex:1},children:[(0,d.jsx)(s.A,{variant:"body2",sx:{fontWeight:500,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),p?(0,d.jsx)(a.A,{variant:"rounded",sx:{width:72,height:30,mt:.5},animation:"wave"}):(0,d.jsx)(s.A,{sx:{mt:.25,fontWeight:700,letterSpacing:"-0.015em",color:"grey.800",lineHeight:1.15,fontSize:{xs:"1.375rem",md:"1.5rem"},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),u&&(0,d.jsx)(s.A,{variant:"caption",sx:{display:"block",mt:.5,color:"text.secondary"},children:u})]}),x&&(0,d.jsx)(c.A,{variant:"rounded",sx:{width:42,height:42,borderRadius:2,bgcolor:"".concat(h,"14"),color:h,flexShrink:0},children:x})]})})})}},47659:(e,r,t)=>{t.d(r,{A:()=>d});var o=t(89379),n=t(48089),i=t(50704),l=t(16491),s=t(82053),a=t(60899),c=t(44414);const d=e=>{let{primary:r,secondary:t,percentage:d,color:x,sx:h}=e;return(0,c.jsx)(n.A,{elevation:0,sx:(0,o.A)({background:x,position:"relative",color:"#fff","&:hover svg":{opacity:1,transform:"scale(1.1)"}},h),children:(0,c.jsxs)(i.A,{children:[(0,c.jsx)(l.A,{sx:{position:"absolute",right:15,top:25,color:"#fff","& svg":{width:36,height:36,opacity:.5,transition:"all .3s ease-in-out"}},children:(0,c.jsx)(s.A,{variant:"h2",color:"inherit",sx:{fontSize:{xs:20,md:25}},children:d&&"number"===typeof d?"".concat(d.toString()," %"):d})}),(0,c.jsxs)(a.Ay,{container:!0,spacing:0,children:[(0,c.jsx)(a.Ay,{item:!0,xs:12,children:(0,c.jsx)(s.A,{variant:"h3",color:"inherit",sx:{fontSize:{xs:16,md:20}},children:t})}),(0,c.jsx)(a.Ay,{item:!0,xs:12,children:(0,c.jsx)(s.A,{variant:"subtitle2",color:"inherit",children:r})})]})]})})}},56311:(e,r,t)=>{t.d(r,{A:()=>u});var o=t(89379),n=t(9950),i=t(2660),l=t(2046),s=t(83274),a=t(25333),c=t(97125),d=t(7762),x=t(52097),h=t(44414);const u=e=>{let{value:r,onChange:t,onDebouncedChange:u,debounceTime:p=500,placeholder:A="Search (ctrl+k)",sx:g}=e;const f=(0,n.useRef)(null),[m]=(0,x.d7)(r,p);return(0,n.useEffect)((()=>{u&&u(m)}),[m,u]),(0,n.useEffect)((()=>{const e=e=>{var r;"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),null===(r=f.current)||void 0===r||r.focus());"Escape"===e.key&&document.activeElement===f.current&&f.current.blur()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[]),(0,h.jsx)(i.A,{sx:(0,o.A)({},g),inputRef:f,placeholder:A,autoComplete:"off",value:r,fullWidth:!0,onChange:e=>t(e.target.value),startAdornment:(0,h.jsx)(l.A,{position:"start",sx:{mr:-.5},children:(0,h.jsx)(c.A,{})}),endAdornment:(0,h.jsx)(s.A,{title:"Clear",children:(0,h.jsx)(a.A,{sx:{visibility:r?"visible":"hidden"},onClick:()=>t(""),children:(0,h.jsx)(d.A,{})})})})}},58691:(e,r,t)=>{t.d(r,{A:()=>s});t(9950);var o=t(16491),n=t(46639),i=t(62217),l=t(44414);function s(e){let{size:r=70,imgSize:t=40,alt:s="loader"}=e;return(0,l.jsxs)(o.A,{position:"relative",display:"inline-flex",justifyContent:"center",alignItems:"center",children:[(0,l.jsx)(n.A,{size:r}),(0,l.jsx)(o.A,{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",sx:{width:t,height:t},children:(0,l.jsx)("img",{src:i,alt:s,style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"contain"}})})]})}},59212:(e,r,t)=>{t.d(r,{A:()=>h});var o=t(89379),n=t(9950),i=t(93230),l=t(41413),s=t(77922),a=t(29925),c=t(26910),d=t(31222),x=t(44414);const h=(0,n.forwardRef)(((e,r)=>{let{setAppId:t,setLocoName:h,setPage:u,sx:p,textfeildSx:A,textfieldSx:g,pill:f=!1,accentColor:m="#6366f1",icon:j,placeholder:b="Select Zone",paperComponent:v}=e;const[y,k]=(0,n.useState)(JSON.parse(localStorage.getItem("applocations")||"[]"));(0,n.useEffect)((()=>{0===y.length&&(async()=>{try{const e=localStorage.getItem("userid");if(!e)return;const r=await c.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/partners/getlocations/?userid=").concat(e));if(r.data.status){const e=[...r.data.details,{locationname:"All",applocationid:0}];localStorage.setItem("applocations",JSON.stringify(e)),k(e)}}catch(e){console.error("Error fetching locations in LocationAutocomplete:",e)}})()}),[y.length]);const S=e=>"".concat(m).concat(e),w=S("26"),C=S("18"),W=f?{cursor:"pointer","& .MuiOutlinedInput-root":{borderRadius:"10px",bgcolor:"#ffffff",fontWeight:600,color:"#0f172a",paddingRight:"8px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s","& fieldset":{borderColor:"#e2e8f0",borderWidth:1},"&:hover fieldset":{borderColor:"#cbd5e1"},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(w)},"&.Mui-focused fieldset":{borderColor:m,borderWidth:1.5}},"& .MuiAutocomplete-endAdornment .MuiSvgIcon-root":{color:"#94a3b8"}}:{},D=f&&(0,x.jsx)(i.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25,flexShrink:0},children:(0,x.jsx)(l.A,{sx:{width:24,height:24,bgcolor:C,color:m,transition:"background-color 0.15s, color 0.15s"},children:j||(0,x.jsx)(d.HPi,{size:14})})});return(0,x.jsx)(s.A,{id:"location-autocomplete",options:y||[],getOptionLabel:e=>{var r;return null!==(r=null===e||void 0===e?void 0:e.locationname)&&void 0!==r?r:""},PaperComponent:v,sx:(0,o.A)({},p),onChange:(e,r,o)=>{"clear"===o?(null===t||void 0===t||t(0),null===h||void 0===h||h(""),null===u||void 0===u||u(0)):r&&(null===t||void 0===t||t(r.applocationid),null===h||void 0===h||h(r.locationname),null===u||void 0===u||u(0))},renderInput:e=>f?(0,x.jsx)(a.A,(0,o.A)((0,o.A)({},e),{},{inputRef:r,placeholder:b,InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:D}),sx:(0,o.A)((0,o.A)({},W),g||A||{})})):(0,x.jsx)(a.A,(0,o.A)((0,o.A)({},e),{},{inputRef:r,label:"Select Zones",sx:(0,o.A)({},g||A||{})}))})}))},96646:(e,r,t)=>{t.d(r,{r:()=>a});var o=t(9213),n=t(21671),i=t(82917),l=t(93230),s=t(44414);const a=e=>{let{rowsPerPage:r=5,col:t=1}=e;return(0,s.jsx)(s.Fragment,{children:Array.from(new Array(r)).map(((e,r)=>(0,s.jsxs)(o.A,{children:[(0,s.jsx)(n.A,{children:(0,s.jsx)(i.A,{variant:"circular",width:24,height:24})}),(0,s.jsx)(n.A,{children:(0,s.jsx)(i.A,{variant:"text",width:30})}),Array.from({length:t}).map(((e,r)=>(0,s.jsx)(n.A,{children:(0,s.jsxs)(l.A,{spacing:.5,children:[(0,s.jsx)(i.A,{variant:"text",width:100}),(0,s.jsx)(i.A,{variant:"text",width:80})]})},r))),(0,s.jsx)(n.A,{children:(0,s.jsx)(i.A,{variant:"text",width:150})}),(0,s.jsx)(n.A,{children:(0,s.jsx)(i.A,{variant:"rounded",width:60,height:24})}),(0,s.jsx)(n.A,{align:"center",children:(0,s.jsxs)(l.A,{direction:"row",spacing:1,justifyContent:"flex-end",children:[(0,s.jsx)(i.A,{variant:"circular",width:28,height:28}),(0,s.jsx)(i.A,{variant:"circular",width:28,height:28})]})})]},r)))})}}}]); |