1 line
44 KiB
JavaScript
1 line
44 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[3750],{1367:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(89379),i=(t(9950),t(16491)),o=t(93230),s=t(82053),l=t(44414);const a=e=>{let{sx:r,title:t,children:a,starticon:c}=e;return(0,l.jsx)(i.A,{sx:(0,n.A)({},r),children:(0,l.jsxs)(o.A,{direction:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:1,children:[(0,l.jsxs)(o.A,{children:[c&&c,(0,l.jsx)(s.A,{variant:"h3",children:t})]}),a]})})}},47659:(e,r,t)=>{t.d(r,{A:()=>d});var n=t(89379),i=t(48089),o=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)(i.A,{elevation:0,sx:(0,n.A)({background:x,position:"relative",color:"#fff","&:hover svg":{opacity:1,transform:"scale(1.1)"}},h),children:(0,c.jsxs)(o.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})})]})]})})}},69317:(e,r,t)=>{t.r(r),t.d(r,{default:()=>ye});var n=t(89379),i=t(9950),o=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),A=t(14857),g=t(94118),j=t(37476),m=t(94826),v=t(52351),f=t(67562),y=t(49883),b=t(69476),k=t(31222),C=t(8951),w=t(35678),S=t(56311),W=t(1367),I=t(50027),z=t(20466),D=t(96646),O=t(59212);const M=t.p+"static/media/aiImage.89c2ccb91a41d85031e3.png";var Y=t(63189),F=t(99324),P=t(6604),T=t(55158),E=t(59382),L=t(28810),q=t(79046),R=t(33092),N=t(60899),_=t(82917),H=t(93230),K=t(25277),B=t(41413),Q=t(82053),G=t(77922),U=t(29925),V=t(48159),Z=t(47223),X=t(84142),J=t(1320),$=t(15769),ee=t(69780),re=t(9213),te=t(21671),ne=t(93038),ie=t(34075),oe=t(83274),se=t(25333),le=t(96583),ae=t(40033),ce=t(28170),de=t(79739),xe=t(82223),he=t(2235),ue=t(74745),pe=t(81425),Ae=t(58691),ge=t(28429),je=t(90376),me=t(34815),ve=t(44414),fe=t(36220);d().extend(fe);const ye=()=>{const e=(0,A.A)(),r=(0,ge.Zp)(),t=(0,i.useRef)(),c=(0,i.useRef)(),fe=(0,i.useRef)(null),ye=(0,i.useRef)(null),[be,ke]=(0,i.useState)(0),[Ce,we]=(0,i.useState)("All"),[Se,We]=(0,i.useState)(!1),[Ie,ze]=(0,i.useState)(d()().format("YYYY-MM-DD")),[De,Oe]=(0,i.useState)(d()().format("YYYY-MM-DD")),[Me,Ye]=(0,i.useState)("Today"),[Fe,Pe]=(0,i.useState)(!1),[Te,Ee]=(0,i.useState)(0),[Le,qe]=(0,i.useState)("created"),[Re,Ne]=(0,i.useState)(!1),[_e,He]=(0,i.useState)(!1),[Ke,Be]=(0,i.useState)(!1),[Qe,Ge]=(0,i.useState)(null),[Ue,Ve]=(0,i.useState)(null),[Ze,Xe]=(0,i.useState)(""),[Je,$e]=(0,i.useState)(0),[er,rr]=(0,i.useState)(null),[tr,nr]=(0,i.useState)(0),[ir,or]=(0,i.useState)(0),[sr,lr]=(0,i.useState)(""),[ar,cr]=(0,i.useState)(""),[dr,xr]=(0,i.useState)(!1),[hr,ur]=(0,i.useState)(!1),[pr,Ar]=(0,i.useState)(null),[gr,jr]=(0,i.useState)(null),[mr,vr]=(0,i.useState)(!1),[fr,yr]=(0,i.useState)(!1),[br,kr]=(0,i.useState)(!1),[Cr,wr]=(0,i.useState)(null),[Sr,Wr]=(0,i.useState)([]),[Ir,zr]=(0,i.useState)([]),[Dr,Or]=(0,i.useState)(null),[Mr,Yr]=(0,i.useState)(null),[Fr]=(0,i.useState)(0),[Pr,Tr]=(0,i.useState)([]),[Er,Lr]=(0,i.useState)([]),qr=(0,i.useRef)(0),[Rr,Nr]=(0,i.useState)(null),[_r,Hr]=(0,i.useState)([]);(0,i.useEffect)((()=>{nr(0),Ar(null),or(0),jr(null)}),[be]),(0,i.useEffect)((()=>{or(0),jr(null)}),[tr]),(0,i.useEffect)((()=>{const e=Er.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})));Tr(e),console.log("csvExportData",e)}),[Er]),(0,i.useEffect)((()=>{if(null===Ir||void 0===Ir||!Ir.length)return;const e=Ir.map((e=>{const r=Number(e.cumulativekms||0),t=Number(e.minkm||0),i=Number(e.baseprice||0),o=Number(e.priceperkm||0);return r<=t?(0,n.A)((0,n.A)({},e),{},{deliveryamt:i}):(0,n.A)((0,n.A)({},e),{},{deliveryamt:(r-t)*o+i})}));Lr(e),console.log("finaldeliveryList",e)}),[Ir]);const{data:Kr,isLoading:Br,isError:Qr,error:Gr,refetch:Ur}=(0,x.I)({queryKey:["percentageData",be],queryFn:()=>(0,pe.jy)(be),enabled:!0}),{data:Vr,isLoading:Zr,isError:Xr,error:Jr}=(0,x.I)({queryKey:["tenantlist",be],queryFn:()=>(0,pe.Mn)(be),enabled:0!==be}),{data:$r,isLoading:et,isError:rt,error:tt}=(0,x.I)({queryKey:["gettenantlocations",tr],queryFn:()=>(0,pe.DL)(tr),enabled:0!==tr}),{data:nt=[],isLoading:it}=(0,x.I)({queryKey:["paymentmodes"],queryFn:pe.HY}),{data:ot=[],isLoading:st}=(0,x.I)({queryKey:["ridersList",be],queryFn:pe.Sd,enabled:0!==be}),{data:lt,isLoading:at,isError:ct,error:dt,refetch:xt}=(0,x.I)({queryKey:["ordersCount",be,Ie,De,Le,tr,ir],queryFn:pe.Hh,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:ht}=(0,x.I)({queryKey:["getallriders"],queryFn:pe.Xw,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:ut,isLoading:pt,isError:At,error:gt,fetchNextPage:jt,hasNextPage:mt,isFetchingNextPage:vt,refetch:ft}=(0,h.q)({queryKey:["fetchOrders",be,Le,ar,Ie,De,100,tr,ir],queryFn:pe.nQ,getNextPageParam:e=>{var r;return null!==(r=e.nextPage)&&void 0!==r?r:void 0},refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!0,staleTime:0}),yt=(null===ut||void 0===ut?void 0:ut.pages.flatMap((e=>e.rows)))||[];(0,i.useEffect)((()=>{if(!mt)return;const e=new IntersectionObserver((e=>{e[0].isIntersecting&&jt()}),{root:document.querySelector(".MuiTableContainer-root"),rootMargin:"0px",threshold:1});return t.current&&e.observe(t.current),()=>{t.current&&e.unobserve(t.current)}}),[mt,jt]);const bt=(0,u.n)({mutationFn:0==qr.current?pe.FC:pe.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),xt(),ft(),We(!1),xr(!1),0==qr.current?(zr(null===e||void 0===e?void 0:e.details),Or(null===e||void 0===e?void 0:e.zones),Yr(null===e||void 0===e?void 0:e.meta),kr(!0)):(zr(null===e||void 0===e?void 0:e.details),Or(null===e||void 0===e?void 0:e.zones),Yr(null===e||void 0===e?void 0:e.meta),wr(e),yr(!0))},onError:e=>{(0,z.k)(e.message,"error",4e3),xr(!1),We(!1)},onSettled:()=>{zt(),We(!1),xr(!1),ur(!1)}}),kt=(0,u.n)({mutationFn:pe.H2,onMutate:()=>{ur(!0)},onSuccess:e=>{console.log("create data",e),(0,z.k)("Delivery Created Successfully","success",2e3),r("/nearle/deliveries"),St.mutate(null===Qe||void 0===Qe?void 0:Qe.userfcmtoken)},onError:e=>{(0,z.k)(e.message,"error",4e3)},onSettled:()=>{ur(!1)}}),Ct=(0,u.n)({mutationFn:pe.N4,onSuccess:e=>{e.status&&(Ne(!1),(0,z.k)("Order Cancelled Successfully","success",2e3),xt(),Ur())},onError:e=>{(0,z.k)(e.message,"error",2e3)}}),wt=(0,u.n)({mutationFn:pe.zR,onSuccess:e=>{e.status&&(Be(!1),(0,z.k)("Order Cancelled Successfully","success",2e3),ft(),xt(),Ur(),Wr([]))},onError:e=>{(0,z.k)(e.message,"error",2e3)}}),St=(0,u.n)({mutationFn:pe.k3,onSuccess:()=>{(0,z.k)("Notification sent Successfully","success",2e3)},onError:e=>{(0,z.k)(e.message,"error",2e3)}}),Wt=async e=>{ur(!0),We(!0);const r=Sr.map((e=>(0,n.A)((0,n.A)({},e),{},{deliveryid:0,deliverydate:d()(e.deliverydate).utc().format("YYYY-MM-DD HH:mm:ss"),assigntime:d()().format("YYYY-MM-DD HH:mm:ss"),orderstatus:"pending",orderamount:e.deliverycharge,droplat:e.deliverylat,droplon:e.deliverylong,pickuplat:e.pickuplat,pickuplon:e.pickuplong,ordernotes:e.ordernotes,deliverycharges:e.deliverycharge,pickuplocation:e.pickupsuburb,deliverylocation:e.deliverysuburb})));console.log("deliveryData",r);const t=(_r||[]).map((e=>({userid:e.userid,username:"".concat(e.firstname||""," ").concat(e.lastname||"").trim()||e.username||"Rider ".concat(e.userid)})));0==qr.current?bt.mutate({deliveries:r}):Rr&&1==(null===Rr||void 0===Rr?void 0:Rr.value)?bt.mutate({deliveries:1==Rr.value?r:{body:r},hypertuning_params:e||null,selectedMode:Rr,absent_riders:t}):bt.mutate({data:{orders:r,riders:ht,config:{pay_type:"hourly",base_pay:300,strategy:"multi_trip"},absent_riders:t},selectedMode:Rr})},It=(0,u.n)({mutationFn:pe.H2,onSuccess:(e,t)=>{console.log("data",e),console.log("varialbles",t),(0,z.k)("Delivery Created Successfully","success",2e3),ur(!1),r("/nearle/deliveries")},onError:e=>{(0,z.k)(e.message,"error",4e3)},onSettled:()=>{ur(!1)}}),zt=()=>{He(!1),Ge(null),Ve(null),Nr(null),Hr([])},Dt=Qr?"Error fetching percentages: ".concat(null===Gr||void 0===Gr?void 0:Gr.message):ct?"Error fetching orders Count: ".concat(null===dt||void 0===dt?void 0:dt.message):At?"Error fetching orders : ".concat(null===gt||void 0===gt?void 0:gt.message):Xr?"Error Fetching on Tenants:".concat(null===Jr||void 0===Jr?void 0:Jr.message," "):rt?"Error Fetching on Tenants Locations:".concat(null===tt||void 0===tt?void 0:tt.message," "):null;return(0,i.useEffect)((()=>{Dt&&(console.log(Dt),(0,z.k)(Dt,"error",3e3))}),[Dt]),(0,ve.jsxs)(i.Fragment,{children:[(Br||at||pt||Zr||et||dr)&&(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(v.A,{}),(0,ve.jsx)(m.A,{})]}),(0,ve.jsx)(T.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:dr||pt,children:(0,ve.jsx)(m.A,{color:"inherit"})}),(0,ve.jsx)(T.A,{sx:{zIndex:1e3},open:mr}),Sr.length>0&&(0,ve.jsxs)(E.A,{ariaLabel:"Actions",icon:(0,ve.jsx)(L.A,{badgeContent:(null===Sr||void 0===Sr?void 0:Sr.length)||"",color:"secondary",children:(0,ve.jsx)(q.A,{})}),open:mr,onOpen:()=>vr(!0),onClose:()=>vr(!1),sx:{position:"fixed",bottom:52,right:16,"& .MuiFab-primary":{bgcolor:"#7b1fa2",color:"#fff","&:hover":{bgcolor:"#6a1b9a"},width:64,height:64}},children:[(0,ve.jsx)(R.A,{icon:(0,ve.jsx)("img",{src:M,alt:"Assign",style:{width:38,height:38,objectFit:"contain",borderRadius:50}}),tooltipTitle:" Optimisation",FabProps:{sx:{bgcolor:"primary.main",color:"#fff","&:hover":{bgcolor:"primary.dark"},width:64,height:64}},onClick:()=>{qr.current=1,vr(!1),He(!0)}}),(0,ve.jsx)(R.A,{icon:(0,ve.jsx)(o.A,{style:{fontSize:22}}),tooltipTitle:"Manual Assign",FabProps:{sx:{bgcolor:"success.600",color:"#fff","&:hover":{bgcolor:"success.dark"},width:64,height:64}},onClick:()=>{qr.current=0,vr(!1),He(!0)}}),(0,ve.jsx)(R.A,{icon:(0,ve.jsx)(s.A,{style:{fontSize:22}}),tooltipTitle:"Delete",FabProps:{sx:{bgcolor:"#d32f2f",color:"#fff","&:hover":{bgcolor:"#9a0007"},width:64,height:64}},onClick:()=>{vr(!1),Be(!0)}})]}),(0,ve.jsx)(W.A,{title:"Orders",children:(0,ve.jsx)(O.A,{ref:fe,locaName:Ce,setAppId:ke,setLocoName:we,setPage:$e,sx:{width:{xs:"100%",custom450:300},zIndex:"100"}})}),(0,ve.jsx)(N.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 t;return(0,ve.jsx)(N.Ay,{item:!0,xs:12,custom400:6,sm:3,sx:{cursor:"pointer"},children:(0,ve.jsx)(p.A,{primary:e.label,secondary:Br?(0,ve.jsx)(_.A,{sx:{width:"30px"},animation:"wave"}):e.value,percentage:null===(t=e.percentage)||void 0===t?void 0:t.toString(),color:e.color})},r)}))}),(0,ve.jsxs)(H.A,{direction:"row",justifyContent:"space-between",alignItems:"center",gap:2,sx:{flexWrap:"wrap",my:2},children:[(0,ve.jsx)(H.A,{direction:"row",spacing:2,alignItems:"center",sx:{flexWrap:"wrap"},children:Ie&&De?(0,ve.jsxs)(H.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,ve.jsx)(K.A,{avatar:(0,ve.jsx)(C.jkt,{fontSize:"20px",style:{color:"red"}}),label:"Orders-".concat(Me),color:"error",variant:"combined"}),(0,ve.jsx)(K.A,{avatar:(0,ve.jsx)(B.A,{sx:{backgroundColor:"transparent"},children:(0,ve.jsx)(k.tjE,{fontSize:"24px",style:{color:"#fbc02d"}})}),label:(0,ve.jsx)(Q.A,{noWrap:!0,color:"secondary",fontSize:"0.8rem",children:"".concat(d()(Ie).format("DD/MM/YYYY")," - ").concat(d()(De).format("DD/MM/YYYY"))}),color:"warning",variant:"combined",onClick:()=>Pe(!0),sx:{cursor:"pointer"}}),(0,ve.jsx)(K.A,{avatar:(0,ve.jsx)(B.A,{sx:{backgroundColor:"transparent"},children:(0,ve.jsx)(b.LSI,{fontSize:"24px",style:{color:"#00bcd4"}})}),label:Ce,color:"info",variant:"combined"})]}):(0,ve.jsx)(K.A,{label:"Orders-All",color:"primary",variant:"light",size:"small"})}),(0,ve.jsxs)(H.A,{display:"flex",flexDirection:"row",alignItems:"center",flexWrap:"wrap",gap:2,sx:{width:{xs:"100%",md:"auto"}},children:[(0,ve.jsx)(G.A,{options:Vr||[],value:pr,sx:{minWidth:250,maxWidth:600,flex:1},onOpen:e=>{be||(e.preventDefault(),(0,z.k)("Please select location first!","warning",3e3),setTimeout((()=>{var e;null===(e=fe.current)||void 0===e||e.focus()}),0))},onChange:(e,r,t)=>{"clear"===t?(nr(0),Ar(null),or(0),jr(null)):(nr((null===r||void 0===r?void 0:r.tenantid)||0),Ar(r),or(0),jr(null))},renderInput:e=>(0,ve.jsx)(U.A,(0,n.A)((0,n.A)({},e),{},{inputRef:ye,label:"Select Tenant"}))}),(0,ve.jsx)(G.A,{options:$r||[],getOptionLabel:e=>"".concat(e.locationname," (").concat(e.suburb,")")||0,value:gr,sx:{minWidth:250,maxWidth:600,flex:1},onOpen:e=>{be||tr?tr||(e.preventDefault(),(0,z.k)("Please select Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=ye.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=fe.current)||void 0===e||e.focus()}),0))},onChange:(e,r,t)=>{"clear"===t?(or(0),jr(null)):(or(r.locationid||0),jr(r))},renderInput:e=>(0,ve.jsx)(U.A,(0,n.A)((0,n.A)({},e),{},{label:"Select Location"}))}),(0,ve.jsx)(w.A,{open:Fe,onClose:()=>Pe(!1),onSelect:e=>{ze(e.startDate),Oe(e.endDate),Ye(e.label),console.log("Selected Date Range:",e)}})]})]}),(0,ve.jsxs)(H.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,ve.jsxs)(V.A,{value:Te,onChange:(e,r)=>{$e(0),Ee(r),0===r&&qe("created"),1===r&&qe("pending"),2===r&&qe("delivered"),3===r&&qe("cancelled"),lr("")},variant:"scrollable",scrollButtons:!!(0,Z.A)(e.breakpoints.down("custom650")),allowScrollButtonsMobile:!0,children:[(0,ve.jsx)(X.A,{label:"Created",icon:(0,ve.jsx)(K.A,{label:(null===lt||void 0===lt?void 0:lt.created)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"}),(0,ve.jsx)(X.A,{label:"Pending",icon:(0,ve.jsx)(K.A,{label:(null===lt||void 0===lt?void 0:lt.pending)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"}),(0,ve.jsx)(X.A,{label:"Delivered",icon:(0,ve.jsx)(K.A,{label:(null===lt||void 0===lt?void 0:lt.delivered)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"}),(0,ve.jsx)(X.A,{label:"Cancelled",icon:(0,ve.jsx)(K.A,{label:(null===lt||void 0===lt?void 0:lt.cancelled)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"})]}),(0,ve.jsx)(S.A,{value:sr,onChange:lr,onDebouncedChange:cr,sx:{width:{xs:"100%",custom1000:275},m:0}})]}),(0,ve.jsx)(I.A,{content:!1,children:(0,ve.jsx)(J.A,{ref:c,onScroll:e=>{const{scrollTop:r,scrollHeight:t,clientHeight:n}=e.currentTarget;r+n>=t-50&&mt&&!vt&&jt()},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,ve.jsxs)($.A,{stickyHeader:!0,children:[(0,ve.jsx)(ee.A,{children:(0,ve.jsxs)(re.A,{children:["created"==Le&&(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:(0,ve.jsx)(ne.A,{indeterminate:Sr.length>0&&Sr.length!==(null===yt||void 0===yt?void 0:yt.length),checked:Sr.length===(null===yt||void 0===yt?void 0:yt.length),onChange:e=>{var r;if(!be)return(0,z.k)("Please select a location first!","warning",2e3),void(null===(r=fe.current)||void 0===r||r.focus());if(e.target.checked){const e=null===yt||void 0===yt?void 0:yt.map(((e,r)=>(0,n.A)((0,n.A)({},e),{},{sno:r+1})));Wr(e)}else Wr([])}})}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["#"," "]}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Tenant"," "]}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","Location"]}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","Pickup"," "]}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","Drop"," "]}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","QTY"," "]}),(0,ve.jsx)(te.A,{align:"right",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"COD"}),(0,ve.jsx)(te.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"KMS"}),(0,ve.jsx)(te.A,{align:"right",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Charges"}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:[" ","Notes"," "]}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["status"," "]}),"created"==Le&&(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Actions"})]})}),(0,ve.jsxs)(ie.A,{children:[0===(null===yt||void 0===yt?void 0:yt.length)&&!pt&&(0,ve.jsx)(re.A,{children:(0,ve.jsx)(te.A,{colSpan:13,children:(0,ve.jsx)(H.A,{width:"100%",direction:"row",justifyContent:"center",children:(0,ve.jsx)(a.A,{description:"No ".concat(Le," Orders"),styles:{description:{color:e.palette.error.main}}})})})}),pt&&(0,ve.jsx)(D.r,{col:8}),null===yt||void 0===yt?void 0:yt.map(((r,t)=>{const i=!!Sr.find((e=>e.orderheaderid===r.orderheaderid));return(0,ve.jsxs)(re.A,{role:"checkbox",tabIndex:-1,sx:{cursor:"pointer",backgroundColor:i?"#e1bee7":"","&:hover":{backgroundColor:i?"#e1bee7 !important":""}},children:["created"===Le&&(0,ve.jsx)(te.A,{children:(0,ve.jsx)(ne.A,{sx:{backgroundColor:i?"#e1bee7":"","&:hover":{backgroundColor:i?"#e1bee7 !important":""}},onChange:e=>{var t;if(!be)return(0,z.k)("Please select a location first!","warning",2e3),void(null===(t=fe.current)||void 0===t||t.focus());e.target.checked?Wr((e=>[...e,(0,n.A)((0,n.A)({},r),{},{sno:e.length+1})])):Wr((e=>e.filter((e=>e.orderheaderid!==r.orderheaderid)).map(((e,r)=>(0,n.A)((0,n.A)({},e),{},{sno:r+1})))))},checked:i})}),(0,ve.jsx)(te.A,{children:(0,ve.jsx)(Q.A,{children:100*Je+t+1})}),(0,ve.jsx)(te.A,{children:(0,ve.jsxs)(oe.A,{title:r.tenantaddress,children:[(0,ve.jsx)(Q.A,{variant:"subtitle1",noWrap:!0,children:r.tenantname}),(0,ve.jsxs)(Q.A,{noWrap:!0,variant:"body2",children:[r.tenantsuburb,(0,ve.jsx)("br",{})]}),(0,ve.jsx)(Q.A,{noWrap:!0,variant:"body2",children:r.applocation})]})}),(0,ve.jsxs)(te.A,{align:"left",children:[(0,ve.jsx)(Q.A,{variant:"subtitle1",noWrap:!0,children:"".concat(r.locationname,"-(").concat(r.locationsuburb,")")}),(0,ve.jsx)(oe.A,{title:"TenantId - OrderId",children:(0,ve.jsx)(Q.A,{variant:"body2",noWrap:!0,children:r.orderid})}),(0,ve.jsx)(oe.A,{title:"Pickup Slot",children:(0,ve.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,ve.jsx)(te.A,{align:"left",children:(0,ve.jsxs)(H.A,{direction:"column",children:[(0,ve.jsx)(Q.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:r.pickupcustomer}),(0,ve.jsx)(Q.A,{variant:"caption",children:r.pickupcontactno}),(0,ve.jsx)(oe.A,{title:r.pickupaddress,children:(0,ve.jsx)(Q.A,{variant:"caption",children:"".concat(r.pickupsuburb||r.pickupaddress.slice(0,12)+".....")})})]})}),(0,ve.jsx)(te.A,{align:"left",children:(0,ve.jsxs)(H.A,{direction:"column",children:[(0,ve.jsx)(Q.A,{variant:"subtitle1",sx:{maxWidth:120,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.deliverycustomer}),(0,ve.jsx)(Q.A,{variant:"caption",children:r.deliverycontactno}),(0,ve.jsx)(oe.A,{title:r.deliveryaddress,sx:{whiteSpace:"nowrap"},children:(0,ve.jsx)(Q.A,{variant:"caption",children:"".concat(r.deliverysuburb||r.deliveryaddress.slice(0,12)+".....")})})]})}),(0,ve.jsx)(te.A,{align:"center",children:r.quantity?(0,ve.jsx)(Q.A,{variant:"subtitle1",color:"error",sx:{whiteSpace:"nowrap"},children:r.quantity}):(0,ve.jsx)(Q.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:r.quantity})}),(0,ve.jsx)(te.A,{align:"right",children:r.collectionamt?(0,ve.jsxs)(Q.A,{variant:"subtitle1",color:r.collectionamt?"error":null,sx:{whiteSpace:"nowrap"},children:["\u20b9",r.collectionamt.toFixed(2)]}):(0,ve.jsxs)(Q.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:["\u20b9",r.collectionamt.toFixed(2)]})}),(0,ve.jsx)(te.A,{align:"center",children:(0,ve.jsx)(Q.A,{variant:"subtitle1",color:r.kms?"error":null,children:r.kms})}),(0,ve.jsx)(te.A,{align:"right",children:r.deliverycharge?(0,ve.jsxs)(Q.A,{variant:"subtitle1",color:r.deliverycharge?"error":null,sx:{whiteSpace:"nowrap"},children:["\u20b9",r.deliverycharge.toFixed(2)]}):(0,ve.jsxs)(Q.A,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:["\u20b9",r.deliverycharge.toFixed(2)]})}),(0,ve.jsx)(te.A,{align:"left",children:(0,ve.jsx)(Q.A,{variant:"body1",fontSize:"12px",sx:{maxWidth:120,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.ordernotes})}),(0,ve.jsx)(te.A,{align:"left",children:(0,ve.jsx)(K.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,ve.jsx)(te.A,{align:"center",children:(0,ve.jsxs)(H.A,{flexDirection:"row",justifyContent:"end",children:["C"===r.deliverytype&&(0,ve.jsx)(oe.A,{title:"Product details",children:(0,ve.jsx)(se.A,{color:"primary",onClick:()=>{(null===er||void 0===er?void 0:er.orderid)===r.orderid?rr(null):rr(r)},children:(null===er||void 0===er?void 0:er.orderid)===r.orderid?(0,ve.jsx)(f.A,{}):(0,ve.jsx)(y.A,{})})}),(0,ve.jsx)(oe.A,{title:"To Cancel",children:(0,ve.jsx)(se.A,{"aria-describedby":"aria-".concat(r.sno),disabled:i,onClick:()=>{Ne(!0),Xe(r.orderheaderid)},children:(0,ve.jsx)(g.A,{style:{color:i?e.palette.secondary.main:e.palette.error.main}})})})]})})]},r.sno)})),0!=(null===yt||void 0===yt?void 0:yt.length)&&(0,ve.jsx)(re.A,{children:(0,ve.jsx)(te.A,{colSpan:15,rowSpan:3,children:(0,ve.jsx)("div",{ref:t,style:{height:40,textAlign:"center"},children:vt||mt?(0,ve.jsx)(Ae.A,{}):"No More Orders"})})})]})]})})}),(0,ve.jsxs)(le.A,{fullScreen:!0,open:_e,TransitionComponent:j.s,children:[(0,ve.jsx)(T.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:dr,children:(0,ve.jsx)(m.A,{color:"inherit",text:"Optimising ... .."})}),(0,ve.jsx)(ae.A,{sx:{bgcolor:e.palette.primary.lighter},children:(0,ve.jsx)(L.A,{badgeContent:null===Sr||void 0===Sr?void 0:Sr.length,color:"primary",children:(0,ve.jsx)(K.A,{label:(0,ve.jsx)(Q.A,{variant:"h3",children:"Preview Orders "}),variant:"contained"})})}),(0,ve.jsx)(ce.A,{dividers:!0,children:(0,ve.jsx)(I.A,{content:!1,children:(0,ve.jsx)(J.A,{children:(0,ve.jsxs)($.A,{stickyHeader:!0,children:[(0,ve.jsx)(ee.A,{children:(0,ve.jsxs)(re.A,{children:[(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"#"}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Tenant"," "]}),(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"order Location"}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:["Pickup"," "]}),(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Delivery"}),(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Notes"}),(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"Charges"}),(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.lighter},children:"KMS"})]})}),(0,ve.jsx)(ie.A,{children:Sr.map(((e,r)=>(0,ve.jsx)(i.Fragment,{children:(0,ve.jsxs)(re.A,{sx:{},children:[(0,ve.jsx)(te.A,{children:(0,ve.jsxs)(Q.A,{children:[" ",e.sno]})}),(0,ve.jsx)(te.A,{children:(0,ve.jsxs)(oe.A,{title:e.tenantaddress,children:[(0,ve.jsx)(Q.A,{variant:"body1",noWrap:!0,children:e.tenantname}),(0,ve.jsxs)(Q.A,{noWrap:!0,sx:{fontSize:"11px"},children:[e.tenantsuburb,(0,ve.jsx)("br",{})]}),(0,ve.jsx)(Q.A,{noWrap:!0,variant:"body2",children:e.applocation})]})}),(0,ve.jsxs)(te.A,{align:"left",children:[(0,ve.jsx)(oe.A,{title:e.locationaddress,placement:"top",children:(0,ve.jsx)(Q.A,{variant:"body1",noWrap:!0,children:"".concat(e.locationname,"-(").concat(e.locationsuburb,")")})}),(0,ve.jsx)(oe.A,{title:"Order Id",children:(0,ve.jsx)(Q.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,ve.jsxs)(H.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,ve.jsxs)(oe.A,{title:"Ordered date",children:[(0,ve.jsx)(Q.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.orderdate).utc().format("DD/MM/YYYY")}),(0,ve.jsx)(Q.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.orderdate).utc().format("hh:mm A")})]}),"-",(0,ve.jsxs)(oe.A,{title:"Delivery date",children:[(0,ve.jsx)(Q.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.deliverydate).utc().format("DD/MM/YYYY")}),(0,ve.jsx)(Q.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.deliverydate).utc().format("hh:mm A")})]})]})]}),(0,ve.jsx)(te.A,{align:"left",children:(0,ve.jsx)(H.A,{direction:"row",spacing:1,children:(0,ve.jsxs)(H.A,{direction:"column",children:[(0,ve.jsx)(Q.A,{variant:"caption",children:e.pickupcustomer}),(0,ve.jsx)(Q.A,{variant:"caption",children:e.pickupcontactno}),(0,ve.jsx)(oe.A,{title:e.pickupaddress,children:(0,ve.jsx)(Q.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,ve.jsx)(te.A,{align:"left",children:(0,ve.jsx)(H.A,{direction:"row",spacing:1,children:(0,ve.jsxs)(H.A,{direction:"column",children:[(0,ve.jsx)(Q.A,{variant:"caption",children:e.deliverycustomer}),(0,ve.jsx)(Q.A,{variant:"caption",children:e.deliverycontactno}),(0,ve.jsx)(oe.A,{title:e.deliveryaddress,children:(0,ve.jsx)(Q.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,ve.jsx)(te.A,{align:"left",children:e.ordernotes}),(0,ve.jsxs)(te.A,{align:"left",children:["\u20b9 ",e.deliverycharge.toFixed(2)]}),(0,ve.jsx)(te.A,{align:"left",children:e.kms})]})},r)))})]})})})}),(0,ve.jsx)(de.A,{sx:{bgcolor:e.palette.secondary.light},children:(0,ve.jsx)(N.Ay,{container:!0,sx:{},children:(0,ve.jsx)(N.Ay,{item:!0,xs:12,children:(0,ve.jsxs)(H.A,{sx:{mt:2,mr:2},direction:"row",justifyContent:"flex-end",flexWrap:"wrap",gap:2,spacing:5,children:[(0,ve.jsx)(xe.A,{sx:{width:"130px"},color:"secondary",variant:"contained",onClick:()=>{zt()},startIcon:(0,ve.jsx)(g.A,{}),children:"Close"}),1==qr.current&&(0,ve.jsx)(G.A,{options:[{label:"Bike",value:1},{label:"Auto",value:2}],getOptionLabel:e=>e.label,value:Rr,onChange:(e,r)=>{Nr(r),console.log("Selected value:",null===r||void 0===r?void 0:r.value)},renderInput:e=>(0,ve.jsx)(U.A,(0,n.A)((0,n.A)({sx:{width:200,border:"1px solid ",borderColor:"primary.main"}},e),{},{placeholder:"Select Transport"})),isOptionEqualToValue:(e,r)=>e.value===r.value}),1==qr.current&&(0,ve.jsx)(G.A,{multiple:!0,fullWidth:!1,options:ot||[],loading:st,disableCloseOnSelect:!0,limitTags:2,value:_r,onChange:(e,r)=>Hr(r),getOptionLabel:e=>"".concat(e.firstname||""," ").concat(e.lastname||"").trim()||"Rider #".concat(e.userid),isOptionEqualToValue:(e,r)=>e.userid===r.userid,PaperComponent:e=>(0,ve.jsx)(he.A,(0,n.A)((0,n.A)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:"0 14px 40px rgba(15, 23, 42, 0.18)",border:"1px solid",borderColor:"divider",overflow:"hidden"}})),ListboxProps:{sx:{py:0,maxHeight:340}},noOptionsText:(0,ve.jsxs)(H.A,{alignItems:"center",py:2,spacing:1,children:[(0,ve.jsx)(k.vbW,{size:26,color:"#94a3b8"}),(0,ve.jsx)(Q.A,{variant:"caption",color:"text.secondary",children:"No riders to show for this location"})]}),renderTags:(e,r)=>e.map(((e,t)=>{const o="".concat(e.firstname||""," ").concat(e.lastname||"").trim()||"Rider #".concat(e.userid),s=(o.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()||"?",l=r({index:t});return(0,i.createElement)(K.A,(0,n.A)((0,n.A)({},l),{},{key:e.userid,size:"small",avatar:(0,ve.jsx)(B.A,{sx:{bgcolor:"#fed7aa",color:"#9a3412",fontSize:10,fontWeight:800},children:s}),label:o,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:o}=t;const s="".concat(r.firstname||""," ").concat(r.lastname||"").trim(),l=(s.match(/\b\w/g)||[]).slice(0,2).join("").toUpperCase()||"?";return(0,i.createElement)("li",(0,n.A)((0,n.A)({},e),{},{key:r.userid,style:{display:"flex",alignItems:"center",gap:12,padding:"8px 12px",borderBottom:"1px solid #f1f5f9",backgroundColor:o?"#fff7ed":"transparent"}}),(0,ve.jsx)(ne.A,{size:"small",checked:o,sx:{p:.5,color:"#fb923c","&.Mui-checked":{color:"#ea580c"}}}),(0,ve.jsx)(B.A,{sx:{width:34,height:34,bgcolor:o?"#fb923c":"#f1f5f9",color:o?"#fff":"#475569",fontSize:12,fontWeight:800,transition:"background-color 0.15s, color 0.15s"},children:l}),(0,ve.jsxs)(H.A,{direction:"column",spacing:0,flex:1,minWidth:0,children:[(0,ve.jsx)(Q.A,{variant:"body2",fontWeight:700,color:"#0f172a",noWrap:!0,children:s||"Rider #".concat(r.userid)}),(0,ve.jsxs)(Q.A,{variant:"caption",color:"text.secondary",noWrap:!0,children:["ID #",r.userid,r.contactno?" \xb7 ".concat(r.contactno):""]})]}),o&&(0,ve.jsx)(K.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,ve.jsx)(U.A,(0,n.A)((0,n.A)({},e),{},{label:"Absent Riders",placeholder:_r.length?"":"Pick riders unavailable today",InputLabelProps:{shrink:!0},InputProps:(0,n.A)((0,n.A)({},e.InputProps),{},{startAdornment:(0,ve.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25},children:[(0,ve.jsx)(k.ihY,{size:18,color:"#ea580c"}),_r.length>0&&(0,ve.jsx)(K.A,{size:"small",label:_r.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,ve.jsx)(xe.A,{color:"primary",disabled:!Rr&&1==qr.current,variant:"contained",startIcon:1==qr.current&&(0,ve.jsx)("img",{src:M,alt:"Assign",style:{width:32,height:32,objectFit:"contain",borderRadius:50}}),onClick:()=>{xr(!0),Wt()},children:Se?"Optimising...":0==qr.current?"Optimise Orders":"AI Optimise Orders"})]})})})})]}),(0,ve.jsxs)(le.A,{fullScreen:!0,open:br,TransitionComponent:j.s,children:[(0,ve.jsx)(ae.A,{children:(0,ve.jsx)(H.A,{children:(0,ve.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:1,sx:{ml:1},children:[(0,ve.jsx)(oe.A,{title:"Back to orders",placement:"top",children:(0,ve.jsx)(se.A,{onClick:()=>kr(!1),sx:{backgroundColor:"action.hover",color:"text.primary","&:hover":{backgroundColor:"action.selected"}},children:(0,ve.jsx)(F.eQE,{size:22})})}),(0,ve.jsx)(Q.A,{sx:{m:2},variant:"h3",children:"Assign Orders"})]})})}),(0,ve.jsx)(ue.A,{}),(0,ve.jsx)(ce.A,{children:(0,ve.jsxs)(I.A,{content:!1,children:[(it||st||hr)&&(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(v.A,{}),(0,ve.jsx)(m.A,{})]}),(0,ve.jsx)(T.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:it||st||hr,children:(0,ve.jsx)(m.A,{color:"inherit"})}),(0,ve.jsx)(J.A,{children:(0,ve.jsxs)($.A,{stickyHeader:!0,children:[(0,ve.jsx)(ee.A,{children:(0,ve.jsxs)(re.A,{sx:{backgroundColor:"red"},children:[(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"#"}),1==Fr&&(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Zone"," "]}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Tenant"," "]}),(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"order Location"}),(0,ve.jsxs)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:["Pickup"," "]}),(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Delivery"}),(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Notes"}),1==Fr&&(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Rider"}),(0,ve.jsx)(te.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Type"}),(0,ve.jsx)(te.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Charges"}),(0,ve.jsx)(te.A,{align:"center",sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"KMS"})]})}),(0,ve.jsxs)(ie.A,{children:[0==(null===Er||void 0===Er?void 0:Er.length)&&(0,ve.jsx)(re.A,{children:(0,ve.jsx)(te.A,{colSpan:10,children:(0,ve.jsx)(a.A,{})})}),null===Er||void 0===Er?void 0:Er.map(((e,r)=>(0,ve.jsxs)(re.A,{sx:{},children:[(0,ve.jsx)(te.A,{children:(0,ve.jsxs)(Q.A,{children:[" ",r+1]})}),(0,ve.jsx)(te.A,{children:(0,ve.jsxs)(oe.A,{title:e.tenantaddress,children:[(0,ve.jsx)(Q.A,{variant:"body1",noWrap:!0,children:e.tenantname}),(0,ve.jsxs)(Q.A,{noWrap:!0,sx:{fontSize:"11px"},children:[e.tenantsuburb,(0,ve.jsx)("br",{})]}),(0,ve.jsx)(Q.A,{noWrap:!0,variant:"body2",children:e.applocation})]})}),(0,ve.jsxs)(te.A,{align:"left",children:[(0,ve.jsx)(oe.A,{title:e.locationaddress,placement:"top",children:(0,ve.jsx)(Q.A,{variant:"body1",noWrap:!0,children:"".concat(e.locationname,"-(").concat(e.locationsuburb,")")})}),(0,ve.jsx)(oe.A,{title:"Order Id",children:(0,ve.jsx)(Q.A,{variant:"body2",noWrap:!0,children:e.orderid})}),(0,ve.jsxs)(H.A,{display:"flex",flexDirection:"row",gap:3,children:[(0,ve.jsxs)(oe.A,{title:"Ordered date",children:[(0,ve.jsx)(Q.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.orderdate).utc().format("DD/MM/YYYY")}),(0,ve.jsx)(Q.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.orderdate).utc().format("hh:mm A")})]}),"-",(0,ve.jsxs)(oe.A,{title:"Delivery date",children:[(0,ve.jsx)(Q.A,{noWrap:!0,sx:{fontSize:"12px"},children:d()(e.deliverydate).utc().format("DD/MM/YYYY")}),(0,ve.jsx)(Q.A,{noWrap:!0,sx:{fontSize:"11px"},children:d()(e.deliverydate).utc().format("hh:mm A")})]})]})]}),(0,ve.jsx)(te.A,{align:"left",children:(0,ve.jsx)(H.A,{direction:"row",spacing:1,children:(0,ve.jsxs)(H.A,{direction:"column",children:[(0,ve.jsx)(Q.A,{variant:"caption",children:e.pickupcustomer}),(0,ve.jsx)(Q.A,{variant:"caption",children:e.pickupcontactno}),(0,ve.jsx)(oe.A,{title:e.pickupaddress,children:(0,ve.jsx)(Q.A,{variant:"caption",children:e.pickupsuburb||e.pickupaddress.slice(0,20)})})]})})}),(0,ve.jsx)(te.A,{align:"left",children:(0,ve.jsx)(H.A,{direction:"row",spacing:1,children:(0,ve.jsxs)(H.A,{direction:"column",children:[(0,ve.jsx)(Q.A,{variant:"caption",children:e.deliverycustomer}),(0,ve.jsx)(Q.A,{variant:"caption",children:e.deliverycontactno}),(0,ve.jsx)(oe.A,{title:e.deliveryaddress,children:(0,ve.jsx)(Q.A,{variant:"caption",children:e.deliverysuburb||e.deliveryaddress.slice(0,20)})})]})})}),(0,ve.jsx)(te.A,{align:"left",children:e.ordernotes}),(0,ve.jsx)(te.A,{align:"center",children:(0,ve.jsx)(K.A,{size:"small",label:e.ordertype,color:"Economy"==e.ordertype?"success":"Risky"==e.ordertype?"error":"primary",variant:"light"})}),(0,ve.jsx)(te.A,{align:"center",children:(0,ve.jsxs)(H.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,ve.jsx)(oe.A,{title:"Charges",placement:"top",children:(0,ve.jsx)(K.A,{size:"small",label:"\u20b9 ".concat(e.deliverycharge.toFixed(2)," "),color:"error",variant:"light"})}),(0,ve.jsx)(oe.A,{title:"Amount",placement:"left",children:(0,ve.jsx)(K.A,{size:"small",label:"\u20b9 ".concat(e.deliveryamt.toFixed(2)," "),color:"success",variant:"light"})})]})}),(0,ve.jsx)(te.A,{align:"center",children:(0,ve.jsxs)(H.A,{display:"flex",flexDirection:"column",gap:1,sx:{cursor:"pointer"},children:[(0,ve.jsx)(oe.A,{title:"KMS",placement:"top",children:(0,ve.jsx)(K.A,{size:"small",label:"".concat(e.kms," km"),color:"error",variant:"light"})}),(0,ve.jsx)(oe.A,{title:"Cumulative Kms",placement:"right",children:(0,ve.jsx)(K.A,{size:"small",label:"".concat(e.cumulativekms," km"),color:"success",variant:"light"})})]})})]},r)))]})]})}),(0,ve.jsx)(ue.A,{})]})}),(0,ve.jsx)(ue.A,{}),(0,ve.jsxs)(de.A,{sx:{flexDirection:"column",alignItems:"stretch",p:2,gap:2},children:[(0,ve.jsxs)(N.Ay,{container:!0,spacing:2,children:[(0,ve.jsx)(N.Ay,{item:!0,xs:12,sm:6,children:(0,ve.jsx)(G.A,{options:nt,fullWidth:!0,renderInput:e=>(0,ve.jsx)(U.A,(0,n.A)((0,n.A)({},e),{},{label:"Choose Payment"})),onChange:(e,r,t)=>{if("clear"!==t){if(r){Ve(r);const e=null===Er||void 0===Er?void 0:Er.map((e=>(0,n.A)((0,n.A)({},e),{},{paymenttype:r.apptypeid||42})));Lr(e)}}else Ve(null)}})}),(0,ve.jsx)(N.Ay,{item:!0,xs:12,sm:6,children:(0,ve.jsx)(G.A,{options:ot,fullWidth:!0,renderInput:e=>(0,ve.jsx)(U.A,(0,n.A)((0,n.A)({},e),{},{label:"Choose Rider"})),onChange:(e,r,t)=>{if("clear"!==t){if(r){Ge(r);const e=null===Er||void 0===Er?void 0:Er.map((e=>(0,n.A)((0,n.A)({},e),{},{userid:r.userid,fuelcharge:r.fuelcharge||0,userfcmtoken:r.userfcmtoken})));Lr(e)}}else Ge(null)}})})]}),(0,ve.jsxs)(H.A,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{pt:1,my:2},children:[(0,ve.jsx)(xe.A,{variant:"outlined",color:"secondary",startIcon:(0,ve.jsx)(Y.A,{}),onClick:()=>kr(!1),children:"Back"}),(0,ve.jsx)(xe.A,{variant:"contained",disabled:!Qe||!Ue,onClick:()=>{null!==Er&&void 0!==Er&&Er.length?kt.mutate({deliveries:Er}):(0,z.k)("No deliveries selected","error",3e3)},children:"Assign Orders"})]})]})]}),(0,ve.jsxs)(le.A,{open:fr,fullScreen:!0,TransitionComponent:j.s,PaperProps:{sx:{display:"flex",flexDirection:"column",overflow:"hidden"}},children:[(0,ve.jsx)(T.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:hr,children:(0,ve.jsx)(m.A,{color:"inherit"})}),(0,ve.jsx)(ae.A,{sx:{py:1.25},children:(0,ve.jsxs)(H.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{},children:[(0,ve.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,ve.jsx)(oe.A,{title:"Back to orders",placement:"top",children:(0,ve.jsx)(se.A,{onClick:()=>r("/nearle/orders"),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},children:(0,ve.jsx)(F.eQE,{size:20})})}),(0,ve.jsx)(Q.A,{variant:"h3",fontWeight:600,children:"Assign Orders"})]}),(0,ve.jsxs)(H.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,ve.jsx)(G.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,ve.jsx)(U.A,(0,n.A)((0,n.A)({},e),{},{label:"Hyper Tuning"})),onChange:(e,r,t)=>{"clear"===t?Wt(null):(console.log("val",r),Wt(r.value))}}),(0,ve.jsx)(xe.A,{variant:"contained",color:"primary",startIcon:(0,ve.jsx)(P.UF6,{}),onClick:()=>{ur(!0),Wt("reshuffle")},children:"Re-Assign"}),(0,ve.jsx)(je.Ay,{data:Pr,filename:"Orders_Detail_".concat(d()().format("YYYY-MM-DD_HHmmss"),".csv"),label:" CSV",style:{m:1}})]})]})}),(0,ve.jsx)(ce.A,{sx:{p:0,display:"flex",flexDirection:"column",overflow:"hidden",flex:1},children:Cr&&(0,ve.jsx)(me.default,{data:Cr,embedded:!0})}),(0,ve.jsx)(de.A,{sx:{px:2,py:1.25},children:(0,ve.jsxs)(H.A,{direction:"row",gap:2,alignItems:"center",justifyContent:"end",children:[(0,ve.jsx)(xe.A,{variant:"contained",color:"secondary",startIcon:(0,ve.jsx)(Y.A,{}),onClick:()=>{yr(!1)},children:"Back"}),(0,ve.jsx)(xe.A,{variant:"contained",onClick:async()=>{ur(!0),It.mutate({deliveries:Er})},children:"Assign Orders"})]})})]}),(0,ve.jsx)(le.A,{open:Re,onClose:()=>handleClose(),maxWidth:"xs",children:(0,ve.jsx)(ce.A,{sx:{mt:2,my:1},children:(0,ve.jsxs)(H.A,{alignItems:"center",spacing:3.5,children:[(0,ve.jsx)(B.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,ve.jsx)(l.A,{})}),(0,ve.jsx)(H.A,{spacing:2,children:(0,ve.jsx)(Q.A,{variant:"h4",align:"center",children:"Are you sure you want to cancel this order?"})}),(0,ve.jsxs)(H.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,ve.jsx)(xe.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{Ct.mutate(Ze)},autoFocus:!0,children:"Yes, Cancel"}),(0,ve.jsx)(xe.A,{fullWidth:!0,onClick:()=>{Ne(!1)},color:"secondary",variant:"outlined",children:"No"})]})]})})}),(0,ve.jsx)(le.A,{open:Ke,onClose:()=>Be(!1),maxWidth:"xs",children:(0,ve.jsx)(ce.A,{sx:{mt:2,my:1},children:(0,ve.jsxs)(H.A,{alignItems:"center",spacing:3.5,children:[(0,ve.jsx)(B.A,{color:"error",sx:{width:72,height:72,fontSize:"1.75rem"},children:(0,ve.jsx)(l.A,{})}),(0,ve.jsx)(H.A,{spacing:2,children:(0,ve.jsx)(Q.A,{variant:"h4",align:"center",children:"Are you sure, you want to cancel multiple orders?"})}),(0,ve.jsxs)(H.A,{direction:"row",spacing:2,sx:{width:1},children:[(0,ve.jsx)(xe.A,{fullWidth:!0,onClick:()=>{Be(!1)},color:"secondary",variant:"outlined",children:"No"}),(0,ve.jsx)(xe.A,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{wt.mutate(Sr)},autoFocus:!0,children:"Yes, Cancel"})]})]})})})]})}},96646:(e,r,t)=>{t.d(r,{r:()=>a});var n=t(9213),i=t(21671),o=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)(n.A,{children:[(0,l.jsx)(i.A,{children:(0,l.jsx)(o.A,{variant:"circular",width:24,height:24})}),(0,l.jsx)(i.A,{children:(0,l.jsx)(o.A,{variant:"text",width:30})}),Array.from({length:t}).map(((e,r)=>(0,l.jsx)(i.A,{children:(0,l.jsxs)(s.A,{spacing:.5,children:[(0,l.jsx)(o.A,{variant:"text",width:100}),(0,l.jsx)(o.A,{variant:"text",width:80})]})},r))),(0,l.jsx)(i.A,{children:(0,l.jsx)(o.A,{variant:"text",width:150})}),(0,l.jsx)(i.A,{children:(0,l.jsx)(o.A,{variant:"rounded",width:60,height:24})}),(0,l.jsx)(i.A,{align:"center",children:(0,l.jsxs)(s.A,{direction:"row",spacing:1,justifyContent:"flex-end",children:[(0,l.jsx)(o.A,{variant:"circular",width:28,height:28}),(0,l.jsx)(o.A,{variant:"circular",width:28,height:28})]})})]},r)))})}}}]); |