1 line
41 KiB
JavaScript
1 line
41 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[3750],{1367:(e,r,n)=>{n.d(r,{A:()=>a});var t=n(89379),i=(n(9950),n(16491)),s=n(93230),o=n(82053),l=n(44414);const a=e=>{let{sx:r,title:n,children:a,starticon:c}=e;return(0,l.jsx)(i.A,{sx:(0,t.A)({},r),children:(0,l.jsxs)(s.A,{direction:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:1,children:[(0,l.jsxs)(s.A,{children:[c&&c,(0,l.jsx)(o.A,{variant:"h3",children:n})]}),a]})})}},47659:(e,r,n)=>{n.d(r,{A:()=>d});var t=n(89379),i=n(48089),s=n(50704),o=n(16491),l=n(82053),a=n(60899),c=n(44414);const d=e=>{let{primary:r,secondary:n,percentage:d,color:x,sx:h}=e;return(0,c.jsx)(i.A,{elevation:0,sx:(0,t.A)({background:x,position:"relative",color:"#fff","&:hover svg":{opacity:1,transform:"scale(1.1)"}},h),children:(0,c.jsxs)(s.A,{children:[(0,c.jsx)(o.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:n})}),(0,c.jsx)(a.Ay,{item:!0,xs:12,children:(0,c.jsx)(l.A,{variant:"subtitle2",color:"inherit",children:r})})]})]})})}},69317:(e,r,n)=>{n.r(r),n.d(r,{default:()=>ke});var t=n(89379),i=n(9950),s=n(47965),o=n(44070),l=n(36256),a=n(13838),c=n(4159),d=n.n(c),x=n(36150),h=n(60010),u=n(51778),p=n(47659),A=n(14857),j=n(94118),g=n(37476),m=n(94826),v=n(52351),y=n(67562),f=n(49883),b=n(69476),k=n(31222),C=n(8951),w=n(35678),S=n(56311),D=n(1367),W=n(50027),z=n(20466),I=n(96646),Y=n(59212);const O=n.p+"static/media/aiImage.89c2ccb91a41d85031e3.png";var F=n(63189),M=n(65913),P=n(43302),T=n(99324),E=n(85527),q=n(6604),L=n(55158),_=n(59382),N=n(28810),H=n(79046),R=n(33092),K=n(60899),B=n(82917),Q=n(93230),Z=n(25277),G=n(41413),V=n(82053),J=n(77922),U=n(29925),X=n(48159),$=n(47223),ee=n(84142),re=n(1320),ne=n(15769),te=n(69780),ie=n(9213),se=n(21671),oe=n(93038),le=n(34075),ae=n(83274),ce=n(25333),de=n(96583),xe=n(40033),he=n(28170),ue=n(79739),pe=n(82223),Ae=n(74745),je=n(81425),ge=n(58691),me=n(28429),ve=n(90376),ye=n(34815),fe=n(44414),be=n(36220);d().extend(be);const ke=()=>{const e=(0,A.A)(),r=(0,me.Zp)(),n=(0,i.useRef)(),c=(0,i.useRef)(),be=(0,i.useRef)(null),ke=(0,i.useRef)(null),[Ce,we]=(0,i.useState)(0),[Se,De]=(0,i.useState)("All"),[We,ze]=(0,i.useState)(!1),[Ie,Ye]=(0,i.useState)(d()().format("YYYY-MM-DD")),[Oe,Fe]=(0,i.useState)(d()().format("YYYY-MM-DD")),[Me,Pe]=(0,i.useState)("Today"),[Te,Ee]=(0,i.useState)(!1),[qe,Le]=(0,i.useState)(0),[_e,Ne]=(0,i.useState)("created"),[He,Re]=(0,i.useState)(!1),[Ke,Be]=(0,i.useState)(!1),[Qe,Ze]=(0,i.useState)(!1),[Ge,Ve]=(0,i.useState)(null),[Je,Ue]=(0,i.useState)(null),[Xe,$e]=(0,i.useState)(""),[er,rr]=(0,i.useState)(0),[nr,tr]=(0,i.useState)(null),[ir,sr]=(0,i.useState)(0),[or,lr]=(0,i.useState)(0),[ar,cr]=(0,i.useState)(""),[dr,xr]=(0,i.useState)(""),[hr,ur]=(0,i.useState)(!1),[pr,Ar]=(0,i.useState)(!1),[jr,gr]=(0,i.useState)(null),[mr,vr]=(0,i.useState)(null),[yr,fr]=(0,i.useState)(!1),[br,kr]=(0,i.useState)(!1),[Cr,wr]=(0,i.useState)(!1),[Sr,Dr]=(0,i.useState)(null),[Wr,zr]=(0,i.useState)([]),[Ir,Yr]=(0,i.useState)([]),[Or,Fr]=(0,i.useState)(null),[Mr,Pr]=(0,i.useState)(null),[Tr]=(0,i.useState)(0),[Er,qr]=(0,i.useState)([]),[Lr,_r]=(0,i.useState)([]),Nr=(0,i.useRef)(0),[Hr,Rr]=(0,i.useState)(null);(0,i.useEffect)((()=>{sr(0),gr(null),lr(0),vr(null)}),[Ce]),(0,i.useEffect)((()=>{lr(0),vr(null)}),[ir]),(0,i.useEffect)((()=>{const e=Lr.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)}),[Lr]),(0,i.useEffect)((()=>{if(null===Ir||void 0===Ir||!Ir.length)return;const e=Ir.map((e=>{const r=Number(e.cumulativekms||0),n=Number(e.minkm||0),i=Number(e.baseprice||0),s=Number(e.priceperkm||0);return r<=n?(0,t.A)((0,t.A)({},e),{},{deliveryamt:i}):(0,t.A)((0,t.A)({},e),{},{deliveryamt:(r-n)*s+i})}));_r(e),console.log("finaldeliveryList",e)}),[Ir]);const{data:Kr,isLoading:Br,isError:Qr,error:Zr,refetch:Gr}=(0,x.I)({queryKey:["percentageData",Ce],queryFn:()=>(0,je.jy)(Ce),enabled:!0}),{data:Vr,isLoading:Jr,isError:Ur,error:Xr}=(0,x.I)({queryKey:["tenantlist",Ce],queryFn:()=>(0,je.Mn)(Ce),enabled:0!==Ce}),{data:$r,isLoading:en,isError:rn,error:nn}=(0,x.I)({queryKey:["gettenantlocations",ir],queryFn:()=>(0,je.DL)(ir),enabled:0!==ir}),{data:tn=[],isLoading:sn}=(0,x.I)({queryKey:["paymentmodes"],queryFn:je.HY}),{data:on=[],isLoading:ln}=(0,x.I)({queryKey:["ridersList",Ce],queryFn:je.Sd,enabled:0!==Ce}),{data:an,isLoading:cn,isError:dn,error:xn,refetch:hn}=(0,x.I)({queryKey:["ordersCount",Ce,Ie,Oe,_e,ir,or],queryFn:je.Hh,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:un}=(0,x.I)({queryKey:["getallriders"],queryFn:je.Xw,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:pn,isLoading:An,isError:jn,error:gn,fetchNextPage:mn,hasNextPage:vn,isFetchingNextPage:yn,refetch:fn}=(0,h.q)({queryKey:["fetchOrders",Ce,_e,dr,Ie,Oe,100,ir,or],queryFn:je.nQ,getNextPageParam:e=>{var r;return null!==(r=e.nextPage)&&void 0!==r?r:void 0},refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,staleTime:0}),bn=(null===pn||void 0===pn?void 0:pn.pages.flatMap((e=>e.rows)))||[];(0,i.useEffect)((()=>{if(!vn)return;const e=new IntersectionObserver((e=>{e[0].isIntersecting&&mn()}),{root:document.querySelector(".MuiTableContainer-root"),rootMargin:"0px",threshold:1});return n.current&&e.observe(n.current),()=>{n.current&&e.unobserve(n.current)}}),[vn,mn]);const kn=(0,u.n)({mutationFn:0==Nr.current?je.FC:je.Yk,onSuccess:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];console.log("data",e),console.log("varialbles",r),(0,z.k)("Orders Optimised Successfully","success",2e3),hn(),fn(),ze(!1),ur(!1),0==Nr.current?(Yr(null===e||void 0===e?void 0:e.details),Fr(null===e||void 0===e?void 0:e.zones),Pr(null===e||void 0===e?void 0:e.meta),wr(!0)):(Yr(null===e||void 0===e?void 0:e.details),Fr(null===e||void 0===e?void 0:e.zones),Pr(null===e||void 0===e?void 0:e.meta),Dr(e),kr(!0))},onError:e=>{(0,z.k)(e.message,"error",4e3),ur(!1),ze(!1)},onSettled:()=>{In(),ze(!1),ur(!1),Ar(!1)}}),Cn=(0,u.n)({mutationFn:je.H2,onMutate:()=>{Ar(!0)},onSuccess:e=>{console.log("create data",e),(0,z.k)("Delivery Created Successfully","success",2e3),r("/nearle/deliveries"),Dn.mutate(null===Ge||void 0===Ge?void 0:Ge.userfcmtoken)},onError:e=>{(0,z.k)(e.message,"error",4e3)},onSettled:()=>{Ar(!1)}}),wn=(0,u.n)({mutationFn:je.N4,onSuccess:e=>{e.status&&(Re(!1),(0,z.k)("Order Cancelled Successfully","success",2e3),hn(),Gr())},onError:e=>{(0,z.k)(e.message,"error",2e3)}}),Sn=(0,u.n)({mutationFn:je.zR,onSuccess:e=>{e.status&&(Ze(!1),(0,z.k)("Order Cancelled Successfully","success",2e3),fn(),hn(),Gr(),zr([]))},onError:e=>{(0,z.k)(e.message,"error",2e3)}}),Dn=(0,u.n)({mutationFn:je.k3,onSuccess:()=>{(0,z.k)("Notification sent Successfully","success",2e3)},onError:e=>{(0,z.k)(e.message,"error",2e3)}}),Wn=async e=>{Ar(!0),ze(!0);const r=Wr.map((e=>(0,t.A)((0,t.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),0==Nr.current?kn.mutate({deliveries:r}):Hr&&1==(null===Hr||void 0===Hr?void 0:Hr.value)?kn.mutate({deliveries:1==Hr.value?r:{body:r},hypertuning_params:e||null,selectedMode:Hr}):kn.mutate({data:{orders:r,riders:un,config:{pay_type:"hourly",base_pay:300,strategy:"multi_trip"}},selectedMode:Hr})},zn=(0,u.n)({mutationFn:je.H2,onSuccess:(e,n)=>{console.log("data",e),console.log("varialbles",n),(0,z.k)("Delivery Created Successfully","success",2e3),Ar(!1),r("/nearle/deliveries")},onError:e=>{(0,z.k)(e.message,"error",4e3)},onSettled:()=>{Ar(!1)}}),In=()=>{Be(!1),Ve(null),Ue(null)},Yn=Qr?"Error fetching percentages: ".concat(null===Zr||void 0===Zr?void 0:Zr.message):dn?"Error fetching orders Count: ".concat(null===xn||void 0===xn?void 0:xn.message):jn?"Error fetching orders : ".concat(null===gn||void 0===gn?void 0:gn.message):Ur?"Error Fetching on Tenants:".concat(null===Xr||void 0===Xr?void 0:Xr.message," "):rn?"Error Fetching on Tenants Locations:".concat(null===nn||void 0===nn?void 0:nn.message," "):null;return(0,i.useEffect)((()=>{Yn&&(console.log(Yn),(0,z.k)(Yn,"error",3e3))}),[Yn]),(0,fe.jsxs)(i.Fragment,{children:[(Br||cn||An||Jr||en||hr)&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(v.A,{}),(0,fe.jsx)(m.A,{})]}),(0,fe.jsx)(L.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:hr||An,children:(0,fe.jsx)(m.A,{color:"inherit"})}),(0,fe.jsx)(L.A,{sx:{zIndex:1e3},open:yr}),Wr.length>0&&(0,fe.jsxs)(_.A,{ariaLabel:"Actions",icon:(0,fe.jsx)(N.A,{badgeContent:(null===Wr||void 0===Wr?void 0:Wr.length)||"",color:"secondary",children:(0,fe.jsx)(H.A,{})}),open:yr,onOpen:()=>fr(!0),onClose:()=>fr(!1),sx:{position:"fixed",bottom:52,right:16,"& .MuiFab-primary":{bgcolor:"#7b1fa2",color:"#fff","&:hover":{bgcolor:"#6a1b9a"},width:64,height:64}},children:[(0,fe.jsx)(R.A,{icon:(0,fe.jsx)("img",{src:O,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:()=>{Nr.current=1,fr(!1),Be(!0)}}),(0,fe.jsx)(R.A,{icon:(0,fe.jsx)(s.A,{style:{fontSize:22}}),tooltipTitle:"Manual Assign",FabProps:{sx:{bgcolor:"success.600",color:"#fff","&:hover":{bgcolor:"success.dark"},width:64,height:64}},onClick:()=>{Nr.current=0,fr(!1),Be(!0)}}),(0,fe.jsx)(R.A,{icon:(0,fe.jsx)(o.A,{style:{fontSize:22}}),tooltipTitle:"Delete",FabProps:{sx:{bgcolor:"#d32f2f",color:"#fff","&:hover":{bgcolor:"#9a0007"},width:64,height:64}},onClick:()=>{fr(!1),Ze(!0)}})]}),(0,fe.jsx)(D.A,{title:"Orders",children:(0,fe.jsx)(Y.A,{ref:be,locaName:Se,setAppId:we,setLocoName:De,setPage:rr,sx:{width:{xs:"100%",custom450:300},zIndex:"100"}})}),(0,fe.jsx)(K.Ay,{container:!0,spacing:2,sx:{mt:"1px"},children:[{label:"Created orders",value:null===Kr||void 0===Kr?void 0:Kr.created,percentage:null===Kr||void 0===Kr?void 0:Kr.percentage1,color:e.palette.info.main},{label:"Pending orders",value:null===Kr||void 0===Kr?void 0:Kr.uncoveredOrders,percentage:null===Kr||void 0===Kr?void 0:Kr.percentage2,color:e.palette.warning.main},{label:"Delivered orders",value:null===Kr||void 0===Kr?void 0:Kr.coveredOrders,percentage:null===Kr||void 0===Kr?void 0:Kr.percentage3,color:e.palette.success.main},{label:"Cancelled Orders",value:null===Kr||void 0===Kr?void 0:Kr.cancelled,percentage:null===Kr||void 0===Kr?void 0:Kr.percentage4,color:e.palette.error.main}].map(((e,r)=>{var n;return(0,fe.jsx)(K.Ay,{item:!0,xs:12,custom400:6,sm:3,sx:{cursor:"pointer"},children:(0,fe.jsx)(p.A,{primary:e.label,secondary:Br?(0,fe.jsx)(B.A,{sx:{width:"30px"},animation:"wave"}):e.value,percentage:null===(n=e.percentage)||void 0===n?void 0:n.toString(),color:e.color})},r)}))}),(0,fe.jsxs)(Q.A,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:2,sx:{flexWrap:"wrap",my:2},children:[(0,fe.jsx)(Q.A,{direction:"row",spacing:2,alignItems:"center",sx:{flexWrap:"wrap"},children:Ie&&Oe?(0,fe.jsxs)(Q.A,{direction:"row",spacing:1.5,flexWrap:"wrap",useFlexGap:!0,sx:{rowGap:1.5,columnGap:1.5,alignItems:"center",justifyContent:{xs:"flex-start",sm:"flex-start",md:"flex-start"}},children:[(0,fe.jsx)(Z.A,{avatar:(0,fe.jsx)(C.jkt,{fontSize:"20px",style:{color:"red"}}),label:"Orders-".concat(Me),color:"error",variant:"combined"}),(0,fe.jsx)(Z.A,{avatar:(0,fe.jsx)(G.A,{sx:{backgroundColor:"transparent"},children:(0,fe.jsx)(k.tjE,{fontSize:"24px",style:{color:"#fbc02d"}})}),label:(0,fe.jsx)(V.A,{noWrap:!0,color:"secondary",fontSize:"0.8rem",children:"".concat(d()(Ie).format("DD/MM/YYYY")," - ").concat(d()(Oe).format("DD/MM/YYYY"))}),color:"warning",variant:"combined",onClick:()=>Ee(!0),sx:{cursor:"pointer"}}),(0,fe.jsx)(Z.A,{avatar:(0,fe.jsx)(G.A,{sx:{backgroundColor:"transparent"},children:(0,fe.jsx)(b.LSI,{fontSize:"24px",style:{color:"#00bcd4"}})}),label:Se,color:"info",variant:"combined"})]}):(0,fe.jsx)(Z.A,{label:"Orders-All",color:"primary",variant:"light",size:"small"})}),(0,fe.jsxs)(Q.A,{display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"wrap",gap:2,sx:{width:{xs:"100%",md:"auto"}},children:[(0,fe.jsx)(J.A,{options:Vr||[],value:jr,sx:{minWidth:250,maxWidth:600,flex:1},onOpen:e=>{Ce||(e.preventDefault(),(0,z.k)("Please select location first!","warning",3e3),setTimeout((()=>{var e;null===(e=be.current)||void 0===e||e.focus()}),0))},onChange:(e,r,n)=>{"clear"===n?(sr(0),gr(null),lr(0),vr(null)):(sr((null===r||void 0===r?void 0:r.tenantid)||0),gr(r),lr(0),vr(null))},renderInput:e=>(0,fe.jsx)(U.A,(0,t.A)((0,t.A)({},e),{},{inputRef:ke,label:"Select Tenant"}))}),(0,fe.jsx)(J.A,{options:$r||[],getOptionLabel:e=>"".concat(e.locationname," (").concat(e.suburb,")")||0,value:mr,sx:{minWidth:250,maxWidth:600,flex:1},onOpen:e=>{Ce||ir?ir||(e.preventDefault(),(0,z.k)("Please select Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=ke.current)||void 0===e||e.focus()}),0)):(e.preventDefault(),(0,z.k)("Please select a your Location and Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=be.current)||void 0===e||e.focus()}),0))},onChange:(e,r,n)=>{"clear"===n?(lr(0),vr(null)):(lr(r.locationid||0),vr(r))},renderInput:e=>(0,fe.jsx)(U.A,(0,t.A)((0,t.A)({},e),{},{label:"Select Location"}))}),(0,fe.jsx)(w.A,{open:Te,onClose:()=>Ee(!1),onSelect:e=>{Ye(e.startDate),Fe(e.endDate),Pe(e.label),console.log("Selected Date Range:",e)}})]})]}),(0,fe.jsxs)(Q.A,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap-reverse",gap:2,sx:{border:"1px solid ",borderBottom:0,borderColor:"bg.main",p:1.5},children:[(0,fe.jsxs)(X.A,{value:qe,onChange:(e,r)=>{rr(0),Le(r),0===r&&Ne("created"),1===r&&Ne("pending"),2===r&&Ne("delivered"),3===r&&Ne("cancelled"),cr("")},variant:"scrollable",scrollButtons:!!(0,$.A)(e.breakpoints.down("custom650")),allowScrollButtonsMobile:!0,children:[(0,fe.jsx)(ee.A,{label:"Created",icon:(0,fe.jsx)(Z.A,{label:(null===an||void 0===an?void 0:an.created)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"}),(0,fe.jsx)(ee.A,{label:"Pending",icon:(0,fe.jsx)(Z.A,{label:(null===an||void 0===an?void 0:an.pending)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"}),(0,fe.jsx)(ee.A,{label:"Delivered",icon:(0,fe.jsx)(Z.A,{label:(null===an||void 0===an?void 0:an.delivered)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"}),(0,fe.jsx)(ee.A,{label:"Cancelled",icon:(0,fe.jsx)(Z.A,{label:(null===an||void 0===an?void 0:an.cancelled)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"})]}),(0,fe.jsx)(S.A,{value:ar,onChange:cr,onDebouncedChange:xr,sx:{width:{xs:"100%",custom1000:275},m:0}})]}),(0,fe.jsx)(W.A,{content:!1,children:(0,fe.jsx)(re.A,{ref:c,onScroll:e=>{const{scrollTop:r,scrollHeight:n,clientHeight:t}=e.currentTarget;r+t>=n-50&&vn&&!yn&&mn()},sx:{maxHeight:"calc(100vh - 90px)",overflow:"auto","&::-webkit-scrollbar":{width:"12px",cursor:"pointer"},"&::-webkit-scrollbar-thumb":{backgroundColor:e.palette.primary.main,borderRadius:"8px",cursor:"pointer"},"&::-webkit-scrollbar-thumb:hover":{backgroundColor:e.palette.primary.dark,cursor:"pointer"},"&::-webkit-scrollbar-track":{backgroundColor:e.palette.primary.lighter,cursor:"pointer"}},children:(0,fe.jsxs)(ne.A,{stickyHeader:!0,children:[(0,fe.jsx)(te.A,{children:(0,fe.jsxs)(ie.A,{children:["created"==_e&&(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:(0,fe.jsx)(oe.A,{indeterminate:Wr.length>0&&Wr.length!==(null===bn||void 0===bn?void 0:bn.length),checked:Wr.length===(null===bn||void 0===bn?void 0:bn.length),onChange:e=>{var r;if(!Ce)return(0,z.k)("Please select a location first!","warning",2e3),void(null===(r=be.current)||void 0===r||r.focus());if(e.target.checked){const e=null===bn||void 0===bn?void 0:bn.map(((e,r)=>(0,t.A)((0,t.A)({},e),{},{sno:r+1})));zr(e)}else zr([])}})}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["#"," "]}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Tenant"," "]}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","Location"]}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","Pickup"," "]}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","Drop"," "]}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","QTY"," "]}),(0,fe.jsx)(se.A,{align:"right",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"COD"}),(0,fe.jsx)(se.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"KMS"}),(0,fe.jsx)(se.A,{align:"right",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Charges"}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","Notes"," "]}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["status"," "]}),"created"==_e&&(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Actions"})]})}),(0,fe.jsxs)(le.A,{children:[0===(null===bn||void 0===bn?void 0:bn.length)&&!An&&(0,fe.jsx)(ie.A,{children:(0,fe.jsx)(se.A,{colSpan:13,children:(0,fe.jsx)(Q.A,{width:"100%",direction:"row",justifyContent:"center",children:(0,fe.jsx)(a.A,{description:"No ".concat(_e," Orders"),styles:{description:{color:e.palette.error.main}}})})})}),An&&(0,fe.jsx)(I.r,{col:8}),null===bn||void 0===bn?void 0:bn.map(((r,n)=>{const i=!!Wr.find((e=>e.orderheaderid===r.orderheaderid));return(0,fe.jsxs)(ie.A,{role:"checkbox",tabIndex:-1,sx:{cursor:"pointer",backgroundColor:i?"#e1bee7":"","&:hover":{backgroundColor:i?"#e1bee7 !important":""}},children:["created"===_e&&(0,fe.jsx)(se.A,{children:(0,fe.jsx)(oe.A,{sx:{backgroundColor:i?"#e1bee7":"","&:hover":{backgroundColor:i?"#e1bee7 !important":""}},onChange:e=>{var n;if(!Ce)return(0,z.k)("Please select a location first!","warning",2e3),void(null===(n=be.current)||void 0===n||n.focus());e.target.checked?zr((e=>[...e,(0,t.A)((0,t.A)({},r),{},{sno:e.length+1})])):zr((e=>e.filter((e=>e.orderheaderid!==r.orderheaderid)).map(((e,r)=>(0,t.A)((0,t.A)({},e),{},{sno:r+1})))))},checked:i})}),(0,fe.jsx)(se.A,{children:(0,fe.jsx)(V.A,{children:100*er+n+1})}),(0,fe.jsx)(se.A,{children:(0,fe.jsxs)(ae.A,{title:r.tenantaddress,children:[(0,fe.jsx)(V.A,{variant:"subtitle1",noWrap:!0,children:r.tenantname}),(0,fe.jsxs)(V.A,{noWrap:!0,variant:"body2",children:[r.tenantsuburb,(0,fe.jsx)("br",{})]}),(0,fe.jsx)(V.A,{noWrap:!0,variant:"body2",children:r.applocation})]})}),(0,fe.jsxs)(se.A,{align:"left",children:[(0,fe.jsx)(V.A,{variant:"subtitle1",noWrap:!0,children:"".concat(r.locationname,"-(").concat(r.locationsuburb,")")}),(0,fe.jsx)(ae.A,{title:"TenantId - OrderId",children:(0,fe.jsx)(V.A,{variant:"body2",noWrap:!0,children:r.orderid})}),(0,fe.jsx)(ae.A,{title:"Pickup Slot",children:(0,fe.jsxs)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:[d()(r.pickupslot).utc().format("DD/MM/YYYY")," ",d()(r.pickupslot).format("hh:mm A")]})})]}),(0,fe.jsx)(se.A,{align:"left",children:(0,fe.jsxs)(Q.A,{direction:"column",children:[(0,fe.jsx)(V.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:r.pickupcustomer}),(0,fe.jsx)(V.A,{variant:"caption",children:r.pickupcontactno}),(0,fe.jsx)(ae.A,{title:r.pickupaddress,children:(0,fe.jsx)(V.A,{variant:"caption",children:"".concat(r.pickupsuburb||r.pickupaddress.slice(0,12)+".....")})})]})}),(0,fe.jsx)(se.A,{align:"left",children:(0,fe.jsxs)(Q.A,{direction:"column",children:[(0,fe.jsx)(V.A,{variant:"subtitle1",sx:{maxWidth:120,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.deliverycustomer}),(0,fe.jsx)(V.A,{variant:"caption",children:r.deliverycontactno}),(0,fe.jsx)(ae.A,{title:r.deliveryaddress,sx:{whiteSpace:"nowrap"},children:(0,fe.jsx)(V.A,{variant:"caption",children:"".concat(r.deliverysuburb||r.deliveryaddress.slice(0,12)+".....")})})]})}),(0,fe.jsx)(se.A,{align:"center",children:r.quantity?(0,fe.jsx)(V.A,{variant:"subtitle1",color:"error",sx:{whiteSpace:"nowrap"},children:r.quantity}):(0,fe.jsx)(V.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:r.quantity})}),(0,fe.jsx)(se.A,{align:"right",children:r.collectionamt?(0,fe.jsxs)(V.A,{variant:"subtitle1",color:r.collectionamt?"error":null,sx:{whiteSpace:"nowrap"},children:["\u20b9",r.collectionamt.toFixed(2)]}):(0,fe.jsxs)(V.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:["\u20b9",r.collectionamt.toFixed(2)]})}),(0,fe.jsx)(se.A,{align:"center",children:(0,fe.jsx)(V.A,{variant:"subtitle1",color:r.kms?"error":null,children:r.kms})}),(0,fe.jsx)(se.A,{align:"right",children:r.deliverycharge?(0,fe.jsxs)(V.A,{variant:"subtitle1",color:r.deliverycharge?"error":null,sx:{whiteSpace:"nowrap"},children:["\u20b9",r.deliverycharge.toFixed(2)]}):(0,fe.jsxs)(V.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:["\u20b9",r.deliverycharge.toFixed(2)]})}),(0,fe.jsx)(se.A,{align:"left",children:(0,fe.jsx)(V.A,{variant:"body1",fontSize:"12px",sx:{maxWidth:120,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.ordernotes})}),(0,fe.jsx)(se.A,{align:"left",children:(0,fe.jsx)(Z.A,{label:r.orderstatus,color:"pending"===r.orderstatus?"warning":"modified"===r.orderstatus||"confirmed"===r.orderstatus||"delivered"===r.orderstatus||"accepted"===r.orderstatus?"success":"cancelled"===r.orderstatus?"error":(r.orderstatus,"primary"),size:"small",variant:"light"})}),"created"===r.orderstatus&&(0,fe.jsx)(se.A,{align:"center",children:(0,fe.jsxs)(Q.A,{flexDirection:"row",justifyContent:"end",children:["C"===r.deliverytype&&(0,fe.jsx)(ae.A,{title:"Product details",children:(0,fe.jsx)(ce.A,{color:"primary",onClick:()=>{(null===nr||void 0===nr?void 0:nr.orderid)===r.orderid?tr(null):tr(r)},children:(null===nr||void 0===nr?void 0:nr.orderid)===r.orderid?(0,fe.jsx)(y.A,{}):(0,fe.jsx)(f.A,{})})}),(0,fe.jsx)(ae.A,{title:"To Cancel",children:(0,fe.jsx)(ce.A,{"aria-describedby":"aria-".concat(r.sno),disabled:i,onClick:()=>{Re(!0),$e(r.orderheaderid)},children:(0,fe.jsx)(j.A,{style:{color:i?e.palette.secondary.main:e.palette.error.main}})})})]})})]},r.sno)})),0!=(null===bn||void 0===bn?void 0:bn.length)&&(0,fe.jsx)(ie.A,{children:(0,fe.jsx)(se.A,{colSpan:15,rowSpan:3,children:(0,fe.jsx)("div",{ref:n,style:{height:40,textAlign:"center"},children:yn||vn?(0,fe.jsx)(ge.A,{}):"No More Orders"})})})]})]})})}),(0,fe.jsxs)(de.A,{fullScreen:!0,open:Ke,TransitionComponent:g.s,children:[(0,fe.jsx)(L.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:hr,children:(0,fe.jsx)(m.A,{color:"inherit",text:"Optimising ... .."})}),(0,fe.jsx)(xe.A,{sx:{bgcolor:e.palette.primary.lighter},children:(0,fe.jsx)(N.A,{badgeContent:null===Wr||void 0===Wr?void 0:Wr.length,color:"primary",children:(0,fe.jsx)(Z.A,{label:(0,fe.jsx)(V.A,{variant:"h3",children:"Preview Orders "}),variant:"contained"})})}),(0,fe.jsx)(he.A,{dividers:!0,children:(0,fe.jsx)(W.A,{content:!1,children:(0,fe.jsx)(re.A,{children:(0,fe.jsxs)(ne.A,{stickyHeader:!0,children:[(0,fe.jsx)(te.A,{children:(0,fe.jsxs)(ie.A,{children:[(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"#"}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Tenant"," "]}),(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"order Location"}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Pickup"," "]}),(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Delivery"}),(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Notes"}),(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Charges"}),(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"KMS"})]})}),(0,fe.jsx)(le.A,{children:Wr.map(((e,r)=>(0,fe.jsx)(i.Fragment,{children:(0,fe.jsxs)(ie.A,{sx:{},children:[(0,fe.jsx)(se.A,{children:(0,fe.jsxs)(V.A,{children:[" ",e.sno]})}),(0,fe.jsx)(se.A,{children:(0,fe.jsxs)(ae.A,{title:e.tenantaddress,children:[(0,fe.jsx)(V.A,{variant:"body1",noWrap:!0,children:e.tenantname}),(0,fe.jsxs)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:[e.tenantsuburb,(0,fe.jsx)("br",{})]}),(0,fe.jsx)(V.A,{noWrap:!0,variant:"body2",children:e.applocation})]})}),(0,fe.jsxs)(se.A,{align:"left",children:[(0,fe.jsx)(ae.A,{title:e.locationaddress,placement:"top",children:(0,fe.jsx)(V.A,{variant:"body1",noWrap:!0,children:"".concat(e.locationname,"-(").concat(e.locationsuburb,")")})}),(0,fe.jsx)(ae.A,{title:"Order Id",children:(0,fe.jsx)(V.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,fe.jsxs)(Q.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,fe.jsxs)(ae.A,{title:"Ordered date",children:[(0,fe.jsx)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.orderdate).utc().format("DD/MM/YYYY")}),(0,fe.jsx)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.orderdate).utc().format("hh:mm A")})]}),"-",(0,fe.jsxs)(ae.A,{title:"Delivery date",children:[(0,fe.jsx)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.deliverydate).utc().format("DD/MM/YYYY")}),(0,fe.jsx)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.deliverydate).utc().format("hh:mm A")})]})]})]}),(0,fe.jsx)(se.A,{align:"left",children:(0,fe.jsx)(Q.A,{direction:"row",spacing:1,children:(0,fe.jsxs)(Q.A,{direction:"column",children:[(0,fe.jsx)(V.A,{variant:"caption",children:e.pickupcustomer}),(0,fe.jsx)(V.A,{variant:"caption",children:e.pickupcontactno}),(0,fe.jsx)(ae.A,{title:e.pickupaddress,children:(0,fe.jsx)(V.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,fe.jsx)(se.A,{align:"left",children:(0,fe.jsx)(Q.A,{direction:"row",spacing:1,children:(0,fe.jsxs)(Q.A,{direction:"column",children:[(0,fe.jsx)(V.A,{variant:"caption",children:e.deliverycustomer}),(0,fe.jsx)(V.A,{variant:"caption",children:e.deliverycontactno}),(0,fe.jsx)(ae.A,{title:e.deliveryaddress,children:(0,fe.jsx)(V.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,fe.jsx)(se.A,{align:"left",children:e.ordernotes}),(0,fe.jsxs)(se.A,{align:"left",children:["\u20b9 ",e.deliverycharge.toFixed(2)]}),(0,fe.jsx)(se.A,{align:"left",children:e.kms})]})},r)))})]})})})}),(0,fe.jsx)(ue.A,{sx:{bgcolor:e.palette.secondary.light},children:(0,fe.jsx)(K.Ay,{container:!0,sx:{},children:(0,fe.jsx)(K.Ay,{item:!0,xs:12,children:(0,fe.jsxs)(Q.A,{sx:{mt:2,mr:2},direction:"row",justifyContent:"flex-end",flexWrap:"wrap",gap:2,spacing:5,children:[(0,fe.jsx)(pe.A,{sx:{width:"130px"},color:"secondary",variant:"contained",onClick:()=>{In()},startIcon:(0,fe.jsx)(j.A,{}),children:"Close"}),1==Nr.current&&(0,fe.jsx)(J.A,{options:[{label:"Bike",value:1},{label:"Auto",value:2}],getOptionLabel:e=>e.label,value:Hr,onChange:(e,r)=>{Rr(r),console.log("Selected value:",null===r||void 0===r?void 0:r.value)},renderInput:e=>(0,fe.jsx)(U.A,(0,t.A)((0,t.A)({sx:{width:200,border:"1px solid ",borderColor:"primary.main"}},e),{},{placeholder:"Select Transport"})),isOptionEqualToValue:(e,r)=>e.value===r.value}),(0,fe.jsx)(pe.A,{color:"primary",disabled:!Hr&&1==Nr.current,variant:"contained",startIcon:1==Nr.current&&(0,fe.jsx)("img",{src:O,alt:"Assign",style:{width:32,height:32,objectFit:"contain",borderRadius:50}}),onClick:()=>{ur(!0),Wn()},children:We?"Optimising...":0==Nr.current?"Optimise Orders":"AI Optimise Orders"})]})})})})]}),(0,fe.jsxs)(de.A,{fullScreen:!0,open:Cr,TransitionComponent:g.s,children:[(0,fe.jsx)(xe.A,{children:(0,fe.jsx)(Q.A,{children:(0,fe.jsxs)(Q.A,{direction:"row",alignItems:"center",spacing:1,sx:{ml:1},children:[(0,fe.jsx)(ae.A,{title:"Back to orders",placement:"top",children:(0,fe.jsx)(ce.A,{onClick:()=>wr(!1),sx:{backgroundColor:"action.hover",color:"text.primary","&:hover":{backgroundColor:"action.selected"}},children:(0,fe.jsx)(T.eQE,{size:22})})}),(0,fe.jsx)(V.A,{sx:{m:2},variant:"h3",children:"Assign Orders"})]})})}),(0,fe.jsx)(Ae.A,{}),(0,fe.jsx)(he.A,{children:(0,fe.jsxs)(W.A,{content:!1,children:[(sn||ln||pr)&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(v.A,{}),(0,fe.jsx)(m.A,{})]}),(0,fe.jsx)(L.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:sn||ln||pr,children:(0,fe.jsx)(m.A,{color:"inherit"})}),(0,fe.jsx)(re.A,{children:(0,fe.jsxs)(ne.A,{stickyHeader:!0,children:[(0,fe.jsx)(te.A,{children:(0,fe.jsxs)(ie.A,{sx:{backgroundColor:"red"},children:[(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"#"}),1==Tr&&(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Zone"," "]}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Tenant"," "]}),(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"order Location"}),(0,fe.jsxs)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Pickup"," "]}),(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Delivery"}),(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Notes"}),1==Tr&&(0,fe.jsx)(se.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Rider"}),(0,fe.jsx)(se.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Type"}),(0,fe.jsx)(se.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Charges"}),(0,fe.jsx)(se.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"KMS"})]})}),(0,fe.jsxs)(le.A,{children:[0==(null===Lr||void 0===Lr?void 0:Lr.length)&&(0,fe.jsx)(ie.A,{children:(0,fe.jsx)(se.A,{colSpan:10,children:(0,fe.jsx)(a.A,{})})}),null===Lr||void 0===Lr?void 0:Lr.map(((e,r)=>(0,fe.jsxs)(ie.A,{sx:{},children:[(0,fe.jsx)(se.A,{children:(0,fe.jsxs)(V.A,{children:[" ",r+1]})}),(0,fe.jsx)(se.A,{children:(0,fe.jsxs)(ae.A,{title:e.tenantaddress,children:[(0,fe.jsx)(V.A,{variant:"body1",noWrap:!0,children:e.tenantname}),(0,fe.jsxs)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:[e.tenantsuburb,(0,fe.jsx)("br",{})]}),(0,fe.jsx)(V.A,{noWrap:!0,variant:"body2",children:e.applocation})]})}),(0,fe.jsxs)(se.A,{align:"left",children:[(0,fe.jsx)(ae.A,{title:e.locationaddress,placement:"top",children:(0,fe.jsx)(V.A,{variant:"body1",noWrap:!0,children:"".concat(e.locationname,"-(").concat(e.locationsuburb,")")})}),(0,fe.jsx)(ae.A,{title:"Order Id",children:(0,fe.jsx)(V.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,fe.jsxs)(Q.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,fe.jsxs)(ae.A,{title:"Ordered date",children:[(0,fe.jsx)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.orderdate).utc().format("DD/MM/YYYY")}),(0,fe.jsx)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.orderdate).utc().format("hh:mm A")})]}),"-",(0,fe.jsxs)(ae.A,{title:"Delivery date",children:[(0,fe.jsx)(V.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.deliverydate).utc().format("DD/MM/YYYY")}),(0,fe.jsx)(V.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.deliverydate).utc().format("hh:mm A")})]})]})]}),(0,fe.jsx)(se.A,{align:"left",children:(0,fe.jsx)(Q.A,{direction:"row",spacing:1,children:(0,fe.jsxs)(Q.A,{direction:"column",children:[(0,fe.jsx)(V.A,{variant:"caption",children:e.pickupcustomer}),(0,fe.jsx)(V.A,{variant:"caption",children:e.pickupcontactno}),(0,fe.jsx)(ae.A,{title:e.pickupaddress,children:(0,fe.jsx)(V.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,fe.jsx)(se.A,{align:"left",children:(0,fe.jsx)(Q.A,{direction:"row",spacing:1,children:(0,fe.jsxs)(Q.A,{direction:"column",children:[(0,fe.jsx)(V.A,{variant:"caption",children:e.deliverycustomer}),(0,fe.jsx)(V.A,{variant:"caption",children:e.deliverycontactno}),(0,fe.jsx)(ae.A,{title:e.deliveryaddress,children:(0,fe.jsx)(V.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,fe.jsx)(se.A,{align:"left",children:e.ordernotes}),(0,fe.jsx)(se.A,{align:"center",children:(0,fe.jsx)(Z.A,{size:"small",label:e.ordertype,color:"Economy"==e.ordertype?"success":"Risky"==e.ordertype?"error":"primary",variant:"light"})}),(0,fe.jsx)(se.A,{align:"center",children:(0,fe.jsxs)(Q.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,fe.jsx)(ae.A,{title:"Charges",placement:"top",children:(0,fe.jsx)(Z.A,{size:"small",label:"\u20b9 ".concat(e.deliverycharge.toFixed(2)," "),color:"error",variant:"light"})}),(0,fe.jsx)(ae.A,{title:"Amount",placement:"left",children:(0,fe.jsx)(Z.A,{size:"small",label:"\u20b9 ".concat(e.deliveryamt.toFixed(2)," "),color:"success",variant:"light"})})]})}),(0,fe.jsx)(se.A,{align:"center",children:(0,fe.jsxs)(Q.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,fe.jsx)(ae.A,{title:"KMS",placement:"top",children:(0,fe.jsx)(Z.A,{size:"small",label:"".concat(e.kms," km"),color:"error",variant:"light"})}),(0,fe.jsx)(ae.A,{title:"Cumulative Kms",placement:"right",children:(0,fe.jsx)(Z.A,{size:"small",label:"".concat(e.cumulativekms," km"),color:"success",variant:"light"})})]})})]},r)))]})]})}),(0,fe.jsx)(Ae.A,{})]})}),(0,fe.jsx)(Ae.A,{}),(0,fe.jsxs)(ue.A,{sx:{flexDirection:"column",alignItems:"stretch",p:2,gap:2},children:[(0,fe.jsxs)(K.Ay,{container:!0,spacing:2,children:[(0,fe.jsx)(K.Ay,{item:!0,xs:12,sm:6,children:(0,fe.jsx)(J.A,{options:tn,fullWidth:!0,renderInput:e=>(0,fe.jsx)(U.A,(0,t.A)((0,t.A)({},e),{},{label:"Choose Payment"})),onChange:(e,r,n)=>{if("clear"!==n){if(r){Ue(r);const e=null===Lr||void 0===Lr?void 0:Lr.map((e=>(0,t.A)((0,t.A)({},e),{},{paymenttype:r.apptypeid||42})));_r(e)}}else Ue(null)}})}),(0,fe.jsx)(K.Ay,{item:!0,xs:12,sm:6,children:(0,fe.jsx)(J.A,{options:on,fullWidth:!0,renderInput:e=>(0,fe.jsx)(U.A,(0,t.A)((0,t.A)({},e),{},{label:"Choose Rider"})),onChange:(e,r,n)=>{if("clear"!==n){if(r){Ve(r);const e=null===Lr||void 0===Lr?void 0:Lr.map((e=>(0,t.A)((0,t.A)({},e),{},{userid:r.userid,fuelcharge:r.fuelcharge||0,userfcmtoken:r.userfcmtoken})));_r(e)}}else Ve(null)}})})]}),(0,fe.jsxs)(Q.A,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{pt:1,my:2},children:[(0,fe.jsx)(pe.A,{variant:"outlined",color:"secondary",startIcon:(0,fe.jsx)(F.A,{}),onClick:()=>wr(!1),children:"Back"}),(0,fe.jsx)(pe.A,{variant:"contained",disabled:!Ge||!Je,onClick:()=>{null!==Lr&&void 0!==Lr&&Lr.length?Cn.mutate({deliveries:Lr}):(0,z.k)("No deliveries selected","error",3e3)},children:"Assign Orders"})]})]})]}),(0,fe.jsxs)(de.A,{open:br,fullScreen:!0,TransitionComponent:g.s,PaperProps:{sx:{display:"flex",flexDirection:"column",overflow:"hidden"}},children:[(0,fe.jsx)(L.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:pr,children:(0,fe.jsx)(m.A,{color:"inherit"})}),(0,fe.jsxs)(xe.A,{children:[(0,fe.jsxs)(Q.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{},children:[(0,fe.jsxs)(Q.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,fe.jsx)(ae.A,{title:"Back to orders",placement:"top",children:(0,fe.jsx)(ce.A,{onClick:()=>r("/nearle/orders"),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},children:(0,fe.jsx)(T.eQE,{size:20})})}),(0,fe.jsx)(V.A,{variant:"h3",fontWeight:600,children:"Assign Orders"})]}),(0,fe.jsxs)(Q.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,fe.jsx)(J.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,fe.jsx)(U.A,(0,t.A)((0,t.A)({},e),{},{label:"Hyper Tuning"})),onChange:(e,r,n)=>{"clear"===n?Wn(null):(console.log("val",r),Wn(r.value))}}),(0,fe.jsx)(pe.A,{variant:"contained",color:"primary",startIcon:(0,fe.jsx)(q.UF6,{}),onClick:()=>{Ar(!0),Wn("reshuffle")},children:"Re-Assign"}),(0,fe.jsx)(ve.Ay,{data:Er,filename:"Orders_Detail_".concat(d()().format("YYYY-MM-DD_HHmmss"),".csv"),label:" CSV",style:{m:1}})]})]}),(0,fe.jsx)(Q.A,{sx:{my:2},children:(0,fe.jsxs)(K.Ay,{container:!0,spacing:2,children:[(0,fe.jsx)(K.Ay,{item:!0,xs:6,sm:6,md:3,children:(0,fe.jsx)(p.A,{secondary:null===Mr||void 0===Mr?void 0:Mr.total_orders,primary:"Orders",percentage:(0,fe.jsx)(M.A,{}),color:e.palette.success.main,sx:{cursor:"pointer"}})}),(0,fe.jsx)(K.Ay,{item:!0,xs:6,sm:6,md:3,children:(0,fe.jsx)(p.A,{secondary:null===Mr||void 0===Mr?void 0:Mr.utilized_riders,primary:"Riders",percentage:(0,fe.jsx)(k.bsz,{}),color:e.palette.warning.main})}),(0,fe.jsx)(K.Ay,{item:!0,xs:6,sm:6,md:3,children:(0,fe.jsx)(p.A,{secondary:null===Or||void 0===Or?void 0:Or.length,primary:"Zones",percentage:(0,fe.jsx)(P.us2,{}),color:e.palette.info.main})}),(0,fe.jsx)(K.Ay,{item:!0,xs:6,sm:6,md:3,children:(0,fe.jsx)(p.A,{secondary:null===Mr||void 0===Mr?void 0:Mr.total_profit,primary:"Profit",percentage:(0,fe.jsx)(E.BJH,{}),color:e.palette.error.main})})]})})]}),(0,fe.jsx)(he.A,{sx:{p:0,display:"flex",flexDirection:"column",overflow:"hidden",flex:1},children:Sr&&(0,fe.jsx)(ye.default,{data:Sr,embedded:!0})}),(0,fe.jsx)(ue.A,{children:(0,fe.jsxs)(Q.A,{display:"flex",flexDirection:"row",gap:2,alignItems:"center",justifyContent:"end",sx:{p:2},children:[(0,fe.jsx)(pe.A,{sx:{},variant:"contained",color:"secondary",startIcon:(0,fe.jsx)(F.A,{}),onClick:()=>{kr(!1)},children:"Back"}),(0,fe.jsx)(pe.A,{sx:{my:2},variant:"contained",onClick:async()=>{Ar(!0),zn.mutate({deliveries:Lr})},children:"Assign Orders"})]})})]}),(0,fe.jsx)(de.A,{open:He,onClose:()=>handleClose(),maxWidth:"xs",children:(0,fe.jsx)(he.A,{sx:{mt:2,my:1},children:(0,fe.jsxs)(Q.A,{alignItems:"center",spacing:3.5,children:[(0,fe.jsx)(G.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,fe.jsx)(l.A,{})}),(0,fe.jsx)(Q.A,{spacing:2,children:(0,fe.jsx)(V.A,{variant:"h4",align:"center",children:"Are you sure you want to cancel this order?"})}),(0,fe.jsxs)(Q.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,fe.jsx)(pe.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{wn.mutate(Xe)},autoFocus:!0,children:"Yes, Cancel"}),(0,fe.jsx)(pe.A,{fullWidth:!0,onClick:()=>{Re(!1)},color:"secondary",variant:"outlined",children:"No"})]})]})})}),(0,fe.jsx)(de.A,{open:Qe,onClose:()=>Ze(!1),maxWidth:"xs",children:(0,fe.jsx)(he.A,{sx:{mt:2,my:1},children:(0,fe.jsxs)(Q.A,{alignItems:"center",spacing:3.5,children:[(0,fe.jsx)(G.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,fe.jsx)(l.A,{})}),(0,fe.jsx)(Q.A,{spacing:2,children:(0,fe.jsx)(V.A,{variant:"h4",align:"center",children:"Are you sure, you want to cancel multiple orders?"})}),(0,fe.jsxs)(Q.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,fe.jsx)(pe.A,{fullWidth:!0,onClick:()=>{Ze(!1)},color:"secondary",variant:"outlined",children:"No"}),(0,fe.jsx)(pe.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{Sn.mutate(Wr)},autoFocus:!0,children:"Yes, Cancel"})]})]})})})]})}},96646:(e,r,n)=>{n.d(r,{r:()=>a});var t=n(9213),i=n(21671),s=n(82917),o=n(93230),l=n(44414);const a=e=>{let{rowsPerPage:r=5,col:n=1}=e;return(0,l.jsx)(l.Fragment,{children:Array.from(new Array(r)).map(((e,r)=>(0,l.jsxs)(t.A,{children:[(0,l.jsx)(i.A,{children:(0,l.jsx)(s.A,{variant:"circular",width:24,height:24})}),(0,l.jsx)(i.A,{children:(0,l.jsx)(s.A,{variant:"text",width:30})}),Array.from({length:n}).map(((e,r)=>(0,l.jsx)(i.A,{children:(0,l.jsxs)(o.A,{spacing:.5,children:[(0,l.jsx)(s.A,{variant:"text",width:100}),(0,l.jsx)(s.A,{variant:"text",width:80})]})},r))),(0,l.jsx)(i.A,{children:(0,l.jsx)(s.A,{variant:"text",width:150})}),(0,l.jsx)(i.A,{children:(0,l.jsx)(s.A,{variant:"rounded",width:60,height:24})}),(0,l.jsx)(i.A,{align:"center",children:(0,l.jsxs)(o.A,{direction:"row",spacing:1,justifyContent:"flex-end",children:[(0,l.jsx)(s.A,{variant:"circular",width:28,height:28}),(0,l.jsx)(s.A,{variant:"circular",width:28,height:28})]})})]},r)))})}}}]); |