1 line
25 KiB
JavaScript
1 line
25 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[9438],{9438:(e,t,r)=>{r.r(t),r.d(t,{default:()=>Z});var o=r(89379),n=r(9950),i=r(60010),l=r(2235),s=r(41413),a=r(83274),d=r(16491),c=r(14857),u=r(47223),x=r(60899),h=r(82053),f=r(93230),p=r(1320),g=r(15769),m=r(69780),v=r(9213),b=r(21671),A=r(34075),j=r(25277),w=r(31222),S=r(4159),y=r.n(S),C=r(81425),D=r(52351),R=r(35678),k=r(59212),M=r(56311),P=r(27001),N=r(36803),Y=r(23787),W=r(44414),I=r(36220);y().extend(I);const z={radiusPill:999,radiusCard:14,shadowSoft:"0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.05)",shadowMd:"0 1px 3px rgba(15, 23, 42, 0.06)",shadowPop:"0 12px 32px rgba(15, 23, 42, 0.12)",textPrimary:"#0f172a",textSecondary:"#64748b",textMuted:"#94a3b8",borderSubtle:"#e2e8f0",divider:"#f1f5f9",surface:"#ffffff",surfaceAlt:"#f8fafc"},L=(e,t)=>"".concat(e).concat(t),F=e=>L(e,"18"),T=e=>L(e,"08"),O=e=>L(e,"55"),H=e=>L(e,"26"),B="#662582",E=e=>(0,W.jsx)(l.A,(0,o.A)((0,o.A)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:z.shadowPop,border:"1px solid",borderColor:"divider",overflow:"hidden"}})),_=e=>{let{color:t,selected:r,size:o=24,children:n}=e;return(0,W.jsx)(s.A,{sx:{width:o,height:o,bgcolor:r?t:F(t),color:r?"#fff":t,transition:"background-color 0.15s, color 0.15s"},children:n})},J=e=>{let{color:t,icon:r,label:o,tooltip:n,minWidth:i=80}=e;return(0,W.jsx)(a.A,{title:n||"",placement:"top",children:(0,W.jsxs)(d.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:"#ffffff",border:"1px solid ".concat(O(t)),color:t,fontSize:11,fontWeight:800,minWidth:i,justifyContent:"center",whiteSpace:"nowrap"},children:[r,o]})})},K=[{id:"morning",name:"Morning Batch",startHour:0,endHour:8},{id:"afternoon",name:"Afternoon Batch",startHour:9,endHour:12.5},{id:"evening",name:"Evening Batch",startHour:16,endHour:19}],V=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K;const r=null===e||void 0===e?void 0:e.assigntime;if(!r)return null;const o=String(r).trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return null;const n=y()(r);return n.isValid()?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K;for(const r of t)if(e>=r.startHour&&e<r.endHour)return r.id;return null}(n.hour()+n.minute()/60,t):null};function q(e){return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:2}).format(Number(e)||0)}function Z(){var e,t,r,S,I,L,Z,$,G,U,Q,X,ee,te;const re=(0,c.A)(),oe=(0,u.A)(re.breakpoints.down("md")),[ne,ie]=(0,n.useState)(y()().format("YYYY-MM-DD")),[le,se]=(0,n.useState)(y()().format("YYYY-MM-DD")),[ae,de]=(0,n.useState)("All"),[ce,ue]=(0,n.useState)(!1),[xe,he]=(0,n.useState)("Today"),[fe,pe]=(0,n.useState)(0),[ge,me]=(0,n.useState)(""),[ve,be]=(0,n.useState)(""),Ae="undefined"!==typeof window&&localStorage.getItem("userid")||0,je=(0,n.useMemo)((()=>{if("undefined"===typeof window)return K;try{const e=window.localStorage.getItem("dispatch.slots.v9");if(!e)return K;const t=JSON.parse(e);return Array.isArray(t)&&t.length===K.length?t.map(((e,t)=>{var r;const o=e.id||"slot-".concat(t+1),n=Number(e.startHour)||0,i=Number(e.endHour)||24;return{id:o,name:e.name||(null===(r=K.find((e=>e.id===o)))||void 0===r?void 0:r.name)||"Slot ".concat(t+1),startHour:n,endHour:i}})):K}catch(e){return K}}),[]),{data:we,isLoading:Se,fetchNextPage:ye,hasNextPage:Ce,isFetchingNextPage:De}=(0,i.q)({queryKey:["fetchdeliveries",fe,Ae,"all",ne,le,2e3,"",0,0,0],queryFn:C.tL,getNextPageParam:e=>{var t;return null!==(t=e.nextPage)&&void 0!==t?t:void 0},refetchOnWindowFocus:!1});(0,n.useEffect)((()=>{Ce&&!De&&ye()}),[Ce,De,ye]);const Re=(0,n.useMemo)((()=>{const e=((null===we||void 0===we?void 0:we.pages)||[]).flatMap((e=>e.rows||[])),t=new Set,r=[];for(const o of e){const e=null!=o.orderid?String(o.orderid):null;e&&t.has(e)||(e&&t.add(e),r.push(o))}return r}),[we]),ke=(0,n.useMemo)((()=>{const e={};return Re.forEach((t=>{const r=String(t.userid||t.rider_id||"");r&&"unassigned"!==r&&"0"!==r&&(e[r]||(e[r]={id:r,riderName:t.ridername||t.rider_name||t.username||"Rider ".concat(r),orders:[]}),e[r].orders.some((e=>e.orderid===t.orderid))||e[r].orders.push(t))})),Object.values(e).map((e=>(0,o.A)((0,o.A)({},e),{},{orders:[...e.orders].sort(((e,t)=>{const r=e.trip_number||1,o=t.trip_number||1;return r!==o?r-o:(e.step||0)-(t.step||0)}))}))).sort(((e,t)=>t.orders.length-e.orders.length))}),[Re]),Me=(0,n.useMemo)((()=>{let e=0,t=0,r=0,n=0,i=0,l=0;const s=ke.map((s=>{let a=0,d=0;const c={};let u=0;if(s.orders.forEach((e=>{const t=V(e,je);if(!t)return;const r=parseFloat(e.kms||e.actualkms||0);d+=r,a+=r<=8?30:30+6*(r-8);const o=e.assigntime?y()(e.assigntime).format("YYYY-MM-DD"):e.deliverydate?y()(e.deliverydate).format("YYYY-MM-DD"):null;o&&(c[o]||(c[o]=new Set),c[o].add(t),u++)})),0===u)return null;let x=0;Object.values(c).forEach((e=>{x+=Math.min(e.size,3)}));const h=2.5*d,f=x*(500/3),p=h+f,g=a-p,m=a>0?g/a*100:0;return g>=0?i++:l++,t+=u,r+=a,n+=p,e++,(0,o.A)((0,o.A)({},s),{},{kms:d,revenue:a,varCost:h,fixedCost:f,totalCost:p,net:g,margin:m})})).filter(Boolean),a=r-n;return{activeRiders:e,totalOrders:t,totalRevenue:r,totalCost:n,totalNet:a,totalMargin:r>0?a/r*100:0,profitableRiders:i,lossRiders:l,enrichedRiders:s}}),[ke,je]),Pe=(0,n.useMemo)((()=>{if(null===Me||void 0===Me||!Me.enrichedRiders||!Array.isArray(Me.enrichedRiders))return[];const e=Me.enrichedRiders.filter(Boolean);if(!ve)return e;const t=ve.toLowerCase().trim();return e.filter((e=>e&&[e.riderName,String(e.id)].filter(Boolean).some((e=>String(e).toLowerCase().includes(t)))))}),[null===Me||void 0===Me?void 0:Me.enrichedRiders,ve]),Ne=[{key:"riders",label:"Riders Active",color:B,icon:w.LTk,value:null!==(e=null===Me||void 0===Me?void 0:Me.activeRiders)&&void 0!==e?e:0,detail:"".concat(null!==(t=null===Me||void 0===Me?void 0:Me.profitableRiders)&&void 0!==t?t:0," in profit \xb7 ").concat(null!==(r=null===Me||void 0===Me?void 0:Me.lossRiders)&&void 0!==r?r:0," at loss")},{key:"revenue",label:"Slot Revenue",color:"#0ea5e9",icon:w.HU2,value:q(null!==(S=null===Me||void 0===Me?void 0:Me.totalRevenue)&&void 0!==S?S:0),detail:"From ".concat(null!==(I=null===Me||void 0===Me?void 0:Me.totalOrders)&&void 0!==I?I:0," orders")},{key:"cost",label:"Slot Cost",color:"#f59e0b",icon:w.DwJ,value:q(null!==(L=null===Me||void 0===Me?void 0:Me.totalCost)&&void 0!==L?L:0),detail:"Fixed + variable"},{key:"net",label:"Slot Net",color:(null!==(Z=null===Me||void 0===Me?void 0:Me.totalNet)&&void 0!==Z?Z:0)>=0?"#10b981":"#ef4444",icon:(null!==($=null===Me||void 0===Me?void 0:Me.totalNet)&&void 0!==$?$:0)>=0?w.imn:w.Rod,value:"".concat((null!==(G=null===Me||void 0===Me?void 0:Me.totalNet)&&void 0!==G?G:0)>=0?"+":"").concat(q(null!==(U=null===Me||void 0===Me?void 0:Me.totalNet)&&void 0!==U?U:0)),detail:"".concat((null!==(Q=null===Me||void 0===Me?void 0:Me.totalRevenue)&&void 0!==Q?Q:0)>0&&(null!==(X=null===Me||void 0===Me?void 0:Me.totalNet)&&void 0!==X?X:0)/(null!==(ee=null===Me||void 0===Me?void 0:Me.totalRevenue)&&void 0!==ee?ee:1)>=0?"+":"").concat((null!==(te=null===Me||void 0===Me?void 0:Me.totalMargin)&&void 0!==te?te:0).toFixed(0),"% margin")}];return(0,W.jsxs)(W.Fragment,{children:[(Se||De)&&(0,W.jsx)(D.A,{}),(0,W.jsx)(P.A,{title:"Profitability Report",subtitle:"Live \xb7 ".concat(ae||"All Zones"," \xb7 ").concat(xe),live:!0,action:(0,W.jsx)(k.A,{locaName:ae,setAppId:pe,setLocoName:de,pill:!0,accentColor:B,icon:(0,W.jsx)(w.HPi,{size:14}),placeholder:"Select Zone",paperComponent:E,sx:{width:{xs:"100%",sm:280},zIndex:100}})}),(0,W.jsx)(x.Ay,{container:!0,spacing:{xs:2,md:2.5},sx:{mb:{xs:1.5,md:2}},children:Ne.map((e=>{var t;const r=e.icon;return(0,W.jsxs)(x.Ay,{item:!0,xs:6,sm:6,md:3,children:[(0,W.jsx)(N.A,{title:e.label,value:null!==(t=e.value)&&void 0!==t?t:0,icon:(0,W.jsx)(r,{size:20}),color:e.color,loading:Se}),(0,W.jsx)(h.A,{variant:"caption",sx:{color:z.textSecondary,display:"block",mt:.5,px:2,fontWeight:500},children:e.detail})]},e.key)}))}),(0,W.jsx)(l.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1,md:1.5},borderTopLeftRadius:z.radiusCard/8,borderTopRightRadius:z.radiusCard/8,borderBottomLeftRadius:0,borderBottomRightRadius:0,border:"1px solid",borderColor:z.borderSubtle,borderBottom:0,background:"#fff"},children:(0,W.jsxs)(f.A,{direction:{xs:"column",sm:"row"},alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between",spacing:1.25,children:[(0,W.jsxs)(f.A,{direction:"row",alignItems:"center",spacing:1.25,flexWrap:"wrap",children:[(0,W.jsx)(_,{color:B,size:32,children:(0,W.jsx)(w.LTk,{size:18})}),(0,W.jsxs)(f.A,{children:[(0,W.jsxs)(h.A,{variant:"caption",sx:{fontWeight:800,color:z.textSecondary,letterSpacing:.6,textTransform:"uppercase"},children:["Profitability Overview \xb7 ",xe]}),(0,W.jsxs)(h.A,{variant:"body2",sx:{color:z.textPrimary,fontWeight:700},children:[Pe.length," riders \xb7 ",Me.profitableRiders," profitable \xb7 ",Me.lossRiders," at loss"]})]}),(0,W.jsx)(a.A,{title:"Date Filter",placement:"top",children:(0,W.jsxs)(d.A,{onClick:()=>ue(!0),sx:{display:"inline-flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:999,cursor:"pointer",bgcolor:T("#f59e0b"),border:"1.5px solid ".concat(O("#f59e0b")),color:"#f59e0b",fontWeight:800,fontSize:12,ml:1,transition:"all 0.18s","&:hover":{borderColor:"#f59e0b",boxShadow:"0 0 0 3px ".concat(H("#f59e0b"))}},children:[(0,W.jsx)(w.Ki0,{size:14}),y()(ne).format("DD/MM/YY")," \u2013 ",y()(le).format("DD/MM/YY")]})})]}),(0,W.jsx)(d.A,{sx:{width:{xs:"100%",sm:280,lg:340},flex:{xs:"1 1 100%",sm:"0 0 auto"}},children:(0,W.jsx)(M.A,{value:ge,onChange:me,onDebouncedChange:be,placeholder:"Search riders",sx:{m:0,width:"100%",borderRadius:999,bgcolor:"#ffffff","& fieldset":{borderColor:"#e2e8f0",borderWidth:1},"&:hover fieldset":{borderColor:"#cbd5e1"},"&.Mui-focused fieldset":{borderColor:"#662582",borderWidth:1.5},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(H(B))}}})})]})}),(0,W.jsx)(l.A,{elevation:0,sx:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:z.radiusCard/8,borderBottomRightRadius:z.radiusCard/8,border:"1px solid",borderColor:z.borderSubtle,overflow:"hidden",background:"#fff"},children:oe?(0,W.jsx)(Y.nV,{scroll:!0,children:Pe&&0!==Pe.length?Pe.map(((e,t)=>{var r;if(!e)return null;const o=(null!==(r=e.net)&&void 0!==r?r:0)>=0;return(0,W.jsx)(Y.pg,{accent:o?"#10b981":"#ef4444",header:(0,W.jsxs)(f.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,W.jsx)(_,{color:o?"#10b981":"#ef4444",size:36,children:(0,W.jsx)(w.LTk,{size:18})}),(0,W.jsxs)(f.A,{children:[(0,W.jsx)(h.A,{variant:"subtitle2",sx:{fontWeight:700,color:z.textPrimary},children:e.riderName}),(0,W.jsxs)(h.A,{variant:"caption",sx:{color:z.textSecondary},children:["ID #",e.id]})]})]}),children:(0,W.jsxs)(Y.FG,{columns:2,children:[(0,W.jsx)(Y.pY,{label:"Orders",value:e.orders.length}),(0,W.jsx)(Y.pY,{label:"Distance",value:"".concat(e.kms.toFixed(2)," km")}),(0,W.jsx)(Y.pY,{label:"Revenue",value:q(e.revenue)}),(0,W.jsx)(Y.pY,{label:"Fixed Cost",value:q(e.fixedCost)}),(0,W.jsx)(Y.pY,{label:"Variable Cost",value:q(e.varCost)}),(0,W.jsx)(Y.pY,{label:"Total Cost",value:q(e.totalCost)}),(0,W.jsx)(Y.pY,{label:"Net Profit",value:"".concat(o?"+":"").concat(q(e.net)),full:!0}),(0,W.jsx)(Y.pY,{label:"Margin",value:"".concat(Math.abs(e.margin).toFixed(0),"%"),full:!0})]})},e.id||t)})):(0,W.jsxs)(f.A,{alignItems:"center",spacing:1.5,sx:{py:6},children:[(0,W.jsx)(s.A,{sx:{width:64,height:64,bgcolor:F("#94a3b8"),color:z.textMuted},children:(0,W.jsx)(w.LTk,{size:28})}),(0,W.jsx)(h.A,{variant:"subtitle1",sx:{fontWeight:700,color:z.textPrimary},children:"No riders to show"})]})}):(0,W.jsx)(p.A,{sx:{maxHeight:"calc(100vh - 280px)","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:O(B),borderRadius:8,"&:hover":{backgroundColor:B}},"&::-webkit-scrollbar-track":{backgroundColor:z.surfaceAlt}},children:(0,W.jsxs)(g.A,{stickyHeader:!0,sx:{minWidth:1e3},children:[(0,W.jsx)(m.A,{children:(0,W.jsxs)(v.A,{sx:{"& th":{backgroundColor:z.surfaceAlt,color:z.textSecondary,fontSize:11,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(z.borderSubtle),py:1.25,px:2}},children:[(0,W.jsx)(b.A,{children:"#"}),(0,W.jsx)(b.A,{children:"Rider"}),(0,W.jsx)(b.A,{align:"center",children:"Orders"}),(0,W.jsx)(b.A,{align:"center",children:"Distance"}),(0,W.jsx)(b.A,{align:"center",children:"Revenue"}),(0,W.jsx)(b.A,{align:"center",children:"Fixed Cost"}),(0,W.jsx)(b.A,{align:"center",children:"Variable Cost"}),(0,W.jsx)(b.A,{align:"center",children:"Total Cost"}),(0,W.jsx)(b.A,{align:"center",children:"Net Profit"}),(0,W.jsx)(b.A,{align:"center",children:"Margin"})]})}),(0,W.jsx)(A.A,{children:Pe&&0!==Pe.length?Pe.map(((e,t)=>{var r;if(!e)return null;const o=(null!==(r=e.net)&&void 0!==r?r:0)>=0;return(0,W.jsxs)(v.A,{sx:{transition:"background-color 0.15s","& td":{borderBottom:"1px solid ".concat(z.divider),py:1.5,px:2},"&:hover":{backgroundColor:z.surfaceAlt}},children:[(0,W.jsx)(b.A,{children:(0,W.jsx)(h.A,{variant:"caption",sx:{fontWeight:700,color:z.textMuted},children:String(t+1).padStart(2,"0")})}),(0,W.jsx)(b.A,{children:(0,W.jsxs)(f.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,W.jsx)(_,{color:B,size:36,children:(0,W.jsx)(w.LTk,{size:18})}),(0,W.jsxs)(f.A,{children:[(0,W.jsx)(h.A,{variant:"subtitle2",sx:{fontWeight:700,color:z.textPrimary,whiteSpace:"nowrap"},children:e.riderName}),(0,W.jsxs)(h.A,{variant:"caption",sx:{color:z.textSecondary},children:["ID #",e.id]})]})]})}),(0,W.jsx)(b.A,{align:"center",children:(0,W.jsx)(h.A,{variant:"body2",sx:{fontWeight:700,color:z.textPrimary},children:e.orders.length})}),(0,W.jsx)(b.A,{align:"center",children:(0,W.jsx)(J,{color:"#10b981",icon:(0,W.jsx)(w.xI$,{size:11}),label:"".concat(e.kms.toFixed(2)," km"),tooltip:"KMS"})}),(0,W.jsx)(b.A,{align:"center",children:(0,W.jsx)(J,{color:B,icon:(0,W.jsx)(w.S75,{size:11}),label:q(e.revenue).replace("\u20b9","").trim(),tooltip:"Revenue"})}),(0,W.jsx)(b.A,{align:"center",children:(0,W.jsx)(J,{color:"#6366f1",icon:(0,W.jsx)(w.DwJ,{size:11}),label:q(e.fixedCost).replace("\u20b9","").trim(),tooltip:"Fixed Cost"})}),(0,W.jsx)(b.A,{align:"center",children:(0,W.jsx)(J,{color:"#f59e0b",icon:(0,W.jsx)(w.pk7,{size:11}),label:q(e.varCost).replace("\u20b9","").trim(),tooltip:"Variable Cost"})}),(0,W.jsx)(b.A,{align:"center",children:(0,W.jsx)(J,{color:"#94a3b8",icon:(0,W.jsx)(w.DwJ,{size:11}),label:q(e.totalCost).replace("\u20b9","").trim(),tooltip:"Total Cost"})}),(0,W.jsx)(b.A,{align:"center",children:(0,W.jsx)(J,{color:o?"#10b981":"#ef4444",icon:o?(0,W.jsx)(w.imn,{size:11}):(0,W.jsx)(w.Rod,{size:11}),label:"".concat(o?"+":"").concat(q(e.net).replace("\u20b9","").trim()),tooltip:"Net Profit"})}),(0,W.jsx)(b.A,{align:"center",children:(0,W.jsx)(j.A,{label:"".concat(Math.abs(e.margin).toFixed(0),"%"),color:o?"success":"error",size:"small",sx:{fontWeight:700,minWidth:60}})})]},e.id||t)})):(0,W.jsx)(v.A,{children:(0,W.jsx)(b.A,{colSpan:10,sx:{py:6},children:(0,W.jsxs)(f.A,{alignItems:"center",spacing:1.5,children:[(0,W.jsx)(s.A,{sx:{width:64,height:64,bgcolor:F("#94a3b8"),color:z.textMuted},children:(0,W.jsx)(w.LTk,{size:28})}),(0,W.jsx)(h.A,{variant:"subtitle1",sx:{fontWeight:700,color:z.textPrimary},children:"No riders to show"})]})})})})]})})}),(0,W.jsx)(R.A,{open:ce,onClose:()=>ue(!1),onSelect:e=>{ie(e.startDate),se(e.endDate),he(e.label)}})]})}},23787:(e,t,r)=>{r.d(t,{FG:()=>h,nV:()=>u,pY:()=>f,pg:()=>x});var o=r(89379),n=r(80045),i=r(93230),l=r(2235),s=r(16491),a=r(82053),d=r(44414);const c=["children","scroll","onScroll","sx"],u=e=>{let{children:t,scroll:r=!1,onScroll:l,sx:s}=e,a=(0,n.A)(e,c);return(0,d.jsx)(i.A,(0,o.A)((0,o.A)({spacing:1.25,onScroll:l,sx:(0,o.A)((0,o.A)({p:1.5},r&&{maxHeight:"calc(100vh - 220px)",overflowY:"auto",overflowX:"hidden"}),s)},a),{},{children:t}))},x=e=>{let{accent:t="#662582",header:r,footer:n,selected:i=!1,onClick:a,children:c,sx:u}=e;return(0,d.jsxs)(l.A,{elevation:0,onClick:a,sx:(0,o.A)({position:"relative",overflow:"hidden",flexShrink:0,borderRadius:2.5,border:"1px solid",borderColor:i?t:"#e2e8f0",background:i?"".concat(t,"0a"):"#fff",boxShadow:"0 4px 14px rgba(15,23,42,0.05)",transition:"border-color 0.15s, box-shadow 0.15s"},u),children:[(0,d.jsx)(s.A,{sx:{position:"absolute",left:0,top:0,bottom:0,width:3,bgcolor:t}}),(0,d.jsxs)(s.A,{sx:{p:1.5,pl:2},children:[r,c,n]})]})},h=e=>{let{children:t,columns:r=2,sx:n}=e;return(0,d.jsx)(s.A,{sx:(0,o.A)({display:"grid",gridTemplateColumns:"repeat(".concat(r,", minmax(0, 1fr))"),gap:1,mt:1.25},n),children:t})},f=e=>{let{label:t,value:r,children:o,full:n=!1,align:i="left"}=e;return(0,d.jsxs)(s.A,{sx:{gridColumn:n?"1 / -1":"auto",minWidth:0,textAlign:i},children:[(0,d.jsx)(a.A,{sx:{fontSize:9.5,fontWeight:800,letterSpacing:.5,textTransform:"uppercase",color:"#94a3b8",lineHeight:1.4},children:t}),(0,d.jsx)(s.A,{sx:{mt:.25,minWidth:0},children:void 0!==o?o:(0,d.jsx)(a.A,{sx:{fontSize:13,fontWeight:600,color:"#0f172a"},noWrap:!0,children:null!==r&&void 0!==r?r:"\u2014"})})]})}},27001:(e,t,r)=>{r.d(t,{A:()=>s});var o=r(93230),n=r(16491),i=r(82053),l=r(44414);function s(e){let{title:t,subtitle:r,live:s=!1,action:a}=e;return(0,l.jsxs)(o.A,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{xs:"flex-start",sm:"center"},spacing:1.5,sx:{mb:{xs:2,md:2.5}},children:[(0,l.jsxs)(n.A,{sx:{minWidth:0},children:[(0,l.jsx)(i.A,{variant:"h3",sx:{fontWeight:700,letterSpacing:"-0.02em",color:"grey.800"},children:t}),r&&(0,l.jsxs)(o.A,{direction:"row",alignItems:"center",spacing:.75,sx:{mt:.5},children:[s&&(0,l.jsx)(n.A,{sx:{width:7,height:7,borderRadius:"50%",bgcolor:"success.main",boxShadow:"0 0 0 3px rgba(16,185,129,0.18)"}}),(0,l.jsx)(i.A,{variant:"caption",sx:{color:"text.secondary",fontWeight:500},children:r})]})]}),a&&(0,l.jsx)(n.A,{sx:{flexShrink:0,width:{xs:"100%",sm:"auto"}},children:a})]})}},35678:(e,t,r)=>{r.d(t,{A:()=>j});var o=r(9950),n=r(96583),i=r(40033),l=r(82053),s=r(28170),a=r(93230),d=r(82223),c=r(55916),u=r(4159),x=r.n(u),h=r(56712),f=r(81417),p=r(96600),g=r(53132),m=r(94289),v=r(57326),b=r(50624),A=r(44414);const j=e=>{let{open:t,onClose:r,onSelect:u}=e;const[j,w]=(0,o.useState)(null);return(0,A.jsxs)(n.A,{open:t,onClose:r,children:[(0,A.jsx)(i.A,{align:"left",children:(0,A.jsx)(l.A,{variant:"h4",children:"Select Filter Options"})}),(0,A.jsx)(s.A,{sx:{width:"100%"},className:"datedialog",children:(0,A.jsx)(c.U,{open:t,toggle:r,id:"daterange1",onChange:e=>{w({startDate:x()(e.startDate).format("YYYY-MM-DD"),endDate:x()(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,f.A)(new Date),endDate:(0,p.A)(new Date)},{label:"Last Week",startDate:(0,f.A)((0,g.A)(new Date,-1)),endDate:(0,p.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,m.A)(new Date),endDate:(0,v.A)(new Date)},{label:"Last Month",startDate:(0,m.A)((0,b.A)(new Date,-1)),endDate:(0,v.A)((0,b.A)(new Date,-1))}]})}),(0,A.jsx)(a.A,{direction:"row",justifyContent:"flex-end",sx:{width:"100%",p:2},children:(0,A.jsx)(d.A,{variant:"contained",size:"small",onClick:()=>{j?(u(j),r()):r()},children:"OK"})})]})}},36803:(e,t,r)=>{r.d(t,{A:()=>u});var o=r(48089),n=r(50704),i=r(93230),l=r(16491),s=r(82053),a=r(82917),d=r(41413),c=r(44414);function u(e){let{title:t,value:r,icon:u,color:x="#662582",caption:h,loading:f=!1}=e;return(0,c.jsx)(o.A,{sx:{height:"100%"},children:(0,c.jsx)(n.A,{sx:{p:{xs:1.75,md:2},"&:last-child":{pb:{xs:1.75,md:2}}},children:(0,c.jsxs)(i.A,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:1,children:[(0,c.jsxs)(l.A,{sx:{minWidth:0,flex:1},children:[(0,c.jsx)(s.A,{variant:"body2",sx:{fontWeight:500,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),f?(0,c.jsx)(a.A,{variant:"rounded",sx:{width:72,height:30,mt:.5},animation:"wave"}):(0,c.jsx)(s.A,{sx:{mt:.25,fontWeight:700,letterSpacing:"-0.015em",color:"grey.800",lineHeight:1.15,fontSize:{xs:"1.375rem",md:"1.5rem"},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),h&&(0,c.jsx)(s.A,{variant:"caption",sx:{display:"block",mt:.5,color:"text.secondary"},children:h})]}),u&&(0,c.jsx)(d.A,{variant:"rounded",sx:{width:42,height:42,borderRadius:2,bgcolor:"".concat(x,"14"),color:x,flexShrink:0},children:u})]})})})}},56311:(e,t,r)=>{r.d(t,{A:()=>h});var o=r(89379),n=r(9950),i=r(2660),l=r(2046),s=r(83274),a=r(25333),d=r(97125),c=r(7762),u=r(52097),x=r(44414);const h=e=>{let{value:t,onChange:r,onDebouncedChange:h,debounceTime:f=500,placeholder:p="Search (ctrl+k)",sx:g}=e;const m=(0,n.useRef)(null),[v]=(0,u.d7)(t,f);return(0,n.useEffect)((()=>{h&&h(v)}),[v,h]),(0,n.useEffect)((()=>{const e=e=>{var t;"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),null===(t=m.current)||void 0===t||t.focus());"Escape"===e.key&&document.activeElement===m.current&&m.current.blur()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[]),(0,x.jsx)(i.A,{sx:(0,o.A)({},g),inputRef:m,placeholder:p,autoComplete:"off",value:t,fullWidth:!0,onChange:e=>r(e.target.value),startAdornment:(0,x.jsx)(l.A,{position:"start",sx:{mr:-.5},children:(0,x.jsx)(d.A,{})}),endAdornment:(0,x.jsx)(s.A,{title:"Clear",children:(0,x.jsx)(a.A,{sx:{visibility:t?"visible":"hidden"},onClick:()=>r(""),children:(0,x.jsx)(c.A,{})})})})}},59212:(e,t,r)=>{r.d(t,{A:()=>x});var o=r(89379),n=r(9950),i=r(93230),l=r(41413),s=r(77922),a=r(29925),d=r(26910),c=r(31222),u=r(44414);const x=(0,n.forwardRef)(((e,t)=>{let{setAppId:r,setLocoName:x,setPage:h,sx:f,textfeildSx:p,textfieldSx:g,pill:m=!1,accentColor:v="#6366f1",icon:b,placeholder:A="Select Zone",paperComponent:j}=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 d.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(v).concat(e),C=y("26"),D=y("18"),R=m?{cursor:"pointer","& .MuiOutlinedInput-root":{borderRadius:"10px",bgcolor:"#ffffff",fontWeight:600,color:"#0f172a",paddingRight:"8px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s","& fieldset":{borderColor:"#e2e8f0",borderWidth:1},"&:hover fieldset":{borderColor:"#cbd5e1"},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(C)},"&.Mui-focused fieldset":{borderColor:v,borderWidth:1.5}},"& .MuiAutocomplete-endAdornment .MuiSvgIcon-root":{color:"#94a3b8"}}:{},k=m&&(0,u.jsx)(i.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25,flexShrink:0},children:(0,u.jsx)(l.A,{sx:{width:24,height:24,bgcolor:D,color:v,transition:"background-color 0.15s, color 0.15s"},children:b||(0,u.jsx)(c.HPi,{size:14})})});return(0,u.jsx)(s.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:j,sx:(0,o.A)({},f),onChange:(e,t,o)=>{"clear"===o?(null===r||void 0===r||r(0),null===x||void 0===x||x(""),null===h||void 0===h||h(0)):t&&(null===r||void 0===r||r(t.applocationid),null===x||void 0===x||x(t.locationname),null===h||void 0===h||h(0))},renderInput:e=>m?(0,u.jsx)(a.A,(0,o.A)((0,o.A)({},e),{},{inputRef:t,placeholder:A,InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:k}),sx:(0,o.A)((0,o.A)({},R),g||p||{})})):(0,u.jsx)(a.A,(0,o.A)((0,o.A)({},e),{},{inputRef:t,label:"Select Zones",sx:(0,o.A)({},g||p||{})}))})}))},60010:(e,t,r)=>{r.d(t,{q:()=>a});var o=r(89379),n=r(69347),i=r(45247),l=class extends n.${constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e,t){super.setOptions((0,o.A)((0,o.A)({},e),{},{behavior:(0,i.PL)()}),t)}getOptimisticResult(e){return e.behavior=(0,i.PL)(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch((0,o.A)((0,o.A)({},e),{},{meta:{fetchMore:{direction:"forward"}}}))}fetchPreviousPage(e){return this.fetch((0,o.A)((0,o.A)({},e),{},{meta:{fetchMore:{direction:"backward"}}}))}createResult(e,t){var r,n;const{state:l}=e,s=super.createResult(e,t),{isFetching:a,isRefetching:d}=s,c=a&&"forward"===(null===(r=l.fetchMeta)||void 0===r||null===(r=r.fetchMore)||void 0===r?void 0:r.direction),u=a&&"backward"===(null===(n=l.fetchMeta)||void 0===n||null===(n=n.fetchMore)||void 0===n?void 0:n.direction);return(0,o.A)((0,o.A)({},s),{},{fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:(0,i.rB)(t,l.data),hasPreviousPage:(0,i.RQ)(t,l.data),isFetchingNextPage:c,isFetchingPreviousPage:u,isRefetching:d&&!c&&!u})}},s=r(1729);function a(e,t){return(0,s.t)(e,l,t)}}}]); |