1 line
24 KiB
JavaScript
1 line
24 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:()=>q});var o=r(22555),n=r(85672),i=r(41033),s=r(55235),l=r(97043),a=r(23440),c=r(48738),d=r(69039),x=r(76264),u=r(1939),h=r(71392),f=r(2866),p=r(83209),m=r(72486),g=r(54016),b=r(50755),A=r(1596),v=r(81802),j=r(81062),w=r(48952),S=r(46077),C=r.n(S),y=r(81425),k=r(52351),D=r(35678),M=r(59212),R=r(56311),P=r(27001),Y=r(36803),W=r(23787),I=r(65908),N=r(22686);C().extend(N);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"),K=e=>L(e,"55"),H=e=>L(e,"26"),O="#662582",B=e=>(0,I.jsx)(s.A,(0,o.A)((0,o.A)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:z.shadowPop,border:"1px solid",borderColor:"divider",overflow:"hidden"}})),E=e=>{let{color:t,selected:r,size:o=24,children:n}=e;return(0,I.jsx)(l.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})},_=e=>{let{color:t,icon:r,label:o,tooltip:n,minWidth:i=80}=e;return(0,I.jsx)(a.A,{title:n||"",placement:"top",children:(0,I.jsxs)(c.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:"#ffffff",border:"1px solid ".concat(K(t)),color:t,fontSize:11,fontWeight:800,minWidth:i,justifyContent:"center",whiteSpace:"nowrap"},children:[r,o]})})},V=[{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}],J=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:V;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=C()(r);return n.isValid()?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:V;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 $(e){return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:2}).format(Number(e)||0)}function q(){var e,t,r,S,N;const L=(0,d.A)(),q=(0,x.A)(L.breakpoints.down("md")),[Z,G]=(0,n.useState)(C()().format("YYYY-MM-DD")),[Q,U]=(0,n.useState)(C()().format("YYYY-MM-DD")),[X,ee]=(0,n.useState)("All"),[te,re]=(0,n.useState)(!1),[oe,ne]=(0,n.useState)("Today"),[ie,se]=(0,n.useState)(0),[le,ae]=(0,n.useState)(""),[ce,de]=(0,n.useState)(""),xe="undefined"!==typeof window&&localStorage.getItem("userid")||0,ue=(0,n.useMemo)((()=>{if("undefined"===typeof window)return V;try{const e=window.localStorage.getItem("dispatch.slots.v9");if(!e)return V;const t=JSON.parse(e);return Array.isArray(t)&&t.length===V.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=V.find((e=>e.id===o)))||void 0===r?void 0:r.name)||"Slot ".concat(t+1),startHour:n,endHour:i}})):V}catch(e){return V}}),[]),{data:he,isLoading:fe,fetchNextPage:pe,hasNextPage:me,isFetchingNextPage:ge}=(0,i.q)({queryKey:["fetchdeliveries",ie,xe,"all",Z,Q,2e3,"",0,0,0],queryFn:y.tL,getNextPageParam:e=>{var t;return null!==(t=e.nextPage)&&void 0!==t?t:void 0},refetchOnWindowFocus:!1});(0,n.useEffect)((()=>{me&&!ge&&pe()}),[me,ge,pe]);const be=(0,n.useMemo)((()=>{const e=((null===he||void 0===he?void 0:he.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}),[he]),Ae=(0,n.useMemo)((()=>{const e={};return be.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))}),[be]),ve=(0,n.useMemo)((()=>{let e=0,t=0,r=0,n=0,i=0,s=0;const l=Ae.map((l=>{let a=0,c=0,d=0,x=0;const u={};let h=0;if(l.orders.forEach((e=>{const t=String(e.orderstatus||"").toLowerCase();if("cancelled"===t||"skipped"===t)return;const r=J(e,ue);if(!r)return;const o=parseFloat(e.riderkms||0);c+=o,d+=parseFloat(e.kms||0),x+=parseFloat(e.actualkms||0),a+=o<=8?30:30+6*(o-8);const n=e.assigntime?C()(e.assigntime).format("YYYY-MM-DD"):e.deliverydate?C()(e.deliverydate).format("YYYY-MM-DD"):null;n&&(u[n]||(u[n]=new Set),u[n].add(r),h++)})),0===h)return null;let f=0;Object.values(u).forEach((e=>{f+=Math.min(e.size,3)}));const p=2.5*c,m=f*(500/3),g=p+m,b=a-g,A=a>0?b/a*100:0;return b>=0?t++:r++,n+=c,i+=d,s+=x,e++,(0,o.A)((0,o.A)({},l),{},{orderCount:h,kms:c,plannedKms:d,actualKms:x,revenue:a,varCost:p,fixedCost:m,totalCost:g,net:b,margin:A})})).filter(Boolean);return{activeRiders:e,profitableRiders:t,lossRiders:r,totalKms:n,totalPlannedKms:i,totalActualKms:s,enrichedRiders:l}}),[Ae,ue]),je=(0,n.useMemo)((()=>{if(null===ve||void 0===ve||!ve.enrichedRiders||!Array.isArray(ve.enrichedRiders))return[];const e=ve.enrichedRiders.filter(Boolean);if(!ce)return e;const t=ce.toLowerCase().trim();return e.filter((e=>e&&[e.riderName,String(e.id)].filter(Boolean).some((e=>String(e).toLowerCase().includes(t)))))}),[null===ve||void 0===ve?void 0:ve.enrichedRiders,ce]),we=[{key:"riders",label:"Riders Active",color:O,icon:w.LTk,value:null!==(e=null===ve||void 0===ve?void 0:ve.activeRiders)&&void 0!==e?e:0},{key:"planned-kms",label:"Planned KMs",color:"#0ea5e9",icon:w.pk7,value:"".concat((null!==(t=null===ve||void 0===ve?void 0:ve.totalPlannedKms)&&void 0!==t?t:0).toFixed(1)," km")},{key:"actual-kms",label:"Actual KMs",color:"#f59e0b",icon:w.HPi,value:"".concat((null!==(r=null===ve||void 0===ve?void 0:ve.totalActualKms)&&void 0!==r?r:0).toFixed(1)," km")},{key:"rider-kms",label:"Rider KMs",color:O,icon:w.xI$,value:"".concat((null!==(S=null===ve||void 0===ve?void 0:ve.totalKms)&&void 0!==S?S:0).toFixed(1)," km")},{key:"total-distance",label:"Trip KMs",color:"#10b981",icon:w.xI$,value:"".concat((null!==(N=null===ve||void 0===ve?void 0:ve.totalKms)&&void 0!==N?N:0).toFixed(1)," km")}];return(0,I.jsxs)(I.Fragment,{children:[(fe||ge)&&(0,I.jsx)(k.A,{}),(0,I.jsx)(P.A,{title:"Profitability Report",subtitle:"Live \xb7 ".concat(X||"All Zones"," \xb7 ").concat(oe),live:!0,action:(0,I.jsx)(M.A,{locaName:X,setAppId:se,setLocoName:ee,pill:!0,accentColor:O,icon:(0,I.jsx)(w.HPi,{size:14}),placeholder:"Select Zone",paperComponent:B,sx:{width:{xs:"100%",sm:280},zIndex:100}})}),(0,I.jsx)(u.Ay,{container:!0,spacing:{xs:2,md:2.5},sx:{mb:{xs:1.5,md:2}},children:we.map((e=>{var t;const r=e.icon;return(0,I.jsx)(u.Ay,{item:!0,xs:6,sm:4,md:2.4,children:(0,I.jsx)(Y.A,{title:e.label,value:null!==(t=e.value)&&void 0!==t?t:0,icon:(0,I.jsx)(r,{size:20}),color:e.color,loading:fe})},e.key)}))}),(0,I.jsx)(s.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,I.jsxs)(h.A,{direction:{xs:"column",sm:"row"},alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between",spacing:1.25,children:[(0,I.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1.25,flexWrap:"wrap",children:[(0,I.jsx)(E,{color:O,size:32,children:(0,I.jsx)(w.LTk,{size:18})}),(0,I.jsxs)(h.A,{children:[(0,I.jsxs)(f.A,{variant:"caption",sx:{fontWeight:800,color:z.textSecondary,letterSpacing:.6,textTransform:"uppercase"},children:["Profitability Overview \xb7 ",oe]}),(0,I.jsxs)(f.A,{variant:"body2",sx:{color:z.textPrimary,fontWeight:700},children:[je.length," riders \xb7 ",ve.profitableRiders," profitable \xb7 ",ve.lossRiders," at loss"]})]}),(0,I.jsx)(a.A,{title:"Date Filter",placement:"top",children:(0,I.jsxs)(c.A,{onClick:()=>re(!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(K("#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,I.jsx)(w.Ki0,{size:14}),C()(Z).format("DD/MM/YY")," \u2013 ",C()(Q).format("DD/MM/YY")]})})]}),(0,I.jsx)(c.A,{sx:{width:{xs:"100%",sm:280,lg:340},flex:{xs:"1 1 100%",sm:"0 0 auto"}},children:(0,I.jsx)(R.A,{value:le,onChange:ae,onDebouncedChange:de,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(O))}}})})]})}),(0,I.jsx)(s.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:q?(0,I.jsx)(W.nV,{scroll:!0,children:je&&0!==je.length?je.map(((e,t)=>{var r;if(!e)return null;const o=(null!==(r=e.net)&&void 0!==r?r:0)>=0;return(0,I.jsx)(W.pg,{accent:o?"#10b981":"#ef4444",header:(0,I.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,I.jsx)(E,{color:o?"#10b981":"#ef4444",size:36,children:(0,I.jsx)(w.LTk,{size:18})}),(0,I.jsxs)(h.A,{children:[(0,I.jsx)(f.A,{variant:"subtitle2",sx:{fontWeight:700,color:z.textPrimary},children:e.riderName}),(0,I.jsxs)(f.A,{variant:"caption",sx:{color:z.textSecondary},children:["ID #",e.id]})]})]}),children:(0,I.jsxs)(W.FG,{columns:2,children:[(0,I.jsx)(W.pY,{label:"Orders",value:e.orderCount}),(0,I.jsx)(W.pY,{label:"Rider KMs",value:"".concat(Math.round(e.kms)," km")}),(0,I.jsx)(W.pY,{label:"Revenue",value:$(e.revenue)}),(0,I.jsx)(W.pY,{label:"Fixed Cost",value:$(e.fixedCost)}),(0,I.jsx)(W.pY,{label:"Variable Cost",value:$(e.varCost)}),(0,I.jsx)(W.pY,{label:"Total Cost",value:$(e.totalCost)}),(0,I.jsx)(W.pY,{label:"Net Profit",value:"".concat(o?"+":"").concat($(e.net)),full:!0}),(0,I.jsx)(W.pY,{label:"Margin",value:"".concat(Math.abs(e.margin).toFixed(0),"%"),full:!0})]})},e.id||t)})):(0,I.jsxs)(h.A,{alignItems:"center",spacing:1.5,sx:{py:6},children:[(0,I.jsx)(l.A,{sx:{width:64,height:64,bgcolor:F("#94a3b8"),color:z.textMuted},children:(0,I.jsx)(w.LTk,{size:28})}),(0,I.jsx)(f.A,{variant:"subtitle1",sx:{fontWeight:700,color:z.textPrimary},children:"No riders to show"})]})}):(0,I.jsx)(p.A,{sx:{maxHeight:"calc(100vh - 280px)","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:K(O),borderRadius:8,"&:hover":{backgroundColor:O}},"&::-webkit-scrollbar-track":{backgroundColor:z.surfaceAlt}},children:(0,I.jsxs)(m.A,{stickyHeader:!0,sx:{minWidth:1e3},children:[(0,I.jsx)(g.A,{children:(0,I.jsxs)(b.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,I.jsx)(A.A,{children:"#"}),(0,I.jsx)(A.A,{children:"Rider"}),(0,I.jsx)(A.A,{align:"center",children:"Orders"}),(0,I.jsx)(A.A,{align:"center",children:"Rider KMs"}),(0,I.jsx)(A.A,{align:"center",children:"Revenue"}),(0,I.jsx)(A.A,{align:"center",children:"Fixed Cost"}),(0,I.jsx)(A.A,{align:"center",children:"Variable Cost"}),(0,I.jsx)(A.A,{align:"center",children:"Total Cost"}),(0,I.jsx)(A.A,{align:"center",children:"Net Profit"}),(0,I.jsx)(A.A,{align:"center",children:"Margin"})]})}),(0,I.jsx)(v.A,{children:je&&0!==je.length?je.map(((e,t)=>{var r;if(!e)return null;const o=(null!==(r=e.net)&&void 0!==r?r:0)>=0;return(0,I.jsxs)(b.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,I.jsx)(A.A,{children:(0,I.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:z.textMuted},children:String(t+1).padStart(2,"0")})}),(0,I.jsx)(A.A,{children:(0,I.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,I.jsx)(E,{color:O,size:36,children:(0,I.jsx)(w.LTk,{size:18})}),(0,I.jsxs)(h.A,{children:[(0,I.jsx)(f.A,{variant:"subtitle2",sx:{fontWeight:700,color:z.textPrimary,whiteSpace:"nowrap"},children:e.riderName}),(0,I.jsxs)(f.A,{variant:"caption",sx:{color:z.textSecondary},children:["ID #",e.id]})]})]})}),(0,I.jsx)(A.A,{align:"center",children:(0,I.jsx)(f.A,{variant:"body2",sx:{fontWeight:700,color:z.textPrimary},children:e.orderCount})}),(0,I.jsx)(A.A,{align:"center",children:(0,I.jsx)(_,{color:"#10b981",icon:(0,I.jsx)(w.xI$,{size:11}),label:"".concat(Math.round(e.kms)," km"),tooltip:"KMS"})}),(0,I.jsx)(A.A,{align:"center",children:(0,I.jsx)(_,{color:O,icon:(0,I.jsx)(w.S75,{size:11}),label:$(e.revenue).replace("\u20b9","").trim(),tooltip:"Revenue"})}),(0,I.jsx)(A.A,{align:"center",children:(0,I.jsx)(_,{color:"#6366f1",icon:(0,I.jsx)(w.DwJ,{size:11}),label:$(e.fixedCost).replace("\u20b9","").trim(),tooltip:"Fixed Cost"})}),(0,I.jsx)(A.A,{align:"center",children:(0,I.jsx)(_,{color:"#f59e0b",icon:(0,I.jsx)(w.pk7,{size:11}),label:$(e.varCost).replace("\u20b9","").trim(),tooltip:"Variable Cost"})}),(0,I.jsx)(A.A,{align:"center",children:(0,I.jsx)(_,{color:"#94a3b8",icon:(0,I.jsx)(w.DwJ,{size:11}),label:$(e.totalCost).replace("\u20b9","").trim(),tooltip:"Total Cost"})}),(0,I.jsx)(A.A,{align:"center",children:(0,I.jsx)(_,{color:o?"#10b981":"#ef4444",icon:o?(0,I.jsx)(w.imn,{size:11}):(0,I.jsx)(w.Rod,{size:11}),label:"".concat(o?"+":"").concat($(e.net).replace("\u20b9","").trim()),tooltip:"Net Profit"})}),(0,I.jsx)(A.A,{align:"center",children:(0,I.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,I.jsx)(b.A,{children:(0,I.jsx)(A.A,{colSpan:10,sx:{py:6},children:(0,I.jsxs)(h.A,{alignItems:"center",spacing:1.5,children:[(0,I.jsx)(l.A,{sx:{width:64,height:64,bgcolor:F("#94a3b8"),color:z.textMuted},children:(0,I.jsx)(w.LTk,{size:28})}),(0,I.jsx)(f.A,{variant:"subtitle1",sx:{fontWeight:700,color:z.textPrimary},children:"No riders to show"})]})})})})]})})}),(0,I.jsx)(D.A,{open:te,onClose:()=>re(!1),onSelect:e=>{G(e.startDate),U(e.endDate),ne(e.label)}})]})}},23787:(e,t,r)=>{r.d(t,{FG:()=>h,nV:()=>x,pY:()=>f,pg:()=>u});var o=r(22555),n=r(53986),i=r(71392),s=r(55235),l=r(48738),a=r(2866),c=r(65908);const d=["children","scroll","onScroll","sx"],x=e=>{let{children:t,scroll:r=!1,onScroll:s,sx:l}=e,a=(0,n.A)(e,d);return(0,c.jsx)(i.A,(0,o.A)((0,o.A)({spacing:1.25,onScroll:s,sx:(0,o.A)((0,o.A)({p:1.5},r&&{maxHeight:"calc(100vh - 220px)",overflowY:"auto",overflowX:"hidden"}),l)},a),{},{children:t}))},u=e=>{let{accent:t="#662582",header:r,footer:n,selected:i=!1,onClick:a,children:d,sx:x}=e;return(0,c.jsxs)(s.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"},x),children:[(0,c.jsx)(l.A,{sx:{position:"absolute",left:0,top:0,bottom:0,width:3,bgcolor:t}}),(0,c.jsxs)(l.A,{sx:{p:1.5,pl:2},children:[r,d,n]})]})},h=e=>{let{children:t,columns:r=2,sx:n}=e;return(0,c.jsx)(l.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,c.jsxs)(l.A,{sx:{gridColumn:n?"1 / -1":"auto",minWidth:0,textAlign:i},children:[(0,c.jsx)(a.A,{sx:{fontSize:9.5,fontWeight:800,letterSpacing:.5,textTransform:"uppercase",color:"#94a3b8",lineHeight:1.4},children:t}),(0,c.jsx)(l.A,{sx:{mt:.25,minWidth:0},children:void 0!==o?o:(0,c.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:()=>l});var o=r(71392),n=r(48738),i=r(2866),s=r(65908);function l(e){let{title:t,subtitle:r,live:l=!1,action:a}=e;return(0,s.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,s.jsxs)(n.A,{sx:{minWidth:0},children:[(0,s.jsx)(i.A,{variant:"h3",sx:{fontWeight:700,letterSpacing:"-0.02em",color:"grey.800"},children:t}),r&&(0,s.jsxs)(o.A,{direction:"row",alignItems:"center",spacing:.75,sx:{mt:.5},children:[l&&(0,s.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,s.jsx)(i.A,{variant:"caption",sx:{color:"text.secondary",fontWeight:500},children:r})]})]}),a&&(0,s.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(85672),n=r(58689),i=r(19619),s=r(2866),l=r(5670),a=r(71392),c=r(80911),d=r(36117),x=r(46077),u=r.n(x),h=r(36738),f=r(80959),p=r(33090),m=r(52994),g=r(33323),b=r(75732),A=r(43962),v=r(65908);const j=e=>{let{open:t,onClose:r,onSelect:x}=e;const[j,w]=(0,o.useState)(null);return(0,v.jsxs)(n.A,{open:t,onClose:r,children:[(0,v.jsx)(i.A,{align:"left",children:(0,v.jsx)(s.A,{variant:"h4",children:"Select Filter Options"})}),(0,v.jsx)(l.A,{sx:{width:"100%"},className:"datedialog",children:(0,v.jsx)(d.U,{open:t,toggle:r,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,f.A)(new Date),endDate:(0,p.A)(new Date)},{label:"Last Week",startDate:(0,f.A)((0,m.A)(new Date,-1)),endDate:(0,p.A)((0,m.A)(new Date,-1))},{label:"Last 7 Days",startDate:(0,m.A)(new Date,-1),endDate:new Date},{label:"This Month",startDate:(0,g.A)(new Date),endDate:(0,b.A)(new Date)},{label:"Last Month",startDate:(0,g.A)((0,A.A)(new Date,-1)),endDate:(0,b.A)((0,A.A)(new Date,-1))}]})}),(0,v.jsx)(a.A,{direction:"row",justifyContent:"flex-end",sx:{width:"100%",p:2},children:(0,v.jsx)(c.A,{variant:"contained",size:"small",onClick:()=>{j?(x(j),r()):r()},children:"OK"})})]})}},36803:(e,t,r)=>{r.d(t,{A:()=>x});var o=r(84007),n=r(75953),i=r(71392),s=r(48738),l=r(2866),a=r(91834),c=r(97043),d=r(65908);function x(e){let{title:t,value:r,icon:x,color:u="#662582",caption:h,loading:f=!1}=e;return(0,d.jsx)(o.A,{sx:{height:"100%"},children:(0,d.jsx)(n.A,{sx:{p:{xs:1.75,md:2},"&:last-child":{pb:{xs:1.75,md:2}}},children:(0,d.jsxs)(i.A,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:1,children:[(0,d.jsxs)(s.A,{sx:{minWidth:0,flex:1},children:[(0,d.jsx)(l.A,{variant:"body2",sx:{fontWeight:500,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),f?(0,d.jsx)(a.A,{variant:"rounded",sx:{width:72,height:30,mt:.5},animation:"wave"}):(0,d.jsx)(l.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,d.jsx)(l.A,{variant:"caption",sx:{display:"block",mt:.5,color:"text.secondary"},children:h})]}),x&&(0,d.jsx)(c.A,{variant:"rounded",sx:{width:42,height:42,borderRadius:2,bgcolor:"".concat(u,"14"),color:u,flexShrink:0},children:x})]})})})}},41033:(e,t,r)=>{r.d(t,{q:()=>a});var o=r(22555),n=r(48149),i=r(59949),s=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,s,l;const{state:a}=e,c=super.createResult(e,t),{isFetching:d,isRefetching:x}=c,u=d&&"forward"===(null===(r=a.fetchMeta)||void 0===r||null===(n=r.fetchMore)||void 0===n?void 0:n.direction),h=d&&"backward"===(null===(s=a.fetchMeta)||void 0===s||null===(l=s.fetchMore)||void 0===l?void 0:l.direction);return(0,o.A)((0,o.A)({},c),{},{fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:(0,i.rB)(t,a.data),hasPreviousPage:(0,i.RQ)(t,a.data),isFetchingNextPage:u,isFetchingPreviousPage:h,isRefetching:x&&!u&&!h})}},l=r(59363);function a(e,t){return(0,l.t)(e,s,t)}},56311:(e,t,r)=>{r.d(t,{A:()=>h});var o=r(22555),n=r(85672),i=r(29776),s=r(43318),l=r(23440),a=r(11969),c=r(80795),d=r(51808),x=r(93811),u=r(65908);const h=e=>{let{value:t,onChange:r,onDebouncedChange:h,debounceTime:f=500,placeholder:p="Search (ctrl+k)",sx:m}=e;const g=(0,n.useRef)(null),[b]=(0,x.d7)(t,f);return(0,n.useEffect)((()=>{h&&h(b)}),[b,h]),(0,n.useEffect)((()=>{const e=e=>{var t;"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),null===(t=g.current)||void 0===t||t.focus());"Escape"===e.key&&document.activeElement===g.current&&g.current.blur()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[]),(0,u.jsx)(i.A,{sx:(0,o.A)({},m),inputRef:g,placeholder:p,autoComplete:"off",value:t,fullWidth:!0,onChange:e=>r(e.target.value),startAdornment:(0,u.jsx)(s.A,{position:"start",sx:{mr:-.5},children:(0,u.jsx)(c.A,{})}),endAdornment:(0,u.jsx)(l.A,{title:"Clear",children:(0,u.jsx)(a.A,{sx:{visibility:t?"visible":"hidden"},onClick:()=>r(""),children:(0,u.jsx)(d.A,{})})})})}},59212:(e,t,r)=>{r.d(t,{A:()=>u});var o=r(22555),n=r(85672),i=r(71392),s=r(97043),l=r(17488),a=r(86270),c=r(66157),d=r(48952),x=r(65908);const u=(0,n.forwardRef)(((e,t)=>{let{setAppId:r,setLocoName:u,setPage:h,sx:f,textfeildSx:p,textfieldSx:m,pill:g=!1,accentColor:b="#6366f1",icon:A,placeholder:v="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 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 C=e=>"".concat(b).concat(e),y=C("26"),k=C("18"),D=g?{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(y)},"&.Mui-focused fieldset":{borderColor:b,borderWidth:1.5}},"& .MuiAutocomplete-endAdornment .MuiSvgIcon-root":{color:"#94a3b8"}}:{},M=g&&(0,x.jsx)(i.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25,flexShrink:0},children:(0,x.jsx)(s.A,{sx:{width:24,height:24,bgcolor:k,color:b,transition:"background-color 0.15s, color 0.15s"},children:A||(0,x.jsx)(d.HPi,{size:14})})});return(0,x.jsx)(l.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===u||void 0===u||u(""),null===h||void 0===h||h(0)):t&&(null===r||void 0===r||r(t.applocationid),null===u||void 0===u||u(t.locationname),null===h||void 0===h||h(0))},renderInput:e=>g?(0,x.jsx)(a.A,(0,o.A)((0,o.A)({},e),{},{inputRef:t,placeholder:v,InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:M}),sx:(0,o.A)((0,o.A)({},D),m||p||{})})):(0,x.jsx)(a.A,(0,o.A)((0,o.A)({},e),{},{inputRef:t,label:"Select Zones",sx:(0,o.A)({},m||p||{})}))})}))}}]); |