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,o)=>{o.r(r),o.d(r,{default:()=>Ee});var n=o(89379),t=o(9950),i=o(47965),s=o(44070),l=o(36256),a=o(13838),c=o(4159),d=o.n(c),x=o(36150),h=o(60010),p=o(51778),u=(o(47659),o(14857)),A=o(94118),g=o(37476),m=o(94826),j=o(52351),f=o(67562),b=o(49883),v=o(31222),y=o(35678),k=o(56311),w=o(44414);var S=o(50027),C=o(20466),W=o(96646),D=o(59212);const z=o.p+"static/media/aiImage.89c2ccb91a41d85031e3.png";var I=o(63189),M=o(99324),Y=o(6604),R=o(2235),O=o(41413),P=o(47223),F=o(55158),T=o(59382),L=o(28810),E=o(79046),N=o(33092),H=o(93230),q=o(82053),K=o(16491),_=o(60899),B=o(82917),U=o(77922),Z=o(29925),X=o(83274),Q=o(1320),V=o(93038),G=o(25333),J=o(15769),$=o(69780),ee=o(9213),re=o(21671),oe=o(34075),ne=o(96583),te=o(40033),ie=o(25277),se=o(28170),le=o(79739),ae=o(82223),ce=o(74745),de=o(81425),xe=o(58691),he=o(23787),pe=o(28429),ue=o(90376),Ae=o(54413),ge=o(36220);d().extend(ge);const me=999,je=16,fe="0 14px 40px rgba(15, 23, 42, 0.10)",be="0 8px 24px rgba(15, 23, 42, 0.08)",ve="0 18px 50px rgba(15, 23, 42, 0.18)",ye="#0f172a",ke="#64748b",we="#94a3b8",Se="#e2e8f0",Ce="#f1f5f9",We="#f8fafc",De=(e,r)=>"".concat(e).concat(r),ze=e=>De(e,"08"),Ie=e=>De(e,"18"),Me=e=>De(e,"26"),Ye=e=>De(e,"55"),Re="#662582",Oe=e=>(0,w.jsx)(R.A,(0,n.A)((0,n.A)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:ve,border:"1px solid",borderColor:"divider",overflow:"hidden"}})),Pe=e=>{let{color:r,selected:o,size:n=24,children:t}=e;return(0,w.jsx)(O.A,{sx:{width:n,height:n,bgcolor:o?r:Ie(r),color:o?"#fff":r,transition:"background-color 0.15s, color 0.15s"},children:t})},Fe=e=>({"& .MuiOutlinedInput-root":{borderRadius:me+"px",bgcolor:ze(e),fontWeight:600,"& fieldset":{borderColor:Ye(e),borderWidth:1.5},"&:hover fieldset":{borderColor:e},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(Me(e))},"&.Mui-focused fieldset":{borderColor:e,borderWidth:2}}}),Te={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}},Le=[{idx:0,status:"created",label:"Created",color:Re,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"}],Ee=()=>{const e=(0,u.A)(),r=(0,P.A)(e.breakpoints.down("md")),o=(0,pe.Zp)(),c=(0,t.useRef)(),ge=(0,t.useRef)(),me=(0,t.useRef)(null),ve=(0,t.useRef)(null),[De,Ee]=(0,t.useState)(0),[Ne,He]=(0,t.useState)("All"),[qe,Ke]=(0,t.useState)(!1),[_e,Be]=(0,t.useState)(d()().format("YYYY-MM-DD")),[Ue,Ze]=(0,t.useState)(d()().format("YYYY-MM-DD")),[Xe,Qe]=(0,t.useState)("Today"),[Ve,Ge]=(0,t.useState)(!1),[Je,$e]=(0,t.useState)(0),[er,rr]=(0,t.useState)("created"),[or,nr]=(0,t.useState)(!1),[tr,ir]=(0,t.useState)(!1),[sr,lr]=(0,t.useState)(!1),[ar,cr]=(0,t.useState)(null),[dr,xr]=(0,t.useState)(null),[hr,pr]=(0,t.useState)(""),[ur,Ar]=(0,t.useState)(0),[gr,mr]=(0,t.useState)(null),[jr,fr]=(0,t.useState)(0),[br,vr]=(0,t.useState)(0),[yr,kr]=(0,t.useState)(""),[wr,Sr]=(0,t.useState)(""),[Cr,Wr]=(0,t.useState)(!1),[Dr,zr]=(0,t.useState)(!1),[Ir,Mr]=(0,t.useState)(null),[Yr,Rr]=(0,t.useState)(null),[Or,Pr]=(0,t.useState)(!1),[Fr,Tr]=(0,t.useState)(!1),[Lr,Er]=(0,t.useState)(!1),[Nr,Hr]=(0,t.useState)(null),[qr,Kr]=(0,t.useState)([]),[_r,Br]=(0,t.useState)([]),[Ur,Zr]=(0,t.useState)(null),[Xr,Qr]=(0,t.useState)(null),[Vr]=(0,t.useState)(0),[Gr,Jr]=(0,t.useState)([]),[$r,eo]=(0,t.useState)([]),ro=(0,t.useRef)(0),oo=(0,t.useRef)(null),[no,to]=(0,t.useState)(null),[io,so]=(0,t.useState)([]);(0,t.useEffect)((()=>{fr(0),Mr(null),vr(0),Rr(null)}),[De]),(0,t.useEffect)((()=>{vr(0),Rr(null)}),[jr]),(0,t.useEffect)((()=>{const e=$r.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})));Jr(e),console.log("csvExportData",e)}),[$r]),(0,t.useEffect)((()=>{if(null===_r||void 0===_r||!_r.length)return;const e=_r.map((e=>{const r=Number(e.cumulativekms||0),o=Number(e.minkm||0),t=Number(e.baseprice||0),i=Number(e.priceperkm||0);return r<=o?(0,n.A)((0,n.A)({},e),{},{deliveryamt:t}):(0,n.A)((0,n.A)({},e),{},{deliveryamt:(r-o)*i+t})}));eo(e),console.log("finaldeliveryList",e)}),[_r]);const{data:lo,isLoading:ao,isError:co,error:xo,refetch:ho}=(0,x.I)({queryKey:["percentageData",De],queryFn:()=>(0,de.jy)(De),enabled:!0}),{data:po,isLoading:uo,isError:Ao,error:go}=(0,x.I)({queryKey:["tenantlist",De],queryFn:()=>(0,de.Mn)(De),enabled:0!==De}),{data:mo,isLoading:jo,isError:fo,error:bo}=(0,x.I)({queryKey:["gettenantlocations",jr],queryFn:()=>(0,de.DL)(jr),enabled:0!==jr}),{data:vo=[],isLoading:yo}=(0,x.I)({queryKey:["paymentmodes"],queryFn:de.HY}),{data:ko=[],isLoading:wo}=(0,x.I)({queryKey:["ridersList",De],queryFn:de.Sd,enabled:0!==De}),{data:So,isLoading:Co,isError:Wo,error:Do,refetch:zo}=(0,x.I)({queryKey:["ordersCount",De,_e,Ue,er,jr,br],queryFn:de.Hh,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:Io}=(0,x.I)({queryKey:["getallriders"],queryFn:de.Xw,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:Mo,isLoading:Yo,isError:Ro,error:Oo,fetchNextPage:Po,hasNextPage:Fo,isFetchingNextPage:To,refetch:Lo}=(0,h.q)({queryKey:["fetchOrders",De,er,wr,_e,Ue,100,jr,br],queryFn:de.nQ,getNextPageParam:e=>{var r;return null!==(r=e.nextPage)&&void 0!==r?r:void 0},refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,staleTime:0}),Eo=(null===Mo||void 0===Mo?void 0:Mo.pages.flatMap((e=>e.rows)))||[];(0,t.useEffect)((()=>{if(!Fo)return;const e=new IntersectionObserver((e=>{e[0].isIntersecting&&Po()}),{root:document.querySelector(".MuiTableContainer-root"),rootMargin:"0px",threshold:1});return c.current&&e.observe(c.current),()=>{c.current&&e.unobserve(c.current)}}),[Fo,Po]);const No=(0,p.n)({mutationFn:0==ro.current?de.FC:de.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),zo(),Lo(),Ke(!1),Wr(!1),0==ro.current)Br(null===e||void 0===e?void 0:e.details),Zr(null===e||void 0===e?void 0:e.zones),Qr(null===e||void 0===e?void 0:e.meta),Er(!0);else{var n,t,i;Br(null===e||void 0===e?void 0:e.details),Zr(null===e||void 0===e?void 0:e.zones),Qr(null===e||void 0===e?void 0:e.meta),Hr(e);const r=oo.current||{};o("/nearle/dispatch/preview",{state:{dispatchPreviewData:e,aiMode:null!==(n=r.aiMode)&&void 0!==n?n:ro.current,selectedMode:r.selectedMode||no,deliveryData:r.deliveryData||[],autoRiders:r.autoRiders||Io||[],absentRidersPayload:r.absentRidersPayload||[],rider:r.rider||ar,appId:null!==(t=r.appId)&&void 0!==t?t:De,tenantId:null!==(i=r.tenantid)&&void 0!==i?i:jr,startdate:_e}})}},onError:e=>{(0,C.k)(e.message,"error",4e3),Wr(!1),Ke(!1)},onSettled:()=>{Zo(),Ke(!1),Wr(!1),zr(!1)}}),Ho=(0,p.n)({mutationFn:de.H2,onMutate:()=>{zr(!0)},onSuccess:e=>{console.log("create data",e),(0,C.k)("Delivery Created Successfully","success",2e3),o("/nearle/deliveries"),_o.mutate(null===ar||void 0===ar?void 0:ar.userfcmtoken)},onError:e=>{(0,C.k)(e.message,"error",4e3)},onSettled:()=>{zr(!1)}}),qo=(0,p.n)({mutationFn:de.N4,onSuccess:e=>{e.status&&(nr(!1),(0,C.k)("Order Cancelled Successfully","success",2e3),zo(),ho())},onError:e=>{(0,C.k)(e.message,"error",2e3)}}),Ko=(0,p.n)({mutationFn:de.zR,onSuccess:e=>{e.status&&(lr(!1),(0,C.k)("Order Cancelled Successfully","success",2e3),Lo(),zo(),ho(),Kr([]))},onError:e=>{(0,C.k)(e.message,"error",2e3)}}),_o=(0,p.n)({mutationFn:de.k3,onSuccess:()=>{(0,C.k)("Notification sent Successfully","success",2e3)},onError:e=>{(0,C.k)(e.message,"error",2e3)}}),Bo=async e=>{zr(!0),Ke(!0);const r=qr.map((e=>(0,n.A)((0,n.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 o=(io||[]).map((e=>({userid:e.userid,username:"".concat(e.firstname||""," ").concat(e.lastname||"").trim()||e.username||"Rider ".concat(e.userid)})));oo.current={deliveryData:r,absentRidersPayload:o,autoRiders:Io,selectedMode:no,aiMode:ro.current,rider:ar,appId:De,tenantid:jr},0==ro.current?No.mutate({deliveries:r}):no&&1==(null===no||void 0===no?void 0:no.value)?No.mutate({deliveries:1==no.value?r:{body:r},hypertuning_params:e||null,selectedMode:no,absent_riders:o}):No.mutate({data:{orders:r,riders:Io,config:{pay_type:"hourly",base_pay:300,strategy:"multi_trip"},absent_riders:o},selectedMode:no})},Uo=(0,p.n)({mutationFn:de.H2,onSuccess:(e,r)=>{console.log("data",e),console.log("varialbles",r),(0,C.k)("Delivery Created Successfully","success",2e3),zr(!1),o("/nearle/deliveries")},onError:e=>{(0,C.k)(e.message,"error",4e3)},onSettled:()=>{zr(!1)}}),Zo=()=>{ir(!1),cr(null),xr(null),to(null),so([])},Xo=co?"Error fetching percentages: ".concat(null===xo||void 0===xo?void 0:xo.message):Wo?"Error fetching orders Count: ".concat(null===Do||void 0===Do?void 0:Do.message):Ro?"Error fetching orders : ".concat(null===Oo||void 0===Oo?void 0:Oo.message):Ao?"Error Fetching on Tenants:".concat(null===go||void 0===go?void 0:go.message," "):fo?"Error Fetching on Tenants Locations:".concat(null===bo||void 0===bo?void 0:bo.message," "):null;return(0,t.useEffect)((()=>{Xo&&(console.log(Xo),(0,C.k)(Xo,"error",3e3))}),[Xo]),(0,w.jsxs)(t.Fragment,{children:[(ao||Co||Yo||uo||jo||Cr)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(j.A,{}),(0,w.jsx)(m.A,{})]}),(0,w.jsx)(F.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:Cr||Yo,children:(0,w.jsx)(m.A,{color:"inherit"})}),(0,w.jsx)(F.A,{sx:{zIndex:1e3},open:Or}),qr.length>0&&(0,w.jsxs)(T.A,{ariaLabel:"Actions",icon:(0,w.jsx)(L.A,{badgeContent:(null===qr||void 0===qr?void 0:qr.length)||"",color:"secondary",children:(0,w.jsx)(E.A,{})}),open:Or,onOpen:()=>Pr(!0),onClose:()=>Pr(!1),sx:{position:"fixed",bottom:52,right:16,"& .MuiFab-primary":{bgcolor:"#7b1fa2",color:"#fff","&:hover":{bgcolor:"#6a1b9a"},width:64,height:64}},children:[(0,w.jsx)(N.A,{icon:(0,w.jsx)("img",{src:z,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:()=>{ro.current=1,Pr(!1),ir(!0)}}),(0,w.jsx)(N.A,{icon:(0,w.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:()=>{ro.current=0,Pr(!1),ir(!0)}}),(0,w.jsx)(N.A,{icon:(0,w.jsx)(s.A,{style:{fontSize:22}}),tooltipTitle:"Delete",FabProps:{sx:{bgcolor:"#d32f2f",color:"#fff","&:hover":{bgcolor:"#9a0007"},width:64,height:64}},onClick:()=>{Pr(!1),lr(!0)}})]}),(0,w.jsx)(R.A,{elevation:0,sx:{mb:{xs:1.5,md:2},p:{xs:1.5,sm:2,md:2.5},borderRadius:je/8,border:"1px solid",borderColor:Se,background:"linear-gradient(135deg, ".concat(ze(Re)," 0%, ").concat(ze("#9255AB")," 100%)"),boxShadow:be},children:(0,w.jsxs)(H.A,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",spacing:{xs:1.5,sm:2},children:[(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:{xs:1.25,sm:1.75},children:[(0,w.jsx)(O.A,{sx:{width:{xs:40,sm:48},height:{xs:40,sm:48},bgcolor:Re,color:"#fff",boxShadow:"0 6px 18px ".concat(Me(Re))},children:(0,w.jsx)(v.F6S,{size:22})}),(0,w.jsxs)(H.A,{children:[(0,w.jsx)(q.A,{variant:"h3",sx:{fontWeight:800,color:ye,lineHeight:1.1,fontSize:{xs:"1.25rem",sm:"1.5rem",md:"1.75rem"}},children:"Orders"}),(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:.75,sx:{mt:.5},children:[(0,w.jsx)(K.A,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:"#10b981",boxShadow:"0 0 0 4px rgba(16,185,129,0.18)"}}),(0,w.jsxs)(q.A,{variant:"caption",sx:{color:ke,fontWeight:600},children:["Live \xb7 ",Ne||"All Zones"," \xb7 ",Xe]})]})]})]}),(0,w.jsx)(D.A,{ref:me,locaName:Ne,setAppId:Ee,setLocoName:He,setPage:Ar,pill:!0,accentColor:Re,icon:(0,w.jsx)(v.HPi,{size:14}),placeholder:"Select Zone",paperComponent:Oe,sx:{width:{xs:"100%",sm:280},zIndex:100}})]})}),(0,w.jsx)(_.Ay,{container:!0,spacing:{xs:1.25,sm:1.5,md:2},sx:{mt:"1px"},children:[{key:"created",label:"Created Orders",color:"#0ea5e9",icon:v.F6S,value:null===lo||void 0===lo?void 0:lo.created,percentage:null===lo||void 0===lo?void 0:lo.percentage1},{key:"pending",label:"Pending Orders",color:"#f59e0b",icon:v.tX0,value:null===lo||void 0===lo?void 0:lo.uncoveredOrders,percentage:null===lo||void 0===lo?void 0:lo.percentage2},{key:"delivered",label:"Delivered Orders",color:"#10b981",icon:v.mU9,value:null===lo||void 0===lo?void 0:lo.coveredOrders,percentage:null===lo||void 0===lo?void 0:lo.percentage3},{key:"cancelled",label:"Cancelled Orders",color:"#ef4444",icon:v.uDv,value:null===lo||void 0===lo?void 0:lo.cancelled,percentage:null===lo||void 0===lo?void 0:lo.percentage4}].map((e=>{var r;const o=e.icon;return(0,w.jsx)(_.Ay,{item:!0,xs:6,sm:6,md:3,children:(0,w.jsxs)(R.A,{elevation:0,sx:{position:"relative",overflow:"hidden",p:{xs:1.25,sm:1.75,md:2.25},borderRadius:je/8,border:"1px solid",borderColor:Se,background:"#fff",transition:"transform 0.2s, box-shadow 0.2s, border-color 0.2s","&:hover":{transform:"translateY(-3px)",boxShadow:be,borderColor:Ye(e.color)}},children:[(0,w.jsx)(K.A,{sx:{position:"absolute",top:0,left:0,right:0,height:3,background:"linear-gradient(90deg, ".concat(e.color," 0%, ").concat(Ie(e.color)," 100%)")}}),(0,w.jsxs)(H.A,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",spacing:1,children:[(0,w.jsxs)(H.A,{spacing:.5,sx:{minWidth:0,flex:1},children:[(0,w.jsx)(q.A,{variant:"caption",sx:{color:ke,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",fontSize:{xs:10,sm:11},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label}),(0,w.jsx)(q.A,{sx:{fontWeight:800,color:ye,lineHeight:1.1,fontSize:{xs:"1.25rem",sm:"1.5rem",md:"1.75rem"}},children:ao?(0,w.jsx)(B.A,{sx:{width:40},animation:"wave"}):null!==(r=e.value)&&void 0!==r?r:0}),null!=e.percentage&&(0,w.jsxs)(q.A,{variant:"caption",sx:{color:ke,fontWeight:700},children:[e.percentage,"%"]})]}),(0,w.jsx)(O.A,{sx:{width:{xs:36,sm:42,md:48},height:{xs:36,sm:42,md:48},bgcolor:Ie(e.color),color:e.color,boxShadow:"inset 0 0 0 1px ".concat(Ye(e.color)),flexShrink:0},children:(0,w.jsx)(o,{size:20})})]})]})},e.key)}))}),(0,w.jsxs)(R.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1.25,md:1.75},borderRadius:je/8,border:"1px solid",borderColor:Se,background:"#fff",boxShadow:fe},children:[(0,w.jsxs)(_.Ay,{container:!0,spacing:1.25,alignItems:"center",children:[(0,w.jsx)(_.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,w.jsx)(U.A,{options:po||[],value:Ir,getOptionLabel:e=>(null===e||void 0===e?void 0:e.tenantname)||"",PaperComponent:Oe,onOpen:e=>{De||(e.preventDefault(),(0,C.k)("Please select location first!","warning",3e3),setTimeout((()=>{var e;null===(e=me.current)||void 0===e||e.focus()}),0))},onChange:(e,r,o)=>{"clear"===o?(fr(0),Mr(null),vr(0),Rr(null)):(fr((null===r||void 0===r?void 0:r.tenantid)||0),Mr(r),vr(0),Rr(null))},renderInput:e=>(0,w.jsx)(Z.A,(0,n.A)((0,n.A)({},e),{},{inputRef:ve,placeholder:"Select Tenant",size:"small",sx:Fe("#0ea5e9"),InputProps:(0,n.A)((0,n.A)({},e.InputProps),{},{startAdornment:(0,w.jsx)(H.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:(0,w.jsx)(Pe,{color:"#0ea5e9",size:22,selected:!0,children:(0,w.jsx)(v.Itr,{size:13})})})})}))})}),(0,w.jsx)(_.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,w.jsx)(U.A,{options:mo||[],getOptionLabel:e=>e?"".concat(e.locationname," (").concat(e.suburb,")"):"",value:Yr,PaperComponent:Oe,onOpen:e=>{De||jr?jr||(e.preventDefault(),(0,C.k)("Please select Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=ve.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=me.current)||void 0===e||e.focus()}),0))},onChange:(e,r,o)=>{"clear"===o?(vr(0),Rr(null)):(vr(r.locationid||0),Rr(r))},renderInput:e=>(0,w.jsx)(Z.A,(0,n.A)((0,n.A)({},e),{},{placeholder:"Select Location",size:"small",sx:Fe("#10b981"),InputProps:(0,n.A)((0,n.A)({},e.InputProps),{},{startAdornment:(0,w.jsx)(H.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:(0,w.jsx)(Pe,{color:"#10b981",size:22,selected:!0,children:(0,w.jsx)(v.JFD,{size:13})})})})}))})}),(0,w.jsx)(_.Ay,{item:!0,xs:12,sm:12,md:4,children:(0,w.jsxs)(H.A,{direction:"row",spacing:1,alignItems:"center",justifyContent:{xs:"flex-start",md:"flex-end"},flexWrap:"wrap",children:[(0,w.jsx)(X.A,{title:"Date Filter",placement:"top",children:(0,w.jsxs)(K.A,{onClick:()=>Ge(!0),sx:{display:"inline-flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:999,cursor:"pointer",bgcolor:ze("#f59e0b"),border:"1.5px solid ".concat(Ye("#f59e0b")),color:"#f59e0b",fontWeight:800,fontSize:12,transition:"all 0.18s","&:hover":{borderColor:"#f59e0b",boxShadow:"0 0 0 3px ".concat(Me("#f59e0b"))}},children:[(0,w.jsx)(v.Ki0,{size:14}),d()(_e).format("DD/MM/YY")," \u2013 ",d()(Ue).format("DD/MM/YY")]})}),(0,w.jsxs)(K.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.5,borderRadius:999,bgcolor:ze(Re),border:"1px solid ".concat(Ye(Re)),color:Re,fontSize:11,fontWeight:800},children:[(0,w.jsx)(v.GdF,{size:12})," ",Xe]})]})})]}),(0,w.jsx)(y.A,{open:Ve,onClose:()=>Ge(!1),onSelect:e=>{Be(e.startDate),Ze(e.endDate),Qe(e.label),console.log("Selected Date Range:",e)}})]}),(0,w.jsx)(R.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1,md:1.5},borderTopLeftRadius:je/8,borderTopRightRadius:je/8,borderBottomLeftRadius:0,borderBottomRightRadius:0,border:"1px solid",borderColor:Se,borderBottom:0,background:"#fff"},children:(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{flexWrap:"wrap-reverse"},children:[(0,w.jsx)(H.A,{direction:"row",spacing:.75,sx:{flex:1,overflowX:"auto",py:.5,px:.25,"&::-webkit-scrollbar":{height:6},"&::-webkit-scrollbar-thumb":{backgroundColor:Se,borderRadius:4}},children:Le.map((e=>{var r;const o=e.icon,n=Je===e.idx,t=null!==(r=null===So||void 0===So?void 0:So[e.countKey])&&void 0!==r?r:0;return(0,w.jsxs)(K.A,{onClick:r=>{return o=e.idx,Ar(0),$e(o),0===o&&rr("created"),1===o&&rr("pending"),2===o&&rr("delivered"),3===o&&rr("cancelled"),void kr("");var o},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:999,border:"1.5px solid ".concat(n?e.color:Ye(e.color)),bgcolor:n?e.color:ze(e.color),color:n?"#fff":e.color,fontWeight:700,boxShadow:n?"0 6px 18px ".concat(Me(e.color)):"none",transition:"all 0.18s","&:hover":{borderColor:e.color,boxShadow:n?"0 6px 18px ".concat(Me(e.color)):"0 0 0 3px ".concat(Me(e.color))}},children:[(0,w.jsx)(O.A,{sx:{width:{xs:22,md:26},height:{xs:22,md:26},bgcolor:n?"rgba(255,255,255,0.22)":Ie(e.color),color:n?"#fff":e.color},children:(0,w.jsx)(o,{size:13})}),(0,w.jsx)(q.A,{variant:"caption",sx:{fontWeight:800,fontSize:{xs:11.5,md:13},lineHeight:1},children:e.label}),(0,w.jsx)(K.A,{sx:{minWidth:{xs:22,md:26},height:{xs:18,md:22},px:.625,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:999,fontSize:{xs:10,md:11},fontWeight:800,bgcolor:n?"rgba(255,255,255,0.22)":"#fff",color:n?"#fff":e.color,border:n?"none":"1px solid ".concat(Ye(e.color))},children:t})]},e.status)}))}),(0,w.jsx)(K.A,{sx:{width:{xs:"100%",sm:240,lg:280},flex:{xs:"1 1 100%",sm:"0 0 auto"}},children:(0,w.jsx)(k.A,{value:yr,onChange:kr,onDebouncedChange:Sr,placeholder:"Search orders (ctrl+k)",sx:{m:0,width:"100%",borderRadius:999,bgcolor:ze(Re),"& fieldset":{borderColor:Ye(Re),borderWidth:1.5},"&:hover fieldset":{borderColor:Re},"&.Mui-focused fieldset":{borderColor:Re,borderWidth:2},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(Me(Re))}}})})]})}),(0,w.jsx)(R.A,{elevation:0,sx:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:je/8,borderBottomRightRadius:je/8,border:"1px solid",borderColor:Se,overflow:"hidden",background:"#fff"},children:(0,w.jsx)(Q.A,{ref:ge,onScroll:e=>{const{scrollTop:r,scrollHeight:o,clientHeight:n}=e.currentTarget;r+n>=o-50&&Fo&&!To&&Po()},sx:{maxHeight:{xs:"calc(100vh - 220px)",md:"calc(100vh - 190px)"},overflow:"auto","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:Ye(Re),borderRadius:8,"&:hover":{backgroundColor:Re}},"&::-webkit-scrollbar-track":{backgroundColor:We}},children:r?(0,w.jsxs)(he.nV,{sx:{p:1.25},children:[0===(null===Eo||void 0===Eo?void 0:Eo.length)&&!Yo&&(0,w.jsxs)(H.A,{alignItems:"center",spacing:1.5,sx:{py:6},children:[(0,w.jsx)(O.A,{sx:{width:64,height:64,bgcolor:Ie("#94a3b8"),color:we},children:(0,w.jsx)(v.F6S,{size:28})}),(0,w.jsxs)(q.A,{variant:"subtitle1",sx:{fontWeight:700,color:ye},children:["No ",er," orders"]}),(0,w.jsx)(q.A,{variant:"caption",sx:{color:ke,textAlign:"center",px:2},children:yr?"Try a different keyword.":"Adjust the filters above to load orders."})]}),Yo&&(0,w.jsxs)(H.A,{alignItems:"center",sx:{py:6},children:[(0,w.jsx)(xe.A,{}),(0,w.jsx)(q.A,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Loading orders\u2026"})]}),null===Eo||void 0===Eo?void 0:Eo.map(((r,o)=>{const t=!!qr.find((e=>e.orderheaderid===r.orderheaderid)),i=Te[String(r.orderstatus||"").toLowerCase()]||{label:r.orderstatus||"\u2014",color:Re,icon:v.bfP},s=i.icon;return(0,w.jsx)(he.pg,{accent:i.color,selected:t,header:(0,w.jsxs)(H.A,{spacing:1.25,children:[(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,children:[(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:.75,sx:{minWidth:0},children:["created"===er&&(0,w.jsx)(V.A,{size:"small",sx:{p:.25,color:Ye(Re),"&.Mui-checked":{color:Re}},onChange:e=>{var o;if(!De)return(0,C.k)("Please select a location first!","warning",2e3),void(null===(o=me.current)||void 0===o||o.focus());e.target.checked?Kr((e=>[...e,(0,n.A)((0,n.A)({},r),{},{sno:e.length+1})])):Kr((e=>e.filter((e=>e.orderheaderid!==r.orderheaderid)).map(((e,r)=>(0,n.A)((0,n.A)({},e),{},{sno:r+1})))))},checked:t}),(0,w.jsx)(q.A,{variant:"caption",sx:{fontWeight:700,color:we},children:String(100*ur+o+1).padStart(2,"0")}),(0,w.jsxs)(K.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:ze(i.color),border:"1px solid ".concat(Ye(i.color)),color:i.color,fontSize:10.5,fontWeight:800,whiteSpace:"nowrap"},children:[(0,w.jsx)(s,{size:11})," ",i.label]})]}),"created"===r.orderstatus&&(0,w.jsxs)(H.A,{direction:"row",spacing:.75,sx:{flexShrink:0},children:["C"===r.deliverytype&&(0,w.jsx)(G.A,{size:"small",onClick:()=>{(null===gr||void 0===gr?void 0:gr.orderid)===r.orderid?mr(null):mr(r)},sx:{borderRadius:999,bgcolor:ze("#06b6d4"),color:"#06b6d4",border:"1px solid ".concat(Ye("#06b6d4")),"&:hover":{bgcolor:Ie("#06b6d4")}},children:(null===gr||void 0===gr?void 0:gr.orderid)===r.orderid?(0,w.jsx)(f.A,{fontSize:"small"}):(0,w.jsx)(b.A,{fontSize:"small"})}),(0,w.jsx)(G.A,{size:"small",disabled:t,onClick:()=>{nr(!0),pr(r.orderheaderid)},sx:{borderRadius:999,bgcolor:ze("#ef4444"),color:"#ef4444",border:"1px solid ".concat(Ye("#ef4444")),"&:hover":{bgcolor:Ie("#ef4444")},"&.Mui-disabled":{color:e.palette.secondary.main}},children:(0,w.jsx)(A.A,{})})]})]}),(0,w.jsxs)(K.A,{sx:{minWidth:0},children:[(0,w.jsx)(q.A,{sx:{fontWeight:800,color:ye,fontSize:15},noWrap:!0,children:r.tenantname}),(0,w.jsx)(q.A,{variant:"caption",sx:{color:ke},noWrap:!0,children:[r.tenantsuburb,r.applocation].filter(Boolean).join(" \xb7 ")||"\u2014"})]})]}),children:(0,w.jsxs)(he.FG,{children:[(0,w.jsxs)(he.pY,{label:"Order / Location",full:!0,children:[(0,w.jsx)(q.A,{sx:{fontSize:13,fontWeight:600,color:ye},noWrap:!0,children:"".concat(r.locationname,"-(").concat(r.locationsuburb,")")}),(0,w.jsxs)(q.A,{variant:"caption",sx:{color:ke},children:[r.orderid," \xb7 ",d()(r.pickupslot).utc().format("DD/MM/YYYY")," ",d()(r.pickupslot).format("hh:mm A")]})]}),(0,w.jsxs)(he.pY,{label:"Pickup",children:[(0,w.jsx)(q.A,{sx:{fontSize:13,fontWeight:600,color:ye},noWrap:!0,children:r.pickupcustomer||"\u2014"}),(0,w.jsx)(q.A,{variant:"caption",sx:{color:ke},noWrap:!0,children:r.pickupcontactno}),(0,w.jsx)(q.A,{variant:"caption",sx:{color:ke},noWrap:!0,children:r.pickupsuburb||r.pickupaddress})]}),(0,w.jsxs)(he.pY,{label:"Drop",children:[(0,w.jsx)(q.A,{sx:{fontSize:13,fontWeight:600,color:ye},noWrap:!0,children:r.deliverycustomer||"\u2014"}),(0,w.jsx)(q.A,{variant:"caption",sx:{color:ke},noWrap:!0,children:r.deliverycontactno}),(0,w.jsx)(q.A,{variant:"caption",sx:{color:ke},noWrap:!0,children:r.deliverysuburb||r.deliveryaddress})]}),(0,w.jsx)(he.pY,{label:"Qty",value:r.quantity||"\u2014"}),(0,w.jsx)(he.pY,{label:"KMS",children:(0,w.jsxs)(K.A,{sx:(l="#06b6d4",{display:"inline-flex",alignItems:"center",justifyContent:"center",px:1,py:.25,borderRadius:999,bgcolor:ze(l),color:l,fontWeight:700,fontSize:11,border:"1px solid ".concat(Ye(l)),whiteSpace:"nowrap"}),children:[r.kms||0," km"]})}),(0,w.jsx)(he.pY,{label:"COD",children:(0,w.jsx)(q.A,{sx:{fontSize:13,fontWeight:800,color:r.collectionamt?"#ef4444":we},children:r.collectionamt?"\u20b9 ".concat(r.collectionamt.toFixed(2)):"\u2014"})}),(0,w.jsx)(he.pY,{label:"Charges",children:(0,w.jsx)(q.A,{sx:{fontSize:13,fontWeight:800,color:r.deliverycharge?"#ef4444":we},children:r.deliverycharge?"\u20b9 ".concat(r.deliverycharge.toFixed(2)):"\u2014"})}),r.ordernotes&&(0,w.jsx)(he.pY,{label:"Notes",full:!0,children:(0,w.jsx)(q.A,{variant:"caption",sx:{color:ke},children:r.ordernotes})})]})},r.sno);var l})),0!=(null===Eo||void 0===Eo?void 0:Eo.length)&&(0,w.jsx)("div",{ref:c,style:{height:40,textAlign:"center"},children:To||Fo?(0,w.jsx)(xe.A,{}):(0,w.jsx)(q.A,{variant:"caption",sx:{color:we,fontWeight:600},children:"No more orders"})})]}):(0,w.jsxs)(J.A,{stickyHeader:!0,sx:{minWidth:{xs:960,md:1180}},children:[(0,w.jsx)($.A,{children:(0,w.jsxs)(ee.A,{sx:{"& th":{backgroundColor:We,color:ke,fontSize:{xs:10,md:11},fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(Se),py:{xs:1,md:1.25},px:{xs:1,md:1.5}}},children:["created"==er&&(0,w.jsx)(re.A,{sx:{position:"sticky !important"},children:(0,w.jsx)(V.A,{size:"small",sx:{p:.5,color:Ye(Re),"&.Mui-checked, &.MuiCheckbox-indeterminate":{color:Re}},indeterminate:qr.length>0&&qr.length!==(null===Eo||void 0===Eo?void 0:Eo.length),checked:qr.length===(null===Eo||void 0===Eo?void 0:Eo.length),onChange:e=>{var r;if(!De)return(0,C.k)("Please select a location first!","warning",2e3),void(null===(r=me.current)||void 0===r||r.focus());if(e.target.checked){const e=null===Eo||void 0===Eo?void 0:Eo.map(((e,r)=>(0,n.A)((0,n.A)({},e),{},{sno:r+1})));Kr(e)}else Kr([])}})}),(0,w.jsx)(re.A,{children:"#"}),(0,w.jsx)(re.A,{children:"Tenant"}),(0,w.jsx)(re.A,{children:"Location"}),(0,w.jsx)(re.A,{children:"Pickup"}),(0,w.jsx)(re.A,{children:"Drop"}),(0,w.jsx)(re.A,{align:"center",children:"QTY"}),(0,w.jsx)(re.A,{align:"right",children:"COD"}),(0,w.jsx)(re.A,{align:"center",children:"KMS"}),(0,w.jsx)(re.A,{align:"right",children:"Charges"}),(0,w.jsx)(re.A,{children:"Notes"}),(0,w.jsx)(re.A,{children:"Status"}),"created"==er&&(0,w.jsx)(re.A,{align:"right",children:"Actions"})]})}),(0,w.jsxs)(oe.A,{children:[0===(null===Eo||void 0===Eo?void 0:Eo.length)&&!Yo&&(0,w.jsx)(ee.A,{children:(0,w.jsx)(re.A,{colSpan:13,sx:{py:6},children:(0,w.jsxs)(H.A,{alignItems:"center",spacing:1.5,children:[(0,w.jsx)(O.A,{sx:{width:64,height:64,bgcolor:Ie("#94a3b8"),color:we},children:(0,w.jsx)(v.F6S,{size:28})}),(0,w.jsxs)(q.A,{variant:"subtitle1",sx:{fontWeight:700,color:ye},children:["No ",er," orders"]}),(0,w.jsx)(q.A,{variant:"caption",sx:{color:ke},children:yr?"Try a different keyword.":"Adjust the filters above to load orders."})]})})}),Yo&&(0,w.jsx)(W.r,{col:8}),null===Eo||void 0===Eo?void 0:Eo.map(((r,o)=>{const t=!!qr.find((e=>e.orderheaderid===r.orderheaderid));return(0,w.jsxs)(ee.A,{role:"checkbox",tabIndex:-1,sx:{cursor:"pointer",transition:"background-color 0.15s",backgroundColor:t?ze(Re):"transparent","& td":{borderBottom:"1px solid ".concat(Ce),py:{xs:1,md:1.25},px:{xs:1,md:1.5}},"&:hover":{backgroundColor:t?Ie(Re)+" !important":We}},children:["created"===er&&(0,w.jsx)(re.A,{children:(0,w.jsx)(V.A,{size:"small",sx:{p:.5,color:Ye(Re),"&.Mui-checked":{color:Re}},onChange:e=>{var o;if(!De)return(0,C.k)("Please select a location first!","warning",2e3),void(null===(o=me.current)||void 0===o||o.focus());e.target.checked?Kr((e=>[...e,(0,n.A)((0,n.A)({},r),{},{sno:e.length+1})])):Kr((e=>e.filter((e=>e.orderheaderid!==r.orderheaderid)).map(((e,r)=>(0,n.A)((0,n.A)({},e),{},{sno:r+1})))))},checked:t})}),(0,w.jsx)(re.A,{children:(0,w.jsx)(q.A,{children:100*ur+o+1})}),(0,w.jsx)(re.A,{children:(0,w.jsxs)(X.A,{title:r.tenantaddress,children:[(0,w.jsx)(q.A,{variant:"subtitle1",noWrap:!0,children:r.tenantname}),(0,w.jsxs)(q.A,{noWrap:!0,variant:"body2",children:[r.tenantsuburb,(0,w.jsx)("br",{})]}),(0,w.jsx)(q.A,{noWrap:!0,variant:"body2",children:r.applocation})]})}),(0,w.jsxs)(re.A,{align:"left",children:[(0,w.jsx)(q.A,{variant:"subtitle1",noWrap:!0,children:"".concat(r.locationname,"-(").concat(r.locationsuburb,")")}),(0,w.jsx)(X.A,{title:"TenantId - OrderId",children:(0,w.jsx)(q.A,{variant:"body2",noWrap:!0,children:r.orderid})}),(0,w.jsx)(X.A,{title:"Pickup Slot",children:(0,w.jsxs)(q.A,{noWrap:!0,sx:{fontSize:"12px"},children:[d()(r.pickupslot).utc().format("DD/MM/YYYY")," ",d()(r.pickupslot).format("hh:mm A")]})})]}),(0,w.jsx)(re.A,{align:"left",children:(0,w.jsxs)(H.A,{direction:"column",children:[(0,w.jsx)(q.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:r.pickupcustomer}),(0,w.jsx)(q.A,{variant:"caption",children:r.pickupcontactno}),(0,w.jsx)(X.A,{title:r.pickupaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:"".concat(r.pickupsuburb||r.pickupaddress.slice(0,12)+".....")})})]})}),(0,w.jsx)(re.A,{align:"left",children:(0,w.jsxs)(H.A,{direction:"column",children:[(0,w.jsx)(q.A,{variant:"subtitle1",sx:{maxWidth:120,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.deliverycustomer}),(0,w.jsx)(q.A,{variant:"caption",children:r.deliverycontactno}),(0,w.jsx)(X.A,{title:r.deliveryaddress,sx:{whiteSpace:"nowrap"},children:(0,w.jsx)(q.A,{variant:"caption",children:"".concat(r.deliverysuburb||r.deliveryaddress.slice(0,12)+".....")})})]})}),(0,w.jsx)(re.A,{align:"center",children:r.quantity?(0,w.jsx)(q.A,{variant:"subtitle1",color:"error",sx:{whiteSpace:"nowrap"},children:r.quantity}):(0,w.jsx)(q.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:r.quantity})}),(0,w.jsx)(re.A,{align:"right",children:r.collectionamt?(0,w.jsxs)(q.A,{variant:"subtitle1",color:r.collectionamt?"error":null,sx:{whiteSpace:"nowrap"},children:["\u20b9",r.collectionamt.toFixed(2)]}):(0,w.jsxs)(q.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:["\u20b9",r.collectionamt.toFixed(2)]})}),(0,w.jsx)(re.A,{align:"center",children:(0,w.jsx)(q.A,{variant:"subtitle1",color:r.kms?"error":null,children:r.kms})}),(0,w.jsx)(re.A,{align:"right",children:r.deliverycharge?(0,w.jsxs)(q.A,{variant:"subtitle1",color:r.deliverycharge?"error":null,sx:{whiteSpace:"nowrap"},children:["\u20b9",r.deliverycharge.toFixed(2)]}):(0,w.jsxs)(q.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:["\u20b9",r.deliverycharge.toFixed(2)]})}),(0,w.jsx)(re.A,{align:"left",children:(0,w.jsx)(q.A,{variant:"body1",fontSize:"12px",sx:{maxWidth:120,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.ordernotes})}),(0,w.jsx)(re.A,{align:"left",children:(()=>{const e=Te[String(r.orderstatus||"").toLowerCase()]||{label:r.orderstatus||"\u2014",color:Re,icon:v.bfP},o=e.icon;return(0,w.jsxs)(K.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:ze(e.color),border:"1px solid ".concat(Ye(e.color)),color:e.color,fontSize:11,fontWeight:800,whiteSpace:"nowrap"},children:[(0,w.jsx)(o,{size:12})," ",e.label]})})()}),"created"===r.orderstatus&&(0,w.jsx)(re.A,{align:"center",children:(0,w.jsxs)(H.A,{flexDirection:"row",justifyContent:"end",children:["C"===r.deliverytype&&(0,w.jsx)(X.A,{title:"Product details",children:(0,w.jsx)(G.A,{color:"primary",onClick:()=>{(null===gr||void 0===gr?void 0:gr.orderid)===r.orderid?mr(null):mr(r)},children:(null===gr||void 0===gr?void 0:gr.orderid)===r.orderid?(0,w.jsx)(f.A,{}):(0,w.jsx)(b.A,{})})}),(0,w.jsx)(X.A,{title:"To Cancel",children:(0,w.jsx)(G.A,{"aria-describedby":"aria-".concat(r.sno),disabled:t,onClick:()=>{nr(!0),pr(r.orderheaderid)},children:(0,w.jsx)(A.A,{style:{color:t?e.palette.secondary.main:e.palette.error.main}})})})]})})]},r.sno)})),0!=(null===Eo||void 0===Eo?void 0:Eo.length)&&(0,w.jsx)(ee.A,{children:(0,w.jsx)(re.A,{colSpan:15,rowSpan:3,sx:{borderBottom:"none"},children:(0,w.jsx)("div",{ref:c,style:{height:40,textAlign:"center"},children:To||Fo?(0,w.jsx)(xe.A,{}):(0,w.jsx)(q.A,{variant:"caption",sx:{color:we,fontWeight:600},children:"No more orders"})})})})]})]})})}),(0,w.jsxs)(ne.A,{fullScreen:!0,open:tr,TransitionComponent:g.s,children:[(0,w.jsx)(F.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:Cr,children:(0,w.jsx)(m.A,{color:"inherit",text:"Optimising ... .."})}),(0,w.jsx)(te.A,{sx:{bgcolor:e.palette.primary.lighter},children:(0,w.jsx)(L.A,{badgeContent:null===qr||void 0===qr?void 0:qr.length,color:"primary",children:(0,w.jsx)(ie.A,{label:(0,w.jsx)(q.A,{variant:"h3",children:"Preview Orders "}),variant:"contained"})})}),(0,w.jsx)(se.A,{dividers:!0,children:(0,w.jsx)(S.A,{content:!1,children:(0,w.jsx)(Q.A,{children:(0,w.jsxs)(J.A,{stickyHeader:!0,children:[(0,w.jsx)($.A,{children:(0,w.jsxs)(ee.A,{children:[(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"#"}),(0,w.jsxs)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Tenant"," "]}),(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"order Location"}),(0,w.jsxs)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Pickup"," "]}),(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Delivery"}),(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Notes"}),(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Charges"}),(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"KMS"})]})}),(0,w.jsx)(oe.A,{children:qr.map(((e,r)=>(0,w.jsx)(t.Fragment,{children:(0,w.jsxs)(ee.A,{sx:{},children:[(0,w.jsx)(re.A,{children:(0,w.jsxs)(q.A,{children:[" ",e.sno]})}),(0,w.jsx)(re.A,{children:(0,w.jsxs)(X.A,{title:e.tenantaddress,children:[(0,w.jsx)(q.A,{variant:"body1",noWrap:!0,children:e.tenantname}),(0,w.jsxs)(q.A,{noWrap:!0,sx:{fontSize:"11px"},children:[e.tenantsuburb,(0,w.jsx)("br",{})]}),(0,w.jsx)(q.A,{noWrap:!0,variant:"body2",children:e.applocation})]})}),(0,w.jsxs)(re.A,{align:"left",children:[(0,w.jsx)(X.A,{title:e.locationaddress,placement:"top",children:(0,w.jsx)(q.A,{variant:"body1",noWrap:!0,children:"".concat(e.locationname,"-(").concat(e.locationsuburb,")")})}),(0,w.jsx)(X.A,{title:"Order Id",children:(0,w.jsx)(q.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,w.jsxs)(H.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,w.jsxs)(X.A,{title:"Ordered date",children:[(0,w.jsx)(q.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.orderdate).utc().format("DD/MM/YYYY")}),(0,w.jsx)(q.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.orderdate).utc().format("hh:mm A")})]}),"-",(0,w.jsxs)(X.A,{title:"Delivery date",children:[(0,w.jsx)(q.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.deliverydate).utc().format("DD/MM/YYYY")}),(0,w.jsx)(q.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.deliverydate).utc().format("hh:mm A")})]})]})]}),(0,w.jsx)(re.A,{align:"left",children:(0,w.jsx)(H.A,{direction:"row",spacing:1,children:(0,w.jsxs)(H.A,{direction:"column",children:[(0,w.jsx)(q.A,{variant:"caption",children:e.pickupcustomer}),(0,w.jsx)(q.A,{variant:"caption",children:e.pickupcontactno}),(0,w.jsx)(X.A,{title:e.pickupaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,w.jsx)(re.A,{align:"left",children:(0,w.jsx)(H.A,{direction:"row",spacing:1,children:(0,w.jsxs)(H.A,{direction:"column",children:[(0,w.jsx)(q.A,{variant:"caption",children:e.deliverycustomer}),(0,w.jsx)(q.A,{variant:"caption",children:e.deliverycontactno}),(0,w.jsx)(X.A,{title:e.deliveryaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,w.jsx)(re.A,{align:"left",children:e.ordernotes}),(0,w.jsxs)(re.A,{align:"left",children:["\u20b9 ",e.deliverycharge.toFixed(2)]}),(0,w.jsx)(re.A,{align:"left",children:e.kms})]})},r)))})]})})})}),(0,w.jsx)(le.A,{sx:{bgcolor:e.palette.secondary.light},children:(0,w.jsx)(_.Ay,{container:!0,sx:{},children:(0,w.jsx)(_.Ay,{item:!0,xs:12,children:(0,w.jsxs)(H.A,{sx:{mt:2,mr:2},direction:"row",justifyContent:"flex-end",flexWrap:"wrap",gap:2,spacing:5,children:[(0,w.jsx)(ae.A,{sx:{width:"130px"},color:"secondary",variant:"contained",onClick:()=>{Zo()},startIcon:(0,w.jsx)(A.A,{}),children:"Close"}),1==ro.current&&(0,w.jsx)(U.A,{options:[{label:"Bike",value:1},{label:"Auto",value:2}],getOptionLabel:e=>e.label,value:no,onChange:(e,r)=>{to(r),console.log("Selected value:",null===r||void 0===r?void 0:r.value)},renderInput:e=>(0,w.jsx)(Z.A,(0,n.A)((0,n.A)({sx:{width:200,border:"1px solid ",borderColor:"primary.main"}},e),{},{placeholder:"Select Transport"})),isOptionEqualToValue:(e,r)=>e.value===r.value}),1==ro.current&&(0,w.jsx)(U.A,{multiple:!0,fullWidth:!1,options:ko||[],loading:wo,disableCloseOnSelect:!0,limitTags:2,value:io,onChange:(e,r)=>so(r),getOptionLabel:e=>"".concat(e.firstname||""," ").concat(e.lastname||"").trim()||"Rider #".concat(e.userid),isOptionEqualToValue:(e,r)=>e.userid===r.userid,PaperComponent:e=>(0,w.jsx)(R.A,(0,n.A)((0,n.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,w.jsxs)(H.A,{alignItems:"center",py:2,spacing:1,children:[(0,w.jsx)(v.vbW,{size:26,color:"#94a3b8"}),(0,w.jsx)(q.A,{variant:"caption",color:"text.secondary",children:"No riders to show for this location"})]}),renderTags:(e,r)=>e.map(((e,o)=>{const i="".concat(e.firstname||""," ").concat(e.lastname||"").trim()||"Rider #".concat(e.userid),s=(i.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()||"?",l=r({index:o});return(0,t.createElement)(ie.A,(0,n.A)((0,n.A)({},l),{},{key:e.userid,size:"small",avatar:(0,w.jsx)(O.A,{sx:{bgcolor:"#fed7aa",color:"#9a3412",fontSize:10,fontWeight:800},children:s}),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,o)=>{let{selected:i}=o;const s="".concat(r.firstname||""," ").concat(r.lastname||"").trim(),l=(s.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()||"?";return(0,t.createElement)("li",(0,n.A)((0,n.A)({},e),{},{key:r.userid,style:{display:"flex",alignItems:"center",gap:12,padding:"8px 12px",borderBottom:"1px solid #f1f5f9",backgroundColor:i?"#fff7ed":"transparent"}}),(0,w.jsx)(V.A,{size:"small",checked:i,sx:{p:.5,color:"#fb923c","&.Mui-checked":{color:"#ea580c"}}}),(0,w.jsx)(O.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:l}),(0,w.jsxs)(H.A,{direction:"column",spacing:0,flex:1,minWidth:0,children:[(0,w.jsx)(q.A,{variant:"body2",fontWeight:700,color:"#0f172a",noWrap:!0,children:s||"Rider #".concat(r.userid)}),(0,w.jsxs)(q.A,{variant:"caption",color:"text.secondary",noWrap:!0,children:["ID #",r.userid,r.contactno?" \xb7 ".concat(r.contactno):""]})]}),i&&(0,w.jsx)(ie.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,w.jsx)(Z.A,(0,n.A)((0,n.A)({},e),{},{label:"Absent Riders",placeholder:io.length?"":"Pick riders unavailable today",InputLabelProps:{shrink:!0},InputProps:(0,n.A)((0,n.A)({},e.InputProps),{},{startAdornment:(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25},children:[(0,w.jsx)(v.ihY,{size:18,color:"#ea580c"}),io.length>0&&(0,w.jsx)(ie.A,{size:"small",label:io.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,w.jsx)(ae.A,{color:"primary",disabled:!no&&1==ro.current,variant:"contained",startIcon:1==ro.current&&(0,w.jsx)("img",{src:z,alt:"Assign",style:{width:32,height:32,objectFit:"contain",borderRadius:50}}),onClick:()=>{Wr(!0),Bo()},children:qe?"Optimising...":0==ro.current?"Optimise Orders":"AI Optimise Orders"})]})})})})]}),(0,w.jsxs)(ne.A,{fullScreen:!0,open:Lr,TransitionComponent:g.s,children:[(0,w.jsx)(te.A,{children:(0,w.jsx)(H.A,{children:(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:1,sx:{ml:1},children:[(0,w.jsx)(X.A,{title:"Back to orders",placement:"top",children:(0,w.jsx)(G.A,{onClick:()=>Er(!1),sx:{backgroundColor:"action.hover",color:"text.primary","&:hover":{backgroundColor:"action.selected"}},children:(0,w.jsx)(M.eQE,{size:22})})}),(0,w.jsx)(q.A,{sx:{m:2},variant:"h3",children:"Assign Orders"})]})})}),(0,w.jsx)(ce.A,{}),(0,w.jsx)(se.A,{children:(0,w.jsxs)(S.A,{content:!1,children:[(yo||wo||Dr)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(j.A,{}),(0,w.jsx)(m.A,{})]}),(0,w.jsx)(F.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:yo||wo||Dr,children:(0,w.jsx)(m.A,{color:"inherit"})}),(0,w.jsx)(Q.A,{children:(0,w.jsxs)(J.A,{stickyHeader:!0,children:[(0,w.jsx)($.A,{children:(0,w.jsxs)(ee.A,{sx:{backgroundColor:"red"},children:[(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"#"}),1==Vr&&(0,w.jsxs)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Zone"," "]}),(0,w.jsxs)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Tenant"," "]}),(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"order Location"}),(0,w.jsxs)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Pickup"," "]}),(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Delivery"}),(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Notes"}),1==Vr&&(0,w.jsx)(re.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Rider"}),(0,w.jsx)(re.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Type"}),(0,w.jsx)(re.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Charges"}),(0,w.jsx)(re.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"KMS"})]})}),(0,w.jsxs)(oe.A,{children:[0==(null===$r||void 0===$r?void 0:$r.length)&&(0,w.jsx)(ee.A,{children:(0,w.jsx)(re.A,{colSpan:10,children:(0,w.jsx)(a.A,{})})}),null===$r||void 0===$r?void 0:$r.map(((e,r)=>(0,w.jsxs)(ee.A,{sx:{},children:[(0,w.jsx)(re.A,{children:(0,w.jsxs)(q.A,{children:[" ",r+1]})}),(0,w.jsx)(re.A,{children:(0,w.jsxs)(X.A,{title:e.tenantaddress,children:[(0,w.jsx)(q.A,{variant:"body1",noWrap:!0,children:e.tenantname}),(0,w.jsxs)(q.A,{noWrap:!0,sx:{fontSize:"11px"},children:[e.tenantsuburb,(0,w.jsx)("br",{})]}),(0,w.jsx)(q.A,{noWrap:!0,variant:"body2",children:e.applocation})]})}),(0,w.jsxs)(re.A,{align:"left",children:[(0,w.jsx)(X.A,{title:e.locationaddress,placement:"top",children:(0,w.jsx)(q.A,{variant:"body1",noWrap:!0,children:"".concat(e.locationname,"-(").concat(e.locationsuburb,")")})}),(0,w.jsx)(X.A,{title:"Order Id",children:(0,w.jsx)(q.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,w.jsxs)(H.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,w.jsxs)(X.A,{title:"Ordered date",children:[(0,w.jsx)(q.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.orderdate).utc().format("DD/MM/YYYY")}),(0,w.jsx)(q.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.orderdate).utc().format("hh:mm A")})]}),"-",(0,w.jsxs)(X.A,{title:"Delivery date",children:[(0,w.jsx)(q.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.deliverydate).utc().format("DD/MM/YYYY")}),(0,w.jsx)(q.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.deliverydate).utc().format("hh:mm A")})]})]})]}),(0,w.jsx)(re.A,{align:"left",children:(0,w.jsx)(H.A,{direction:"row",spacing:1,children:(0,w.jsxs)(H.A,{direction:"column",children:[(0,w.jsx)(q.A,{variant:"caption",children:e.pickupcustomer}),(0,w.jsx)(q.A,{variant:"caption",children:e.pickupcontactno}),(0,w.jsx)(X.A,{title:e.pickupaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,w.jsx)(re.A,{align:"left",children:(0,w.jsx)(H.A,{direction:"row",spacing:1,children:(0,w.jsxs)(H.A,{direction:"column",children:[(0,w.jsx)(q.A,{variant:"caption",children:e.deliverycustomer}),(0,w.jsx)(q.A,{variant:"caption",children:e.deliverycontactno}),(0,w.jsx)(X.A,{title:e.deliveryaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,w.jsx)(re.A,{align:"left",children:e.ordernotes}),(0,w.jsx)(re.A,{align:"center",children:(0,w.jsx)(ie.A,{size:"small",label:e.ordertype,color:"Economy"==e.ordertype?"success":"Risky"==e.ordertype?"error":"primary",variant:"light"})}),(0,w.jsx)(re.A,{align:"center",children:(0,w.jsxs)(H.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,w.jsx)(X.A,{title:"Charges",placement:"top",children:(0,w.jsx)(ie.A,{size:"small",label:"\u20b9 ".concat(e.deliverycharge.toFixed(2)," "),color:"error",variant:"light"})}),(0,w.jsx)(X.A,{title:"Amount",placement:"left",children:(0,w.jsx)(ie.A,{size:"small",label:"\u20b9 ".concat(e.deliveryamt.toFixed(2)," "),color:"success",variant:"light"})})]})}),(0,w.jsx)(re.A,{align:"center",children:(0,w.jsxs)(H.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,w.jsx)(X.A,{title:"KMS",placement:"top",children:(0,w.jsx)(ie.A,{size:"small",label:"".concat(e.kms," km"),color:"error",variant:"light"})}),(0,w.jsx)(X.A,{title:"Cumulative Kms",placement:"right",children:(0,w.jsx)(ie.A,{size:"small",label:"".concat(e.cumulativekms," km"),color:"success",variant:"light"})})]})})]},r)))]})]})}),(0,w.jsx)(ce.A,{})]})}),(0,w.jsx)(ce.A,{}),(0,w.jsxs)(le.A,{sx:{flexDirection:"column",alignItems:"stretch",p:2,gap:2},children:[(0,w.jsxs)(_.Ay,{container:!0,spacing:2,children:[(0,w.jsx)(_.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsx)(U.A,{options:vo,fullWidth:!0,renderInput:e=>(0,w.jsx)(Z.A,(0,n.A)((0,n.A)({},e),{},{label:"Choose Payment"})),onChange:(e,r,o)=>{if("clear"!==o){if(r){xr(r);const e=null===$r||void 0===$r?void 0:$r.map((e=>(0,n.A)((0,n.A)({},e),{},{paymenttype:r.apptypeid||42})));eo(e)}}else xr(null)}})}),(0,w.jsx)(_.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsx)(U.A,{options:ko,fullWidth:!0,renderInput:e=>(0,w.jsx)(Z.A,(0,n.A)((0,n.A)({},e),{},{label:"Choose Rider"})),onChange:(e,r,o)=>{if("clear"!==o){if(r){cr(r);const e=null===$r||void 0===$r?void 0:$r.map((e=>(0,n.A)((0,n.A)({},e),{},{userid:r.userid,fuelcharge:r.fuelcharge||0,userfcmtoken:r.userfcmtoken})));eo(e)}}else cr(null)}})})]}),(0,w.jsxs)(H.A,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{pt:1,my:2},children:[(0,w.jsx)(ae.A,{variant:"outlined",color:"secondary",startIcon:(0,w.jsx)(I.A,{}),onClick:()=>Er(!1),children:"Back"}),(0,w.jsx)(ae.A,{variant:"contained",disabled:!ar||!dr,onClick:()=>{null!==$r&&void 0!==$r&&$r.length?Ho.mutate({deliveries:$r}):(0,C.k)("No deliveries selected","error",3e3)},children:"Assign Orders"})]})]})]}),(0,w.jsxs)(ne.A,{open:Fr,fullScreen:!0,TransitionComponent:g.s,PaperProps:{sx:{display:"flex",flexDirection:"column",overflow:"hidden"}},children:[(0,w.jsx)(F.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:Dr,children:(0,w.jsx)(m.A,{color:"inherit"})}),(0,w.jsx)(te.A,{sx:{py:1.25},children:(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{},children:[(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,w.jsx)(X.A,{title:"Back to orders",placement:"top",children:(0,w.jsx)(G.A,{onClick:()=>o("/nearle/orders"),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},children:(0,w.jsx)(M.eQE,{size:20})})}),(0,w.jsx)(q.A,{variant:"h3",fontWeight:600,children:"Assign Orders"})]}),(0,w.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,w.jsx)(U.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,w.jsx)(Z.A,(0,n.A)((0,n.A)({},e),{},{label:"Hyper Tuning"})),onChange:(e,r,o)=>{"clear"===o?Bo(null):(console.log("val",r),Bo(r.value))}}),(0,w.jsx)(ae.A,{variant:"contained",color:"primary",startIcon:(0,w.jsx)(Y.UF6,{}),onClick:()=>{zr(!0),Bo("reshuffle")},children:"Re-Assign"}),(0,w.jsx)(ue.Ay,{data:Gr,filename:"Orders_Detail_".concat(d()().format("YYYY-MM-DD_HHmmss"),".csv"),label:" CSV",style:{m:1}})]})]})}),(0,w.jsx)(se.A,{sx:{p:0,display:"flex",flexDirection:"column",overflow:"hidden",flex:1},children:Nr&&(0,w.jsx)(Ae.default,{data:Nr,embedded:!0})}),(0,w.jsx)(le.A,{sx:{px:2,py:1.25},children:(0,w.jsxs)(H.A,{direction:"row",gap:2,alignItems:"center",justifyContent:"end",children:[(0,w.jsx)(ae.A,{variant:"contained",color:"secondary",startIcon:(0,w.jsx)(I.A,{}),onClick:()=>{Tr(!1)},children:"Back"}),(0,w.jsx)(ae.A,{variant:"contained",onClick:async()=>{zr(!0),Uo.mutate({deliveries:$r})},children:"Assign Orders"})]})})]}),(0,w.jsx)(ne.A,{open:or,onClose:()=>handleClose(),maxWidth:"xs",children:(0,w.jsx)(se.A,{sx:{mt:2,my:1},children:(0,w.jsxs)(H.A,{alignItems:"center",spacing:3.5,children:[(0,w.jsx)(O.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,w.jsx)(l.A,{})}),(0,w.jsx)(H.A,{spacing:2,children:(0,w.jsx)(q.A,{variant:"h4",align:"center",children:"Are you sure you want to cancel this order?"})}),(0,w.jsxs)(H.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,w.jsx)(ae.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{qo.mutate(hr)},autoFocus:!0,children:"Yes, Cancel"}),(0,w.jsx)(ae.A,{fullWidth:!0,onClick:()=>{nr(!1)},color:"secondary",variant:"outlined",children:"No"})]})]})})}),(0,w.jsx)(ne.A,{open:sr,onClose:()=>lr(!1),maxWidth:"xs",children:(0,w.jsx)(se.A,{sx:{mt:2,my:1},children:(0,w.jsxs)(H.A,{alignItems:"center",spacing:3.5,children:[(0,w.jsx)(O.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,w.jsx)(l.A,{})}),(0,w.jsx)(H.A,{spacing:2,children:(0,w.jsx)(q.A,{variant:"h4",align:"center",children:"Are you sure, you want to cancel multiple orders?"})}),(0,w.jsxs)(H.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,w.jsx)(ae.A,{fullWidth:!0,onClick:()=>{lr(!1)},color:"secondary",variant:"outlined",children:"No"}),(0,w.jsx)(ae.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{Ko.mutate(qr)},autoFocus:!0,children:"Yes, Cancel"})]})]})})})]})}},23787:(e,r,o)=>{o.d(r,{FG:()=>p,nV:()=>x,pY:()=>u,pg:()=>h});var n=o(89379),t=o(80045),i=o(93230),s=o(2235),l=o(16491),a=o(82053),c=o(44414);const d=["children","scroll","onScroll","sx"],x=e=>{let{children:r,scroll:o=!1,onScroll:s,sx:l}=e,a=(0,t.A)(e,d);return(0,c.jsx)(i.A,(0,n.A)((0,n.A)({spacing:1.25,onScroll:s,sx:(0,n.A)((0,n.A)({p:1.5},o&&{maxHeight:"calc(100vh - 220px)",overflowY:"auto",overflowX:"hidden"}),l)},a),{},{children:r}))},h=e=>{let{accent:r="#662582",header:o,footer:t,selected:i=!1,onClick:a,children:d,sx:x}=e;return(0,c.jsxs)(s.A,{elevation:0,onClick:a,sx:(0,n.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)(l.A,{sx:{position:"absolute",left:0,top:0,bottom:0,width:3,bgcolor:r}}),(0,c.jsxs)(l.A,{sx:{p:1.5,pl:2},children:[o,d,t]})]})},p=e=>{let{children:r,columns:o=2,sx:t}=e;return(0,c.jsx)(l.A,{sx:(0,n.A)({display:"grid",gridTemplateColumns:"repeat(".concat(o,", minmax(0, 1fr))"),gap:1,mt:1.25},t),children:r})},u=e=>{let{label:r,value:o,children:n,full:t=!1,align:i="left"}=e;return(0,c.jsxs)(l.A,{sx:{gridColumn:t?"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)(l.A,{sx:{mt:.25,minWidth:0},children:void 0!==n?n:(0,c.jsx)(a.A,{sx:{fontSize:13,fontWeight:600,color:"#0f172a"},noWrap:!0,children:null!==o&&void 0!==o?o:"\u2014"})})]})}},35678:(e,r,o)=>{o.d(r,{A:()=>v});var n=o(9950),t=o(96583),i=o(40033),s=o(82053),l=o(28170),a=o(93230),c=o(82223),d=o(55916),x=o(4159),h=o.n(x),p=o(56712),u=o(81417),A=o(96600),g=o(53132),m=o(94289),j=o(57326),f=o(50624),b=o(44414);const v=e=>{let{open:r,onClose:o,onSelect:x}=e;const[v,y]=(0,n.useState)(null);return(0,b.jsxs)(t.A,{open:r,onClose:o,children:[(0,b.jsx)(i.A,{align:"left",children:(0,b.jsx)(s.A,{variant:"h4",children:"Select Filter Options"})}),(0,b.jsx)(l.A,{sx:{width:"100%"},className:"datedialog",children:(0,b.jsx)(d.U,{open:r,toggle:o,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,p.A)(new Date,-1),endDate:(0,p.A)(new Date,-1)},{label:"Tomorrow",startDate:(0,p.A)(new Date,1),endDate:(0,p.A)(new Date,1)},{label:"This Week",startDate:(0,u.A)(new Date),endDate:(0,A.A)(new Date)},{label:"Last Week",startDate:(0,u.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,m.A)(new Date),endDate:(0,j.A)(new Date)},{label:"Last Month",startDate:(0,m.A)((0,f.A)(new Date,-1)),endDate:(0,j.A)((0,f.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),o()):o()},children:"OK"})})]})}},47659:(e,r,o)=>{o.d(r,{A:()=>d});var n=o(89379),t=o(48089),i=o(50704),s=o(16491),l=o(82053),a=o(60899),c=o(44414);const d=e=>{let{primary:r,secondary:o,percentage:d,color:x,sx:h}=e;return(0,c.jsx)(t.A,{elevation:0,sx:(0,n.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)(s.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)(l.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)(l.A,{variant:"h3",color:"inherit",sx:{fontSize:{xs:16,md:20}},children:o})}),(0,c.jsx)(a.Ay,{item:!0,xs:12,children:(0,c.jsx)(l.A,{variant:"subtitle2",color:"inherit",children:r})})]})]})})}},56311:(e,r,o)=>{o.d(r,{A:()=>p});var n=o(89379),t=o(9950),i=o(2660),s=o(2046),l=o(83274),a=o(25333),c=o(97125),d=o(7762),x=o(52097),h=o(44414);const p=e=>{let{value:r,onChange:o,onDebouncedChange:p,debounceTime:u=500,placeholder:A="Search (ctrl+k)",sx:g}=e;const m=(0,t.useRef)(null),[j]=(0,x.d7)(r,u);return(0,t.useEffect)((()=>{p&&p(j)}),[j,p]),(0,t.useEffect)((()=>{const e=e=>{var r;"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),null===(r=m.current)||void 0===r||r.focus());"Escape"===e.key&&document.activeElement===m.current&&m.current.blur()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[]),(0,h.jsx)(i.A,{sx:(0,n.A)({},g),inputRef:m,placeholder:A,autoComplete:"off",value:r,fullWidth:!0,onChange:e=>o(e.target.value),startAdornment:(0,h.jsx)(s.A,{position:"start",sx:{mr:-.5},children:(0,h.jsx)(c.A,{})}),endAdornment:(0,h.jsx)(l.A,{title:"Clear",children:(0,h.jsx)(a.A,{sx:{visibility:r?"visible":"hidden"},onClick:()=>o(""),children:(0,h.jsx)(d.A,{})})})})}},58691:(e,r,o)=>{o.d(r,{A:()=>l});o(9950);var n=o(16491),t=o(46639),i=o(62217),s=o(44414);function l(e){let{size:r=70,imgSize:o=40,alt:l="loader"}=e;return(0,s.jsxs)(n.A,{position:"relative",display:"inline-flex",justifyContent:"center",alignItems:"center",children:[(0,s.jsx)(t.A,{size:r}),(0,s.jsx)(n.A,{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",sx:{width:o,height:o},children:(0,s.jsx)("img",{src:i,alt:l,style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"contain"}})})]})}},59212:(e,r,o)=>{o.d(r,{A:()=>h});var n=o(89379),t=o(9950),i=o(93230),s=o(41413),l=o(77922),a=o(29925),c=o(26910),d=o(31222),x=o(44414);const h=(0,t.forwardRef)(((e,r)=>{let{setAppId:o,setLocoName:h,setPage:p,sx:u,textfeildSx:A,textfieldSx:g,pill:m=!1,accentColor:j="#6366f1",icon:f,placeholder:b="Select Zone",paperComponent:v}=e;const[y,k]=(0,t.useState)(JSON.parse(localStorage.getItem("applocations")||"[]"));(0,t.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 w=e=>"".concat(j).concat(e),S=w("08"),C=w("26"),W=w("55"),D=w("18"),z=m?{cursor:"pointer","& .MuiOutlinedInput-root":{borderRadius:"999px",bgcolor:S,fontWeight:600,color:"#0f172a",paddingRight:"8px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s, background-color 0.2s","& fieldset":{borderColor:W,borderWidth:1.5},"&:hover fieldset":{borderColor:j},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(C)},"&.Mui-focused fieldset":{borderColor:j,borderWidth:2}},"& .MuiAutocomplete-endAdornment .MuiSvgIcon-root":{color:j}}:{},I=m&&(0,x.jsx)(i.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25,flexShrink:0},children:(0,x.jsx)(s.A,{sx:{width:24,height:24,bgcolor:D,color:j,transition:"background-color 0.15s, color 0.15s"},children:f||(0,x.jsx)(d.HPi,{size:14})})});return(0,x.jsx)(l.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,n.A)({},u),onChange:(e,r,n)=>{"clear"===n?(null===o||void 0===o||o(0),null===h||void 0===h||h(""),null===p||void 0===p||p(0)):r&&(null===o||void 0===o||o(r.applocationid),null===h||void 0===h||h(r.locationname),null===p||void 0===p||p(0))},renderInput:e=>m?(0,x.jsx)(a.A,(0,n.A)((0,n.A)({},e),{},{inputRef:r,placeholder:b,InputProps:(0,n.A)((0,n.A)({},e.InputProps),{},{startAdornment:I}),sx:(0,n.A)((0,n.A)({},z),g||A||{})})):(0,x.jsx)(a.A,(0,n.A)((0,n.A)({},e),{},{inputRef:r,label:"Select Zones",sx:(0,n.A)({},g||A||{})}))})}))},96646:(e,r,o)=>{o.d(r,{r:()=>a});var n=o(9213),t=o(21671),i=o(82917),s=o(93230),l=o(44414);const a=e=>{let{rowsPerPage:r=5,col:o=1}=e;return(0,l.jsx)(l.Fragment,{children:Array.from(new Array(r)).map(((e,r)=>(0,l.jsxs)(n.A,{children:[(0,l.jsx)(t.A,{children:(0,l.jsx)(i.A,{variant:"circular",width:24,height:24})}),(0,l.jsx)(t.A,{children:(0,l.jsx)(i.A,{variant:"text",width:30})}),Array.from({length:o}).map(((e,r)=>(0,l.jsx)(t.A,{children:(0,l.jsxs)(s.A,{spacing:.5,children:[(0,l.jsx)(i.A,{variant:"text",width:100}),(0,l.jsx)(i.A,{variant:"text",width:80})]})},r))),(0,l.jsx)(t.A,{children:(0,l.jsx)(i.A,{variant:"text",width:150})}),(0,l.jsx)(t.A,{children:(0,l.jsx)(i.A,{variant:"rounded",width:60,height:24})}),(0,l.jsx)(t.A,{align:"center",children:(0,l.jsxs)(s.A,{direction:"row",spacing:1,justifyContent:"flex-end",children:[(0,l.jsx)(i.A,{variant:"circular",width:28,height:28}),(0,l.jsx)(i.A,{variant:"circular",width:28,height:28})]})})]},r)))})}}}]); |