"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[7138],{38215:function(e,t,r){r.d(t,{Z:function(){return c}});var n=r(17592),o=r(85281),i=r(46417),s=(0,n.ZP)("div")((function(){return{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:2001,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255, 255, 255, 0.7)",padding:"20px",borderRadius:"10px"}})),a=(0,n.ZP)("div")((function(){return{position:"absolute",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center"}})),c=function(){return(0,i.jsxs)(s,{children:[(0,i.jsx)(o.Z,{color:"primary",size:80,thickness:6}),(0,i.jsx)(a,{children:(0,i.jsx)("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAA+CAYAAABzwahEAAAPnUlEQVR4AdVae3AU9R3/7d4jdyGQQKAhECBAJBSmEAtFSQUjqPgAHGlhRm0lDkWY6Tg+O9qiErR26h8WR8ZWqTMN1ur4qMpDrTyjtDwDJloeCYiBvAgkaZ53l7vb3X4/v9vfZS/Zu9uFwLSfmb3d293f7u/z+z5/399K7CphdW5JrupgBZosZ0ialmu8pklSjUOTamRJbvvjqTUV7CpAYlcIj+SWZHQ55WJZlm7UNK2IXpRhpZ3GWJskSWXUZrPD4Sp77eSva9gVwIATXz35+SJNYWs1phWxAYDEpDKVaZv+fOrZUjaAGDDiK695rpgetpYOc82upw72sMycdJbz/SzmHeKl/ynRay31bbS1s7rjTczXGYj3ihrShnUDNQCXTXzlNS8UyExdbybhSdeNYwXz81nBzflE2pKms7oT51ntiSa276NKVn3wrNktNcGQelNpTUkNuwxcFvFV+S88rKnKy8ZzkOz84uvYvOJZ/PhyAE3Y/+HXbN+HFVwjjJAlR8lr1WueY9wt2MclEYfj8rnkj+nwRnHOLuGWhnbmpfuMKh/3Xn0Atm74IuY8OcGPFYk99kbVM98xm7BFnDyttHLyb3MlRdsjSWycOA+VLv79YpY5Ork6V5efY59s/J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u6i+XvNiIkBQRHlcPHGv6sUbHIKzo56J1AZBkvR5cSFhUVBR2CbD69bIpysvLecdoAHqINOytm0ijJt9J3r+TVBLHXfrGkwsiJRIMLF1i76MBEue7qE0XqTPadYiNnFen3j6Ad5HGYSDwTcslkQYGamVULLrLpH7y6dOnuY1TGctFFR0hcYfhvujinQ6eaNBgYc6sEHm+0WAKqatEWJkwYYI6depUjYhbtuWrBW775GGd1FEXFQA8FFsR8+HRMdFBKocgPrTvRkgnh4l70ijPxtwAzpLnCLpDvSztvFqQ9C8PuAPEINDeTdpgjADYjOFQhESn3s6hP+OKr9dfSUhCaiIcYjNIMur52f850f95/BfoYlARf1CQvwAAAABJRU5ErkJggg==",alt:"Logo",style:{width:"100%",height:"100%"}})})]})}},78710:function(e,t,r){r.d(t,{Z:function(){return j}});var n=r(94469),o=r(33604),i=r(42832),s=r(61113),a=r(96467),c=r(4117),l=r(69099),d=r(25223),u=r(10658),h=r.n(u),x=r(99004),f=r(59376),p=r(34605),g=r(78392),b=r(41156),Z=r(98589),v=r(79254),m=r(46417);function j(e){var t=e.open,r=e.onClose,u=e.onApply,j=[{label:"Today",startDate:new Date,endDate:new Date},{label:"Yesterday",startDate:(0,x.Z)(new Date,-1),endDate:(0,x.Z)(new Date,-1)},{label:"Tomorrow",startDate:(0,x.Z)(new Date,1),endDate:(0,x.Z)(new Date,1)},{label:"This Week",startDate:(0,f.Z)(new Date),endDate:(0,p.Z)(new Date)},{label:"Last Week",startDate:(0,f.Z)((0,g.Z)(new Date,-1)),endDate:(0,p.Z)((0,g.Z)(new Date,-1))},{label:"Last 7 Days",startDate:(0,x.Z)(new Date,-7),endDate:new Date},{label:"This Month",startDate:(0,b.Z)(new Date),endDate:(0,Z.Z)(new Date)},{label:"Last Month",startDate:(0,b.Z)((0,v.Z)(new Date,-1)),endDate:(0,Z.Z)((0,v.Z)(new Date,-1))}];return(0,m.jsxs)(n.Z,{open:t,onClose:function(){return onclose()},fullWidth:!0,maxWidth:"sm",children:[(0,m.jsx)(o.Z,{disableTypography:!0,children:(0,m.jsx)(i.Z,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",sx:{width:"100%"},children:(0,m.jsx)(s.Z,{variant:"h4",children:"Select Date Range"})})}),(0,m.jsx)(a.Z,{sx:{"& .MuiPaper-root":{boxShadow:"none !important"}},children:(0,m.jsx)(d.D,{open:t,toggle:r,definedRanges:j,onChange:function(e){null!==e&&void 0!==e&&e.startDate&&null!==e&&void 0!==e&&e.endDate&&(u({startDate:h()(e.startDate).format("YYYY-MM-DD"),endDate:h()(e.endDate).format("YYYY-MM-DD"),label:e.label||""}),r())},closeOnClickOutside:!1})}),(0,m.jsx)(c.Z,{children:(0,m.jsx)(l.Z,{variant:"contained",onClick:r,sx:{cursor:"pointer"},children:"Close"})})]})}},95872:function(e,t,r){r.d(t,{f:function(){return o}});var n=r(47313),o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"k";(0,n.useEffect)((function(){if(null!==e&&void 0!==e&&e.current){var r=function(r){var n;r.key.toLowerCase()===t.toLowerCase()&&(r.metaKey||r.ctrlKey)&&(r.preventDefault(),null===(n=e.current)||void 0===n||n.focus());"Escape"===r.key&&document.activeElement===e.current&&e.current.blur()};return document.addEventListener("keydown",r),function(){return document.removeEventListener("keydown",r)}}}),[e,t])}},36186:function(e,t,r){r.r(t),r.d(t,{default:function(){return ae}});r(93433);var n=r(1413),o=r(74165),i=r(15861),s=r(29439),a=r(47313),c=r(90842),l=r(10658),d=r.n(l),u=r(56573),h=r(57829),x=r(61113),f=r(69099),p=r(70501),g=r(42832),b=r(48119),Z=r(61689),v=r(51629),m=r(66835),j=r(23477),y=r(24076),w=r(67478),S=r(57861),k=r(84488),W=r(47131),C=r(85281),D=r(94469),Y=r(96467),R=r(22539),M=r(11577),z=r(95872),A=r(78710),T=r(38215),P=(r.p,r(41962)),O=r(25963),L=r(50581),H=r(58467),I=r(71049),F=r(46417),K=r(91635);d().extend(K);var B="0 14px 40px rgba(15, 23, 42, 0.10)",J="0 8px 24px rgba(15, 23, 42, 0.08)",N="#0f172a",E="#64748b",q="#94a3b8",G="#e2e8f0",V="#f1f5f9",U="#f8fafc",Q=function(e,t){return"".concat(e).concat(t)},X=function(e){return Q(e,"08")},_=function(e){return Q(e,"18")},$=function(e){return Q(e,"26")},ee=function(e){return Q(e,"55")},te="#662582",re="#9255AB",ne={created:{label:"Created",color:"#3b82f6",icon:R.ili},pending:{label:"Pending",color:"#f59e0b",icon:R.Ley},processing:{label:"Processing",color:"#3b82f6",icon:R.dKE},modified:{label:"Confirmed",color:"#10b981",icon:R.ZSR},confirmed:{label:"Confirmed",color:"#10b981",icon:R.ZSR},ready:{label:"Accepted",color:"#6366f1",icon:R.ZSR},active:{label:"Picked",color:"#8b5cf6",icon:R.ili},onhold:{label:"On Hold",color:"#8b5cf6",icon:R.Y8K},closed:{label:"Closed",color:"#06b6d4",icon:R.ZSR},delivered:{label:"Delivered",color:"#10b981",icon:R.ZSR},failed:{label:"Failed",color:"#991b1b",icon:R.B4e},cancelled:{label:"Cancelled",color:"#ef4444",icon:R.B4e}},oe=[{idx:0,status:"created",label:"Created",color:te,icon:R.ili,countKey:"created"}],ie=function(e){var t=e.status,r=ne[String(t||"").toLowerCase()]||{label:t||"\u2014",color:q,icon:R.Y8K},n=r.icon;return(0,F.jsxs)(h.Z,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.125,py:.375,borderRadius:999,bgcolor:r.color,color:"#fff",fontSize:11,fontWeight:700,letterSpacing:.2,whiteSpace:"nowrap",minWidth:86,justifyContent:"center",boxShadow:"0 1px 2px ".concat($(r.color))},children:[(0,F.jsx)(n,{size:12})," ",r.label]})},se=function(e){var t=e.value,r=e.color,n=e.icon,o=e.isMoney,i=void 0!==o&&o,s=Number(t),a=i?"\u20b9".concat(Number.isFinite(s)?s.toFixed(2):"0.00"):Number.isFinite(s)?s:t||0;return!Number.isFinite(s)||0===s?(0,F.jsx)(x.Z,{variant:"caption",sx:{color:q,fontWeight:700},children:a}):(0,F.jsxs)(h.Z,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:.875,py:.25,borderRadius:999,bgcolor:X(r),border:"1px solid ".concat(ee(r)),color:r,fontSize:12,fontWeight:800,whiteSpace:"nowrap"},children:[n,a]})},ae=function(){var e=(0,H.s0)(),t=((0,H.TH)(),localStorage.getItem("tenantid")),r=(0,a.useRef)(),l=(0,a.useRef)(),K=(0,a.useState)(0),Q=(0,s.Z)(K,2),ne=Q[0],ae=Q[1],ce=(0,a.useState)(10),le=(0,s.Z)(ce,2),de=le[0],ue=le[1],he=(0,a.useState)(0),xe=(0,s.Z)(he,2),fe=xe[0],pe=xe[1],ge=(0,a.useState)("Created"),be=(0,s.Z)(ge,2),Ze=be[0],ve=be[1],me=(0,a.useState)("created"),je=(0,s.Z)(me,2),ye=je[0],we=je[1],Se=(0,a.useState)(!1),ke=(0,s.Z)(Se,2),We=ke[0],Ce=ke[1],De=(0,a.useState)(""),Ye=(0,s.Z)(De,2),Re=Ye[0],Me=Ye[1],ze=(0,a.useState)(!1),Ae=(0,s.Z)(ze,2),Te=Ae[0],Pe=Ae[1],Oe=(0,a.useState)("Today"),Le=(0,s.Z)(Oe,2),He=Le[0],Ie=Le[1],Fe=(0,a.useState)(d()().format("YYYY-MM-DD")),Ke=(0,s.Z)(Fe,2),Be=Ke[0],Je=Ke[1],Ne=(0,a.useState)(d()().format("YYYY-MM-DD")),Ee=(0,s.Z)(Ne,2),qe=Ee[0],Ge=Ee[1],Ve=(0,a.useState)(""),Ue=(0,s.Z)(Ve,2),Qe=Ue[0],Xe=Ue[1],_e=(0,a.useState)(""),$e=(0,s.Z)(_e,2),et=$e[0],tt=$e[1],rt=(0,a.useState)(!1),nt=(0,s.Z)(rt,2),ot=(nt[0],nt[1],(0,a.useState)(!1)),it=(0,s.Z)(ot,2),st=it[0],at=it[1],ct=(0,a.useState)(!1),lt=(0,s.Z)(ct,2),dt=lt[0],ut=lt[1],ht=(0,a.useState)(!1),xt=(0,s.Z)(ht,2),ft=xt[0],pt=xt[1],gt=(0,a.useState)([]),bt=(0,s.Z)(gt,2),Zt=bt[0],vt=bt[1];(0,a.useEffect)((function(){var e=setTimeout((function(){tt(Qe)}),400);return function(){return clearTimeout(e)}}),[Qe]);var mt=(0,a.useRef)(null);(0,z.f)(mt,"k");var jt=(0,P.a)({queryKey:["percentageData",0,Be,qe,t,0],queryFn:I.Wo,enabled:!0,refetchInterval:15e3}),yt=jt.data,wt=jt.isLoading,St=jt.refetch,kt=(0,P.a)({queryKey:["ordersCount",0,Be,qe,ye,t,0],queryFn:I.RO,refetchOnMount:!0,refetchOnWindowFocus:!0,refetchInterval:15e3}),Wt=kt.data,Ct=kt.refetch,Dt=(0,P.a)({queryKey:["getallriders"],queryFn:I.n7,refetchOnMount:!0,refetchOnWindowFocus:!0}).data,Yt=function(){var e=(0,i.Z)((0,o.Z)().mark((function e(){return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,u.Z.put("".concat("https://jupiter.nearle.app/live/api/v1","/orders/updateorder"),{orderheaderid:Re,orderstatus:"cancelled",cancelled:d()().format("YYYY-MM-DD HH:mm:ss")}).then((function(e){e.data.status&&((0,c.yv)("Order Cancelled Successfully",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:2e3}),Lt(),Ct(),St(),Ce(!1))})).catch((function(e){console.log(e)}));case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Rt=function(){var e=(0,i.Z)((0,o.Z)().mark((function e(r){var n,i,s;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.pageParam,i=void 0===n?1:n,e.next=3,u.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/orders/tenant/getorders/?tenantid=").concat(t,"&locationid=").concat(0,"&status=").concat(ye,"&fromdate=").concat(Be,"&todate=").concat(qe,"&pageno=").concat(i,"&pagesize=").concat(de,"&keyword=").concat(et));case 3:return s=e.sent,e.abrupt("return",{data:s.data.details,nextPage:s.data.details.length===de?i+1:void 0});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Mt=(0,O.N)({queryKey:[Ze,Be,qe,ne,de,et,0],queryFn:Rt,getNextPageParam:function(e){return e.nextPage},refetchInterval:15e3}),zt=Mt.data,At=Mt.fetchNextPage,Tt=Mt.isLoading,Pt=Mt.hasNextPage,Ot=Mt.isFetchingNextPage,Lt=Mt.refetch,Ht=zt?zt.pages.flatMap((function(e){return e.data})):[];(0,a.useEffect)((function(){if(Pt){var e=new IntersectionObserver((function(e){e[0].isIntersecting&&At()}),{root:null,rootMargin:"0px 0px 400px 0px",threshold:0});return r.current&&e.observe(r.current),function(){r.current&&e.unobserve(r.current)}}}),[Pt,At]);var It=(0,L.D)({mutationFn:I.f2,onSuccess:function(r,n){(0,c.yv)("Orders Optimised Successfully",{variant:"success",autoHideDuration:2e3}),Ct(),Lt(),ut(!1),e("/nearle/dispatch/preview",{state:{dispatchPreviewData:r,aiMode:1,selectedMode:{value:1},deliveryData:(null===n||void 0===n?void 0:n.deliveries)||[],appId:0,startdate:Be,tenantId:t,autoRiders:Dt||[]}})},onError:function(e){(0,c.yv)(e.message,{variant:"error",autoHideDuration:4e3}),ut(!1)},onSettled:function(){ut(!1),pt(!1)}}),Ft=(0,L.D)({mutationFn:I.Sr,onSuccess:function(e){e.status&&(at(!1),(0,c.yv)("Orders Cancelled Successfully",{variant:"success",autoHideDuration:2e3}),Lt(),Ct(),St(),vt([]))},onError:function(e){(0,c.yv)(e.message,{variant:"error",autoHideDuration:4e3})}}),Kt=function(){var e=(0,i.Z)((0,o.Z)().mark((function e(){var t;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==Ht.length){e.next=2;break}return e.abrupt("return");case 2:pt(!0),ut(!0),t=Ht.map((function(e){return(0,n.Z)((0,n.Z)({},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})})),It.mutate({deliveries:t,selectedMode:{value:1},hypertuning_params:"balanced",absent_riders:[]});case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();R.ili,null===yt||void 0===yt||yt.created,null===yt||void 0===yt||yt.percentage1,R.Ley,null===yt||void 0===yt||yt.uncoveredOrders,null===yt||void 0===yt||yt.percentage2;return(0,F.jsxs)(a.Fragment,{children:[(wt||Tt||ft||dt)&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(M.Z,{}),(0,F.jsx)(T.Z,{})]}),Ht.length>0&&"created"===ye&&(0,F.jsxs)(f.Z,{variant:"contained",onClick:Kt,sx:{position:"fixed",bottom:32,right:24,bgcolor:te,color:"#fff",px:3,py:1.5,borderRadius:999,fontWeight:850,boxShadow:"0 10px 30px ".concat($(te)),zIndex:1e3,textTransform:"none",fontSize:"14px",gap:1,"&:hover":{bgcolor:re,transform:"translateY(-2px)"}},startIcon:(0,F.jsx)(R.ili,{size:18}),children:["Assign All Orders (",Ht.length,")"]}),(0,F.jsx)(p.Z,{elevation:0,sx:{mb:{xs:1,md:1.25},px:{xs:1.5,sm:2},py:{xs:1,sm:1.25},borderRadius:2,border:"1px solid",borderColor:G,background:"linear-gradient(135deg, ".concat(X(te)," 0%, ").concat(X(re)," 100%)"),boxShadow:J},children:(0,F.jsx)(g.Z,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",spacing:{xs:1,sm:1.5},children:(0,F.jsxs)(g.Z,{direction:"row",alignItems:"center",spacing:1.25,children:[(0,F.jsx)(b.Z,{variant:"rounded",sx:{width:36,height:36,bgcolor:te,color:"#fff",borderRadius:1.5,boxShadow:"0 4px 12px ".concat($(te))},children:(0,F.jsx)(R.ili,{size:19})}),(0,F.jsxs)(g.Z,{spacing:.125,children:[(0,F.jsx)(x.Z,{variant:"h3",sx:{fontWeight:800,color:N,lineHeight:1.1,fontSize:{xs:"1.1rem",sm:"1.25rem",md:"1.375rem"}},children:"Orders"}),(0,F.jsxs)(g.Z,{direction:"row",alignItems:"center",spacing:.75,children:[(0,F.jsx)(h.Z,{sx:{width:7,height:7,borderRadius:"50%",bgcolor:"#10b981",boxShadow:"0 0 0 3px rgba(16,185,129,0.18)"}}),(0,F.jsxs)(x.Z,{sx:{fontSize:11.5,color:E,fontWeight:600},children:["Live \xb7 ","All Locations"," \xb7 ",He]})]})]})]})})}),(0,F.jsx)(p.Z,{elevation:0,sx:{mt:{xs:1,md:1.25},p:{xs:1,md:1.125},borderRadius:2,border:"1px solid",borderColor:G,background:"#fff",boxShadow:B},children:(0,F.jsx)(g.Z,{direction:{xs:"column",md:"row"},spacing:1.25,alignItems:{xs:"stretch",md:"center"},justifyContent:{xs:"flex-start",md:"space-between"},children:(0,F.jsxs)(g.Z,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,children:[(0,F.jsx)(Z.Z,{title:"Date Filter",placement:"top",children:(0,F.jsxs)(h.Z,{onClick:function(){return Pe(!0)},sx:{display:"inline-flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:999,cursor:"pointer",bgcolor:X("#f59e0b"),border:"1.5px solid ".concat(ee("#f59e0b")),color:"#f59e0b",fontWeight:800,fontSize:12,transition:"all 0.18s","&:hover":{borderColor:"#f59e0b",boxShadow:"0 0 0 3px ".concat($("#f59e0b"))}},children:[(0,F.jsx)(R.sHf,{size:14}),d()(Be).format("DD/MM/YY")," \u2013 ",d()(qe).format("DD/MM/YY")]})}),(0,F.jsxs)(h.Z,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.5,borderRadius:999,bgcolor:X(te),border:"1px solid ".concat(ee(te)),color:te,fontSize:11,fontWeight:800},children:[(0,F.jsx)(R.VHP,{size:12})," ",He]})]})})}),(0,F.jsx)(p.Z,{elevation:0,sx:{mt:{xs:1,md:1.25},p:{xs:.875,md:1.125},borderTopLeftRadius:2,borderTopRightRadius:2,borderBottomLeftRadius:0,borderBottomRightRadius:0,border:"1px solid",borderColor:G,borderBottom:0,background:"#fff"},children:(0,F.jsx)(g.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{flexWrap:"wrap-reverse"},children:(0,F.jsx)(g.Z,{direction:"row",spacing:.75,sx:{flex:1,overflowX:"auto",py:.5,px:.25,"&::-webkit-scrollbar":{height:6},"&::-webkit-scrollbar-thumb":{backgroundColor:G,borderRadius:4}},children:oe.map((function(e){var t,r=e.icon,n=fe===e.idx,o=null!==(t=null===Wt||void 0===Wt?void 0:Wt[e.countKey])&&void 0!==t?t:0;return(0,F.jsxs)(h.Z,{onClick:function(t){return function(e,t){Xe(""),ue(10),pe(t);var r=oe[t];ve(r.label),we(r.status),ae(0)}(0,e.idx)},sx:{display:"inline-flex",alignItems:"center",gap:{xs:.625,md:.875},pl:.5,pr:{xs:1,md:1.25},py:.5,flexShrink:0,cursor:"pointer",borderRadius:999,border:"1.5px solid ".concat(n?e.color:ee(e.color)),bgcolor:n?e.color:X(e.color),color:n?"#fff":e.color,fontWeight:700,boxShadow:n?"0 6px 18px ".concat($(e.color)):"none",transition:"all 0.18s","&:hover":{borderColor:e.color,boxShadow:n?"0 6px 18px ".concat($(e.color)):"0 0 0 3px ".concat($(e.color))}},children:[(0,F.jsx)(b.Z,{sx:{width:{xs:22,md:26},height:{xs:22,md:26},bgcolor:n?"rgba(255,255,255,0.22)":_(e.color),color:n?"#fff":e.color},children:(0,F.jsx)(r,{size:13})}),(0,F.jsx)(x.Z,{variant:"caption",sx:{fontWeight:800,fontSize:{xs:11.5,md:13},lineHeight:1},children:e.label}),(0,F.jsx)(h.Z,{sx:{minWidth:{xs:22,md:26},height:{xs:18,md:22},px:.625,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:999,fontSize:{xs:10,md:11},fontWeight:800,bgcolor:n?"rgba(255,255,255,0.22)":"#fff",color:n?"#fff":e.color,border:n?"none":"1px solid ".concat(ee(e.color))},children:null!==o&&void 0!==o?o:0})]},e.status)}))})})}),(0,F.jsx)(p.Z,{elevation:0,sx:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:2,borderBottomRightRadius:2,border:"1px solid",borderColor:G,overflow:"hidden",background:"#fff"},children:(0,F.jsx)(v.Z,{onScroll:function(e){var t=e.currentTarget,r=t.scrollTop,n=t.scrollHeight;r+t.clientHeight>=n-50&&Pt&&!Ot&&At()},ref:l,sx:{overflowX:"auto",overflowY:"visible","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:ee(te),borderRadius:8,"&:hover":{backgroundColor:te}},"&::-webkit-scrollbar-track":{backgroundColor:U}},children:(0,F.jsxs)(m.Z,{stickyHeader:!0,size:"small",sx:{minWidth:{xs:960,md:1100}},children:[(0,F.jsx)(j.Z,{children:(0,F.jsxs)(y.Z,{sx:{"& th":{backgroundColor:U,color:E,fontSize:10.5,fontWeight:800,letterSpacing:.5,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(G),py:.75,px:1}},children:[(0,F.jsx)(w.Z,{children:"#"}),(0,F.jsx)(w.Z,{children:"Order Location"}),(0,F.jsx)(w.Z,{children:"Pickup"}),(0,F.jsx)(w.Z,{children:"Drop"}),(0,F.jsx)(w.Z,{align:"center",children:"Qty"}),(0,F.jsx)(w.Z,{align:"right",children:"COD"}),(0,F.jsx)(w.Z,{align:"center",children:"Kms"}),(0,F.jsx)(w.Z,{align:"right",children:"Charges"}),(0,F.jsx)(w.Z,{children:"Notes"}),(0,F.jsx)(w.Z,{children:"Status"}),"created"===ye&&(0,F.jsx)(w.Z,{align:"right",children:"Actions"})]})}),(0,F.jsxs)(S.Z,{children:[(Tt||dt)&&0===Ht.length&&Array.from({length:10}).map((function(e,t){return(0,F.jsx)(y.Z,{children:Array.from({length:"created"===ye?12:11}).map((function(e,t){return(0,F.jsx)(w.Z,{sx:{borderBottom:"1px solid ".concat(V),py:.625,px:1},children:(0,F.jsx)(k.Z,{animation:"wave",height:20})},t)}))},"sk-".concat(t))})),!Tt&&0===Ht.length&&(0,F.jsx)(y.Z,{children:(0,F.jsx)(w.Z,{colSpan:"created"===ye?12:11,sx:{py:7,borderBottom:"none"},children:(0,F.jsxs)(g.Z,{alignItems:"center",spacing:1.25,children:[(0,F.jsx)(b.Z,{variant:"rounded",sx:{width:56,height:56,bgcolor:_("#94a3b8"),color:q,borderRadius:2},children:(0,F.jsx)(R.ili,{size:26})}),(0,F.jsxs)(x.Z,{sx:{fontWeight:700,color:N,fontSize:14},children:["No ",ye," orders"]}),(0,F.jsx)(x.Z,{sx:{color:E,fontSize:12},children:Qe?"Try a different keyword or clear the search.":"Adjust the location, status, or date range above."}),Qe&&(0,F.jsx)(f.Z,{size:"small",onClick:function(){return Xe("")},sx:{mt:.5,height:28,textTransform:"none",fontSize:12,fontWeight:700,color:te,borderRadius:1.25,"&:hover":{bgcolor:X(te)}},startIcon:(0,F.jsx)(R.lUB,{size:14}),children:"Clear search"})]})})}),Ht.map((function(e,t){var r;Zt.find((function(t){return t.orderheaderid===e.orderheaderid}));return(0,F.jsxs)(y.Z,{sx:{cursor:"pointer",transition:"background-color 0.12s, box-shadow 0.12s",backgroundColor:"transparent","& td":{borderBottom:"1px solid ".concat(V),py:.5,px:1,verticalAlign:"top"},"&:hover":{backgroundColor:U,boxShadow:"inset 3px 0 0 ".concat(te)}},children:[(0,F.jsx)(w.Z,{children:(0,F.jsx)(x.Z,{sx:{fontWeight:700,color:E},children:ne*de+t+1})}),(0,F.jsxs)(w.Z,{children:[(0,F.jsxs)(x.Z,{variant:"subtitle2",sx:{fontWeight:700,color:N},noWrap:!0,children:[e.locationname,e.locationsuburb&&" - ".concat(e.locationsuburb)]}),(0,F.jsx)(Z.Z,{title:"Order Id",children:(0,F.jsx)(x.Z,{variant:"caption",sx:{color:E},noWrap:!0,children:e.orderid})}),(0,F.jsxs)(g.Z,{direction:"row",spacing:.5,alignItems:"center",sx:{mt:.125},children:[(0,F.jsx)(R.dKE,{size:10,style:{color:q,flexShrink:0}}),function(){var t=e.pickupslot&&d()(e.pickupslot).isValid()?d()(e.pickupslot):d()(e.deliverydate||e.orderdate);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(x.Z,{sx:{fontSize:10.5,color:E,fontWeight:700},noWrap:!0,children:t.format("hh:mm A")}),(0,F.jsxs)(x.Z,{sx:{fontSize:10.5,color:q,fontWeight:600},noWrap:!0,children:["\xb7 ",t.format("DD MMM YY")]})]})}()]})]}),(0,F.jsx)(w.Z,{children:(0,F.jsxs)(g.Z,{direction:"column",children:[(0,F.jsx)(x.Z,{variant:"subtitle2",sx:{fontWeight:700,color:N},noWrap:!0,children:e.pickupcustomer}),(0,F.jsx)(x.Z,{variant:"caption",sx:{color:E},children:e.pickupcontactno}),(0,F.jsx)(Z.Z,{title:e.pickupaddress,children:(0,F.jsx)(x.Z,{variant:"caption",sx:{color:q},noWrap:!0,children:e.pickupsuburb||(e.pickupaddress?"".concat(e.pickupaddress.slice(0,20),"\u2026"):"\u2014")})})]})}),(0,F.jsx)(w.Z,{children:(0,F.jsxs)(g.Z,{direction:"column",children:[(0,F.jsx)(x.Z,{variant:"subtitle2",sx:{fontWeight:700,color:N},noWrap:!0,children:e.deliverycustomer}),(0,F.jsx)(x.Z,{variant:"caption",sx:{color:E},children:e.deliverycontactno}),(0,F.jsx)(Z.Z,{title:e.deliveryaddress,children:(0,F.jsx)(x.Z,{variant:"caption",sx:{color:q},noWrap:!0,children:e.deliverysuburb||((null===(r=e.deliveryaddress)||void 0===r?void 0:r.length)>20?"".concat(e.deliveryaddress.slice(0,20),"\u2026"):e.deliveryaddress||"\u2014")})})]})}),(0,F.jsx)(w.Z,{align:"center",children:(0,F.jsx)(se,{value:e.quantity,color:"#0ea5e9",icon:(0,F.jsx)(R.ByW,{size:11})})}),(0,F.jsx)(w.Z,{align:"right",children:(0,F.jsx)(se,{value:e.collectionamt,color:"#10b981",icon:(0,F.jsx)(R.vCl,{size:11}),isMoney:!0})}),(0,F.jsx)(w.Z,{align:"center",children:(0,F.jsx)(se,{value:e.kms,color:"#f59e0b",icon:(0,F.jsx)(R.v93,{size:11})})}),(0,F.jsx)(w.Z,{align:"right",children:(0,F.jsx)(se,{value:e.deliverycharge,color:te,icon:(0,F.jsx)(R.vCl,{size:11}),isMoney:!0})}),(0,F.jsx)(w.Z,{children:e.ordernotes?(0,F.jsxs)(g.Z,{direction:"row",spacing:.5,alignItems:"center",sx:{color:E},children:[(0,F.jsx)(R.hKf,{size:12,style:{color:q,flexShrink:0}}),(0,F.jsx)(x.Z,{variant:"caption",sx:{maxWidth:140,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontWeight:600},children:e.ordernotes})]}):(0,F.jsx)(x.Z,{variant:"caption",sx:{color:q},children:"\u2014"})}),(0,F.jsx)(w.Z,{children:(0,F.jsx)(ie,{status:e.orderstatus})}),"created"===ye&&(0,F.jsx)(w.Z,{align:"right",children:"created"===e.orderstatus&&(0,F.jsx)(Z.Z,{title:"Cancel Order",children:(0,F.jsx)(W.Z,{size:"small",onClick:function(t){t.stopPropagation(),Me(e.orderheaderid),Ce(!0)},sx:{bgcolor:X("#ef4444"),border:"1px solid ".concat(ee("#ef4444")),color:"#ef4444",borderRadius:999,p:.75,"&:hover":{bgcolor:_("#ef4444"),borderColor:"#ef4444"}},children:(0,F.jsx)(R.FU5,{size:14})})})})]},"".concat(e.orderheaderid,"-").concat(t))})),0!==Ht.length&&(0,F.jsx)(y.Z,{sx:{"&:hover":{backgroundColor:"transparent !important"}},children:(0,F.jsx)(w.Z,{colSpan:"created"===ye?12:11,sx:{borderBottom:"none",py:1,bgcolor:U},children:(0,F.jsx)(g.Z,{ref:r,direction:"row",alignItems:"center",justifyContent:"center",spacing:1,sx:{minHeight:32},children:Ot||Pt?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(C.Z,{size:14,sx:{color:te}}),(0,F.jsx)(x.Z,{sx:{fontSize:11.5,color:E,fontWeight:700},children:"Loading more orders\u2026"})]}):(0,F.jsxs)(x.Z,{sx:{fontSize:11.5,color:q,fontWeight:700,letterSpacing:.3},children:[Ht.length," order",1===Ht.length?"":"s"," \xb7 End of list"]})})})})]})]})})}),(0,F.jsxs)(D.Z,{open:We,onClose:function(){return Ce(!1)},maxWidth:"xs",PaperProps:{sx:{borderRadius:3}},children:[(0,F.jsx)(h.Z,{sx:{p:2.5,background:"linear-gradient(135deg, ".concat(X("#ef4444")," 0%, ").concat(X("#f59e0b")," 100%)"),borderBottom:"1px solid ".concat(G)},children:(0,F.jsxs)(g.Z,{direction:"row",alignItems:"center",spacing:1.5,children:[(0,F.jsx)(b.Z,{sx:{bgcolor:"#ef4444",color:"#fff",width:40,height:40},children:(0,F.jsx)(R.F1H,{size:20})}),(0,F.jsx)(x.Z,{variant:"h5",sx:{fontWeight:800,color:N},children:"Cancel Order"})]})}),(0,F.jsx)(Y.Z,{sx:{pt:3},children:(0,F.jsxs)(g.Z,{alignItems:"center",spacing:3,children:[(0,F.jsx)(x.Z,{variant:"body1",align:"center",sx:{color:E,fontWeight:600},children:"Are you sure you want to cancel this order? This action cannot be undone."}),(0,F.jsxs)(g.Z,{direction:"row",spacing:1.5,sx:{width:1},children:[(0,F.jsx)(f.Z,{fullWidth:!0,onClick:function(){return Ce(!1)},variant:"outlined",sx:{borderRadius:999,py:1,borderColor:G,color:E,fontWeight:700,"&:hover":{borderColor:E,bgcolor:U}},children:"No"}),(0,F.jsx)(f.Z,{fullWidth:!0,variant:"contained",onClick:Yt,autoFocus:!0,sx:{borderRadius:999,py:1,bgcolor:"#ef4444",fontWeight:700,boxShadow:"0 6px 18px ".concat($("#ef4444")),"&:hover":{bgcolor:"#dc2626"}},children:"Yes, Cancel"})]})]})})]}),(0,F.jsx)(A.Z,{open:Te,onClose:function(){return Pe(!1)},onApply:function(e){var t=e.startDate,r=e.endDate,n=e.label;Je(t),Ge(r),Ie(n)}}),(0,F.jsxs)(D.Z,{open:st,onClose:function(){return at(!1)},maxWidth:"xs",PaperProps:{sx:{borderRadius:3}},children:[(0,F.jsx)(h.Z,{sx:{p:2.5,background:"linear-gradient(135deg, ".concat(X("#ef4444")," 0%, ").concat(X("#f59e0b")," 100%)"),borderBottom:"1px solid ".concat(G)},children:(0,F.jsxs)(g.Z,{direction:"row",alignItems:"center",spacing:1.5,children:[(0,F.jsx)(b.Z,{sx:{bgcolor:"#ef4444",color:"#fff",width:40,height:40},children:(0,F.jsx)(R.F1H,{size:20})}),(0,F.jsx)(x.Z,{variant:"h5",sx:{fontWeight:800,color:N},children:"Cancel Selected Orders"})]})}),(0,F.jsx)(Y.Z,{sx:{pt:3},children:(0,F.jsxs)(g.Z,{alignItems:"center",spacing:3,children:[(0,F.jsxs)(x.Z,{variant:"body1",align:"center",sx:{color:E,fontWeight:600},children:["Are you sure you want to cancel the ",Zt.length," selected orders? This action cannot be undone."]}),(0,F.jsxs)(g.Z,{direction:"row",spacing:1.5,sx:{width:1},children:[(0,F.jsx)(f.Z,{fullWidth:!0,onClick:function(){return at(!1)},variant:"outlined",sx:{borderRadius:999,py:1,borderColor:G,color:E,fontWeight:700,"&:hover":{borderColor:E,bgcolor:U}},children:"No"}),(0,F.jsx)(f.Z,{fullWidth:!0,variant:"contained",onClick:function(){return Ft.mutate(Zt)},autoFocus:!0,sx:{borderRadius:999,py:1,bgcolor:"#ef4444",fontWeight:700,boxShadow:"0 6px 18px ".concat($("#ef4444")),"&:hover":{bgcolor:"#dc2626"}},children:"Yes, Cancel"})]})]})})]})]})}},50581:function(e,t,r){r.d(t,{D:function(){return M}});var n,o,i,s,a,c,l=r(1413),d=r(29439),u=r(47313),h=r(15671),x=r(43144),f=r(97326),p=r(60136),g=r(27277),b=r(40101),Z=r(72346),v=r(86033),m=r(43889),j=r(13092),y=r(73547),w=r(28127),S=r(27542),k=r(66587),W=(n=new WeakMap,o=new WeakMap,i=new WeakMap,s=new WeakMap,a=new WeakSet,c=new WeakSet,function(e){(0,p.Z)(r,e);var t=(0,g.Z)(r);function r(e,l){var d;return(0,h.Z)(this,r),d=t.call(this),(0,b.Z)((0,f.Z)(d),c),(0,b.Z)((0,f.Z)(d),a),(0,Z.Z)((0,f.Z)(d),n,{writable:!0,value:void 0}),(0,Z.Z)((0,f.Z)(d),o,{writable:!0,value:void 0}),(0,Z.Z)((0,f.Z)(d),i,{writable:!0,value:void 0}),(0,Z.Z)((0,f.Z)(d),s,{writable:!0,value:void 0}),(0,j.Z)((0,f.Z)(d),n,e),d.setOptions(l),d.bindMethods(),(0,m.Z)((0,f.Z)(d),a,C).call((0,f.Z)(d)),d}return(0,x.Z)(r,[{key:"bindMethods",value:function(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}},{key:"setOptions",value:function(e){var t,r=this.options;(this.options=(0,v.Z)(this,n).defaultMutationOptions(e),(0,k.VS)(this.options,r)||(0,v.Z)(this,n).getMutationCache().notify({type:"observerOptionsUpdated",mutation:(0,v.Z)(this,i),observer:this}),null!==r&&void 0!==r&&r.mutationKey&&this.options.mutationKey&&(0,k.Ym)(r.mutationKey)!==(0,k.Ym)(this.options.mutationKey))?this.reset():null===(t=(0,v.Z)(this,i))||void 0===t||t.setOptions(this.options)}},{key:"onUnsubscribe",value:function(){var e;this.hasListeners()||(null===(e=(0,v.Z)(this,i))||void 0===e||e.removeObserver(this))}},{key:"onMutationUpdate",value:function(e){(0,m.Z)(this,a,C).call(this),(0,m.Z)(this,c,D).call(this,e)}},{key:"getCurrentResult",value:function(){return(0,v.Z)(this,o)}},{key:"reset",value:function(){var e;null===(e=(0,v.Z)(this,i))||void 0===e||e.removeObserver(this),(0,j.Z)(this,i,void 0),(0,m.Z)(this,a,C).call(this),(0,m.Z)(this,c,D).call(this)}},{key:"mutate",value:function(e,t){var r;return(0,j.Z)(this,s,t),null===(r=(0,v.Z)(this,i))||void 0===r||r.removeObserver(this),(0,j.Z)(this,i,(0,v.Z)(this,n).getMutationCache().build((0,v.Z)(this,n),this.options)),(0,v.Z)(this,i).addObserver(this),(0,v.Z)(this,i).execute(e)}}]),r}(S.l));function C(){var e,t,r=null!==(e=null===(t=(0,v.Z)(this,i))||void 0===t?void 0:t.state)&&void 0!==e?e:(0,y.R)();(0,j.Z)(this,o,(0,l.Z)((0,l.Z)({},r),{},{isPending:"pending"===r.status,isSuccess:"success"===r.status,isError:"error"===r.status,isIdle:"idle"===r.status,mutate:this.mutate,reset:this.reset}))}function D(e){var t=this;w.V.batch((function(){if((0,v.Z)(t,s)&&t.hasListeners()){var r,n,i,a,c=(0,v.Z)(t,o).variables,l=(0,v.Z)(t,o).context;if("success"===(null===e||void 0===e?void 0:e.type))null===(r=(n=(0,v.Z)(t,s)).onSuccess)||void 0===r||r.call(n,e.data,c,l),null===(i=(a=(0,v.Z)(t,s)).onSettled)||void 0===i||i.call(a,e.data,null,c,l);else if("error"===(null===e||void 0===e?void 0:e.type)){var d,u,h,x;null===(d=(u=(0,v.Z)(t,s)).onError)||void 0===d||d.call(u,e.error,c,l),null===(h=(x=(0,v.Z)(t,s)).onSettled)||void 0===h||h.call(x,void 0,e.error,c,l)}}t.listeners.forEach((function(e){e((0,v.Z)(t,o))}))}))}var Y=r(67109),R=r(24772);function M(e,t){var r=(0,Y.NL)(t),n=u.useState((function(){return new W(r,e)})),o=(0,d.Z)(n,1)[0];u.useEffect((function(){o.setOptions(e)}),[o,e]);var i=u.useSyncExternalStore(u.useCallback((function(e){return o.subscribe(w.V.batchCalls(e))}),[o]),(function(){return o.getCurrentResult()}),(function(){return o.getCurrentResult()})),s=u.useCallback((function(e,t){o.mutate(e,t).catch(z)}),[o]);if(i.error&&(0,R.L)(o.options.throwOnError,[i.error]))throw i.error;return(0,l.Z)((0,l.Z)({},i),{},{mutate:s,mutateAsync:i.mutate})}function z(){}}}]);