1 line
30 KiB
JavaScript
1 line
30 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[6849],{35678:(e,t,o)=>{o.d(t,{A:()=>v});var r=o(9950),n=o(96583),i=o(40033),l=o(82053),a=o(28170),s=o(93230),c=o(82223),d=o(55916),x=o(4159),u=o.n(x),h=o(56712),p=o(81417),m=o(96600),g=o(53132),b=o(94289),A=o(57326),j=o(50624),f=o(44414);const v=e=>{let{open:t,onClose:o,onSelect:x}=e;const[v,w]=(0,r.useState)(null);return(0,f.jsxs)(n.A,{open:t,onClose:o,children:[(0,f.jsx)(i.A,{align:"left",children:(0,f.jsx)(l.A,{variant:"h4",children:"Select Filter Options"})}),(0,f.jsx)(a.A,{sx:{width:"100%"},className:"datedialog",children:(0,f.jsx)(d.U,{open:t,toggle:o,id:"daterange1",onChange:e=>{w({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,m.A)(new Date)},{label:"Last Week",startDate:(0,p.A)((0,g.A)(new Date,-1)),endDate:(0,m.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,b.A)(new Date),endDate:(0,A.A)(new Date)},{label:"Last Month",startDate:(0,b.A)((0,j.A)(new Date,-1)),endDate:(0,A.A)((0,j.A)(new Date,-1))}]})}),(0,f.jsx)(s.A,{direction:"row",justifyContent:"flex-end",sx:{width:"100%",p:2},children:(0,f.jsx)(c.A,{variant:"contained",size:"small",onClick:()=>{v?(x(v),o()):o()},children:"OK"})})]})}},56311:(e,t,o)=>{o.d(t,{A:()=>h});var r=o(89379),n=o(9950),i=o(2660),l=o(2046),a=o(83274),s=o(25333),c=o(97125),d=o(7762),x=o(52097),u=o(44414);const h=e=>{let{value:t,onChange:o,onDebouncedChange:h,debounceTime:p=500,placeholder:m="Search (ctrl+k)",sx:g}=e;const b=(0,n.useRef)(null),[A]=(0,x.d7)(t,p);return(0,n.useEffect)((()=>{h&&h(A)}),[A,h]),(0,n.useEffect)((()=>{const e=e=>{var t;"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),null===(t=b.current)||void 0===t||t.focus());"Escape"===e.key&&document.activeElement===b.current&&b.current.blur()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[]),(0,u.jsx)(i.A,{sx:(0,r.A)({},g),inputRef:b,placeholder:m,autoComplete:"off",value:t,fullWidth:!0,onChange:e=>o(e.target.value),startAdornment:(0,u.jsx)(l.A,{position:"start",sx:{mr:-.5},children:(0,u.jsx)(c.A,{})}),endAdornment:(0,u.jsx)(a.A,{title:"Clear",children:(0,u.jsx)(s.A,{sx:{visibility:t?"visible":"hidden"},onClick:()=>o(""),children:(0,u.jsx)(d.A,{})})})})}},56849:(e,t,o)=>{o.r(t),o.d(t,{default:()=>G});var r=o(89379),n=o(9950),i=o(26910),l=o(36150),a=o(2235),s=o(41413),c=o(83274),d=o(16491),x=o(82053),u=o(93230),h=o(60899),p=o(77922),m=o(29925),g=o(1320),b=o(15769),A=o(69780),j=o(9213),f=o(21671),v=o(34075),w=o(25333),S=o(33738),y=o(74745),C=o(25277),k=o(31222),D=o(4159),z=o.n(D),I=o(81425),W=o(52351),M=o(35678),P=o(59212),R=o(56311),N=o(96646),T=o(20466),O=o(44414),Y=o(36220);z().extend(Y);const F={radiusPill:999,radiusCard:16,shadowSoft:"0 14px 40px rgba(15, 23, 42, 0.10)",shadowMd:"0 8px 24px rgba(15, 23, 42, 0.08)",shadowPop:"0 18px 50px rgba(15, 23, 42, 0.18)",textPrimary:"#0f172a",textSecondary:"#64748b",textMuted:"#94a3b8",borderSubtle:"#e2e8f0",divider:"#f1f5f9",surface:"#ffffff",surfaceAlt:"#f8fafc"},L=(e,t)=>"".concat(e).concat(t),B=e=>L(e,"08"),E=e=>L(e,"18"),K=e=>L(e,"26"),H=e=>L(e,"55"),Z="#662582",q="#9255AB",U=e=>(0,O.jsx)(a.A,(0,r.A)((0,r.A)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:F.shadowPop,border:"1px solid",borderColor:"divider",overflow:"hidden"}})),X=e=>{let{color:t,selected:o,size:r=24,children:n}=e;return(0,O.jsx)(s.A,{sx:{width:r,height:r,bgcolor:o?t:E(t),color:o?"#fff":t,transition:"background-color 0.15s, color 0.15s"},children:n})},$=e=>{let{color:t,icon:o,label:r,tooltip:n,minWidth:i=80}=e;return(0,O.jsx)(c.A,{title:n||"",placement:"top",children:(0,O.jsxs)(d.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:B(t),border:"1px solid ".concat(H(t)),color:t,fontSize:11,fontWeight:800,minWidth:i,justifyContent:"center",whiteSpace:"nowrap"},children:[o,r]})})},_=e=>{let{value:t,color:o="#ef4444",icon:r}=e;const n=Number(t)||0;return 0===n?(0,O.jsx)(x.A,{variant:"caption",sx:{color:F.textMuted,fontWeight:700},children:"0"}):(0,O.jsxs)(d.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:.875,py:.25,borderRadius:999,bgcolor:B(o),border:"1px solid ".concat(H(o)),color:o,fontSize:12,fontWeight:800,minWidth:36,justifyContent:"center"},children:[r,n]})},J=e=>({"& .MuiOutlinedInput-root":{borderRadius:F.radiusPill+"px",bgcolor:B(e),fontWeight:600,"& fieldset":{borderColor:H(e),borderWidth:1.5},"&:hover fieldset":{borderColor:e},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(K(e))},"&.Mui-focused fieldset":{borderColor:e,borderWidth:2}}});function V(e){return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:2}).format(Number(e)||0)}function G(){const e=(0,n.useRef)(null),t=(0,n.useRef)(null),[o,D]=(0,n.useState)(0),[Y,L]=(0,n.useState)(z()().format("YYYY-MM-DD")),[G,Q]=(0,n.useState)(z()().format("YYYY-MM-DD")),[ee,te]=(0,n.useState)("All"),[oe,re]=(0,n.useState)(!1),[ne,ie]=(0,n.useState)(null),[le,ae]=(0,n.useState)("Today"),[se,ce]=(0,n.useState)([]),[de,xe]=(0,n.useState)(!1),[ue,he]=(0,n.useState)(0),[pe,me]=(0,n.useState)(0),[ge,be]=(0,n.useState)(null),[Ae,je]=(0,n.useState)(null),[fe,ve]=(0,n.useState)(""),[we,Se]=(0,n.useState)(""),[,ye]=(0,n.useState)(0);(0,n.useEffect)((()=>{me(0),be(null),he(0),je(null),ie(null)}),[o]),(0,n.useEffect)((()=>{he(0),je(null),ie(null)}),[pe]);const{data:Ce,isLoading:ke,isError:De,error:ze}=(0,l.I)({queryKey:[o,pe,ue,Y,G],queryFn:pe?I.U6:I.DK}),{data:Ie}=(0,l.I)({queryKey:["tenantlist",o],queryFn:()=>(0,I.Mn)(o),enabled:0!==o}),{data:We}=(0,l.I)({queryKey:["gettenantlocations",pe],queryFn:()=>(0,I.DL)(pe),enabled:0!==pe}),Me=(0,n.useMemo)((()=>Array.isArray(Ce)?Ce:[]),[Ce]),Pe=(0,n.useMemo)((()=>{if(!we)return Me;const e=we.toLowerCase().trim();return Me.filter((t=>[t.tenantname,t.locationname,String(t.tenantid||""),String(t.locationid||"")].filter(Boolean).some((t=>String(t).toLowerCase().includes(e)))))}),[Me,we]),Re=(0,n.useMemo)((()=>Pe.reduce(((e,t)=>(e.totalOrders+=Number(t.totalorders)||0,e.orderPend+=Number(t.Orderspending)||0,e.orderComplete+=Number(t.orderscompleted)||0,e.orderCancel+=Number(t.orderscancelled)||0,e.deliPend+=Number(t.deliveriespending)||0,e.deliComplete+=Number(t.deliveriescompleted)||0,e.deliCancel+=Number(t.deliveriescancelled)||0,e.collection+=Number(t.collectionamt)||0,e.kms+=Number(t.kms)||0,e.cumulativekms+=Number(t.cumulativekms)||0,e.amount+=Math.max(Number(t.charges)||0,Number(t.deliveryamt)||0),e)),{totalOrders:0,orderPend:0,orderComplete:0,orderCancel:0,deliPend:0,deliComplete:0,deliCancel:0,collection:0,kms:0,cumulativekms:0,amount:0})),[Pe]);De&&console.warn("ordersSummary error:",null===ze||void 0===ze?void 0:ze.message);const Ne=[{key:"orders",label:"Total Orders",color:Z,icon:k.F6S,value:Re.totalOrders},{key:"pending",label:"Orders Pending",color:"#f59e0b",icon:k.tX0,value:Re.orderPend},{key:"completed",label:"Orders Completed",color:"#10b981",icon:k.mU9,value:Re.orderComplete},{key:"amount",label:"Total Amount",color:"#0ea5e9",icon:k.YHz,value:V(Re.amount)}],Te=Boolean(pe);return(0,O.jsxs)(O.Fragment,{children:[(de||ke)&&(0,O.jsx)(W.A,{}),(0,O.jsx)(a.A,{elevation:0,sx:{mb:{xs:1.5,md:2},p:{xs:1.5,sm:2,md:2.5},borderRadius:F.radiusCard/8,border:"1px solid",borderColor:F.borderSubtle,background:"linear-gradient(135deg, ".concat(B(Z)," 0%, ").concat(B(q)," 100%)"),boxShadow:F.shadowMd},children:(0,O.jsxs)(u.A,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",spacing:{xs:1.5,sm:2},children:[(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",spacing:{xs:1.25,sm:1.75},children:[(0,O.jsx)(s.A,{sx:{width:{xs:40,sm:48},height:{xs:40,sm:48},bgcolor:Z,color:"#fff",boxShadow:"0 6px 18px ".concat(K(Z))},children:(0,O.jsx)(k.GdF,{size:22})}),(0,O.jsxs)(u.A,{children:[(0,O.jsx)(x.A,{variant:"h3",sx:{fontWeight:800,color:F.textPrimary,lineHeight:1.1,fontSize:{xs:"1.25rem",sm:"1.5rem",md:"1.75rem"}},children:"Orders Summary"}),(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",spacing:.75,sx:{mt:.5},children:[(0,O.jsx)(d.A,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:"#10b981",boxShadow:"0 0 0 4px rgba(16,185,129,0.18)"}}),(0,O.jsxs)(x.A,{variant:"caption",sx:{color:F.textSecondary,fontWeight:600},children:["Live \xb7 ",ee||"All Zones"," \xb7 ",le]})]})]})]}),(0,O.jsx)(P.A,{ref:e,locaName:ee,setAppId:D,setLocoName:te,setPage:ye,pill:!0,accentColor:Z,icon:(0,O.jsx)(k.HPi,{size:14}),placeholder:"Select Zone",paperComponent:U,sx:{width:{xs:"100%",sm:280},zIndex:100}})]})}),(0,O.jsx)(h.Ay,{container:!0,spacing:{xs:1.25,sm:1.5,md:2},sx:{mt:"1px"},children:Ne.map((e=>{const t=e.icon;return(0,O.jsx)(h.Ay,{item:!0,xs:6,sm:6,md:3,children:(0,O.jsxs)(a.A,{elevation:0,sx:{position:"relative",overflow:"hidden",p:{xs:1.25,sm:1.75,md:2.25},borderRadius:F.radiusCard/8,border:"1px solid",borderColor:F.borderSubtle,background:"#fff",transition:"transform 0.2s, box-shadow 0.2s, border-color 0.2s","&:hover":{transform:"translateY(-3px)",boxShadow:F.shadowMd,borderColor:H(e.color)}},children:[(0,O.jsx)(d.A,{sx:{position:"absolute",top:0,left:0,right:0,height:3,background:"linear-gradient(90deg, ".concat(e.color," 0%, ").concat(E(e.color)," 100%)")}}),(0,O.jsxs)(u.A,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",spacing:1,children:[(0,O.jsxs)(u.A,{spacing:.5,sx:{minWidth:0,flex:1},children:[(0,O.jsx)(x.A,{variant:"caption",sx:{color:F.textSecondary,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",fontSize:{xs:10,sm:11},whiteSpace:"nowrap"},children:e.label}),(0,O.jsx)(x.A,{sx:{fontWeight:800,color:F.textPrimary,lineHeight:1.1,fontSize:{xs:"1.1rem",sm:"1.4rem",md:"1.6rem"},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.value})]}),(0,O.jsx)(s.A,{sx:{width:{xs:36,sm:42,md:48},height:{xs:36,sm:42,md:48},bgcolor:E(e.color),color:e.color,boxShadow:"inset 0 0 0 1px ".concat(H(e.color)),flexShrink:0},children:(0,O.jsx)(t,{size:20})})]})]})},e.key)}))}),(0,O.jsx)(a.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1,md:1.5},borderTopLeftRadius:F.radiusCard/8,borderTopRightRadius:F.radiusCard/8,borderBottomLeftRadius:0,borderBottomRightRadius:0,border:"1px solid",borderColor:F.borderSubtle,borderBottom:0,background:"#fff"},children:(0,O.jsxs)(u.A,{direction:{xs:"column",md:"row"},alignItems:{xs:"stretch",md:"center"},justifyContent:"space-between",spacing:1.25,children:[(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",spacing:1.25,flexWrap:"wrap",children:[(0,O.jsx)(c.A,{title:"Date Filter",placement:"top",children:(0,O.jsxs)(d.A,{onClick:()=>re(!0),sx:{display:"inline-flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:999,cursor:"pointer",bgcolor:B("#f59e0b"),border:"1.5px solid ".concat(H("#f59e0b")),color:"#f59e0b",fontWeight:800,fontSize:12,transition:"all 0.18s","&:hover":{borderColor:"#f59e0b",boxShadow:"0 0 0 3px ".concat(K("#f59e0b"))}},children:[(0,O.jsx)(k.Ki0,{size:14}),"Orders \xb7 ",le," \xb7 ",z()(Y).format("DD/MM/YY")," \u2013 ",z()(G).format("DD/MM/YY")]})}),(0,O.jsx)(p.A,{options:Ie||[],value:ge,getOptionLabel:e=>(null===e||void 0===e?void 0:e.tenantname)||(null===e||void 0===e?void 0:e.label)||"",isOptionEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.tenantid)===(null===t||void 0===t?void 0:t.tenantid),PaperComponent:U,sx:(0,r.A)({minWidth:{xs:"100%",sm:220}},J(Z)),onOpen:t=>{o||(t.preventDefault(),(0,T.k)("Please select a Zone first!","warning",3e3),setTimeout((()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.focus()}),0))},onChange:(e,t,o)=>{"clear"!==o&&t?(me((null===t||void 0===t?void 0:t.tenantid)||0),be(t),he((null===t||void 0===t?void 0:t.locationid)||0),je(null)):(me(0),be(null),he(0),je(null))},renderInput:e=>(0,O.jsx)(m.A,(0,r.A)((0,r.A)({},e),{},{inputRef:t,placeholder:"Select Tenant",size:"small",InputProps:(0,r.A)((0,r.A)({},e.InputProps),{},{startAdornment:(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:[(0,O.jsx)(X,{color:Z,size:24,selected:Boolean(ge),children:(0,O.jsx)(k.nZo,{size:14})}),e.InputProps.startAdornment]})})}))}),(0,O.jsx)(p.A,{options:We||[],value:Ae,getOptionLabel:e=>null!==e&&void 0!==e&&e.locationname?"".concat(e.locationname).concat(e.suburb?" (".concat(e.suburb,")"):""):"",isOptionEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.locationid)===(null===t||void 0===t?void 0:t.locationid),PaperComponent:U,sx:(0,r.A)({minWidth:{xs:"100%",sm:220}},J("#0ea5e9")),onOpen:r=>{o||pe?pe||(r.preventDefault(),(0,T.k)("Please select a Tenant first!","warning",3e3),setTimeout((()=>{var e;return null===(e=t.current)||void 0===e?void 0:e.focus()}),0)):(r.preventDefault(),(0,T.k)("Please select Zone and Tenant first!","warning",3e3),setTimeout((()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.focus()}),0))},onChange:(e,t,o)=>{"clear"!==o&&t?(he((null===t||void 0===t?void 0:t.locationid)||0),je(t)):(he(0),je(null))},renderInput:e=>(0,O.jsx)(m.A,(0,r.A)((0,r.A)({},e),{},{placeholder:"Select Location",size:"small",InputProps:(0,r.A)((0,r.A)({},e.InputProps),{},{startAdornment:(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5},children:[(0,O.jsx)(X,{color:"#0ea5e9",size:24,selected:Boolean(Ae),children:(0,O.jsx)(k.gwi,{size:14})}),e.InputProps.startAdornment]})})}))})]}),(0,O.jsx)(d.A,{sx:{width:{xs:"100%",md:280,lg:320},flex:{xs:"1 1 100%",md:"0 0 auto"}},children:(0,O.jsx)(R.A,{value:fe,onChange:ve,onDebouncedChange:Se,placeholder:"Search ".concat(Te?"locations":"tenants"," (ctrl+k)"),sx:{m:0,width:"100%",borderRadius:999,bgcolor:B(Z),"& fieldset":{borderColor:H(Z),borderWidth:1.5},"&:hover fieldset":{borderColor:Z},"&.Mui-focused fieldset":{borderColor:Z,borderWidth:2},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(K(Z))}}})})]})}),(0,O.jsxs)(a.A,{elevation:0,sx:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:F.radiusCard/8,borderBottomRightRadius:F.radiusCard/8,border:"1px solid",borderColor:F.borderSubtle,overflow:"hidden",background:"#fff"},children:[(0,O.jsx)(g.A,{sx:{maxHeight:{xs:"calc(100vh - 280px)",md:"calc(100vh - 240px)"},"&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:H(Z),borderRadius:8,"&:hover":{backgroundColor:Z}},"&::-webkit-scrollbar-track":{backgroundColor:F.surfaceAlt}},children:(0,O.jsxs)(b.A,{stickyHeader:!0,sx:{minWidth:{xs:1080,md:1200}},children:[(0,O.jsxs)(A.A,{children:[(0,O.jsxs)(j.A,{sx:{"& th":{backgroundColor:F.surfaceAlt,color:F.textSecondary,fontSize:{xs:10,md:11},fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(F.borderSubtle),py:{xs:1,md:1.25},px:{xs:1,md:1.5}}},children:[(0,O.jsx)(f.A,{rowSpan:2,children:"#"}),(0,O.jsx)(f.A,{rowSpan:2,children:Te?"Location":"Tenant"}),(0,O.jsx)(f.A,{align:"center",rowSpan:2,children:"All"}),(0,O.jsx)(f.A,{align:"center",colSpan:3,sx:{bgcolor:"".concat(B("#ef4444")," !important"),color:"#ef4444 !important"},children:"Orders"}),(0,O.jsx)(f.A,{align:"center",colSpan:3,sx:{bgcolor:"".concat(B("#10b981")," !important"),color:"#10b981 !important"},children:"Deliveries"}),(0,O.jsx)(f.A,{align:"center",rowSpan:2,children:"Collection"}),(0,O.jsx)(f.A,{align:"center",rowSpan:2,children:"KMS / Actual"}),(0,O.jsx)(f.A,{align:"center",rowSpan:2,children:"Amount"}),(0,O.jsx)(f.A,{align:"right",rowSpan:2,children:"Action"})]}),(0,O.jsxs)(j.A,{sx:{"& th":{backgroundColor:F.surfaceAlt,color:F.textSecondary,fontSize:{xs:10,md:10.5},fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(F.borderSubtle),py:{xs:.75,md:1},px:{xs:1,md:1.5}}},children:[(0,O.jsx)(f.A,{align:"center",sx:{bgcolor:"".concat(B("#ef4444")," !important"),color:"#f59e0b !important"},children:"Pending"}),(0,O.jsx)(f.A,{align:"center",sx:{bgcolor:"".concat(B("#ef4444")," !important"),color:"#ef4444 !important"},children:"Cancelled"}),(0,O.jsx)(f.A,{align:"center",sx:{bgcolor:"".concat(B("#ef4444")," !important"),color:"#10b981 !important"},children:"Completed"}),(0,O.jsx)(f.A,{align:"center",sx:{bgcolor:"".concat(B("#10b981")," !important"),color:"#f59e0b !important"},children:"Pending"}),(0,O.jsx)(f.A,{align:"center",sx:{bgcolor:"".concat(B("#10b981")," !important"),color:"#ef4444 !important"},children:"Cancelled"}),(0,O.jsx)(f.A,{align:"center",sx:{bgcolor:"".concat(B("#10b981")," !important"),color:"#10b981 !important"},children:"Completed"})]})]}),(0,O.jsxs)(v.A,{children:[ke&&(0,O.jsx)(N.r,{col:9}),!ke&&0===Pe.length&&(0,O.jsx)(j.A,{children:(0,O.jsx)(f.A,{colSpan:13,sx:{py:6},children:(0,O.jsxs)(u.A,{alignItems:"center",spacing:1.5,children:[(0,O.jsx)(s.A,{sx:{width:64,height:64,bgcolor:E("#94a3b8"),color:F.textMuted},children:(0,O.jsx)(k.Z2J,{size:28})}),(0,O.jsxs)(x.A,{variant:"subtitle1",sx:{fontWeight:700,color:F.textPrimary},children:["No ",Te?"locations":"tenants"," to show"]}),(0,O.jsx)(x.A,{variant:"caption",sx:{color:F.textSecondary,textAlign:"center",maxWidth:360},children:we?"Try a different keyword.":De?"Something went wrong fetching the summary. Try a different filter.":"Pick a zone, tenant, or date range to load the summary."})]})})}),Pe.map(((e,t)=>{const o=Te?e.locationname:e.tenantname,r=ne===o,l=Math.max(Number(e.charges)||0,Number(e.deliveryamt)||0);return(0,O.jsxs)(n.Fragment,{children:[(0,O.jsxs)(j.A,{sx:{transition:"background-color 0.15s","& td":{borderBottom:r?"none":"1px solid ".concat(F.divider),py:{xs:1,md:1.25},px:{xs:1,md:1.5}},"&:hover":{backgroundColor:r?"#fff":F.surfaceAlt},bgcolor:r?B(Z):"transparent"},children:[(0,O.jsx)(f.A,{children:(0,O.jsx)(x.A,{variant:"caption",sx:{fontWeight:700,color:F.textMuted},children:String(t+1).padStart(2,"0")})}),(0,O.jsx)(f.A,{children:(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,O.jsx)(X,{color:Te?"#0ea5e9":Z,size:36,children:Te?(0,O.jsx)(k.gwi,{size:18}):(0,O.jsx)(k.nZo,{size:18})}),(0,O.jsxs)(u.A,{children:[(0,O.jsx)(x.A,{variant:"subtitle2",sx:{fontWeight:700,color:F.textPrimary,whiteSpace:"nowrap"},children:(Te?e.locationname:e.tenantname)||"\u2014"}),(0,O.jsxs)(x.A,{variant:"caption",sx:{color:F.textSecondary},children:["ID #",Te?e.locationid:e.tenantid]})]})]})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.totalorders,color:Z,icon:(0,O.jsx)(k.F6S,{size:11})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.Orderspending,color:"#f59e0b",icon:(0,O.jsx)(k.tX0,{size:11})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.orderscancelled,color:"#ef4444",icon:(0,O.jsx)(k.uDv,{size:11})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.orderscompleted,color:"#10b981",icon:(0,O.jsx)(k.mU9,{size:11})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.deliveriespending,color:"#f59e0b",icon:(0,O.jsx)(k.tX0,{size:11})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.deliveriescancelled,color:"#ef4444",icon:(0,O.jsx)(k.uDv,{size:11})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.deliveriescompleted,color:"#10b981",icon:(0,O.jsx)(k.mU9,{size:11})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)($,{color:"#f59e0b",icon:(0,O.jsx)(k.YHz,{size:11}),label:Number(e.collectionamt||0).toFixed(2),tooltip:"Collection Amount",minWidth:90})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsxs)(u.A,{direction:"column",spacing:.5,alignItems:"center",children:[(0,O.jsx)($,{color:"#ef4444",icon:(0,O.jsx)(k.xI$,{size:11}),label:"".concat(Number(e.kms||0).toFixed(2)," km"),tooltip:"KMS"}),(0,O.jsx)($,{color:"#10b981",icon:(0,O.jsx)(k.xI$,{size:11}),label:"".concat(Number(e.cumulativekms||0).toFixed(2)," km"),tooltip:"Actual KMS"})]})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)($,{color:Z,icon:(0,O.jsx)(k.YHz,{size:11}),label:V(l).replace("\u20b9","").trim(),tooltip:"Total Amount",minWidth:100})}),(0,O.jsx)(f.A,{align:"right",children:(0,O.jsx)(c.A,{title:r?"Hide rider breakdown":"View rider breakdown",placement:"top",children:(0,O.jsx)(w.A,{size:"small",onClick:()=>{const t=!r;ie(t?o:null),t&&(ce([]),Te?(async e=>{xe(!0);try{var t;const o=await i.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/deliveries/getriderlocationsummary/?tenantid=").concat(pe,"&locationid=").concat(e,"&fromdate=").concat(Y,"&todate=").concat(G));ce(Array.isArray(null===(t=o.data)||void 0===t?void 0:t.details)?o.data.details:[])}catch(o){(0,T.k)((null===o||void 0===o?void 0:o.message)||"Failed to load rider breakdown","error",2e3),ce([])}finally{xe(!1)}})(e.locationid):(async e=>{xe(!0);try{var t;const o=await i.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/deliveries/getuserreportsummary/?tenantid=").concat(e,"&fromdate=").concat(Y,"&todate=").concat(G));ce(Array.isArray(null===(t=o.data)||void 0===t?void 0:t.details)?o.data.details:[])}catch(o){(0,T.k)((null===o||void 0===o?void 0:o.message)||"Failed to load rider breakdown","error",2e3),ce([])}finally{xe(!1)}})(e.tenantid))},sx:{bgcolor:r?Z:E(Z),color:r?"#fff":Z,border:"1px solid ".concat(H(Z)),"&:hover":{bgcolor:Z,color:"#fff"}},children:r?(0,O.jsx)(k.Xbk,{size:16}):(0,O.jsx)(k.j1Q,{size:16})})})})]}),r&&(0,O.jsx)(j.A,{children:(0,O.jsx)(f.A,{colSpan:13,sx:{p:0,borderBottom:"1px solid ".concat(F.divider),bgcolor:B(Z)},children:(0,O.jsx)(S.A,{in:r,timeout:"auto",unmountOnExit:!0,children:(0,O.jsx)(d.A,{sx:{p:{xs:1,md:2}},children:(0,O.jsxs)(a.A,{elevation:0,sx:{borderRadius:F.radiusCard/8,border:"1px solid",borderColor:F.borderSubtle,overflow:"hidden",boxShadow:F.shadowSoft},children:[(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",spacing:1,sx:{px:2,py:1.25,background:"linear-gradient(135deg, ".concat(B(Z)," 0%, ").concat(B(q)," 100%)"),borderBottom:"1px solid ".concat(F.borderSubtle)},children:[(0,O.jsx)(X,{color:Z,size:28,selected:!0,children:(0,O.jsx)(k.Itr,{size:14})}),(0,O.jsxs)(x.A,{variant:"caption",sx:{fontWeight:800,color:F.textPrimary,letterSpacing:.6,textTransform:"uppercase"},children:["Rider Breakdown \xb7 ",Te?e.locationname:e.tenantname]})]}),(0,O.jsxs)(b.A,{size:"small",children:[(0,O.jsx)(A.A,{children:(0,O.jsxs)(j.A,{sx:{"& th":{backgroundColor:F.surfaceAlt,color:F.textSecondary,fontSize:10,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(F.borderSubtle),py:1,px:1.5}},children:[(0,O.jsx)(f.A,{children:"#"}),(0,O.jsx)(f.A,{children:"Rider"}),(0,O.jsx)(f.A,{align:"center",children:"Orders"}),(0,O.jsx)(f.A,{align:"center",children:"Deliveries"}),(0,O.jsx)(f.A,{align:"center",children:"Pending"}),(0,O.jsx)(f.A,{align:"center",children:"Cancelled"}),(0,O.jsx)(f.A,{align:"center",children:"Completed"}),(0,O.jsx)(f.A,{align:"center",children:"Collection"}),(0,O.jsx)(f.A,{align:"center",children:"KMS / Actual"}),(0,O.jsx)(f.A,{align:"center",children:"Amount"})]})}),(0,O.jsxs)(v.A,{children:[de&&(0,O.jsx)(N.r,{col:6}),de||se&&0!==se.length?se.map(((e,t)=>{const o=Math.max(Number(e.charges)||0,Number(e.deliveryamt)||0);return(0,O.jsxs)(j.A,{sx:{"& td":{borderBottom:"1px solid ".concat(F.divider),py:1,px:1.5},"&:hover":{backgroundColor:F.surfaceAlt}},children:[(0,O.jsx)(f.A,{children:(0,O.jsx)(x.A,{variant:"caption",sx:{fontWeight:700,color:F.textMuted},children:String(t+1).padStart(2,"0")})}),(0,O.jsx)(f.A,{children:(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",spacing:.75,children:[(0,O.jsx)(X,{color:Z,size:28,children:(0,O.jsx)(k.LTk,{size:14})}),(0,O.jsxs)(u.A,{children:[(0,O.jsx)(x.A,{variant:"subtitle2",sx:{fontWeight:700,color:F.textPrimary,whiteSpace:"nowrap"},children:"".concat(e.firstname||""," ").concat(e.lastname||"").trim()||"\u2014"}),(0,O.jsx)(x.A,{variant:"caption",sx:{color:F.textSecondary},children:e.ridercontact||"ID #".concat(e.userid)})]})]})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.orderscreated,color:Z,icon:(0,O.jsx)(k.F6S,{size:10})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.totalorders,color:"#0ea5e9",icon:(0,O.jsx)(k.F6S,{size:10})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.deliveriespending,color:"#f59e0b",icon:(0,O.jsx)(k.tX0,{size:10})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.deliveriescancelled,color:"#ef4444",icon:(0,O.jsx)(k.uDv,{size:10})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)(_,{value:e.deliveriescompleted,color:"#10b981",icon:(0,O.jsx)(k.mU9,{size:10})})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)($,{color:"#f59e0b",icon:(0,O.jsx)(k.YHz,{size:10}),label:Number(e.collectionamt||0).toFixed(2),tooltip:"Collection",minWidth:80})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsxs)(u.A,{direction:"column",spacing:.5,alignItems:"center",children:[(0,O.jsx)($,{color:"#ef4444",icon:(0,O.jsx)(k.xI$,{size:10}),label:"".concat(Number(e.kms||0).toFixed(2)," km"),tooltip:"KMS"}),(0,O.jsx)($,{color:"#10b981",icon:(0,O.jsx)(k.xI$,{size:10}),label:"".concat(Number(e.cumulativekms||0).toFixed(2)," km"),tooltip:"Actual KMS"})]})}),(0,O.jsx)(f.A,{align:"center",children:(0,O.jsx)($,{color:Z,icon:(0,O.jsx)(k.YHz,{size:10}),label:V(o).replace("\u20b9","").trim(),tooltip:"Total Amount",minWidth:100})})]},"".concat(e.userid,"-").concat(t))})):(0,O.jsx)(j.A,{children:(0,O.jsx)(f.A,{colSpan:10,sx:{py:3},children:(0,O.jsx)(x.A,{variant:"caption",sx:{color:F.textMuted,textAlign:"center",display:"block"},children:"No rider activity for this row."})})})]})]})]})})})})})]},"".concat(o,"-").concat(t))}))]})]})}),Pe.length>0&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(y.A,{}),(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1.5,flexWrap:"wrap",sx:{px:2,py:1.5,background:"linear-gradient(135deg, ".concat(B(Z)," 0%, ").concat(B(q)," 100%)")},children:[(0,O.jsxs)(u.A,{direction:"row",alignItems:"center",spacing:1,flexWrap:"wrap",children:[(0,O.jsx)(x.A,{variant:"caption",sx:{fontWeight:800,color:F.textSecondary,letterSpacing:.6,textTransform:"uppercase"},children:"Grand Total"}),(0,O.jsx)(C.A,{size:"small",label:"".concat(Re.totalOrders," orders"),sx:{fontWeight:700,bgcolor:E(Z),color:Z,border:"1px solid ".concat(H(Z))}}),(0,O.jsx)(C.A,{size:"small",label:"".concat(Re.deliComplete," delivered"),sx:{fontWeight:700,bgcolor:E("#10b981"),color:"#10b981",border:"1px solid ".concat(H("#10b981"))}}),(0,O.jsx)(C.A,{size:"small",label:"".concat(Re.deliPend," pending"),sx:{fontWeight:700,bgcolor:E("#f59e0b"),color:"#f59e0b",border:"1px solid ".concat(H("#f59e0b"))}})]}),(0,O.jsx)(C.A,{label:V(Re.amount),sx:{fontWeight:800,fontSize:13,color:"#fff",background:"linear-gradient(135deg, ".concat(Z," 0%, ").concat(q," 100%)"),boxShadow:"0 6px 16px ".concat(K(Z))}})]})]})]}),(0,O.jsx)(M.A,{open:oe,onClose:()=>re(!1),onSelect:e=>{L(e.startDate),Q(e.endDate),ae(e.label)}})]})}},59212:(e,t,o)=>{o.d(t,{A:()=>u});var r=o(89379),n=o(9950),i=o(93230),l=o(41413),a=o(77922),s=o(29925),c=o(26910),d=o(31222),x=o(44414);const u=(0,n.forwardRef)(((e,t)=>{let{setAppId:o,setLocoName:u,setPage:h,sx:p,textfeildSx:m,textfieldSx:g,pill:b=!1,accentColor:A="#6366f1",icon:j,placeholder:f="Select Zone",paperComponent:v}=e;const[w,S]=(0,n.useState)(JSON.parse(localStorage.getItem("applocations")||"[]"));(0,n.useEffect)((()=>{0===w.length&&(async()=>{try{const e=localStorage.getItem("userid");if(!e)return;const t=await c.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/partners/getlocations/?userid=").concat(e));if(t.data.status){const e=[...t.data.details,{locationname:"All",applocationid:0}];localStorage.setItem("applocations",JSON.stringify(e)),S(e)}}catch(e){console.error("Error fetching locations in LocationAutocomplete:",e)}})()}),[w.length]);const y=e=>"".concat(A).concat(e),C=y("08"),k=y("26"),D=y("55"),z=y("18"),I=b?{cursor:"pointer","& .MuiOutlinedInput-root":{borderRadius:"999px",bgcolor:C,fontWeight:600,color:"#0f172a",paddingRight:"8px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s, background-color 0.2s","& fieldset":{borderColor:D,borderWidth:1.5},"&:hover fieldset":{borderColor:A},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(k)},"&.Mui-focused fieldset":{borderColor:A,borderWidth:2}},"& .MuiAutocomplete-endAdornment .MuiSvgIcon-root":{color:A}}:{},W=b&&(0,x.jsx)(i.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25,flexShrink:0},children:(0,x.jsx)(l.A,{sx:{width:24,height:24,bgcolor:z,color:A,transition:"background-color 0.15s, color 0.15s"},children:j||(0,x.jsx)(d.HPi,{size:14})})});return(0,x.jsx)(a.A,{id:"location-autocomplete",options:w||[],getOptionLabel:e=>{var t;return null!==(t=null===e||void 0===e?void 0:e.locationname)&&void 0!==t?t:""},PaperComponent:v,sx:(0,r.A)({},p),onChange:(e,t,r)=>{"clear"===r?(null===o||void 0===o||o(0),null===u||void 0===u||u(""),null===h||void 0===h||h(0)):t&&(null===o||void 0===o||o(t.applocationid),null===u||void 0===u||u(t.locationname),null===h||void 0===h||h(0))},renderInput:e=>b?(0,x.jsx)(s.A,(0,r.A)((0,r.A)({},e),{},{inputRef:t,placeholder:f,InputProps:(0,r.A)((0,r.A)({},e.InputProps),{},{startAdornment:W}),sx:(0,r.A)((0,r.A)({},I),g||m||{})})):(0,x.jsx)(s.A,(0,r.A)((0,r.A)({},e),{},{inputRef:t,label:"Select Zones",sx:(0,r.A)({},g||m||{})}))})}))},96646:(e,t,o)=>{o.d(t,{r:()=>s});var r=o(9213),n=o(21671),i=o(82917),l=o(93230),a=o(44414);const s=e=>{let{rowsPerPage:t=5,col:o=1}=e;return(0,a.jsx)(a.Fragment,{children:Array.from(new Array(t)).map(((e,t)=>(0,a.jsxs)(r.A,{children:[(0,a.jsx)(n.A,{children:(0,a.jsx)(i.A,{variant:"circular",width:24,height:24})}),(0,a.jsx)(n.A,{children:(0,a.jsx)(i.A,{variant:"text",width:30})}),Array.from({length:o}).map(((e,t)=>(0,a.jsx)(n.A,{children:(0,a.jsxs)(l.A,{spacing:.5,children:[(0,a.jsx)(i.A,{variant:"text",width:100}),(0,a.jsx)(i.A,{variant:"text",width:80})]})},t))),(0,a.jsx)(n.A,{children:(0,a.jsx)(i.A,{variant:"text",width:150})}),(0,a.jsx)(n.A,{children:(0,a.jsx)(i.A,{variant:"rounded",width:60,height:24})}),(0,a.jsx)(n.A,{align:"center",children:(0,a.jsxs)(l.A,{direction:"row",spacing:1,justifyContent:"flex-end",children:[(0,a.jsx)(i.A,{variant:"circular",width:28,height:28}),(0,a.jsx)(i.A,{variant:"circular",width:28,height:28})]})})]},t)))})}}}]); |