Files
Express_console_build/build/static/js/4947.3f1a9374.chunk.js

1 line
54 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:()=>Te});var o=t(89379),n=t(9950),i=t(47965),s=t(44070),l=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),m=t(94826),j=t(52351),f=t(67562),b=t(49883),v=t(31222),y=t(35678),k=t(56311),w=t(44414);var S=t(50027),C=t(20466),D=t(96646),I=t(59212);const W=t.p+"static/media/aiImage.89c2ccb91a41d85031e3.png";var z=t(63189),M=t(99324),R=t(6604),O=t(2235),Y=t(41413),P=t(55158),F=t(59382),T=t(28810),L=t(79046),E=t(33092),N=t(93230),q=t(82053),H=t(16491),K=t(60899),_=t(82917),B=t(77922),U=t(29925),Z=t(83274),X=t(1320),Q=t(15769),J=t(69780),V=t(9213),G=t(21671),$=t(93038),ee=t(34075),re=t(25333),te=t(96583),oe=t(40033),ne=t(25277),ie=t(28170),se=t(79739),le=t(82223),ae=t(74745),ce=t(81425),de=t(58691),xe=t(28429),he=t(90376),ue=t(54413),pe=t(36220);d().extend(pe);const Ae=999,ge=16,me="0 14px 40px rgba(15, 23, 42, 0.10)",je="0 8px 24px rgba(15, 23, 42, 0.08)",fe="0 18px 50px rgba(15, 23, 42, 0.18)",be="#0f172a",ve="#64748b",ye="#94a3b8",ke="#e2e8f0",we="#f1f5f9",Se="#f8fafc",Ce=(e,r)=>"".concat(e).concat(r),De=e=>Ce(e,"08"),Ie=e=>Ce(e,"18"),We=e=>Ce(e,"26"),ze=e=>Ce(e,"55"),Me="#662582",Re=e=>(0,w.jsx)(O.A,(0,o.A)((0,o.A)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:fe,border:"1px solid",borderColor:"divider",overflow:"hidden"}})),Oe=e=>{let{color:r,selected:t,size:o=24,children:n}=e;return(0,w.jsx)(Y.A,{sx:{width:o,height:o,bgcolor:t?r:Ie(r),color:t?"#fff":r,transition:"background-color 0.15s, color 0.15s"},children:n})},Ye=e=>({"& .MuiOutlinedInput-root":{borderRadius:Ae+"px",bgcolor:De(e),fontWeight:600,"& fieldset":{borderColor:ze(e),borderWidth:1.5},"&:hover fieldset":{borderColor:e},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(We(e))},"&.Mui-focused fieldset":{borderColor:e,borderWidth:2}}}),Pe={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}},Fe=[{idx:0,status:"created",label:"Created",color:Me,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"}],Te=()=>{const e=(0,p.A)(),r=(0,xe.Zp)(),t=(0,n.useRef)(),c=(0,n.useRef)(),pe=(0,n.useRef)(null),Ae=(0,n.useRef)(null),[fe,Ce]=(0,n.useState)(0),[Te,Le]=(0,n.useState)("All"),[Ee,Ne]=(0,n.useState)(!1),[qe,He]=(0,n.useState)(d()().format("YYYY-MM-DD")),[Ke,_e]=(0,n.useState)(d()().format("YYYY-MM-DD")),[Be,Ue]=(0,n.useState)("Today"),[Ze,Xe]=(0,n.useState)(!1),[Qe,Je]=(0,n.useState)(0),[Ve,Ge]=(0,n.useState)("created"),[$e,er]=(0,n.useState)(!1),[rr,tr]=(0,n.useState)(!1),[or,nr]=(0,n.useState)(!1),[ir,sr]=(0,n.useState)(null),[lr,ar]=(0,n.useState)(null),[cr,dr]=(0,n.useState)(""),[xr,hr]=(0,n.useState)(0),[ur,pr]=(0,n.useState)(null),[Ar,gr]=(0,n.useState)(0),[mr,jr]=(0,n.useState)(0),[fr,br]=(0,n.useState)(""),[vr,yr]=(0,n.useState)(""),[kr,wr]=(0,n.useState)(!1),[Sr,Cr]=(0,n.useState)(!1),[Dr,Ir]=(0,n.useState)(null),[Wr,zr]=(0,n.useState)(null),[Mr,Rr]=(0,n.useState)(!1),[Or,Yr]=(0,n.useState)(!1),[Pr,Fr]=(0,n.useState)(!1),[Tr,Lr]=(0,n.useState)(null),[Er,Nr]=(0,n.useState)([]),[qr,Hr]=(0,n.useState)([]),[Kr,_r]=(0,n.useState)(null),[Br,Ur]=(0,n.useState)(null),[Zr]=(0,n.useState)(0),[Xr,Qr]=(0,n.useState)([]),[Jr,Vr]=(0,n.useState)([]),Gr=(0,n.useRef)(0),$r=(0,n.useRef)(null),[et,rt]=(0,n.useState)(null),[tt,ot]=(0,n.useState)([]);(0,n.useEffect)((()=>{gr(0),Ir(null),jr(0),zr(null)}),[fe]),(0,n.useEffect)((()=>{jr(0),zr(null)}),[Ar]),(0,n.useEffect)((()=>{const e=Jr.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})));Qr(e),console.log("csvExportData",e)}),[Jr]),(0,n.useEffect)((()=>{if(null===qr||void 0===qr||!qr.length)return;const e=qr.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})}));Vr(e),console.log("finaldeliveryList",e)}),[qr]);const{data:nt,isLoading:it,isError:st,error:lt,refetch:at}=(0,x.I)({queryKey:["percentageData",fe],queryFn:()=>(0,ce.jy)(fe),enabled:!0}),{data:ct,isLoading:dt,isError:xt,error:ht}=(0,x.I)({queryKey:["tenantlist",fe],queryFn:()=>(0,ce.Mn)(fe),enabled:0!==fe}),{data:ut,isLoading:pt,isError:At,error:gt}=(0,x.I)({queryKey:["gettenantlocations",Ar],queryFn:()=>(0,ce.DL)(Ar),enabled:0!==Ar}),{data:mt=[],isLoading:jt}=(0,x.I)({queryKey:["paymentmodes"],queryFn:ce.HY}),{data:ft=[],isLoading:bt}=(0,x.I)({queryKey:["ridersList",fe],queryFn:ce.Sd,enabled:0!==fe}),{data:vt,isLoading:yt,isError:kt,error:wt,refetch:St}=(0,x.I)({queryKey:["ordersCount",fe,qe,Ke,Ve,Ar,mr],queryFn:ce.Hh,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:Ct}=(0,x.I)({queryKey:["getallriders"],queryFn:ce.Xw,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:Dt,isLoading:It,isError:Wt,error:zt,fetchNextPage:Mt,hasNextPage:Rt,isFetchingNextPage:Ot,refetch:Yt}=(0,h.q)({queryKey:["fetchOrders",fe,Ve,vr,qe,Ke,100,Ar,mr],queryFn:ce.nQ,getNextPageParam:e=>{var r;return null!==(r=e.nextPage)&&void 0!==r?r:void 0},refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,staleTime:0}),Pt=(null===Dt||void 0===Dt?void 0:Dt.pages.flatMap((e=>e.rows)))||[];(0,n.useEffect)((()=>{if(!Rt)return;const e=new IntersectionObserver((e=>{e[0].isIntersecting&&Mt()}),{root:document.querySelector(".MuiTableContainer-root"),rootMargin:"0px",threshold:1});return t.current&&e.observe(t.current),()=>{t.current&&e.unobserve(t.current)}}),[Rt,Mt]);const Ft=(0,u.n)({mutationFn:0==Gr.current?ce.FC:ce.Yk,onSuccess:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(console.log("data",e),console.log("varialbles",t),(0,C.k)("Orders Optimised Successfully","success",2e3),St(),Yt(),Ne(!1),wr(!1),0==Gr.current)Hr(null===e||void 0===e?void 0:e.details),_r(null===e||void 0===e?void 0:e.zones),Ur(null===e||void 0===e?void 0:e.meta),Fr(!0);else{var o,n,i;Hr(null===e||void 0===e?void 0:e.details),_r(null===e||void 0===e?void 0:e.zones),Ur(null===e||void 0===e?void 0:e.meta),Lr(e);const t=$r.current||{};r("/nearle/dispatch/preview",{state:{dispatchPreviewData:e,aiMode:null!==(o=t.aiMode)&&void 0!==o?o:Gr.current,selectedMode:t.selectedMode||et,deliveryData:t.deliveryData||[],autoRiders:t.autoRiders||Ct||[],absentRidersPayload:t.absentRidersPayload||[],rider:t.rider||ir,appId:null!==(n=t.appId)&&void 0!==n?n:fe,tenantId:null!==(i=t.tenantid)&&void 0!==i?i:Ar,startdate:qe}})}},onError:e=>{(0,C.k)(e.message,"error",4e3),wr(!1),Ne(!1)},onSettled:()=>{Kt(),Ne(!1),wr(!1),Cr(!1)}}),Tt=(0,u.n)({mutationFn:ce.H2,onMutate:()=>{Cr(!0)},onSuccess:e=>{console.log("create data",e),(0,C.k)("Delivery Created Successfully","success",2e3),r("/nearle/deliveries"),Nt.mutate(null===ir||void 0===ir?void 0:ir.userfcmtoken)},onError:e=>{(0,C.k)(e.message,"error",4e3)},onSettled:()=>{Cr(!1)}}),Lt=(0,u.n)({mutationFn:ce.N4,onSuccess:e=>{e.status&&(er(!1),(0,C.k)("Order Cancelled Successfully","success",2e3),St(),at())},onError:e=>{(0,C.k)(e.message,"error",2e3)}}),Et=(0,u.n)({mutationFn:ce.zR,onSuccess:e=>{e.status&&(nr(!1),(0,C.k)("Order Cancelled Successfully","success",2e3),Yt(),St(),at(),Nr([]))},onError:e=>{(0,C.k)(e.message,"error",2e3)}}),Nt=(0,u.n)({mutationFn:ce.k3,onSuccess:()=>{(0,C.k)("Notification sent Successfully","success",2e3)},onError:e=>{(0,C.k)(e.message,"error",2e3)}}),qt=async e=>{Cr(!0),Ne(!0);const r=Er.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=(tt||[]).map((e=>({userid:e.userid,username:"".concat(e.firstname||""," ").concat(e.lastname||"").trim()||e.username||"Rider ".concat(e.userid)})));$r.current={deliveryData:r,absentRidersPayload:t,autoRiders:Ct,selectedMode:et,aiMode:Gr.current,rider:ir,appId:fe,tenantid:Ar},0==Gr.current?Ft.mutate({deliveries:r}):et&&1==(null===et||void 0===et?void 0:et.value)?Ft.mutate({deliveries:1==et.value?r:{body:r},hypertuning_params:e||null,selectedMode:et,absent_riders:t}):Ft.mutate({data:{orders:r,riders:Ct,config:{pay_type:"hourly",base_pay:300,strategy:"multi_trip"},absent_riders:t},selectedMode:et})},Ht=(0,u.n)({mutationFn:ce.H2,onSuccess:(e,t)=>{console.log("data",e),console.log("varialbles",t),(0,C.k)("Delivery Created Successfully","success",2e3),Cr(!1),r("/nearle/deliveries")},onError:e=>{(0,C.k)(e.message,"error",4e3)},onSettled:()=>{Cr(!1)}}),Kt=()=>{tr(!1),sr(null),ar(null),rt(null),ot([])},_t=st?"Error fetching percentages: ".concat(null===lt||void 0===lt?void 0:lt.message):kt?"Error fetching orders Count: ".concat(null===wt||void 0===wt?void 0:wt.message):Wt?"Error fetching orders : ".concat(null===zt||void 0===zt?void 0:zt.message):xt?"Error Fetching on Tenants:".concat(null===ht||void 0===ht?void 0:ht.message," "):At?"Error Fetching on Tenants Locations:".concat(null===gt||void 0===gt?void 0:gt.message," "):null;return(0,n.useEffect)((()=>{_t&&(console.log(_t),(0,C.k)(_t,"error",3e3))}),[_t]),(0,w.jsxs)(n.Fragment,{children:[(it||yt||It||dt||pt||kr)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(j.A,{}),(0,w.jsx)(m.A,{})]}),(0,w.jsx)(P.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:kr||It,children:(0,w.jsx)(m.A,{color:"inherit"})}),(0,w.jsx)(P.A,{sx:{zIndex:1e3},open:Mr}),Er.length>0&&(0,w.jsxs)(F.A,{ariaLabel:"Actions",icon:(0,w.jsx)(T.A,{badgeContent:(null===Er||void 0===Er?void 0:Er.length)||"",color:"secondary",children:(0,w.jsx)(L.A,{})}),open:Mr,onOpen:()=>Rr(!0),onClose:()=>Rr(!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)(E.A,{icon:(0,w.jsx)("img",{src:W,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:()=>{Gr.current=1,Rr(!1),tr(!0)}}),(0,w.jsx)(E.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:()=>{Gr.current=0,Rr(!1),tr(!0)}}),(0,w.jsx)(E.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:()=>{Rr(!1),nr(!0)}})]}),(0,w.jsx)(O.A,{elevation:0,sx:{mb:{xs:1.5,md:2},p:{xs:1.5,sm:2,md:2.5},borderRadius:ge/8,border:"1px solid",borderColor:ke,background:"linear-gradient(135deg, ".concat(De(Me)," 0%, ").concat(De("#9255AB")," 100%)"),boxShadow:je},children:(0,w.jsxs)(N.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)(N.A,{direction:"row",alignItems:"center",spacing:{xs:1.25,sm:1.75},children:[(0,w.jsx)(Y.A,{sx:{width:{xs:40,sm:48},height:{xs:40,sm:48},bgcolor:Me,color:"#fff",boxShadow:"0 6px 18px ".concat(We(Me))},children:(0,w.jsx)(v.F6S,{size:22})}),(0,w.jsxs)(N.A,{children:[(0,w.jsx)(q.A,{variant:"h3",sx:{fontWeight:800,color:be,lineHeight:1.1,fontSize:{xs:"1.25rem",sm:"1.5rem",md:"1.75rem"}},children:"Orders"}),(0,w.jsxs)(N.A,{direction:"row",alignItems:"center",spacing:.75,sx:{mt:.5},children:[(0,w.jsx)(H.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:ve,fontWeight:600},children:["Live \xb7 ",Te||"All Zones"," \xb7 ",Be]})]})]})]}),(0,w.jsx)(I.A,{ref:pe,locaName:Te,setAppId:Ce,setLocoName:Le,setPage:hr,pill:!0,accentColor:Me,icon:(0,w.jsx)(v.HPi,{size:14}),placeholder:"Select Zone",paperComponent:Re,sx:{width:{xs:"100%",sm:280},zIndex:100}})]})}),(0,w.jsx)(K.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===nt||void 0===nt?void 0:nt.created,percentage:null===nt||void 0===nt?void 0:nt.percentage1},{key:"pending",label:"Pending Orders",color:"#f59e0b",icon:v.tX0,value:null===nt||void 0===nt?void 0:nt.uncoveredOrders,percentage:null===nt||void 0===nt?void 0:nt.percentage2},{key:"delivered",label:"Delivered Orders",color:"#10b981",icon:v.mU9,value:null===nt||void 0===nt?void 0:nt.coveredOrders,percentage:null===nt||void 0===nt?void 0:nt.percentage3},{key:"cancelled",label:"Cancelled Orders",color:"#ef4444",icon:v.uDv,value:null===nt||void 0===nt?void 0:nt.cancelled,percentage:null===nt||void 0===nt?void 0:nt.percentage4}].map((e=>{var r;const t=e.icon;return(0,w.jsx)(K.Ay,{item:!0,xs:6,sm:6,md:3,children:(0,w.jsxs)(O.A,{elevation:0,sx:{position:"relative",overflow:"hidden",p:{xs:1.25,sm:1.75,md:2.25},borderRadius:ge/8,border:"1px solid",borderColor:ke,background:"#fff",transition:"transform 0.2s, box-shadow 0.2s, border-color 0.2s","&:hover":{transform:"translateY(-3px)",boxShadow:je,borderColor:ze(e.color)}},children:[(0,w.jsx)(H.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)(N.A,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",spacing:1,children:[(0,w.jsxs)(N.A,{spacing:.5,sx:{minWidth:0,flex:1},children:[(0,w.jsx)(q.A,{variant:"caption",sx:{color:ve,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:be,lineHeight:1.1,fontSize:{xs:"1.25rem",sm:"1.5rem",md:"1.75rem"}},children:it?(0,w.jsx)(_.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:ve,fontWeight:700},children:[e.percentage,"%"]})]}),(0,w.jsx)(Y.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(ze(e.color)),flexShrink:0},children:(0,w.jsx)(t,{size:20})})]})]})},e.key)}))}),(0,w.jsxs)(O.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1.25,md:1.75},borderRadius:ge/8,border:"1px solid",borderColor:ke,background:"#fff",boxShadow:me},children:[(0,w.jsxs)(K.Ay,{container:!0,spacing:1.25,alignItems:"center",children:[(0,w.jsx)(K.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,w.jsx)(B.A,{options:ct||[],value:Dr,getOptionLabel:e=>(null===e||void 0===e?void 0:e.tenantname)||"",PaperComponent:Re,onOpen:e=>{fe||(e.preventDefault(),(0,C.k)("Please select location first!","warning",3e3),setTimeout((()=>{var e;null===(e=pe.current)||void 0===e||e.focus()}),0))},onChange:(e,r,t)=>{"clear"===t?(gr(0),Ir(null),jr(0),zr(null)):(gr((null===r||void 0===r?void 0:r.tenantid)||0),Ir(r),jr(0),zr(null))},renderInput:e=>(0,w.jsx)(U.A,(0,o.A)((0,o.A)({},e),{},{inputRef:Ae,placeholder:"Select Tenant",size:"small",sx:Ye("#0ea5e9"),InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:(0,w.jsx)(N.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:(0,w.jsx)(Oe,{color:"#0ea5e9",size:22,selected:!0,children:(0,w.jsx)(v.Itr,{size:13})})})})}))})}),(0,w.jsx)(K.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,w.jsx)(B.A,{options:ut||[],getOptionLabel:e=>e?"".concat(e.locationname," (").concat(e.suburb,")"):"",value:Wr,PaperComponent:Re,onOpen:e=>{fe||Ar?Ar||(e.preventDefault(),(0,C.k)("Please select Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=Ae.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=pe.current)||void 0===e||e.focus()}),0))},onChange:(e,r,t)=>{"clear"===t?(jr(0),zr(null)):(jr(r.locationid||0),zr(r))},renderInput:e=>(0,w.jsx)(U.A,(0,o.A)((0,o.A)({},e),{},{placeholder:"Select Location",size:"small",sx:Ye("#10b981"),InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:(0,w.jsx)(N.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:(0,w.jsx)(Oe,{color:"#10b981",size:22,selected:!0,children:(0,w.jsx)(v.JFD,{size:13})})})})}))})}),(0,w.jsx)(K.Ay,{item:!0,xs:12,sm:12,md:4,children:(0,w.jsxs)(N.A,{direction:"row",spacing:1,alignItems:"center",justifyContent:{xs:"flex-start",md:"flex-end"},flexWrap:"wrap",children:[(0,w.jsx)(Z.A,{title:"Date Filter",placement:"top",children:(0,w.jsxs)(H.A,{onClick:()=>Xe(!0),sx:{display:"inline-flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:999,cursor:"pointer",bgcolor:De("#f59e0b"),border:"1.5px solid ".concat(ze("#f59e0b")),color:"#f59e0b",fontWeight:800,fontSize:12,transition:"all 0.18s","&:hover":{borderColor:"#f59e0b",boxShadow:"0 0 0 3px ".concat(We("#f59e0b"))}},children:[(0,w.jsx)(v.Ki0,{size:14}),d()(qe).format("DD/MM/YY")," \u2013 ",d()(Ke).format("DD/MM/YY")]})}),(0,w.jsxs)(H.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.5,borderRadius:999,bgcolor:De(Me),border:"1px solid ".concat(ze(Me)),color:Me,fontSize:11,fontWeight:800},children:[(0,w.jsx)(v.GdF,{size:12})," ",Be]})]})})]}),(0,w.jsx)(y.A,{open:Ze,onClose:()=>Xe(!1),onSelect:e=>{He(e.startDate),_e(e.endDate),Ue(e.label),console.log("Selected Date Range:",e)}})]}),(0,w.jsx)(O.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1,md:1.5},borderTopLeftRadius:ge/8,borderTopRightRadius:ge/8,borderBottomLeftRadius:0,borderBottomRightRadius:0,border:"1px solid",borderColor:ke,borderBottom:0,background:"#fff"},children:(0,w.jsxs)(N.A,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{flexWrap:"wrap-reverse"},children:[(0,w.jsx)(N.A,{direction:"row",spacing:.75,sx:{flex:1,overflowX:"auto",py:.5,px:.25,"&::-webkit-scrollbar":{height:6},"&::-webkit-scrollbar-thumb":{backgroundColor:ke,borderRadius:4}},children:Fe.map((e=>{var r;const t=e.icon,o=Qe===e.idx,n=null!==(r=null===vt||void 0===vt?void 0:vt[e.countKey])&&void 0!==r?r:0;return(0,w.jsxs)(H.A,{onClick:r=>{return t=e.idx,hr(0),Je(t),0===t&&Ge("created"),1===t&&Ge("pending"),2===t&&Ge("delivered"),3===t&&Ge("cancelled"),void br("");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:999,border:"1.5px solid ".concat(o?e.color:ze(e.color)),bgcolor:o?e.color:De(e.color),color:o?"#fff":e.color,fontWeight:700,boxShadow:o?"0 6px 18px ".concat(We(e.color)):"none",transition:"all 0.18s","&:hover":{borderColor:e.color,boxShadow:o?"0 6px 18px ".concat(We(e.color)):"0 0 0 3px ".concat(We(e.color))}},children:[(0,w.jsx)(Y.A,{sx:{width:{xs:22,md:26},height:{xs:22,md:26},bgcolor:o?"rgba(255,255,255,0.22)":Ie(e.color),color:o?"#fff":e.color},children:(0,w.jsx)(t,{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)(H.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:o?"rgba(255,255,255,0.22)":"#fff",color:o?"#fff":e.color,border:o?"none":"1px solid ".concat(ze(e.color))},children:n})]},e.status)}))}),(0,w.jsx)(H.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:fr,onChange:br,onDebouncedChange:yr,placeholder:"Search orders (ctrl+k)",sx:{m:0,width:"100%",borderRadius:999,bgcolor:De(Me),"& fieldset":{borderColor:ze(Me),borderWidth:1.5},"&:hover fieldset":{borderColor:Me},"&.Mui-focused fieldset":{borderColor:Me,borderWidth:2},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(We(Me))}}})})]})}),(0,w.jsx)(O.A,{elevation:0,sx:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:ge/8,borderBottomRightRadius:ge/8,border:"1px solid",borderColor:ke,overflow:"hidden",background:"#fff"},children:(0,w.jsx)(X.A,{ref:c,onScroll:e=>{const{scrollTop:r,scrollHeight:t,clientHeight:o}=e.currentTarget;r+o>=t-50&&Rt&&!Ot&&Mt()},sx:{maxHeight:{xs:"calc(100vh - 220px)",md:"calc(100vh - 190px)"},overflow:"auto","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:ze(Me),borderRadius:8,"&:hover":{backgroundColor:Me}},"&::-webkit-scrollbar-track":{backgroundColor:Se}},children:(0,w.jsxs)(Q.A,{stickyHeader:!0,sx:{minWidth:{xs:960,md:1180}},children:[(0,w.jsx)(J.A,{children:(0,w.jsxs)(V.A,{sx:{"& th":{backgroundColor:Se,color:ve,fontSize:{xs:10,md:11},fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(ke),py:{xs:1,md:1.25},px:{xs:1,md:1.5}}},children:["created"==Ve&&(0,w.jsx)(G.A,{sx:{position:"sticky !important"},children:(0,w.jsx)($.A,{size:"small",sx:{p:.5,color:ze(Me),"&.Mui-checked, &.MuiCheckbox-indeterminate":{color:Me}},indeterminate:Er.length>0&&Er.length!==(null===Pt||void 0===Pt?void 0:Pt.length),checked:Er.length===(null===Pt||void 0===Pt?void 0:Pt.length),onChange:e=>{var r;if(!fe)return(0,C.k)("Please select a location first!","warning",2e3),void(null===(r=pe.current)||void 0===r||r.focus());if(e.target.checked){const e=null===Pt||void 0===Pt?void 0:Pt.map(((e,r)=>(0,o.A)((0,o.A)({},e),{},{sno:r+1})));Nr(e)}else Nr([])}})}),(0,w.jsx)(G.A,{children:"#"}),(0,w.jsx)(G.A,{children:"Tenant"}),(0,w.jsx)(G.A,{children:"Location"}),(0,w.jsx)(G.A,{children:"Pickup"}),(0,w.jsx)(G.A,{children:"Drop"}),(0,w.jsx)(G.A,{align:"center",children:"QTY"}),(0,w.jsx)(G.A,{align:"right",children:"COD"}),(0,w.jsx)(G.A,{align:"center",children:"KMS"}),(0,w.jsx)(G.A,{align:"right",children:"Charges"}),(0,w.jsx)(G.A,{children:"Notes"}),(0,w.jsx)(G.A,{children:"Status"}),"created"==Ve&&(0,w.jsx)(G.A,{align:"right",children:"Actions"})]})}),(0,w.jsxs)(ee.A,{children:[0===(null===Pt||void 0===Pt?void 0:Pt.length)&&!It&&(0,w.jsx)(V.A,{children:(0,w.jsx)(G.A,{colSpan:13,sx:{py:6},children:(0,w.jsxs)(N.A,{alignItems:"center",spacing:1.5,children:[(0,w.jsx)(Y.A,{sx:{width:64,height:64,bgcolor:Ie("#94a3b8"),color:ye},children:(0,w.jsx)(v.F6S,{size:28})}),(0,w.jsxs)(q.A,{variant:"subtitle1",sx:{fontWeight:700,color:be},children:["No ",Ve," orders"]}),(0,w.jsx)(q.A,{variant:"caption",sx:{color:ve},children:fr?"Try a different keyword.":"Adjust the filters above to load orders."})]})})}),It&&(0,w.jsx)(D.r,{col:8}),null===Pt||void 0===Pt?void 0:Pt.map(((r,t)=>{const n=!!Er.find((e=>e.orderheaderid===r.orderheaderid));return(0,w.jsxs)(V.A,{role:"checkbox",tabIndex:-1,sx:{cursor:"pointer",transition:"background-color 0.15s",backgroundColor:n?De(Me):"transparent","& td":{borderBottom:"1px solid ".concat(we),py:{xs:1,md:1.25},px:{xs:1,md:1.5}},"&:hover":{backgroundColor:n?Ie(Me)+" !important":Se}},children:["created"===Ve&&(0,w.jsx)(G.A,{children:(0,w.jsx)($.A,{size:"small",sx:{p:.5,color:ze(Me),"&.Mui-checked":{color:Me}},onChange:e=>{var t;if(!fe)return(0,C.k)("Please select a location first!","warning",2e3),void(null===(t=pe.current)||void 0===t||t.focus());e.target.checked?Nr((e=>[...e,(0,o.A)((0,o.A)({},r),{},{sno:e.length+1})])):Nr((e=>e.filter((e=>e.orderheaderid!==r.orderheaderid)).map(((e,r)=>(0,o.A)((0,o.A)({},e),{},{sno:r+1})))))},checked:n})}),(0,w.jsx)(G.A,{children:(0,w.jsx)(q.A,{children:100*xr+t+1})}),(0,w.jsx)(G.A,{children:(0,w.jsxs)(Z.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)(G.A,{align:"left",children:[(0,w.jsx)(q.A,{variant:"subtitle1",noWrap:!0,children:"".concat(r.locationname,"-(").concat(r.locationsuburb,")")}),(0,w.jsx)(Z.A,{title:"TenantId - OrderId",children:(0,w.jsx)(q.A,{variant:"body2",noWrap:!0,children:r.orderid})}),(0,w.jsx)(Z.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)(G.A,{align:"left",children:(0,w.jsxs)(N.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)(Z.A,{title:r.pickupaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:"".concat(r.pickupsuburb||r.pickupaddress.slice(0,12)+".....")})})]})}),(0,w.jsx)(G.A,{align:"left",children:(0,w.jsxs)(N.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)(Z.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)(G.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)(G.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)(G.A,{align:"center",children:(0,w.jsx)(q.A,{variant:"subtitle1",color:r.kms?"error":null,children:r.kms})}),(0,w.jsx)(G.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)(G.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)(G.A,{align:"left",children:(()=>{const e=Pe[String(r.orderstatus||"").toLowerCase()]||{label:r.orderstatus||"\u2014",color:Me,icon:v.bfP},t=e.icon;return(0,w.jsxs)(H.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:De(e.color),border:"1px solid ".concat(ze(e.color)),color:e.color,fontSize:11,fontWeight:800,whiteSpace:"nowrap"},children:[(0,w.jsx)(t,{size:12})," ",e.label]})})()}),"created"===r.orderstatus&&(0,w.jsx)(G.A,{align:"center",children:(0,w.jsxs)(N.A,{flexDirection:"row",justifyContent:"end",children:["C"===r.deliverytype&&(0,w.jsx)(Z.A,{title:"Product details",children:(0,w.jsx)(re.A,{color:"primary",onClick:()=>{(null===ur||void 0===ur?void 0:ur.orderid)===r.orderid?pr(null):pr(r)},children:(null===ur||void 0===ur?void 0:ur.orderid)===r.orderid?(0,w.jsx)(f.A,{}):(0,w.jsx)(b.A,{})})}),(0,w.jsx)(Z.A,{title:"To Cancel",children:(0,w.jsx)(re.A,{"aria-describedby":"aria-".concat(r.sno),disabled:n,onClick:()=>{er(!0),dr(r.orderheaderid)},children:(0,w.jsx)(A.A,{style:{color:n?e.palette.secondary.main:e.palette.error.main}})})})]})})]},r.sno)})),0!=(null===Pt||void 0===Pt?void 0:Pt.length)&&(0,w.jsx)(V.A,{children:(0,w.jsx)(G.A,{colSpan:15,rowSpan:3,sx:{borderBottom:"none"},children:(0,w.jsx)("div",{ref:t,style:{height:40,textAlign:"center"},children:Ot||Rt?(0,w.jsx)(de.A,{}):(0,w.jsx)(q.A,{variant:"caption",sx:{color:ye,fontWeight:600},children:"No more orders"})})})})]})]})})}),(0,w.jsxs)(te.A,{fullScreen:!0,open:rr,TransitionComponent:g.s,children:[(0,w.jsx)(P.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:kr,children:(0,w.jsx)(m.A,{color:"inherit",text:"Optimising ... .."})}),(0,w.jsx)(oe.A,{sx:{bgcolor:e.palette.primary.lighter},children:(0,w.jsx)(T.A,{badgeContent:null===Er||void 0===Er?void 0:Er.length,color:"primary",children:(0,w.jsx)(ne.A,{label:(0,w.jsx)(q.A,{variant:"h3",children:"Preview Orders "}),variant:"contained"})})}),(0,w.jsx)(ie.A,{dividers:!0,children:(0,w.jsx)(S.A,{content:!1,children:(0,w.jsx)(X.A,{children:(0,w.jsxs)(Q.A,{stickyHeader:!0,children:[(0,w.jsx)(J.A,{children:(0,w.jsxs)(V.A,{children:[(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"#"}),(0,w.jsxs)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Tenant"," "]}),(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"order Location"}),(0,w.jsxs)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Pickup"," "]}),(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Delivery"}),(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Notes"}),(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Charges"}),(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"KMS"})]})}),(0,w.jsx)(ee.A,{children:Er.map(((e,r)=>(0,w.jsx)(n.Fragment,{children:(0,w.jsxs)(V.A,{sx:{},children:[(0,w.jsx)(G.A,{children:(0,w.jsxs)(q.A,{children:[" ",e.sno]})}),(0,w.jsx)(G.A,{children:(0,w.jsxs)(Z.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)(G.A,{align:"left",children:[(0,w.jsx)(Z.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)(Z.A,{title:"Order Id",children:(0,w.jsx)(q.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,w.jsxs)(N.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,w.jsxs)(Z.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)(Z.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)(G.A,{align:"left",children:(0,w.jsx)(N.A,{direction:"row",spacing:1,children:(0,w.jsxs)(N.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)(Z.A,{title:e.pickupaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,w.jsx)(G.A,{align:"left",children:(0,w.jsx)(N.A,{direction:"row",spacing:1,children:(0,w.jsxs)(N.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)(Z.A,{title:e.deliveryaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,w.jsx)(G.A,{align:"left",children:e.ordernotes}),(0,w.jsxs)(G.A,{align:"left",children:["\u20b9 ",e.deliverycharge.toFixed(2)]}),(0,w.jsx)(G.A,{align:"left",children:e.kms})]})},r)))})]})})})}),(0,w.jsx)(se.A,{sx:{bgcolor:e.palette.secondary.light},children:(0,w.jsx)(K.Ay,{container:!0,sx:{},children:(0,w.jsx)(K.Ay,{item:!0,xs:12,children:(0,w.jsxs)(N.A,{sx:{mt:2,mr:2},direction:"row",justifyContent:"flex-end",flexWrap:"wrap",gap:2,spacing:5,children:[(0,w.jsx)(le.A,{sx:{width:"130px"},color:"secondary",variant:"contained",onClick:()=>{Kt()},startIcon:(0,w.jsx)(A.A,{}),children:"Close"}),1==Gr.current&&(0,w.jsx)(B.A,{options:[{label:"Bike",value:1},{label:"Auto",value:2}],getOptionLabel:e=>e.label,value:et,onChange:(e,r)=>{rt(r),console.log("Selected value:",null===r||void 0===r?void 0:r.value)},renderInput:e=>(0,w.jsx)(U.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==Gr.current&&(0,w.jsx)(B.A,{multiple:!0,fullWidth:!1,options:ft||[],loading:bt,disableCloseOnSelect:!0,limitTags:2,value:tt,onChange:(e,r)=>ot(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)(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,w.jsxs)(N.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,t)=>{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:t});return(0,n.createElement)(ne.A,(0,o.A)((0,o.A)({},l),{},{key:e.userid,size:"small",avatar:(0,w.jsx)(Y.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,t)=>{let{selected:i}=t;const s="".concat(r.firstname||""," ").concat(r.lastname||"").trim(),l=(s.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,w.jsx)($.A,{size:"small",checked:i,sx:{p:.5,color:"#fb923c","&.Mui-checked":{color:"#ea580c"}}}),(0,w.jsx)(Y.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)(N.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)(ne.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)(U.A,(0,o.A)((0,o.A)({},e),{},{label:"Absent Riders",placeholder:tt.length?"":"Pick riders unavailable today",InputLabelProps:{shrink:!0},InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:(0,w.jsxs)(N.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25},children:[(0,w.jsx)(v.ihY,{size:18,color:"#ea580c"}),tt.length>0&&(0,w.jsx)(ne.A,{size:"small",label:tt.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)(le.A,{color:"primary",disabled:!et&&1==Gr.current,variant:"contained",startIcon:1==Gr.current&&(0,w.jsx)("img",{src:W,alt:"Assign",style:{width:32,height:32,objectFit:"contain",borderRadius:50}}),onClick:()=>{wr(!0),qt()},children:Ee?"Optimising...":0==Gr.current?"Optimise Orders":"AI Optimise Orders"})]})})})})]}),(0,w.jsxs)(te.A,{fullScreen:!0,open:Pr,TransitionComponent:g.s,children:[(0,w.jsx)(oe.A,{children:(0,w.jsx)(N.A,{children:(0,w.jsxs)(N.A,{direction:"row",alignItems:"center",spacing:1,sx:{ml:1},children:[(0,w.jsx)(Z.A,{title:"Back to orders",placement:"top",children:(0,w.jsx)(re.A,{onClick:()=>Fr(!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)(ae.A,{}),(0,w.jsx)(ie.A,{children:(0,w.jsxs)(S.A,{content:!1,children:[(jt||bt||Sr)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(j.A,{}),(0,w.jsx)(m.A,{})]}),(0,w.jsx)(P.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:jt||bt||Sr,children:(0,w.jsx)(m.A,{color:"inherit"})}),(0,w.jsx)(X.A,{children:(0,w.jsxs)(Q.A,{stickyHeader:!0,children:[(0,w.jsx)(J.A,{children:(0,w.jsxs)(V.A,{sx:{backgroundColor:"red"},children:[(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"#"}),1==Zr&&(0,w.jsxs)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Zone"," "]}),(0,w.jsxs)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Tenant"," "]}),(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"order Location"}),(0,w.jsxs)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Pickup"," "]}),(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Delivery"}),(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Notes"}),1==Zr&&(0,w.jsx)(G.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Rider"}),(0,w.jsx)(G.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Type"}),(0,w.jsx)(G.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Charges"}),(0,w.jsx)(G.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"KMS"})]})}),(0,w.jsxs)(ee.A,{children:[0==(null===Jr||void 0===Jr?void 0:Jr.length)&&(0,w.jsx)(V.A,{children:(0,w.jsx)(G.A,{colSpan:10,children:(0,w.jsx)(a.A,{})})}),null===Jr||void 0===Jr?void 0:Jr.map(((e,r)=>(0,w.jsxs)(V.A,{sx:{},children:[(0,w.jsx)(G.A,{children:(0,w.jsxs)(q.A,{children:[" ",r+1]})}),(0,w.jsx)(G.A,{children:(0,w.jsxs)(Z.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)(G.A,{align:"left",children:[(0,w.jsx)(Z.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)(Z.A,{title:"Order Id",children:(0,w.jsx)(q.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,w.jsxs)(N.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,w.jsxs)(Z.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)(Z.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)(G.A,{align:"left",children:(0,w.jsx)(N.A,{direction:"row",spacing:1,children:(0,w.jsxs)(N.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)(Z.A,{title:e.pickupaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,w.jsx)(G.A,{align:"left",children:(0,w.jsx)(N.A,{direction:"row",spacing:1,children:(0,w.jsxs)(N.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)(Z.A,{title:e.deliveryaddress,children:(0,w.jsx)(q.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,w.jsx)(G.A,{align:"left",children:e.ordernotes}),(0,w.jsx)(G.A,{align:"center",children:(0,w.jsx)(ne.A,{size:"small",label:e.ordertype,color:"Economy"==e.ordertype?"success":"Risky"==e.ordertype?"error":"primary",variant:"light"})}),(0,w.jsx)(G.A,{align:"center",children:(0,w.jsxs)(N.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,w.jsx)(Z.A,{title:"Charges",placement:"top",children:(0,w.jsx)(ne.A,{size:"small",label:"\u20b9 ".concat(e.deliverycharge.toFixed(2)," "),color:"error",variant:"light"})}),(0,w.jsx)(Z.A,{title:"Amount",placement:"left",children:(0,w.jsx)(ne.A,{size:"small",label:"\u20b9 ".concat(e.deliveryamt.toFixed(2)," "),color:"success",variant:"light"})})]})}),(0,w.jsx)(G.A,{align:"center",children:(0,w.jsxs)(N.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,w.jsx)(Z.A,{title:"KMS",placement:"top",children:(0,w.jsx)(ne.A,{size:"small",label:"".concat(e.kms," km"),color:"error",variant:"light"})}),(0,w.jsx)(Z.A,{title:"Cumulative Kms",placement:"right",children:(0,w.jsx)(ne.A,{size:"small",label:"".concat(e.cumulativekms," km"),color:"success",variant:"light"})})]})})]},r)))]})]})}),(0,w.jsx)(ae.A,{})]})}),(0,w.jsx)(ae.A,{}),(0,w.jsxs)(se.A,{sx:{flexDirection:"column",alignItems:"stretch",p:2,gap:2},children:[(0,w.jsxs)(K.Ay,{container:!0,spacing:2,children:[(0,w.jsx)(K.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsx)(B.A,{options:mt,fullWidth:!0,renderInput:e=>(0,w.jsx)(U.A,(0,o.A)((0,o.A)({},e),{},{label:"Choose Payment"})),onChange:(e,r,t)=>{if("clear"!==t){if(r){ar(r);const e=null===Jr||void 0===Jr?void 0:Jr.map((e=>(0,o.A)((0,o.A)({},e),{},{paymenttype:r.apptypeid||42})));Vr(e)}}else ar(null)}})}),(0,w.jsx)(K.Ay,{item:!0,xs:12,sm:6,children:(0,w.jsx)(B.A,{options:ft,fullWidth:!0,renderInput:e=>(0,w.jsx)(U.A,(0,o.A)((0,o.A)({},e),{},{label:"Choose Rider"})),onChange:(e,r,t)=>{if("clear"!==t){if(r){sr(r);const e=null===Jr||void 0===Jr?void 0:Jr.map((e=>(0,o.A)((0,o.A)({},e),{},{userid:r.userid,fuelcharge:r.fuelcharge||0,userfcmtoken:r.userfcmtoken})));Vr(e)}}else sr(null)}})})]}),(0,w.jsxs)(N.A,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{pt:1,my:2},children:[(0,w.jsx)(le.A,{variant:"outlined",color:"secondary",startIcon:(0,w.jsx)(z.A,{}),onClick:()=>Fr(!1),children:"Back"}),(0,w.jsx)(le.A,{variant:"contained",disabled:!ir||!lr,onClick:()=>{null!==Jr&&void 0!==Jr&&Jr.length?Tt.mutate({deliveries:Jr}):(0,C.k)("No deliveries selected","error",3e3)},children:"Assign Orders"})]})]})]}),(0,w.jsxs)(te.A,{open:Or,fullScreen:!0,TransitionComponent:g.s,PaperProps:{sx:{display:"flex",flexDirection:"column",overflow:"hidden"}},children:[(0,w.jsx)(P.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:Sr,children:(0,w.jsx)(m.A,{color:"inherit"})}),(0,w.jsx)(oe.A,{sx:{py:1.25},children:(0,w.jsxs)(N.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{},children:[(0,w.jsxs)(N.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,w.jsx)(Z.A,{title:"Back to orders",placement:"top",children:(0,w.jsx)(re.A,{onClick:()=>r("/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)(N.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,w.jsx)(B.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)(U.A,(0,o.A)((0,o.A)({},e),{},{label:"Hyper Tuning"})),onChange:(e,r,t)=>{"clear"===t?qt(null):(console.log("val",r),qt(r.value))}}),(0,w.jsx)(le.A,{variant:"contained",color:"primary",startIcon:(0,w.jsx)(R.UF6,{}),onClick:()=>{Cr(!0),qt("reshuffle")},children:"Re-Assign"}),(0,w.jsx)(he.Ay,{data:Xr,filename:"Orders_Detail_".concat(d()().format("YYYY-MM-DD_HHmmss"),".csv"),label:" CSV",style:{m:1}})]})]})}),(0,w.jsx)(ie.A,{sx:{p:0,display:"flex",flexDirection:"column",overflow:"hidden",flex:1},children:Tr&&(0,w.jsx)(ue.default,{data:Tr,embedded:!0})}),(0,w.jsx)(se.A,{sx:{px:2,py:1.25},children:(0,w.jsxs)(N.A,{direction:"row",gap:2,alignItems:"center",justifyContent:"end",children:[(0,w.jsx)(le.A,{variant:"contained",color:"secondary",startIcon:(0,w.jsx)(z.A,{}),onClick:()=>{Yr(!1)},children:"Back"}),(0,w.jsx)(le.A,{variant:"contained",onClick:async()=>{Cr(!0),Ht.mutate({deliveries:Jr})},children:"Assign Orders"})]})})]}),(0,w.jsx)(te.A,{open:$e,onClose:()=>handleClose(),maxWidth:"xs",children:(0,w.jsx)(ie.A,{sx:{mt:2,my:1},children:(0,w.jsxs)(N.A,{alignItems:"center",spacing:3.5,children:[(0,w.jsx)(Y.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,w.jsx)(l.A,{})}),(0,w.jsx)(N.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)(N.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,w.jsx)(le.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{Lt.mutate(cr)},autoFocus:!0,children:"Yes, Cancel"}),(0,w.jsx)(le.A,{fullWidth:!0,onClick:()=>{er(!1)},color:"secondary",variant:"outlined",children:"No"})]})]})})}),(0,w.jsx)(te.A,{open:or,onClose:()=>nr(!1),maxWidth:"xs",children:(0,w.jsx)(ie.A,{sx:{mt:2,my:1},children:(0,w.jsxs)(N.A,{alignItems:"center",spacing:3.5,children:[(0,w.jsx)(Y.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,w.jsx)(l.A,{})}),(0,w.jsx)(N.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)(N.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,w.jsx)(le.A,{fullWidth:!0,onClick:()=>{nr(!1)},color:"secondary",variant:"outlined",children:"No"}),(0,w.jsx)(le.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{Et.mutate(Er)},autoFocus:!0,children:"Yes, Cancel"})]})]})})})]})}},35678:(e,r,t)=>{t.d(r,{A:()=>v});var o=t(9950),n=t(96583),i=t(40033),s=t(82053),l=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),m=t(94289),j=t(57326),f=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)(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: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,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),t()):t()},children:"OK"})})]})}},47659:(e,r,t)=>{t.d(r,{A:()=>d});var o=t(89379),n=t(48089),i=t(50704),s=t(16491),l=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)(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:t})}),(0,c.jsx)(a.Ay,{item:!0,xs:12,children:(0,c.jsx)(l.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),s=t(2046),l=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 m=(0,n.useRef)(null),[j]=(0,x.d7)(r,p);return(0,n.useEffect)((()=>{u&&u(j)}),[j,u]),(0,n.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,o.A)({},g),inputRef:m,placeholder:A,autoComplete:"off",value:r,fullWidth:!0,onChange:e=>t(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:()=>t(""),children:(0,h.jsx)(d.A,{})})})})}},58691:(e,r,t)=>{t.d(r,{A:()=>l});t(9950);var o=t(16491),n=t(46639),i=t(62217),s=t(44414);function l(e){let{size:r=70,imgSize:t=40,alt:l="loader"}=e;return(0,s.jsxs)(o.A,{position:"relative",display:"inline-flex",justifyContent:"center",alignItems:"center",children:[(0,s.jsx)(n.A,{size:r}),(0,s.jsx)(o.A,{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",sx:{width:t,height:t},children:(0,s.jsx)("img",{src:i,alt:l,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),s=t(41413),l=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:m=!1,accentColor:j="#6366f1",icon:f,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 w=e=>"".concat(j).concat(e),S=w("08"),C=w("26"),D=w("55"),I=w("18"),W=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:D,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}}:{},z=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:I,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,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=>m?(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:z}),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),s=t(93230),l=t(44414);const a=e=>{let{rowsPerPage:r=5,col:t=1}=e;return(0,l.jsx)(l.Fragment,{children:Array.from(new Array(r)).map(((e,r)=>(0,l.jsxs)(o.A,{children:[(0,l.jsx)(n.A,{children:(0,l.jsx)(i.A,{variant:"circular",width:24,height:24})}),(0,l.jsx)(n.A,{children:(0,l.jsx)(i.A,{variant:"text",width:30})}),Array.from({length:t}).map(((e,r)=>(0,l.jsx)(n.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)(n.A,{children:(0,l.jsx)(i.A,{variant:"text",width:150})}),(0,l.jsx)(n.A,{children:(0,l.jsx)(i.A,{variant:"rounded",width:60,height:24})}),(0,l.jsx)(n.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)))})}}}]);