1 line
48 KiB
JavaScript
1 line
48 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]})})}},35678:(e,r,t)=>{t.d(r,{A:()=>y});var n=t(9950),i=t(96583),o=t(40033),s=t(82053),l=t(28170),a=t(93230),c=t(82223),d=t(55916),x=t(4159),u=t.n(x),h=t(56712),p=t(81417),A=t(96600),g=t(53132),j=t(94289),m=t(57326),v=t(50624),f=t(44414);const y=e=>{let{open:r,onClose:t,onSelect:x}=e;const[y,b]=(0,n.useState)(null);return(0,f.jsxs)(i.A,{open:r,onClose:t,children:[(0,f.jsx)(o.A,{align:"left",children:(0,f.jsx)(s.A,{variant:"h4",children:"Select Filter Options"})}),(0,f.jsx)(l.A,{sx:{width:"100%"},className:"datedialog",children:(0,f.jsx)(d.U,{open:r,toggle:t,id:"daterange1",onChange:e=>{b({startDate:u()(e.startDate).format("YYYY-MM-DD"),endDate:u()(e.endDate).format("YYYY-MM-DD"),label:e.label||"custom"})},definedRanges:[{label:"Today",startDate:new Date,endDate:new Date},{label:"Yesterday",startDate:(0,h.A)(new Date,-1),endDate:(0,h.A)(new Date,-1)},{label:"Tomorrow",startDate:(0,h.A)(new Date,1),endDate:(0,h.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,j.A)(new Date),endDate:(0,m.A)(new Date)},{label:"Last Month",startDate:(0,j.A)((0,v.A)(new Date,-1)),endDate:(0,m.A)((0,v.A)(new Date,-1))}]})}),(0,f.jsx)(a.A,{direction:"row",justifyContent:"flex-end",sx:{width:"100%",p:2},children:(0,f.jsx)(c.A,{variant:"contained",size:"small",onClick:()=>{y?(x(y),t()):t()},children:"OK"})})]})}},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:u}=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)"}},u),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})})]})]})})}},56311:(e,r,t)=>{t.d(r,{A:()=>h});var n=t(89379),i=t(9950),o=t(2660),s=t(2046),l=t(83274),a=t(25333),c=t(97125),d=t(7762),x=t(52097),u=t(44414);const h=e=>{let{value:r,onChange:t,onDebouncedChange:h,debounceTime:p=500,placeholder:A="Search (ctrl+k)",sx:g}=e;const j=(0,i.useRef)(null),[m]=(0,x.d7)(r,p);return(0,i.useEffect)((()=>{h&&h(m)}),[m,h]),(0,i.useEffect)((()=>{const e=e=>{var r;"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),null===(r=j.current)||void 0===r||r.focus());"Escape"===e.key&&document.activeElement===j.current&&j.current.blur()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[]),(0,u.jsx)(o.A,{sx:(0,n.A)({},g),inputRef:j,placeholder:A,autoComplete:"off",value:r,fullWidth:!0,onChange:e=>t(e.target.value),startAdornment:(0,u.jsx)(s.A,{position:"start",sx:{mr:-.5},children:(0,u.jsx)(c.A,{})}),endAdornment:(0,u.jsx)(l.A,{title:"Clear",children:(0,u.jsx)(a.A,{sx:{visibility:r?"visible":"hidden"},onClick:()=>t(""),children:(0,u.jsx)(d.A,{})})})})}},58691:(e,r,t)=>{t.d(r,{A:()=>l});t(9950);var n=t(16491),i=t(46639),o=t(62217),s=t(44414);function l(e){let{size:r=70,imgSize:t=40,alt:l="loader"}=e;return(0,s.jsxs)(n.A,{position:"relative",display:"inline-flex",justifyContent:"center",alignItems:"center",children:[(0,s.jsx)(i.A,{size:r}),(0,s.jsx)(n.A,{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",sx:{width:t,height:t},children:(0,s.jsx)("img",{src:o,alt:l,style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"contain"}})})]})}},59212:(e,r,t)=>{t.d(r,{A:()=>c});var n=t(89379),i=t(9950),o=t(77922),s=t(29925),l=t(26910),a=t(44414);const c=(0,i.forwardRef)(((e,r)=>{let{setAppId:t,setLocoName:c,setPage:d,sx:x,textfeildSx:u}=e;const[h,p]=(0,i.useState)(JSON.parse(localStorage.getItem("applocations")||"[]"));return(0,i.useEffect)((()=>{0===h.length&&(async()=>{try{const e=localStorage.getItem("userid");if(!e)return;const r=await l.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)),p(e)}}catch(e){console.error("Error fetching locations in LocationAutocomplete:",e)}})()}),[h.length]),(0,a.jsx)(o.A,{id:"location-autocomplete",options:h||[],getOptionLabel:e=>{var r;return null!==(r=null===e||void 0===e?void 0:e.locationname)&&void 0!==r?r:""},sx:(0,n.A)({},x),onChange:(e,r,n)=>{"clear"===n?(null===t||void 0===t||t(0),null===c||void 0===c||c(""),null===d||void 0===d||d(0)):r&&(null===t||void 0===t||t(r.applocationid),null===c||void 0===c||c(r.locationname),null===d||void 0===d||d(0))},renderInput:e=>(0,a.jsx)(s.A,(0,n.A)((0,n.A)({},e),{},{inputRef:r,label:"Select Zones",sx:(0,n.A)({},u)}))})}))},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),u=t(60010),h=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),w=t(8951),C=t(35678),S=t(56311),D=t(1367),I=t(50027),W=t(20466),z=t(96646),M=t(59212);const Y=t.p+"static/media/aiImage.89c2ccb91a41d85031e3.png";var O=t(63189),F=t(99324),P=t(6604),E=t(55158),T=t(59382),R=t(28810),L=t(79046),N=t(33092),q=t(60899),_=t(82917),H=t(93230),K=t(25277),B=t(41413),Q=t(82053),U=t(77922),Z=t(29925),G=t(48159),V=t(47223),J=t(84142),X=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),ue=t(2235),he=t(74745),pe=t(81425),Ae=t(58691),ge=t(28429),je=t(90376),me=t(54413),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),[we,Ce]=(0,i.useState)("All"),[Se,De]=(0,i.useState)(!1),[Ie,We]=(0,i.useState)(d()().format("YYYY-MM-DD")),[ze,Me]=(0,i.useState)(d()().format("YYYY-MM-DD")),[Ye,Oe]=(0,i.useState)("Today"),[Fe,Pe]=(0,i.useState)(!1),[Ee,Te]=(0,i.useState)(0),[Re,Le]=(0,i.useState)("created"),[Ne,qe]=(0,i.useState)(!1),[_e,He]=(0,i.useState)(!1),[Ke,Be]=(0,i.useState)(!1),[Qe,Ue]=(0,i.useState)(null),[Ze,Ge]=(0,i.useState)(null),[Ve,Je]=(0,i.useState)(""),[Xe,$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),[ur,hr]=(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),[wr,Cr]=(0,i.useState)(null),[Sr,Dr]=(0,i.useState)([]),[Ir,Wr]=(0,i.useState)([]),[zr,Mr]=(0,i.useState)(null),[Yr,Or]=(0,i.useState)(null),[Fr]=(0,i.useState)(0),[Pr,Er]=(0,i.useState)([]),[Tr,Rr]=(0,i.useState)([]),Lr=(0,i.useRef)(0),Nr=(0,i.useRef)(null),[qr,_r]=(0,i.useState)(null),[Hr,Kr]=(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=Tr.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})));Er(e),console.log("csvExportData",e)}),[Tr]),(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})}));Rr(e),console.log("finaldeliveryList",e)}),[Ir]);const{data:Br,isLoading:Qr,isError:Ur,error:Zr,refetch:Gr}=(0,x.I)({queryKey:["percentageData",be],queryFn:()=>(0,pe.jy)(be),enabled:!0}),{data:Vr,isLoading:Jr,isError:Xr,error:$r}=(0,x.I)({queryKey:["tenantlist",be],queryFn:()=>(0,pe.Mn)(be),enabled:0!==be}),{data:et,isLoading:rt,isError:tt,error:nt}=(0,x.I)({queryKey:["gettenantlocations",tr],queryFn:()=>(0,pe.DL)(tr),enabled:0!==tr}),{data:it=[],isLoading:ot}=(0,x.I)({queryKey:["paymentmodes"],queryFn:pe.HY}),{data:st=[],isLoading:lt}=(0,x.I)({queryKey:["ridersList",be],queryFn:pe.Sd,enabled:0!==be}),{data:at,isLoading:ct,isError:dt,error:xt,refetch:ut}=(0,x.I)({queryKey:["ordersCount",be,Ie,ze,Re,tr,ir],queryFn:pe.Hh,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:ht}=(0,x.I)({queryKey:["getallriders"],queryFn:pe.Xw,refetchOnMount:!0,refetchOnWindowFocus:!0}),{data:pt,isLoading:At,isError:gt,error:jt,fetchNextPage:mt,hasNextPage:vt,isFetchingNextPage:ft,refetch:yt}=(0,u.q)({queryKey:["fetchOrders",be,Re,ar,Ie,ze,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}),bt=(null===pt||void 0===pt?void 0:pt.pages.flatMap((e=>e.rows)))||[];(0,i.useEffect)((()=>{if(!vt)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)}}),[vt,mt]);const kt=(0,h.n)({mutationFn:0==Lr.current?pe.FC:pe.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,W.k)("Orders Optimised Successfully","success",2e3),ut(),yt(),De(!1),xr(!1),0==Lr.current)Wr(null===e||void 0===e?void 0:e.details),Mr(null===e||void 0===e?void 0:e.zones),Or(null===e||void 0===e?void 0:e.meta),kr(!0);else{var n,i,o;Wr(null===e||void 0===e?void 0:e.details),Mr(null===e||void 0===e?void 0:e.zones),Or(null===e||void 0===e?void 0:e.meta),Cr(e);const t=Nr.current||{};r("/nearle/dispatch/preview",{state:{dispatchPreviewData:e,aiMode:null!==(n=t.aiMode)&&void 0!==n?n:Lr.current,selectedMode:t.selectedMode||qr,deliveryData:t.deliveryData||[],autoRiders:t.autoRiders||ht||[],absentRidersPayload:t.absentRidersPayload||[],rider:t.rider||Qe,appId:null!==(i=t.appId)&&void 0!==i?i:be,tenantId:null!==(o=t.tenantid)&&void 0!==o?o:tr,startdate:Ie}})}},onError:e=>{(0,W.k)(e.message,"error",4e3),xr(!1),De(!1)},onSettled:()=>{zt(),De(!1),xr(!1),hr(!1)}}),wt=(0,h.n)({mutationFn:pe.H2,onMutate:()=>{hr(!0)},onSuccess:e=>{console.log("create data",e),(0,W.k)("Delivery Created Successfully","success",2e3),r("/nearle/deliveries"),Dt.mutate(null===Qe||void 0===Qe?void 0:Qe.userfcmtoken)},onError:e=>{(0,W.k)(e.message,"error",4e3)},onSettled:()=>{hr(!1)}}),Ct=(0,h.n)({mutationFn:pe.N4,onSuccess:e=>{e.status&&(qe(!1),(0,W.k)("Order Cancelled Successfully","success",2e3),ut(),Gr())},onError:e=>{(0,W.k)(e.message,"error",2e3)}}),St=(0,h.n)({mutationFn:pe.zR,onSuccess:e=>{e.status&&(Be(!1),(0,W.k)("Order Cancelled Successfully","success",2e3),yt(),ut(),Gr(),Dr([]))},onError:e=>{(0,W.k)(e.message,"error",2e3)}}),Dt=(0,h.n)({mutationFn:pe.k3,onSuccess:()=>{(0,W.k)("Notification sent Successfully","success",2e3)},onError:e=>{(0,W.k)(e.message,"error",2e3)}}),It=async e=>{hr(!0),De(!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=(Hr||[]).map((e=>({userid:e.userid,username:"".concat(e.firstname||""," ").concat(e.lastname||"").trim()||e.username||"Rider ".concat(e.userid)})));Nr.current={deliveryData:r,absentRidersPayload:t,autoRiders:ht,selectedMode:qr,aiMode:Lr.current,rider:Qe,appId:be,tenantid:tr},0==Lr.current?kt.mutate({deliveries:r}):qr&&1==(null===qr||void 0===qr?void 0:qr.value)?kt.mutate({deliveries:1==qr.value?r:{body:r},hypertuning_params:e||null,selectedMode:qr,absent_riders:t}):kt.mutate({data:{orders:r,riders:ht,config:{pay_type:"hourly",base_pay:300,strategy:"multi_trip"},absent_riders:t},selectedMode:qr})},Wt=(0,h.n)({mutationFn:pe.H2,onSuccess:(e,t)=>{console.log("data",e),console.log("varialbles",t),(0,W.k)("Delivery Created Successfully","success",2e3),hr(!1),r("/nearle/deliveries")},onError:e=>{(0,W.k)(e.message,"error",4e3)},onSettled:()=>{hr(!1)}}),zt=()=>{He(!1),Ue(null),Ge(null),_r(null),Kr([])},Mt=Ur?"Error fetching percentages: ".concat(null===Zr||void 0===Zr?void 0:Zr.message):dt?"Error fetching orders Count: ".concat(null===xt||void 0===xt?void 0:xt.message):gt?"Error fetching orders : ".concat(null===jt||void 0===jt?void 0:jt.message):Xr?"Error Fetching on Tenants:".concat(null===$r||void 0===$r?void 0:$r.message," "):tt?"Error Fetching on Tenants Locations:".concat(null===nt||void 0===nt?void 0:nt.message," "):null;return(0,i.useEffect)((()=>{Mt&&(console.log(Mt),(0,W.k)(Mt,"error",3e3))}),[Mt]),(0,ve.jsxs)(i.Fragment,{children:[(Qr||ct||At||Jr||rt||dr)&&(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(v.A,{}),(0,ve.jsx)(m.A,{})]}),(0,ve.jsx)(E.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:dr||At,children:(0,ve.jsx)(m.A,{color:"inherit"})}),(0,ve.jsx)(E.A,{sx:{zIndex:1e3},open:mr}),Sr.length>0&&(0,ve.jsxs)(T.A,{ariaLabel:"Actions",icon:(0,ve.jsx)(R.A,{badgeContent:(null===Sr||void 0===Sr?void 0:Sr.length)||"",color:"secondary",children:(0,ve.jsx)(L.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)(N.A,{icon:(0,ve.jsx)("img",{src:Y,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:()=>{Lr.current=1,vr(!1),He(!0)}}),(0,ve.jsx)(N.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:()=>{Lr.current=0,vr(!1),He(!0)}}),(0,ve.jsx)(N.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)(D.A,{title:"Orders",children:(0,ve.jsx)(M.A,{ref:fe,locaName:we,setAppId:ke,setLocoName:Ce,setPage:$e,sx:{width:{xs:"100%",custom450:300},zIndex:"100"}})}),(0,ve.jsx)(q.Ay,{container:!0,spacing:2,sx:{mt:"1px"},children:[{label:"Created orders",value:null===Br||void 0===Br?void 0:Br.created,percentage:null===Br||void 0===Br?void 0:Br.percentage1,color:e.palette.info.main},{label:"Pending orders",value:null===Br||void 0===Br?void 0:Br.uncoveredOrders,percentage:null===Br||void 0===Br?void 0:Br.percentage2,color:e.palette.warning.main},{label:"Delivered orders",value:null===Br||void 0===Br?void 0:Br.coveredOrders,percentage:null===Br||void 0===Br?void 0:Br.percentage3,color:e.palette.success.main},{label:"Cancelled Orders",value:null===Br||void 0===Br?void 0:Br.cancelled,percentage:null===Br||void 0===Br?void 0:Br.percentage4,color:e.palette.error.main}].map(((e,r)=>{var t;return(0,ve.jsx)(q.Ay,{item:!0,xs:12,custom400:6,sm:3,sx:{cursor:"pointer"},children:(0,ve.jsx)(p.A,{primary:e.label,secondary:Qr?(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&&ze?(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)(w.jkt,{fontSize:"20px",style:{color:"red"}}),label:"Orders-".concat(Ye),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()(ze).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:we,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)(U.A,{options:Vr||[],value:pr,sx:{minWidth:250,maxWidth:600,flex:1},onOpen:e=>{be||(e.preventDefault(),(0,W.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)(Z.A,(0,n.A)((0,n.A)({},e),{},{inputRef:ye,label:"Select Tenant"}))}),(0,ve.jsx)(U.A,{options:et||[],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,W.k)("Please select Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=ye.current)||void 0===e||e.focus()}),0)):(e.preventDefault(),(0,W.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)(Z.A,(0,n.A)((0,n.A)({},e),{},{label:"Select Location"}))}),(0,ve.jsx)(C.A,{open:Fe,onClose:()=>Pe(!1),onSelect:e=>{We(e.startDate),Me(e.endDate),Oe(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)(G.A,{value:Ee,onChange:(e,r)=>{$e(0),Te(r),0===r&&Le("created"),1===r&&Le("pending"),2===r&&Le("delivered"),3===r&&Le("cancelled"),lr("")},variant:"scrollable",scrollButtons:!!(0,V.A)(e.breakpoints.down("custom650")),allowScrollButtonsMobile:!0,children:[(0,ve.jsx)(J.A,{label:"Created",icon:(0,ve.jsx)(K.A,{label:(null===at||void 0===at?void 0:at.created)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"}),(0,ve.jsx)(J.A,{label:"Pending",icon:(0,ve.jsx)(K.A,{label:(null===at||void 0===at?void 0:at.pending)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"}),(0,ve.jsx)(J.A,{label:"Delivered",icon:(0,ve.jsx)(K.A,{label:(null===at||void 0===at?void 0:at.delivered)||0,color:"primary",variant:"light",sx:{minWidth:32,justifyContent:"center"},size:"small"}),iconPosition:"end"}),(0,ve.jsx)(J.A,{label:"Cancelled",icon:(0,ve.jsx)(K.A,{label:(null===at||void 0===at?void 0:at.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)(X.A,{ref:c,onScroll:e=>{const{scrollTop:r,scrollHeight:t,clientHeight:n}=e.currentTarget;r+n>=t-50&&vt&&!ft&&mt()},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"==Re&&(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===bt||void 0===bt?void 0:bt.length),checked:Sr.length===(null===bt||void 0===bt?void 0:bt.length),onChange:e=>{var r;if(!be)return(0,W.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===bt||void 0===bt?void 0:bt.map(((e,r)=>(0,n.A)((0,n.A)({},e),{},{sno:r+1})));Dr(e)}else Dr([])}})}),(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"==Re&&(0,ve.jsx)(te.A,{sx:{position:"sticky !important",backgroundColor:e.palette.secondary.light},children:"Actions"})]})}),(0,ve.jsxs)(ie.A,{children:[0===(null===bt||void 0===bt?void 0:bt.length)&&!At&&(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(Re," Orders"),styles:{description:{color:e.palette.error.main}}})})})}),At&&(0,ve.jsx)(z.r,{col:8}),null===bt||void 0===bt?void 0:bt.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"===Re&&(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,W.k)("Please select a location first!","warning",2e3),void(null===(t=fe.current)||void 0===t||t.focus());e.target.checked?Dr((e=>[...e,(0,n.A)((0,n.A)({},r),{},{sno:e.length+1})])):Dr((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*Xe+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:()=>{qe(!0),Je(r.orderheaderid)},children:(0,ve.jsx)(g.A,{style:{color:i?e.palette.secondary.main:e.palette.error.main}})})})]})})]},r.sno)})),0!=(null===bt||void 0===bt?void 0:bt.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:ft||vt?(0,ve.jsx)(Ae.A,{}):"No More Orders"})})})]})]})})}),(0,ve.jsxs)(le.A,{fullScreen:!0,open:_e,TransitionComponent:j.s,children:[(0,ve.jsx)(E.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)(R.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)(X.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)(q.Ay,{container:!0,sx:{},children:(0,ve.jsx)(q.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==Lr.current&&(0,ve.jsx)(U.A,{options:[{label:"Bike",value:1},{label:"Auto",value:2}],getOptionLabel:e=>e.label,value:qr,onChange:(e,r)=>{_r(r),console.log("Selected value:",null===r||void 0===r?void 0:r.value)},renderInput:e=>(0,ve.jsx)(Z.A,(0,n.A)((0,n.A)({sx:{width:200,border:"1px solid ",borderColor:"primary.main"}},e),{},{placeholder:"Select Transport"})),isOptionEqualToValue:(e,r)=>e.value===r.value}),1==Lr.current&&(0,ve.jsx)(U.A,{multiple:!0,fullWidth:!1,options:st||[],loading:lt,disableCloseOnSelect:!0,limitTags:2,value:Hr,onChange:(e,r)=>Kr(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)(ue.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)(Z.A,(0,n.A)((0,n.A)({},e),{},{label:"Absent Riders",placeholder:Hr.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"}),Hr.length>0&&(0,ve.jsx)(K.A,{size:"small",label:Hr.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:!qr&&1==Lr.current,variant:"contained",startIcon:1==Lr.current&&(0,ve.jsx)("img",{src:Y,alt:"Assign",style:{width:32,height:32,objectFit:"contain",borderRadius:50}}),onClick:()=>{xr(!0),It()},children:Se?"Optimising...":0==Lr.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)(he.A,{}),(0,ve.jsx)(ce.A,{children:(0,ve.jsxs)(I.A,{content:!1,children:[(ot||lt||ur)&&(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(v.A,{}),(0,ve.jsx)(m.A,{})]}),(0,ve.jsx)(E.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:ot||lt||ur,children:(0,ve.jsx)(m.A,{color:"inherit"})}),(0,ve.jsx)(X.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===Tr||void 0===Tr?void 0:Tr.length)&&(0,ve.jsx)(re.A,{children:(0,ve.jsx)(te.A,{colSpan:10,children:(0,ve.jsx)(a.A,{})})}),null===Tr||void 0===Tr?void 0:Tr.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)(he.A,{})]})}),(0,ve.jsx)(he.A,{}),(0,ve.jsxs)(de.A,{sx:{flexDirection:"column",alignItems:"stretch",p:2,gap:2},children:[(0,ve.jsxs)(q.Ay,{container:!0,spacing:2,children:[(0,ve.jsx)(q.Ay,{item:!0,xs:12,sm:6,children:(0,ve.jsx)(U.A,{options:it,fullWidth:!0,renderInput:e=>(0,ve.jsx)(Z.A,(0,n.A)((0,n.A)({},e),{},{label:"Choose Payment"})),onChange:(e,r,t)=>{if("clear"!==t){if(r){Ge(r);const e=null===Tr||void 0===Tr?void 0:Tr.map((e=>(0,n.A)((0,n.A)({},e),{},{paymenttype:r.apptypeid||42})));Rr(e)}}else Ge(null)}})}),(0,ve.jsx)(q.Ay,{item:!0,xs:12,sm:6,children:(0,ve.jsx)(U.A,{options:st,fullWidth:!0,renderInput:e=>(0,ve.jsx)(Z.A,(0,n.A)((0,n.A)({},e),{},{label:"Choose Rider"})),onChange:(e,r,t)=>{if("clear"!==t){if(r){Ue(r);const e=null===Tr||void 0===Tr?void 0:Tr.map((e=>(0,n.A)((0,n.A)({},e),{},{userid:r.userid,fuelcharge:r.fuelcharge||0,userfcmtoken:r.userfcmtoken})));Rr(e)}}else Ue(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)(O.A,{}),onClick:()=>kr(!1),children:"Back"}),(0,ve.jsx)(xe.A,{variant:"contained",disabled:!Qe||!Ze,onClick:()=>{null!==Tr&&void 0!==Tr&&Tr.length?wt.mutate({deliveries:Tr}):(0,W.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)(E.A,{sx:{position:"absolute",color:"#fff",zIndex:e=>e.zIndex.modal+1},open:ur,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)(U.A,{options:[{tuneid:1,type:"Balanced",value:"balanced"},{tuneid:2,type:"Aggressive Speed",value:"aggressive_speed"},{tuneid:3,type:"Fuel Saver",value:"fuel_saver"},{tuneid:4,type:"Zone Strict",value:"zone_strict"}]||[],getOptionLabel:e=>e.type,sx:{minWidth:250,maxWidth:600,flex:1},renderInput:e=>(0,ve.jsx)(Z.A,(0,n.A)((0,n.A)({},e),{},{label:"Hyper Tuning"})),onChange:(e,r,t)=>{"clear"===t?It(null):(console.log("val",r),It(r.value))}}),(0,ve.jsx)(xe.A,{variant:"contained",color:"primary",startIcon:(0,ve.jsx)(P.UF6,{}),onClick:()=>{hr(!0),It("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:wr&&(0,ve.jsx)(me.default,{data:wr,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)(O.A,{}),onClick:()=>{yr(!1)},children:"Back"}),(0,ve.jsx)(xe.A,{variant:"contained",onClick:async()=>{hr(!0),Wt.mutate({deliveries:Tr})},children:"Assign Orders"})]})})]}),(0,ve.jsx)(le.A,{open:Ne,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(Ve)},autoFocus:!0,children:"Yes, Cancel"}),(0,ve.jsx)(xe.A,{fullWidth:!0,onClick:()=>{qe(!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:()=>{St.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)))})}}}]); |