1 line
47 KiB
JavaScript
1 line
47 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[4910],{7519:function(e,o,t){t.d(o,{ZZ:function(){return x}});var r=t(1413),n=(t(47313),t(17592)),i=t(61689),l=t(69099),s=t(85281),c=t(42832),a=t(36287),d=t(53245),u=t(6986),h=t(46417),x=((0,n.ZP)("div")((function(e){var o=e.theme,t=e.x,r=e.y;return{color:o.palette.text.secondary,position:"fixed",pointerEvents:"none",left:12,top:24,transform:"translate(".concat(t,"px, ").concat(r,"px)"),opacity:.6}})),function(e){var o=e.data,t=e.filename,n=e.headers,c=e.label,a=e.style,x=e.btnLoading,f=e.onClick;return(0,h.jsx)(d.CSVLink,{data:o,filename:t,headers:n,children:(0,h.jsx)(i.Z,{title:"CSV Export",children:(0,h.jsx)(l.Z,{startIcon:!x&&(0,h.jsx)(u.Z,{}),variant:x?"outlined":"contained",sx:(0,r.Z)({},a),disabled:x,onClick:function(e){null===f||void 0===f||f(e)},children:x?(0,h.jsx)(s.Z,{size:20,thickness:5}):c||"Download"})})})});(0,n.ZP)(c.Z)((function(e){var o=e.theme;return{height:"400px","& .ant-empty-img-1":{fill:o.palette.mode===a.hY.DARK?o.palette.secondary[200]:o.palette.secondary[400]},"& .ant-empty-img-2":{fill:o.palette.secondary.light},"& .ant-empty-img-3":{fill:o.palette.mode===a.hY.DARK?o.palette.secondary.A200:o.palette.secondary[200]},"& .ant-empty-img-4":{fill:o.palette.mode===a.hY.DARK?o.palette.secondary.A300:o.palette.secondary.A100},"& .ant-empty-img-5":{fillOpacity:o.palette.mode===a.hY.DARK?"0.09":"0.95",fill:o.palette.mode===a.hY.DARK?o.palette.secondary.darker:o.palette.secondary.light}}}))},85278:function(e,o,t){t.r(o),t.d(o,{default:function(){return oo}});var r=t(74165),n=t(15861),i=t(4942),l=t(29439),s=t(1413),c=t(47313),a=t(56573),d=t(25963),u=t(41962),h=t(19860),x=(t(90842),t(70501)),f=t(48119),p=t(57829),g=t(61113),m=t(42832),b=t(61689),v=t(69099),Z=t(9019),j=t(84488),y=t(76088),w=t(16783),S=t(54882),k=t(47131),z=t(51629),C=t(66835),W=t(23477),D=t(24076),M=t(67478),I=t(57861),A=t(85281),R=t(79601),Y=t(70024),P=t(94469),H=t(96467),L=t(22539),T=t(10658),E=t.n(T),O=t(25223),B=t(99004),F=t(59376),N=t(34605),V=t(78392),K=t(41156),q=t(98589),U=t(79254),J=t(71049),_=t(7519),G=t(11577),$=t(93433),X=t(74580),Q=t(88153),ee=t(39062),oe=t(73999),te=t(98817),re=t(87248),ne=t.n(re),ie=(t(63331),t(66212)),le=t(16132),se=t(5049),ce=t(46417),ae=t(91635);E().extend(ae);var de=new(ne().Icon)({iconUrl:"https://cdn.rawgit.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-green.png",shadowUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]}),ue=new(ne().Icon)({iconUrl:"https://cdn.rawgit.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png",shadowUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]}),he=function(e){var o=e.coordinates,t=e.additionalProps,r=e.order,n=e.setMapOpen;console.log("setMapOpen:",typeof n),console.log("coordinates",o),console.log(t.riderStart),console.log(t.riderEnd),console.log("order",r);var i=(0,c.useRef)(null);le.u;(0,c.useEffect)((function(){if(i.current&&o.length>0){var e=l(o);i.current.fitBounds(e)}}),[o]);var l=function(e){var o=e.map((function(e){return e.lat})),t=e.map((function(e){return e.lng})),r=Math.min.apply(Math,(0,$.Z)(o)),n=Math.max.apply(Math,(0,$.Z)(o));return[[r,Math.min.apply(Math,(0,$.Z)(t))],[n,Math.max.apply(Math,(0,$.Z)(t))]]},s=o.length,a=Math.round(o.length/2),d=o[0],u=o[s-1],h=o[a],x=function(e,o){return(0,ce.jsxs)(m.Z,{direction:"row",spacing:1,alignItems:"center",children:[(0,ce.jsxs)(g.Z,{variant:"h5",color:"text.primary",sx:{fontSize:13},children:[e,":"]}),(0,ce.jsx)(ie.Z,{label:o||"N/A",color:"primary",variant:"combined",size:"small",sx:{fontWeight:1e3,fontSize:14}})]})};return o&&o.length>0&&(0,ce.jsxs)("div",{id:"map",style:{width:"100%",height:"90vh",margin:"0 auto",position:"relative"},children:[(0,ce.jsx)(ie.Z,{label:"close",color:"primary",variant:"combined",onClick:function(){return n(!1)},size:"large",sx:{position:"absolute",top:8,right:8,zIndex:1e3,"&:hover":{},cursor:"pointer"},icon:(0,ce.jsx)(se.Z,{})}),(0,ce.jsxs)(m.Z,{direction:"row",gap:2,flexWrap:"wrap",alignItems:"center",justifyContent:"flex-start",sx:{position:"absolute",bottom:0,zIndex:1e3,left:0,right:0,px:{xs:1,custom500:2,custom700:2},py:{xs:1,custom500:2,custom900:4},backgroundColor:"rgba(255, 255, 255, 0.95)",maxWidth:"100%",width:"auto",boxShadow:function(e){return e.shadows[3]}},children:[x("Tenant",null===r||void 0===r?void 0:r.tenantname),x("Rider",null===r||void 0===r?void 0:r.ridername),x("Pickup",null===r||void 0===r?void 0:r.pickupcustomer),x("Drop",null===r||void 0===r?void 0:r.deliverycustomer),x("Kms",null===r||void 0===r?void 0:r.kms),x("Actual kms",null===r||void 0===r?void 0:r.actualkms),x("Rider kms",null===r||void 0===r?void 0:r.riderkms)]}),(0,ce.jsxs)(X.h,{center:h,zoom:15,scrollWheelZoom:!1,style:{height:"100%",width:"100%"},ref:i,children:[(0,ce.jsx)(Q.I,{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),(0,ce.jsx)(ee.J,{position:d,icon:de,children:(0,ce.jsx)(oe.u,{direction:"bottom",children:(0,ce.jsx)("span",{children:"Pickup Point: ".concat(E()(t.riderStart).utc().format("DD-MM-YYYY")," (").concat(E()(t.riderStart).utc().format("hh:mm A"),")")})})}),(0,ce.jsx)(ee.J,{position:u,icon:ue,children:(0,ce.jsx)(oe.u,{direction:"bottom",children:(0,ce.jsx)("span",{children:"Drop Point: ".concat(E()(t.riderEnd).utc().format("DD-MM-YYYY")," (").concat(E()(t.riderEnd).utc().format("hh:mm A"),")")})})}),(0,ce.jsx)(te.a,{pathOptions:{color:"blue",weight:8,dashArray:"4 4"},positions:o})]})]})},xe=t(65033),fe=t(46923),pe=t(19536),ge=t(27162),me="#662582",be="#0f172a",ve="#64748b",Ze="#94a3b8",je="#e2e8f0",ye="#f8fafc",we={blocking:{label:"Blocking",color:"#b3261e",bg:"#fdecea",Icon:L.wr$},high:{label:"High",color:"#9a5b00",bg:"#fdf1de",Icon:L.ESo},medium:{label:"Medium",color:"#475569",bg:"#f1f5f9",Icon:L.ESo},low:{label:"Low",color:"#475569",bg:"#f1f5f9",Icon:L.ESo}},Se='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',ke=function(e){var o=e.label,t=e.value,r=e.hint,n=e.tone;return(0,ce.jsxs)(x.Z,{elevation:0,sx:{flex:"1 1 128px",minWidth:128,px:1.5,py:1.125,borderRadius:2,border:"1px solid",borderColor:je,bgcolor:"#fff"},children:[(0,ce.jsx)(g.Z,{sx:{fontSize:10,letterSpacing:.6,textTransform:"uppercase",color:Ze,fontWeight:700},children:o}),(0,ce.jsx)(g.Z,{sx:{fontSize:24,fontWeight:700,lineHeight:1.2,color:n||be,fontVariantNumeric:"tabular-nums"},children:t}),r&&(0,ce.jsx)(g.Z,{sx:{fontSize:11,color:ve},children:r})]})},ze=function(e){var o=e.finding,t=e.expanded,r=e.onToggle,n=e.onHighlight,i=we[o.severity]||we.medium,l=i.Icon;return(0,ce.jsxs)(x.Z,{elevation:0,sx:{borderRadius:2,border:"1px solid",borderColor:je,borderLeft:"3px solid ".concat(i.color),overflow:"hidden",bgcolor:"#fff"},children:[(0,ce.jsxs)(p.Z,{role:"button",tabIndex:0,onClick:r,onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r())},sx:{px:1.5,py:1.25,cursor:"pointer",display:"flex",gap:1,alignItems:"flex-start","&:hover":{bgcolor:ye},"&:focus-visible":{outline:"2px solid ".concat(me),outlineOffset:-2}},children:[(0,ce.jsx)(l,{size:17,color:i.color,style:{flex:"none",marginTop:2}}),(0,ce.jsxs)(p.Z,{sx:{flex:1,minWidth:0},children:[(0,ce.jsxs)(m.Z,{direction:"row",spacing:.75,alignItems:"center",flexWrap:"wrap",sx:{mb:.25},children:[(0,ce.jsx)(ie.Z,{label:i.label,size:"small",sx:{height:18,fontSize:10,fontWeight:700,bgcolor:i.bg,color:i.color,"& .MuiChip-label":{px:.75}}}),o.orderIds.length>0&&(0,ce.jsxs)(g.Z,{sx:{fontSize:11,color:Ze},children:[o.orderIds.length," orders"]})]}),(0,ce.jsx)(g.Z,{sx:{fontSize:13.5,fontWeight:600,color:be,lineHeight:1.4},children:o.title})]}),t?(0,ce.jsx)(L.Faw,{size:18,color:Ze}):(0,ce.jsx)(L.Yc6,{size:18,color:Ze})]}),(0,ce.jsx)(xe.Z,{in:t,unmountOnExit:!0,children:(0,ce.jsxs)(p.Z,{sx:{px:1.5,pb:1.5,pt:0},children:[(0,ce.jsx)(g.Z,{sx:{fontSize:12.5,color:ve,lineHeight:1.6,mb:1},children:o.detail}),o.evidence.length>0&&(0,ce.jsx)(p.Z,{sx:{p:1,borderRadius:1.5,bgcolor:ye,border:"1px solid",borderColor:je,mb:1},children:o.evidence.map((function(e){return(0,ce.jsx)(g.Z,{sx:{fontFamily:Se,fontSize:11,color:ve,whiteSpace:"pre-wrap"},children:e},e)}))}),(0,ce.jsxs)(g.Z,{sx:{fontSize:12.5,color:be,lineHeight:1.6},children:[(0,ce.jsx)(p.Z,{component:"span",sx:{fontSize:10,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",color:me,mr:.75},children:"Fix"}),o.fix]}),o.orderIds.length>0&&n&&(0,ce.jsxs)(v.Z,{size:"small",onClick:function(){return n(o.orderIds)},sx:{mt:1,textTransform:"none",fontSize:12,fontWeight:700,color:me,px:.5},children:["Show these ",o.orderIds.length," orders"]})]})})]})},Ce=function(e){var o=e.open,t=e.onClose,i=e.rows,s=e.meta,a=e.onHighlight,d=e.totalAvailable,u=(0,c.useState)(null),h=(0,l.Z)(u,2),f=h[0],v=h[1],Z=(0,c.useState)(!1),j=(0,l.Z)(Z,2),y=j[0],w=j[1],S=(0,c.useMemo)((function(){if(!o)return null;var e=Array.isArray(i)?i:[];return{summary:(0,ge.oz)(e),findings:(0,ge.JU)(e),zones:(0,ge.DI)(e)}}),[o,i]),z=function(){var e=(0,n.Z)((0,r.Z)().mark((function e(){return(0,r.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.clipboard.writeText(JSON.stringify((0,ge.GO)(i||[],s),null,2));case 3:w(!0),setTimeout((function(){return w(!1)}),2e3),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),w(!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}(),C=S&&S.summary,W=S?S.findings.filter((function(e){return"blocking"===e.severity})).length:0,D=Boolean(C&&d&&d>C.orderCount);return(0,ce.jsx)(fe.ZP,{anchor:"right",open:o,onClose:t,PaperProps:{sx:{width:{xs:"100%",sm:460},bgcolor:ye}},children:(0,ce.jsxs)(m.Z,{sx:{height:"100%"},children:[(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",spacing:1,sx:{px:2,py:1.5,bgcolor:"#fff",borderBottom:"1px solid",borderColor:je},children:[(0,ce.jsxs)(p.Z,{sx:{flex:1,minWidth:0},children:[(0,ce.jsx)(g.Z,{sx:{fontSize:14.5,fontWeight:800,color:be,lineHeight:1.3},children:"Ops Agent"}),(0,ce.jsxs)(g.Z,{sx:{fontSize:11.5,color:ve},children:[C?"".concat(C.orderCount).concat(D?" of ".concat(d):""," order").concat(1===C.orderCount?"":"s"," \xb7 ")+"".concat(C.riders.length," rider").concat(1===C.riders.length?"":"s"):"\u2014",s&&s.range?" \xb7 ".concat(s.range):""]})]}),(0,ce.jsx)(b.Z,{title:y?"Copied":"Copy the fact sheet an agent would be given",arrow:!0,children:(0,ce.jsx)(k.Z,{size:"small",onClick:z,"aria-label":"Copy agent context",children:y?(0,ce.jsx)(L.Tcr,{size:18,color:"#2c6b45"}):(0,ce.jsx)(L.Fqs,{size:17,color:ve})})}),(0,ce.jsx)(k.Z,{size:"small",onClick:t,"aria-label":"Close",children:(0,ce.jsx)(L.FU5,{size:18,color:ve})})]}),(0,ce.jsx)(p.Z,{sx:{flex:1,overflowY:"auto",px:2,py:2},children:C&&0!==C.orderCount?(0,ce.jsxs)(m.Z,{spacing:2,children:[(0,ce.jsxs)(x.Z,{elevation:0,sx:{p:1.5,borderRadius:2,bgcolor:"#fff",border:"1px solid",borderColor:je,borderLeft:"3px solid ".concat(W?we.blocking.color:"#2c6b45")},children:[(0,ce.jsx)(g.Z,{sx:{fontSize:13.5,fontWeight:700,color:be,lineHeight:1.45},children:W?"".concat(C.trustworthyDeliveryTimes," of ").concat(C.deliveryStampCount," delivery times can be trusted."):"Timestamps on this range look sound."}),(0,ce.jsx)(g.Z,{sx:{fontSize:12.5,color:ve,lineHeight:1.55,mt:.5},children:W?"Until the findings below are resolved, treat any lateness, ETA or productivity number from this range as unmeasured.":"No blocking data-quality problems were detected in this range."})]}),(0,ce.jsxs)(m.Z,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:[(0,ce.jsx)(ke,{label:"Trusted times",value:"".concat(C.trustworthyDeliveryTimes,"/").concat(C.deliveryStampCount),hint:"delivery stamps",tone:C.trustworthyDeliveryTimes<C.deliveryStampCount?we.blocking.color:"#2c6b45"}),(0,ce.jsx)(ke,{label:"Lifecycle capture",value:"".concat(Math.round(100*C.lifecycleRatio),"%"),hint:"".concat(C.lifecycleCaptured," of ").concat(C.lifecycleExpected," stamps"),tone:C.lifecycleRatio<.9?we.high.color:"#2c6b45"}),(0,ce.jsx)(ke,{label:"Slot \u2192 assign",value:null===C.medianAssignDelayMin?"\u2014":"".concat(C.medianAssignDelayMin>0?"+":"").concat(C.medianAssignDelayMin,"m"),hint:C.skew.suspected?"median, skew-corrected":"median"}),(0,ce.jsx)(ke,{label:"Settled",value:"\u20b9".concat(C.totalCharge),hint:"".concat(C.totalKm," km")})]}),(0,ce.jsxs)(p.Z,{children:[(0,ce.jsx)(g.Z,{sx:{fontSize:10.5,fontWeight:800,letterSpacing:.8,textTransform:"uppercase",color:Ze,mb:1},children:S.findings.length?"".concat(S.findings.length," findings"):"Findings"}),0===S.findings.length?(0,ce.jsx)(g.Z,{sx:{fontSize:13,color:ve},children:"Nothing flagged in this range."}):(0,ce.jsx)(m.Z,{spacing:1,children:S.findings.map((function(e){return(0,ce.jsx)(ze,{finding:e,expanded:f===e.id,onToggle:function(){return v(f===e.id?null:e.id)},onHighlight:a},e.id)}))})]}),S.zones.length>0&&(0,ce.jsxs)(p.Z,{children:[(0,ce.jsx)(g.Z,{sx:{fontSize:10.5,fontWeight:800,letterSpacing:.8,textTransform:"uppercase",color:Ze,mb:1},children:"By zone"}),(0,ce.jsx)(x.Z,{elevation:0,sx:{borderRadius:2,border:"1px solid",borderColor:je,bgcolor:"#fff",overflow:"hidden"},children:S.zones.map((function(e,o){return(0,ce.jsxs)(p.Z,{children:[o>0&&(0,ce.jsx)(pe.Z,{}),(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",spacing:1,sx:{px:1.5,py:1},children:[(0,ce.jsx)(g.Z,{sx:{flex:1,fontSize:12.5,fontWeight:600,color:be},children:e.zone}),(0,ce.jsxs)(g.Z,{sx:{fontFamily:Se,fontSize:11.5,color:ve},children:[e.orders," \xb7 ",e.km," km \xb7 \u20b9",e.charge]})]})]},e.zone)}))})]}),(0,ce.jsxs)(g.Z,{sx:{fontSize:11,color:Ze,lineHeight:1.55},children:["Computed in the browser from the ",C.orderCount," rows currently loaded",D?" of ".concat(d," matching this filter \u2014 scroll the table to load the rest"):"",C.skew.suspected?", slots corrected by ".concat((0,ge.JB)(C.skew.suggestedShiftMin)):"",". No model was called."]})]}):(0,ce.jsx)(g.Z,{sx:{fontSize:13,color:ve},children:"No orders in the current filter. Widen the date range or clear the status filter, then reopen this panel."})})]})})},We=t(91635);E().extend(We);var De=999,Me="0 14px 40px rgba(15, 23, 42, 0.10)",Ie="0 8px 24px rgba(15, 23, 42, 0.08)",Ae="0 18px 50px rgba(15, 23, 42, 0.18)",Re="#0f172a",Ye="#64748b",Pe="#94a3b8",He="#e2e8f0",Le="#f1f5f9",Te="#f8fafc",Ee=function(e,o){return"".concat(e).concat(o)},Oe=function(e){return Ee(e,"08")},Be=function(e){return Ee(e,"18")},Fe=function(e){return Ee(e,"26")},Ne=function(e){return Ee(e,"55")},Ve="#662582",Ke="#9255AB",qe={created:{label:"Created",color:"#3b82f6",icon:L.ili},pending:{label:"Pending",color:"#f59e0b",icon:L.Ley},accepted:{label:"Accepted",color:"#6366f1",icon:L.Z5O},arrived:{label:"Arrived",color:"#06b6d4",icon:L.ZSR},picked:{label:"Picked",color:"#8b5cf6",icon:L.ili},active:{label:"Active",color:"#0ea5e9",icon:L.ili},processing:{label:"Processing",color:"#3b82f6",icon:L.dKE},onhold:{label:"On Hold",color:"#8b5cf6",icon:L.Y8K},"on hold":{label:"On Hold",color:"#8b5cf6",icon:L.Y8K},delivered:{label:"Delivered",color:"#10b981",icon:L.ZSR},skipped:{label:"Skipped",color:"#f97316",icon:L.B4e},failed:{label:"Failed",color:"#991b1b",icon:L.B4e},cancelled:{label:"Cancelled",color:"#ef4444",icon:L.B4e}},Ue=[{id:0,status:"All",statusLow:"All",color:Ve,icon:L.YgO},{id:1,status:"Pending",statusLow:"pending",color:"#f59e0b",icon:L.Ley},{id:2,status:"Accepted",statusLow:"accepted",color:"#6366f1",icon:L.Z5O},{id:3,status:"Arrived",statusLow:"arrived",color:"#06b6d4",icon:L.ZSR},{id:4,status:"Picked",statusLow:"picked",color:"#8b5cf6",icon:L.ili},{id:5,status:"Active",statusLow:"active",color:"#14b8a6",icon:L.ili},{id:6,status:"Delivered",statusLow:"delivered",color:"#10b981",icon:L.ZSR},{id:7,status:"Skipped",statusLow:"skipped",color:"#f97316",icon:L.B4e},{id:8,status:"Cancelled",statusLow:"cancelled",color:"#ef4444",icon:L.B4e}],Je=function(e){return(0,ce.jsx)(x.Z,(0,s.Z)((0,s.Z)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:Ae,border:"1px solid",borderColor:"divider",overflow:"hidden"}}))},_e=function(e){var o=e.color,t=e.selected,r=e.size,n=void 0===r?24:r,i=e.children;return(0,ce.jsx)(f.Z,{sx:{width:n,height:n,bgcolor:t?o:Be(o),color:t?"#fff":o,transition:"background-color 0.15s, color 0.15s"},children:i})},Ge=function(e){return{"& .MuiOutlinedInput-root":{borderRadius:De+"px",bgcolor:Oe(e),fontWeight:600,"& fieldset":{borderColor:Ne(e),borderWidth:1.5},"&:hover fieldset":{borderColor:e},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(Fe(e))},"&.Mui-focused fieldset":{borderColor:e,borderWidth:2}}}},$e=function(e){var o=e.status,t=qe[String(o||"").toLowerCase()]||{label:o||"\u2014",color:Pe,icon:L.Y8K},r=t.icon;return(0,ce.jsxs)(p.Z,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.125,py:.375,borderRadius:999,bgcolor:t.color,color:"#fff",fontSize:11,fontWeight:700,letterSpacing:.2,whiteSpace:"nowrap",minWidth:86,justifyContent:"center",boxShadow:"0 1px 2px ".concat(Fe(t.color))},children:[(0,ce.jsx)(r,{size:12})," ",t.label]})},Xe=function(e){var o=e.value,t=e.color,r=e.icon,n=e.isMoney,i=void 0!==n&&n,l=Number(o),s=i?eo(l):Number.isFinite(l)?l:o||0;return!Number.isFinite(l)||0===l?(0,ce.jsx)(g.Z,{variant:"caption",sx:{color:Pe,fontWeight:700},children:s}):(0,ce.jsxs)(p.Z,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:.875,py:.25,borderRadius:999,bgcolor:Oe(t),border:"1px solid ".concat(Ne(t)),color:t,fontSize:12,fontWeight:800,whiteSpace:"nowrap"},children:[r,s]})},Qe=function(e){var o=e.value;return o?(0,ce.jsxs)(m.Z,{spacing:0,sx:{lineHeight:1.1},children:[(0,ce.jsx)(g.Z,{sx:{fontSize:12.5,fontWeight:800,color:Re,letterSpacing:.1,lineHeight:1.15},noWrap:!0,children:E()(o).format("hh:mm A")}),(0,ce.jsx)(g.Z,{sx:{fontSize:10.5,fontWeight:600,color:Pe,lineHeight:1.2},noWrap:!0,children:E()(o).format("DD MMM YYYY")})]}):(0,ce.jsx)(g.Z,{sx:{fontSize:12,color:Pe,fontWeight:700},children:"\u2014"})};function eo(e){return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:2}).format(e||0)}function oo(){(0,h.Z)();var e,o,t,T=localStorage.getItem("tenantid"),$=(0,c.useRef)(null),X=(0,c.useRef)(),Q=(0,c.useRef)(),ee=(0,c.useState)(E()().format("YYYY-MM-DD")),oe=(0,l.Z)(ee,2),te=oe[0],re=oe[1],ne=(0,c.useState)(E()().format("YYYY-MM-DD")),ie=(0,l.Z)(ne,2),le=ie[0],se=ie[1],ae=(0,c.useState)(!1),de=(0,l.Z)(ae,2),ue=de[0],xe=de[1],fe=(0,c.useState)("Today"),pe=(0,l.Z)(fe,2),ge=pe[0],me=pe[1],be=(0,c.useState)(0),ve=(0,l.Z)(be,2),Ze=(ve[0],ve[1]),je=(0,c.useState)(0),ye=(0,l.Z)(je,2),we=(ye[0],ye[1]),Se=(0,c.useState)(""),ke=(0,l.Z)(Se,2),ze=ke[0],We=ke[1],De=(0,c.useState)(!1),Ee=(0,l.Z)(De,2),qe=Ee[0],oo=Ee[1],to=(0,c.useState)((function(){try{return localStorage.getItem("ordersDetails.density")||"compact"}catch(e){return"compact"}})),ro=(0,l.Z)(to,2),no=ro[0],io=ro[1],lo="compact"===no,so=lo?.5:1;(0,c.useEffect)((function(){try{localStorage.setItem("ordersDetails.density",no)}catch(e){}}),[no]);var co=[{key:"index",label:"#",group:"Core",required:!0,defaultVisible:!0,width:36},{key:"location",label:"Location / Order",group:"Core",required:!0,defaultVisible:!0,minWidth:150},{key:"pickup",label:"Pickup",group:"Core",defaultVisible:!0,minWidth:140},{key:"drop",label:"Drop",group:"Core",defaultVisible:!0,minWidth:140},{key:"status",label:"Status",group:"Core",required:!0,defaultVisible:!0,width:110},{key:"assigned",label:"Assigned",group:"Lifecycle",defaultVisible:!0,minWidth:110},{key:"accepted",label:"Accepted",group:"Lifecycle",defaultVisible:!1,minWidth:90},{key:"arrived",label:"Arrived",group:"Lifecycle",defaultVisible:!1,minWidth:90},{key:"picked",label:"Picked",group:"Lifecycle",defaultVisible:!0,minWidth:90},{key:"delivered",label:"Delivered",group:"Lifecycle",defaultVisible:!0,minWidth:90},{key:"cancelled",label:"Cancelled",group:"Lifecycle",defaultVisible:!1,minWidth:90},{key:"kms",label:"Kms",group:"Metrics",defaultVisible:!0,width:70,align:"center"}],ao=co.reduce((function(e,o){return(0,s.Z)((0,s.Z)({},e),{},(0,i.Z)({},o.key,o.defaultVisible))}),{}),uo=(0,c.useState)((function(){try{var e=JSON.parse(localStorage.getItem("ordersDetails.cols")||"null");return e&&"object"===typeof e?(0,s.Z)((0,s.Z)({},ao),e):ao}catch(o){return ao}})),ho=(0,l.Z)(uo,2),xo=ho[0],fo=ho[1];(0,c.useEffect)((function(){try{localStorage.setItem("ordersDetails.cols",JSON.stringify(xo))}catch(e){}}),[xo]);var po=function(e){var o=co.find((function(o){return o.key===e}));return(null===o||void 0===o?void 0:o.required)||!1!==xo[e]},go=co.filter((function(e){return po(e.key)})).length,mo=co.length-go,bo=(0,c.useState)(null),vo=(0,l.Z)(bo,2),Zo=vo[0],jo=vo[1],yo=function(e){return fo((function(o){return(0,s.Z)((0,s.Z)({},o),{},(0,i.Z)({},e,!(!1!==o[e])))}))},wo=co.every((function(e){return po(e.key)===!!e.defaultVisible})),So=(0,c.useState)([]),ko=(0,l.Z)(So,2),zo=ko[0],Co=(ko[1],(0,c.useState)()),Wo=(0,l.Z)(Co,2),Do=Wo[0],Mo=(Wo[1],(0,c.useState)()),Io=(0,l.Z)(Mo,2),Ao=Io[0],Ro=(Io[1],(0,c.useState)(!1)),Yo=(0,l.Z)(Ro,2),Po=Yo[0],Ho=Yo[1],Lo=(0,c.useState)({}),To=(0,l.Z)(Lo,2),Eo=To[0],Oo=(To[1],(0,c.useState)("All")),Bo=(0,l.Z)(Oo,2),Fo=Bo[0],No=Bo[1],Vo=(0,c.useState)(0),Ko=(0,l.Z)(Vo,2),qo=Ko[0],Uo=Ko[1],Jo=(0,c.useState)(Ue[0]),_o=(0,l.Z)(Jo,2),Go=_o[0],$o=_o[1],Xo=(0,c.useState)([]),Qo=(0,l.Z)(Xo,2),et=Qo[0],ot=Qo[1],tt=(0,c.useState)(0),rt=(0,l.Z)(tt,2),nt=rt[0],it=rt[1],lt=(0,c.useState)("All Locations"),st=(0,l.Z)(lt,2),ct=st[0],at=st[1],dt=(0,c.useState)(null),ut=(0,l.Z)(dt,2),ht=ut[0],xt=ut[1],ft=function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,t=(0,c.useState)(e),r=(0,l.Z)(t,2),n=r[0],i=r[1];return(0,c.useEffect)((function(){var t=setTimeout((function(){i(e)}),o);return function(){return clearTimeout(t)}}),[e,o]),n}(ze,500),pt=function(){var e=(0,n.Z)((0,r.Z)().mark((function e(o){var t;return(0,r.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,a.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantlocations/?tenantid=").concat(o));case 3:t=e.sent,ot(t.data.details||[]),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.log("gettenantlocations",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(o){return e.apply(this,arguments)}}();(0,c.useEffect)((function(){pt(T)}),[]);(0,c.useEffect)((function(){var e=function(e){"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),$.current&&$.current.focus()),"Escape"===e.key&&document.activeElement===$.current&&$.current.blur()};return document.addEventListener("keydown",e),function(){return document.removeEventListener("keydown",e)}}),[]);var gt=(0,d.N)({queryKey:[te,le,Fo,nt,ft],queryFn:J.$w,getNextPageParam:function(e){return e.nextPage}}),mt=gt.data,bt=gt.isError,vt=gt.error,Zt=gt.fetchNextPage,jt=gt.isLoading,yt=gt.hasNextPage,wt=gt.isFetchingNextPage,St=(null===mt||void 0===mt?void 0:mt.pages.flatMap((function(e){return e.details})))||[];(0,c.useEffect)((function(){if(yt){var e=new IntersectionObserver((function(e){e[0].isIntersecting&&Zt()}),{root:null,rootMargin:"0px 0px 400px 0px",threshold:0});return X.current&&e.observe(X.current),function(){X.current&&e.unobserve(X.current)}}}),[yt,Zt]);var kt=(0,u.a)({queryKey:["deliverycount",te,le,Fo,nt],queryFn:J.Vf}).data;if((0,c.useEffect)((function(){var e,o={All:null===kt||void 0===kt?void 0:kt.total,pending:null===kt||void 0===kt?void 0:kt.pending,accepted:null===kt||void 0===kt?void 0:kt.accepted,arrived:null===kt||void 0===kt?void 0:kt.arrived,picked:null===kt||void 0===kt?void 0:kt.picked,active:null===kt||void 0===kt?void 0:kt.active,delivered:null===kt||void 0===kt?void 0:kt.delivered,cancelled:null===kt||void 0===kt?void 0:kt.cancelled};Uo(null!==(e=o[Fo])&&void 0!==e?e:0)}),[Fo,kt]),(0,c.useEffect)((function(){var e=0,o=0;St&&St.forEach((function(t){e+=t.deliverycharges,o+=t.deliveryamt})),Ze(e),we(o)}),[St]),bt)return"An error has occurred:(isErrorOrderDetails) "+vt.message;var zt=St.map((function(e){return{tenantname:e.tenantname,tenantcity:e.tenantcity,tenantcontactno:e.tenantcontactno,rider:e.rider,orderid:e.orderid,orderdate:e.orderdate,deliverydate:e.deliverydate,orderstatus:e.orderstatus,deliverystatus:e.deliverystatus,ordernotes:e.ordernotes,kms:e.kms,actualkms:e.actualkms,assigntime:e.assigntime,starttime:e.starttime,arrivaltime:e.arrivaltime,pickuptime:e.pickuptime,deliverytime:e.deliverytime,canceltime:e.canceltime,deliverycharge:e.deliverycharge,deliveryamt:e.deliveryamt,pickupcustomer:e.pickupcustomer,pickupcontactno:e.pickupcontactno,pickupaddress:e.pickupaddress,pickupsuburb:e.pickupsuburb,pickupcity:e.pickupcity,pickuplat:e.pickuplat,pickuplong:e.pickuplong,deliverycustomer:e.deliverycustomer,deliverycontactno:e.deliverycontactno,deliveryaddress:e.deliveryaddress,deliverysuburb:e.deliverysuburb,deliverylat:e.deliverylat,deliverylong:e.deliverylong,locationname:e.locationname,locationsuburb:e.locationsuburb,locationcity:e.locationcity,locationcontactno:e.locationcontactno}})),Ct=[{key:"total",label:"".concat("All"===Fo?"Total":Fo," Orders"),color:Ve,icon:L.YgO,value:qo,hint:"Orders matching the current filters."},{key:"pending",label:"Pending",color:"#f59e0b",icon:L.Ley,value:null!==(e=null===kt||void 0===kt?void 0:kt.pending)&&void 0!==e?e:0,hint:"Orders awaiting rider assignment or pickup."},{key:"delivered",label:"Delivered",color:"#10b981",icon:L.ZSR,value:null!==(o=null===kt||void 0===kt?void 0:kt.delivered)&&void 0!==o?o:0,hint:"Successfully delivered orders."}];return(0,ce.jsxs)(ce.Fragment,{children:[jt&&(0,ce.jsx)(G.Z,{}),(0,ce.jsx)(x.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:He,background:"linear-gradient(135deg, ".concat(Oe(Ve)," 0%, ").concat(Oe(Ke)," 100%)"),boxShadow:Ie},children:(0,ce.jsxs)(m.Z,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",spacing:{xs:1,sm:1.5},children:[(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",spacing:1.25,children:[(0,ce.jsx)(f.Z,{variant:"rounded",sx:{width:36,height:36,bgcolor:Ve,color:"#fff",borderRadius:1.5,boxShadow:"0 4px 12px ".concat(Fe(Ve))},children:(0,ce.jsx)(L.VHP,{size:19})}),(0,ce.jsxs)(m.Z,{spacing:.125,children:[(0,ce.jsx)(g.Z,{variant:"h3",sx:{fontWeight:800,color:Re,lineHeight:1.1,fontSize:{xs:"1.1rem",sm:"1.25rem",md:"1.375rem"}},children:"Orders Details"}),(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",spacing:.75,children:[(0,ce.jsx)(p.Z,{sx:{width:7,height:7,borderRadius:"50%",bgcolor:"#10b981",boxShadow:"0 0 0 3px rgba(16,185,129,0.18)"}}),(0,ce.jsxs)(g.Z,{sx:{fontSize:11.5,color:Ye,fontWeight:600},children:["Live \xb7 ",ct," \xb7 ",ge]})]})]})]}),(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",spacing:.75,flexWrap:"wrap",useFlexGap:!0,children:[(0,ce.jsx)(b.Z,{title:lo?"Switch to comfortable density":"Switch to compact density",arrow:!0,children:(0,ce.jsx)(v.Z,{onClick:function(){return io((function(e){return"compact"===e?"comfortable":"compact"}))},disableElevation:!0,variant:"outlined",size:"small",startIcon:(0,ce.jsx)(L.VK0,{size:15,style:{transform:lo?"none":"scaleY(1.4)"}}),sx:{height:32,px:1.25,borderRadius:1.5,textTransform:"none",fontSize:12.5,fontWeight:700,bgcolor:"#fff",borderColor:He,color:Re,"&:hover":{bgcolor:"#fff",borderColor:Ve,color:Ve,boxShadow:"0 0 0 3px ".concat(Fe(Ve))}},children:lo?"Compact":"Comfortable"})}),(0,ce.jsx)(b.Z,{title:"Show or hide columns",arrow:!0,children:(0,ce.jsx)(v.Z,{onClick:function(e){return jo(e.currentTarget)},disableElevation:!0,variant:"outlined",size:"small",startIcon:(0,ce.jsx)(L.Dx,{size:15}),endIcon:mo>0?(0,ce.jsxs)(p.Z,{component:"span",sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:30,height:18,px:.5,borderRadius:999,bgcolor:Be(Ve),color:Ve,fontSize:10.5,fontWeight:800,lineHeight:1},children:[go,"/",co.length]}):null,sx:{height:32,px:1.25,borderRadius:1.5,textTransform:"none",fontSize:12.5,fontWeight:700,bgcolor:mo>0?Oe(Ve):"#fff",borderColor:mo>0?Ne(Ve):He,color:mo>0?Ve:Re,"&:hover":{bgcolor:mo>0?Oe(Ve):"#fff",borderColor:Ve,color:Ve,boxShadow:"0 0 0 3px ".concat(Fe(Ve))}},children:"Columns"})}),(0,ce.jsx)(b.Z,{title:"Filter by date range",arrow:!0,children:(0,ce.jsx)(v.Z,{onClick:function(){return xe(!0)},disableElevation:!0,variant:"outlined",size:"small",startIcon:(0,ce.jsx)(L.sHf,{size:15}),sx:{height:32,px:1.25,borderRadius:1.5,textTransform:"none",fontSize:12.5,fontWeight:700,letterSpacing:.1,bgcolor:"#fff",borderColor:He,color:Re,"&:hover":{bgcolor:"#fff",borderColor:Ve,color:Ve,boxShadow:"0 0 0 3px ".concat(Fe(Ve))},"&:focus-visible":{boxShadow:"0 0 0 3px ".concat(Fe(Ve))}},children:te&&le?"".concat(E()(te).format("DD MMM")," \u2013 ").concat(E()(le).format("DD MMM")):"All time"})}),(0,ce.jsx)(b.Z,{title:"Check this range for data-quality problems before trusting its numbers",arrow:!0,children:(0,ce.jsx)(v.Z,{onClick:function(){return oo(!0)},disableElevation:!0,variant:"outlined",size:"small",startIcon:(0,ce.jsx)(L.YgO,{size:15}),sx:{height:32,px:1.25,borderRadius:1.5,textTransform:"none",fontSize:12.5,fontWeight:700,letterSpacing:.1,bgcolor:"#fff",borderColor:He,color:Re,"&:hover":{bgcolor:"#fff",borderColor:Ve,color:Ve,boxShadow:"0 0 0 3px ".concat(Fe(Ve))},"&:focus-visible":{boxShadow:"0 0 0 3px ".concat(Fe(Ve))}},children:"Ops Agent"})}),(0,ce.jsx)(p.Z,{sx:{display:"inline-flex","& a":{textDecoration:"none",lineHeight:0}},children:(0,ce.jsx)(_.ZZ,{data:zt,filename:"Orders_Detail_".concat(E()().format("YYYY-MM-DD_HHmmss"),".csv"),label:"Download",style:{height:32,minHeight:32,px:1.5,borderRadius:1.5,bgcolor:Ve,color:"#fff",textTransform:"none",fontSize:12.5,fontWeight:700,letterSpacing:.1,boxShadow:"0 2px 6px ".concat(Fe(Ve)),"&:hover":{bgcolor:Ke,boxShadow:"0 4px 12px ".concat(Fe(Ve))},"&:focus-visible":{boxShadow:"0 0 0 3px ".concat(Fe(Ve))},"& .MuiButton-startIcon":{mr:.75,"& svg":{fontSize:16}}}})})]})]})}),(0,ce.jsx)(Z.ZP,{container:!0,spacing:{xs:1,sm:1.25,md:1.5},children:Ct.map((function(e){var o,t=e.icon;return(0,ce.jsx)(Z.ZP,{item:!0,xs:6,sm:4,md:4,children:(0,ce.jsx)(b.Z,{title:e.hint||"",placement:"top",arrow:!0,children:(0,ce.jsxs)(x.Z,{elevation:0,sx:{position:"relative",overflow:"hidden",px:{xs:1.25,sm:1.5},py:{xs:.875,sm:1.125},borderRadius:2,border:"1px solid",borderColor:He,background:"#fff",transition:"transform 0.15s, box-shadow 0.15s, border-color 0.15s","&:hover":{transform:"translateY(-1px)",boxShadow:Ie,borderColor:Ne(e.color)}},children:[(0,ce.jsx)(p.Z,{sx:{position:"absolute",top:0,left:0,bottom:0,width:3,background:e.color}}),(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,sx:{pl:.5},children:[(0,ce.jsxs)(m.Z,{spacing:.125,sx:{minWidth:0,flex:1},children:[(0,ce.jsx)(g.Z,{sx:{color:Ye,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",fontSize:10.5,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.2},children:e.label}),(0,ce.jsx)(g.Z,{sx:{fontWeight:800,color:Re,lineHeight:1.15,fontSize:{xs:"0.95rem",sm:"1.1rem",md:"1.2rem"}},noWrap:!0,children:jt&&!e.value?(0,ce.jsx)(j.Z,{sx:{width:40},animation:"wave"}):e.isMoney?eo(e.value):null!==(o=e.value)&&void 0!==o?o:0})]}),(0,ce.jsx)(f.Z,{variant:"rounded",sx:{width:30,height:30,bgcolor:Be(e.color),color:e.color,borderRadius:1.25,flexShrink:0},children:(0,ce.jsx)(t,{size:15})})]})]})})},e.key)}))}),(0,ce.jsx)(x.Z,{elevation:0,sx:{mt:{xs:1,md:1.25},p:{xs:1,md:1.125},borderRadius:2,border:"1px solid",borderColor:He,background:"#fff",boxShadow:Me},children:(0,ce.jsxs)(Z.ZP,{container:!0,spacing:1,alignItems:"center",children:[(0,ce.jsx)(Z.ZP,{item:!0,xs:12,sm:6,md:4,children:1===et.length?(0,ce.jsxs)(p.Z,{sx:{display:"inline-flex",alignItems:"center",gap:.75,px:1.5,py:.875,borderRadius:999,bgcolor:Oe(Ve),border:"1.5px solid ".concat(Ne(Ve)),color:Ve,fontWeight:800,fontSize:13,width:"100%"},children:[(0,ce.jsx)(L.x$F,{size:14})," ",et[0].locationname]}):(0,ce.jsx)(y.Z,{fullWidth:!0,options:et||[],value:ht,getOptionLabel:function(e){return e?"".concat(e.locationname," (").concat(e.suburb||"",")"):""},PaperComponent:Je,onChange:function(e,o,t){o&&(xt(o),it(o.locationid),at(o.locationname)),"clear"===t&&(xt(null),it(0),at("All Locations"))},renderInput:function(e){return(0,ce.jsx)(w.Z,(0,s.Z)((0,s.Z)({},e),{},{placeholder:"All Locations",size:"small",sx:Ge("#10b981"),InputProps:(0,s.Z)((0,s.Z)({},e.InputProps),{},{startAdornment:(0,ce.jsx)(m.Z,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:(0,ce.jsx)(_e,{color:"#10b981",size:22,selected:!0,children:(0,ce.jsx)(L.c7Z,{size:13})})})})}))}})}),(0,ce.jsx)(Z.ZP,{item:!0,xs:12,sm:6,md:4,children:(0,ce.jsx)(y.Z,{fullWidth:!0,options:Ue,value:Go,getOptionLabel:function(e){return(null===e||void 0===e?void 0:e.status)||""},PaperComponent:Je,onChange:function(e,o,t){"clear"===t?(No("All"),$o(Ue[0])):(No(o.statusLow),$o(o))},renderInput:function(e){return(0,ce.jsx)(w.Z,(0,s.Z)((0,s.Z)({},e),{},{placeholder:"Status",size:"small",sx:Ge((null===Go||void 0===Go?void 0:Go.color)||Ve),InputProps:(0,s.Z)((0,s.Z)({},e.InputProps),{},{startAdornment:(0,ce.jsx)(m.Z,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:(0,ce.jsx)(_e,{color:(null===Go||void 0===Go?void 0:Go.color)||Ve,size:22,selected:!0,children:null!==Go&&void 0!==Go&&Go.icon?c.createElement(Go.icon,{size:13}):(0,ce.jsx)(L.VK0,{size:13})})})})}))}})}),(0,ce.jsx)(Z.ZP,{item:!0,xs:12,sm:12,md:4,children:(0,ce.jsxs)(p.Z,{sx:{display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:999,bgcolor:Oe(Ve),border:"1.5px solid ".concat(Ne(Ve)),transition:"all 0.18s","&:focus-within":{borderColor:Ve,boxShadow:"0 0 0 3px ".concat(Fe(Ve))}},children:[(0,ce.jsx)(L.vU7,{size:16,style:{color:Ve,flexShrink:0}}),(0,ce.jsx)(S.ZP,{inputRef:$,placeholder:"Search (ctrl+k)",value:ze,onChange:function(e){return We(e.target.value)},autoComplete:"off",sx:{flex:1,fontSize:13,fontWeight:600,color:Re,"& input::placeholder":{color:Pe,opacity:1}}}),ze&&(0,ce.jsx)(k.Z,{size:"small",onClick:function(){return We("")},sx:{p:.25,color:Ve},children:(0,ce.jsx)(L.lUB,{size:14})})]})})]})}),(0,ce.jsx)(x.Z,{elevation:0,sx:{mt:{xs:1,md:1.25},borderRadius:2,border:"1px solid",borderColor:He,overflow:"hidden",background:"#fff"},children:(0,ce.jsx)(z.Z,{ref:Q,onScroll:function(e){var o=e.currentTarget,t=o.scrollTop,r=o.scrollHeight;t+o.clientHeight>=r-50&&yt&&!wt&&Zt()},sx:{overflowX:"auto",overflowY:"visible","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:Ne(Ve),borderRadius:8,"&:hover":{backgroundColor:Ve}},"&::-webkit-scrollbar-track":{backgroundColor:Te}},children:(0,ce.jsxs)(C.Z,{stickyHeader:!0,size:"small",sx:{minWidth:co.filter((function(e){return po(e.key)})).reduce((function(e,o){return e+(o.width||o.minWidth||100)}),0),tableLayout:"auto"},children:[(0,ce.jsx)(W.Z,{children:(0,ce.jsxs)(D.Z,{sx:{"& th":{backgroundColor:Te,color:Ye,fontSize:10.5,fontWeight:800,letterSpacing:.5,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(He),py:.75,px:1}},children:[po("index")&&(0,ce.jsx)(M.Z,{sx:{width:36},children:"#"}),po("location")&&(0,ce.jsx)(M.Z,{sx:{minWidth:150},children:"Location / Order"}),po("pickup")&&(0,ce.jsx)(M.Z,{sx:{minWidth:140},children:"Pickup"}),po("drop")&&(0,ce.jsx)(M.Z,{sx:{minWidth:140},children:"Drop"}),po("status")&&(0,ce.jsx)(M.Z,{sx:{width:110},children:"Status"}),po("assigned")&&(0,ce.jsx)(M.Z,{sx:{minWidth:110},children:"Assigned"}),po("accepted")&&(0,ce.jsx)(M.Z,{sx:{minWidth:90},children:"Accepted"}),po("arrived")&&(0,ce.jsx)(M.Z,{sx:{minWidth:90},children:"Arrived"}),po("picked")&&(0,ce.jsx)(M.Z,{sx:{minWidth:90},children:"Picked"}),po("delivered")&&(0,ce.jsx)(M.Z,{sx:{minWidth:90},children:"Delivered"}),po("cancelled")&&(0,ce.jsx)(M.Z,{sx:{minWidth:90},children:"Cancelled"}),po("kms")&&(0,ce.jsx)(M.Z,{align:"center",sx:{width:70},children:"Kms"})]})}),(0,ce.jsxs)(I.Z,{children:[0===(null===St||void 0===St?void 0:St.length)&&!jt&&(0,ce.jsx)(D.Z,{children:(0,ce.jsx)(M.Z,{colSpan:go,sx:{py:7,borderBottom:"none"},children:(0,ce.jsxs)(m.Z,{alignItems:"center",spacing:1.25,children:[(0,ce.jsx)(f.Z,{sx:{width:56,height:56,bgcolor:Be("#94a3b8"),color:Pe,borderRadius:2},variant:"rounded",children:(0,ce.jsx)(L.VHP,{size:26})}),(0,ce.jsx)(g.Z,{sx:{fontWeight:700,color:Re,fontSize:14},children:"No orders match these filters"}),(0,ce.jsx)(g.Z,{sx:{color:Ye,fontSize:12},children:ze?"Try a different keyword or clear the search.":"Adjust the location, status, or date range above."}),ze&&(0,ce.jsx)(v.Z,{size:"small",onClick:function(){return We("")},sx:{mt:.5,height:28,textTransform:"none",fontSize:12,fontWeight:700,color:Ve,borderRadius:1.25,"&:hover":{bgcolor:Oe(Ve)}},startIcon:(0,ce.jsx)(L.lUB,{size:14}),children:"Clear search"})]})})}),jt&&0===St.length&&Array.from({length:10}).map((function(e,o){return(0,ce.jsx)(D.Z,{children:Array.from({length:go}).map((function(e,o){return(0,ce.jsx)(M.Z,{sx:{borderBottom:"1px solid ".concat(Le),py:.625,px:1},children:(0,ce.jsx)(j.Z,{animation:"wave",height:20})},o)}))},"sk-".concat(o))})),St.map((function(e,o){return(0,ce.jsxs)(D.Z,{sx:{cursor:"pointer",transition:"background-color 0.12s, box-shadow 0.12s","& td":{borderBottom:"1px solid ".concat(Le),py:so,px:1,verticalAlign:"top"},"&:hover":{backgroundColor:Oe(Ve),boxShadow:"inset 3px 0 0 ".concat(Ve)}},children:[po("index")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsx)(g.Z,{sx:{fontWeight:700,fontSize:12,color:Pe},children:o+1})}),po("location")&&(0,ce.jsxs)(M.Z,{children:[(0,ce.jsx)(g.Z,{sx:{fontSize:12.5,fontWeight:700,color:Re,lineHeight:1.25},noWrap:!0,children:e.locationname}),(0,ce.jsx)(b.Z,{title:"Order Id",children:(0,ce.jsx)(g.Z,{sx:{fontSize:11,color:Ye,fontWeight:600,lineHeight:1.3},noWrap:!0,children:e.orderid})}),(0,ce.jsx)(b.Z,{title:"Delivery Date",children:(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",spacing:.5,sx:{mt:.125},children:[(0,ce.jsx)(L.dKE,{size:10,style:{color:Pe,flexShrink:0}}),(0,ce.jsx)(g.Z,{sx:{fontSize:10.5,color:Ye,fontWeight:700},noWrap:!0,children:E()(e.deliverydate).utc().format("hh:mm A")}),(0,ce.jsxs)(g.Z,{sx:{fontSize:10.5,color:Pe,fontWeight:600},noWrap:!0,children:["\xb7 ",E()(e.deliverydate).utc().format("DD MMM YY")]})]})})]}),po("pickup")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsxs)(m.Z,{spacing:.125,children:[(0,ce.jsx)(g.Z,{sx:{fontSize:12.5,fontWeight:700,color:Re,lineHeight:1.25},noWrap:!0,children:e.pickupcustomer}),(0,ce.jsx)(g.Z,{sx:{fontSize:11,color:Ye,fontWeight:600,lineHeight:1.3},noWrap:!0,children:e.pickupcontactno}),(0,ce.jsx)(b.Z,{title:e.Pickupaddress||e.pickupaddress,children:(0,ce.jsx)(g.Z,{sx:{fontSize:10.5,color:Pe,fontWeight:600,lineHeight:1.3},noWrap:!0,children:e.pickupsuburb||e.pickuplocation||(e.Pickupaddress?"".concat(e.Pickupaddress.slice(0,20),"\u2026"):"\u2014")})})]})}),po("drop")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsxs)(m.Z,{spacing:.125,children:[(0,ce.jsx)(g.Z,{sx:{fontSize:12.5,fontWeight:700,color:Re,lineHeight:1.25},noWrap:!0,children:e.deliverycustomer}),(0,ce.jsx)(g.Z,{sx:{fontSize:11,color:Ye,fontWeight:600,lineHeight:1.3},noWrap:!0,children:e.deliverycontactno}),(0,ce.jsx)(b.Z,{title:e.deliveryaddress,children:(0,ce.jsx)(g.Z,{sx:{fontSize:10.5,color:Pe,fontWeight:600,lineHeight:1.3},noWrap:!0,children:e.deliverysuburb||e.deliverylocation||(e.deliveryaddress?"".concat(e.deliveryaddress.slice(0,20),"\u2026"):"\u2014")})})]})}),po("status")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsx)($e,{status:e.orderstatus})}),po("assigned")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsxs)(m.Z,{spacing:.25,children:[e.ridername&&(0,ce.jsx)(g.Z,{sx:{fontSize:11,fontWeight:800,color:Ve},noWrap:!0,children:e.ridername}),(0,ce.jsx)(Qe,{value:e.assigntime})]})}),po("accepted")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsx)(Qe,{value:e.starttime})}),po("arrived")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsx)(Qe,{value:e.arrivaltime})}),po("picked")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsx)(Qe,{value:e.pickuptime})}),po("delivered")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsx)(Qe,{value:e.deliverytime})}),po("cancelled")&&(0,ce.jsx)(M.Z,{children:(0,ce.jsx)(Qe,{value:e.canceltime})}),po("kms")&&(0,ce.jsx)(M.Z,{align:"center",children:(0,ce.jsx)(Xe,{value:"cancelled"===e.orderstatus||""===e.kms?0:Number(parseFloat(e.kms||0).toFixed(1)),color:"#f59e0b",icon:(0,ce.jsx)(L.v93,{size:11})})})]},"".concat(e.orderid,"-").concat(o))})),0!==St.length&&(0,ce.jsx)(D.Z,{sx:{"&:hover":{backgroundColor:"transparent !important"}},children:(0,ce.jsx)(M.Z,{colSpan:go,sx:{borderBottom:"none",py:1,bgcolor:Te},children:(0,ce.jsx)(m.Z,{ref:X,direction:"row",alignItems:"center",justifyContent:"center",spacing:1,sx:{minHeight:32},children:wt||yt?(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(A.Z,{size:14,sx:{color:Ve}}),(0,ce.jsx)(g.Z,{sx:{fontSize:11.5,color:Ye,fontWeight:700},children:"Loading more orders\u2026"})]}):(0,ce.jsxs)(g.Z,{sx:{fontSize:11.5,color:Pe,fontWeight:700,letterSpacing:.3},children:[St.length," order",1===St.length?"":"s"," \xb7 End of list"]})})})})]})]})})}),(0,ce.jsxs)(R.Z,{anchorEl:Zo,open:Boolean(Zo),onClose:function(){return jo(null)},anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{mt:.75,width:300,borderRadius:2.5,border:"1px solid ".concat(He),boxShadow:Ae,overflow:"hidden"}}},MenuListProps:{sx:{py:0}},children:[(0,ce.jsxs)(p.Z,{sx:{px:1.5,pt:1.25,pb:1.125,background:"linear-gradient(135deg, ".concat(Oe(Ve)," 0%, ").concat(Oe(Ke)," 100%)"),borderBottom:"1px solid ".concat(He)},children:[(0,ce.jsx)(m.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,children:(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",spacing:1,children:[(0,ce.jsx)(f.Z,{variant:"rounded",sx:{width:28,height:28,bgcolor:Ve,color:"#fff",borderRadius:1.25},children:(0,ce.jsx)(L.Dx,{size:15})}),(0,ce.jsxs)(m.Z,{spacing:0,children:[(0,ce.jsx)(g.Z,{sx:{fontSize:13,fontWeight:800,color:Re,lineHeight:1.15},children:"Columns"}),(0,ce.jsxs)(g.Z,{sx:{fontSize:10.5,fontWeight:700,color:Ye,lineHeight:1.2},children:[go," of ",co.length," shown"]})]})]})}),(0,ce.jsxs)(m.Z,{direction:"row",spacing:.75,sx:{mt:1.125},children:[(0,ce.jsx)(v.Z,{size:"small",onClick:function(){return fo(co.reduce((function(e,o){return(0,s.Z)((0,s.Z)({},e),{},(0,i.Z)({},o.key,!0))}),{}))},disabled:0===mo,startIcon:(0,ce.jsx)(L.smy,{size:13}),sx:{flex:1,height:28,px:1,fontSize:11.5,fontWeight:800,textTransform:"none",borderRadius:1.25,color:Ve,bgcolor:"#fff",border:"1px solid ".concat(Ne(Ve)),"&:hover":{bgcolor:Oe(Ve),borderColor:Ve},"&.Mui-disabled":{color:Pe,bgcolor:"#fff",borderColor:He,opacity:.7}},children:"Show all"}),(0,ce.jsx)(v.Z,{size:"small",onClick:function(){return fo(ao)},disabled:wo,startIcon:(0,ce.jsx)(L.zq9,{size:14}),sx:{flex:1,height:28,px:1,fontSize:11.5,fontWeight:800,textTransform:"none",borderRadius:1.25,color:Ye,bgcolor:"#fff",border:"1px solid ".concat(He),"&:hover":{bgcolor:Te,borderColor:Pe,color:Re},"&.Mui-disabled":{color:Pe,bgcolor:"#fff",borderColor:He,opacity:.7}},children:"Reset"})]})]}),(0,ce.jsx)(p.Z,{sx:{maxHeight:340,overflowY:"auto",py:.5},children:["Core","Lifecycle","Metrics"].map((function(e){var o=co.filter((function(o){return o.group===e})),t=o.filter((function(e){return po(e.key)})).length;return(0,ce.jsxs)(p.Z,{sx:{px:.5,pb:.25},children:[(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{px:1,pt:.875,pb:.375},children:[(0,ce.jsx)(g.Z,{sx:{fontSize:10,fontWeight:800,color:Pe,letterSpacing:.7,textTransform:"uppercase"},children:e}),(0,ce.jsxs)(g.Z,{sx:{fontSize:10,fontWeight:700,color:Pe},children:[t,"/",o.length]})]}),o.map((function(e){var o=po(e.key),t=!!e.required;return(0,ce.jsxs)(p.Z,{onClick:function(){return!t&&yo(e.key)},sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1,mx:.5,px:1,py:.375,borderRadius:1.5,cursor:t?"default":"pointer",bgcolor:o?Oe(Ve):"transparent",border:"1px solid ".concat(o?Ne(Ve):"transparent"),transition:"background-color 0.15s, border-color 0.15s","&:hover":{bgcolor:t?o?Oe(Ve):"transparent":Be(Ve)}},children:[(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",spacing:.625,sx:{minWidth:0},children:[(0,ce.jsx)(g.Z,{noWrap:!0,sx:{fontSize:13,fontWeight:700,color:o?Re:Ye},children:e.label}),t&&(0,ce.jsx)(b.Z,{title:"Always visible",arrow:!0,children:(0,ce.jsx)(p.Z,{sx:{display:"inline-flex",color:Pe},children:(0,ce.jsx)(L.Tmq,{size:11})})})]}),(0,ce.jsx)(Y.Z,{size:"small",checked:o,disabled:t,onClick:function(e){return e.stopPropagation()},onChange:function(){return!t&&yo(e.key)},sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:Ve},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:Ve,opacity:1},"& .MuiSwitch-switchBase.Mui-disabled.Mui-checked":{color:Ke},"& .MuiSwitch-switchBase.Mui-disabled.Mui-checked + .MuiSwitch-track":{backgroundColor:Ke,opacity:.6}}})]},e.key)}))]},e)}))})]}),(0,ce.jsxs)(P.Z,{open:ue,onClose:function(){return xe(!1)},PaperProps:{sx:{borderRadius:3}},children:[(0,ce.jsx)(p.Z,{sx:{p:2.5,background:"linear-gradient(135deg, ".concat(Oe(Ve)," 0%, ").concat(Oe(Ke)," 100%)"),borderBottom:"1px solid ".concat(He)},children:(0,ce.jsxs)(m.Z,{direction:"row",alignItems:"center",spacing:1.5,children:[(0,ce.jsx)(f.Z,{sx:{bgcolor:Ve,color:"#fff",width:40,height:40,boxShadow:"0 6px 18px ".concat(Fe(Ve))},children:(0,ce.jsx)(L.sHf,{size:20})}),(0,ce.jsxs)(m.Z,{children:[(0,ce.jsx)(g.Z,{variant:"h5",sx:{fontWeight:800,color:Re},children:"Select Date Range"}),(0,ce.jsx)(g.Z,{variant:"caption",sx:{color:Ye,fontWeight:600},children:"Filter the order details by a date range or preset"})]})]})}),(0,ce.jsx)(H.Z,{sx:{width:"100%"},className:"datedialog",children:(0,ce.jsx)(O.D,{open:ue,toggle:function(){return xe(!ue)},id:"daterange1",onChange:function(e){"All"===e.label?(re(""),se(""),me("All"),xe(!1)):(re(E()(e.startDate).format("YYYY-MM-DD")),se(E()(e.endDate).format("YYYY-MM-DD")),me(e.label||""))},definedRanges:[{label:"Today",startDate:new Date,endDate:new Date},{label:"Yesterday",startDate:(0,B.Z)(new Date,-1),endDate:(0,B.Z)(new Date,-1)},{label:"Tomorrow",startDate:(0,B.Z)(new Date,1),endDate:(0,B.Z)(new Date,1)},{label:"This Week",startDate:(0,F.Z)(new Date),endDate:(0,N.Z)(new Date)},{label:"Last Week",startDate:(0,F.Z)((0,V.Z)(new Date,-1)),endDate:(0,N.Z)((0,V.Z)(new Date,-1))},{label:"Last 7 Days",startDate:(0,V.Z)(new Date,-1),endDate:new Date},{label:"This Month",startDate:(0,K.Z)(new Date),endDate:(0,q.Z)(new Date)},{label:"Last Month",startDate:(0,K.Z)((0,U.Z)(new Date,-1)),endDate:(0,q.Z)((0,U.Z)(new Date,-1))},{label:"All",startDate:new Date,endDate:(0,B.Z)(new Date,-1)}]})}),(0,ce.jsxs)(m.Z,{direction:"row",justifyContent:"flex-end",spacing:1,sx:{width:"100%",p:2,borderTop:"1px solid ".concat(Le)},children:[(0,ce.jsx)(v.Z,{variant:"outlined",onClick:function(){return xe(!1)},sx:{borderRadius:999,px:2.5,borderColor:He,color:Ye,fontWeight:700,"&:hover":{borderColor:Ye,bgcolor:Te}},children:"Cancel"}),(0,ce.jsx)(v.Z,{variant:"contained",onClick:function(){return xe(!1)},sx:{borderRadius:999,px:3,bgcolor:Ve,fontWeight:700,boxShadow:"0 6px 18px ".concat(Fe(Ve)),"&:hover":{bgcolor:"#4D1C61"}},children:"Apply"})]})]}),(0,ce.jsx)(P.Z,{open:Po,onClose:function(){return Ho(!1)},maxWidth:"lg",fullWidth:!0,PaperProps:{sx:{borderRadius:3,overflow:"hidden"}},children:zo&&(0,ce.jsx)(p.Z,{children:(0,ce.jsx)(he,{coordinates:zo,additionalProps:{riderStart:Do,riderEnd:Ao},order:Eo,setMapOpen:Ho})})}),(0,ce.jsx)(Ce,{open:qe,onClose:function(){return oo(!1)},rows:St,totalAvailable:qo,meta:{tenant:null===(t=St[0])||void 0===t?void 0:t.tenantname,range:te===le?E()(te).format("DD MMM YYYY"):"".concat(E()(te).format("DD MMM")," \u2013 ").concat(E()(le).format("DD MMM YYYY")),status:Fo}})]})}}}]); |