Files
Express_console_build/build/static/js/6165.f270c746.chunk.js

1 line
16 KiB
JavaScript

"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[6165],{26165:(e,o,r)=>{r.r(o),r.d(o,{default:()=>V});var n=r(9950),t=r(28429),i=r(36150),s=r(4159),c=r.n(s),l=r(41413),a=r(2235),d=r(93230),x=r(82053),h=r(16491),u=r(60899),g=r(1320),p=r(15769),m=r(69780),f=r(9213),b=r(21671),j=r(34075),A=r(83274),v=r(25333),w=r(74745),y=r(6258),k=r(31222),C=r(81425),S=r(52351),I=r(56311),W=r(96646),R=r(44414),z=r(36220);c().extend(z);const M=16,T="0 8px 24px rgba(15, 23, 42, 0.08)",P="#0f172a",L="#64748b",D="#94a3b8",Y="#e2e8f0",B="#f1f5f9",E="#f8fafc",F=(e,o)=>"".concat(e).concat(o),K=e=>F(e,"08"),H=e=>F(e,"18"),N=e=>F(e,"26"),O=e=>F(e,"55"),U="#662582",q="#9255AB",G=e=>{let{color:o,selected:r,size:n=24,children:t}=e;return(0,R.jsx)(l.A,{sx:{width:n,height:n,bgcolor:r?o:H(o),color:r?"#fff":o,transition:"background-color 0.15s, color 0.15s"},children:t})},X={0:{key:"all",label:"All",color:U,icon:k.Uhn,countKey:"totalcount"},1:{key:"open",label:"Open",color:"#ef4444",icon:k.tX0,countKey:"pendingcount"},2:{key:"overdue",label:"Overdue",color:"#f59e0b",icon:k.tMO,countKey:"overduecount"},3:{key:"paid",label:"Paid",color:"#10b981",icon:k.mU9,countKey:"paidcount"}},_=[0,1,2,3];function J(e){return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:2}).format(Number(e)||0)}const V=()=>{var e,o,r,s;const z=(0,t.Zp)(),[F,V]=(0,n.useState)(0),[Z,Q]=(0,n.useState)(10),[$,ee]=(0,n.useState)(0),[oe,re]=(0,n.useState)(!1),[ne,te]=(0,n.useState)(""),[ie,se]=(0,n.useState)(""),ce=n.useCallback((e=>{se(e),V(0)}),[]),{data:le,isLoading:ae,isError:de,error:xe}=(0,i.I)({queryKey:["invoiceInsight"],queryFn:C.Y8,refetchInterval:3e5}),{data:he,isLoading:ue,isError:ge,error:pe}=(0,i.I)({queryKey:[$],queryFn:C.XC,refetchInterval:3e5}),me=ae||ue,fe=de||ge,be=(null===xe||void 0===xe?void 0:xe.message)||(null===pe||void 0===pe?void 0:pe.message),je=(0,n.useMemo)((()=>{if(!he)return[];if(!ie)return he;const e=ie.toLowerCase().trim();return he.filter((o=>[o.tenantname,o.contactperson,String(o.invoiceno)].filter(Boolean).some((o=>String(o).toLowerCase().includes(e)))))}),[he,ie]),Ae=(0,n.useMemo)((()=>{const e=Math.max(0,Math.ceil(je.length/Z)-1);return Math.min(F,e)}),[je.length,F,Z]);n.useEffect((()=>{F!==Ae&&V(Ae)}),[F,Ae]);const ve=(0,n.useMemo)((()=>je.slice(Ae*Z,Ae*Z+Z)),[je,Ae,Z]),we=(0,n.useMemo)((()=>je.reduce(((e,o)=>e+(Number(o.totalamount)||0)),0)),[je]),ye=(0,n.useMemo)((()=>ve.reduce(((e,o)=>e+(Number(o.totalamount)||0)),0)),[ve]);if(fe)return be;const ke=[{idx:0,label:"All Invoices",color:U,icon:k.Uhn,value:null!==(e=null===le||void 0===le?void 0:le.totalcount)&&void 0!==e?e:0},{idx:1,label:"Open",color:"#ef4444",icon:k.tX0,value:null!==(o=null===le||void 0===le?void 0:le.pendingcount)&&void 0!==o?o:0},{idx:2,label:"Overdue",color:"#f59e0b",icon:k.tMO,value:null!==(r=null===le||void 0===le?void 0:le.overduecount)&&void 0!==r?r:0},{idx:3,label:"Paid",color:"#10b981",icon:k.mU9,value:null!==(s=null===le||void 0===le?void 0:le.paidcount)&&void 0!==s?s:0}],Ce=X[$];return(0,R.jsxs)(R.Fragment,{children:[(oe||me)&&(0,R.jsx)(S.A,{}),(0,R.jsx)(a.A,{elevation:0,sx:{mb:{xs:1.5,md:2},p:{xs:1.5,sm:2,md:2.5},borderRadius:M/8,border:"1px solid",borderColor:Y,background:"linear-gradient(135deg, ".concat(K(U)," 0%, ").concat(K(q)," 100%)"),boxShadow:T},children:(0,R.jsxs)(d.A,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",spacing:{xs:1.5,sm:2},children:[(0,R.jsxs)(d.A,{direction:"row",alignItems:"center",spacing:{xs:1.25,sm:1.75},children:[(0,R.jsx)(l.A,{sx:{width:{xs:40,sm:48},height:{xs:40,sm:48},bgcolor:U,color:"#fff",boxShadow:"0 6px 18px ".concat(N(U))},children:(0,R.jsx)(k.GdF,{size:22})}),(0,R.jsxs)(d.A,{children:[(0,R.jsx)(x.A,{variant:"h3",sx:{fontWeight:800,color:P,lineHeight:1.1,fontSize:{xs:"1.25rem",sm:"1.5rem",md:"1.75rem"}},children:"Invoices"}),(0,R.jsxs)(d.A,{direction:"row",alignItems:"center",spacing:.75,sx:{mt:.5},children:[(0,R.jsx)(h.A,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:"#10b981",boxShadow:"0 0 0 4px rgba(16,185,129,0.18)"}}),(0,R.jsxs)(x.A,{variant:"caption",sx:{color:L,fontWeight:600},children:["Live \xb7 Viewing ",Ce.label.toLowerCase()," invoices"]})]})]})]}),(0,R.jsxs)(h.A,{sx:{display:"inline-flex",alignItems:"center",gap:1,px:1.5,py:.875,borderRadius:999,bgcolor:K(U),border:"1.5px solid ".concat(O(U)),color:U,fontWeight:800,fontSize:12},children:[(0,R.jsx)(k.YHz,{size:14}),(0,R.jsx)(x.A,{variant:"caption",sx:{fontWeight:800,color:L,letterSpacing:.4,textTransform:"uppercase"},children:"Grand Total"}),(0,R.jsx)(x.A,{sx:{fontWeight:800,color:U,fontSize:13},children:J(we)})]})]})}),(0,R.jsx)(u.Ay,{container:!0,spacing:{xs:1.25,sm:1.5,md:2},sx:{mt:"1px"},children:ke.map((e=>{const o=e.icon,r=$===e.idx;return(0,R.jsx)(u.Ay,{item:!0,xs:6,sm:6,md:3,children:(0,R.jsxs)(a.A,{elevation:0,onClick:()=>{ee(e.idx),V(0)},sx:{position:"relative",overflow:"hidden",cursor:"pointer",p:{xs:1.25,sm:1.75,md:2.25},borderRadius:M/8,border:"1px solid",borderColor:r?O(e.color):Y,background:r?K(e.color):"#fff",boxShadow:r?"0 0 0 3px ".concat(N(e.color)):"none",transition:"transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.2s","&:hover":{transform:"translateY(-3px)",boxShadow:T,borderColor:O(e.color)}},children:[(0,R.jsx)(h.A,{sx:{position:"absolute",top:0,left:0,right:0,height:3,background:"linear-gradient(90deg, ".concat(e.color," 0%, ").concat(H(e.color)," 100%)")}}),(0,R.jsxs)(d.A,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",spacing:1,children:[(0,R.jsxs)(d.A,{spacing:.5,sx:{minWidth:0,flex:1},children:[(0,R.jsx)(x.A,{variant:"caption",sx:{color:L,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",fontSize:{xs:10,sm:11},whiteSpace:"nowrap"},children:e.label}),(0,R.jsx)(x.A,{sx:{fontWeight:800,color:P,lineHeight:1.1,fontSize:{xs:"1.25rem",sm:"1.5rem",md:"1.75rem"}},children:e.value})]}),(0,R.jsx)(l.A,{sx:{width:{xs:36,sm:42,md:48},height:{xs:36,sm:42,md:48},bgcolor:H(e.color),color:e.color,boxShadow:"inset 0 0 0 1px ".concat(O(e.color)),flexShrink:0},children:(0,R.jsx)(o,{size:20})})]})]})},e.idx)}))}),(0,R.jsx)(a.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1,md:1.5},borderTopLeftRadius:M/8,borderTopRightRadius:M/8,borderBottomLeftRadius:0,borderBottomRightRadius:0,border:"1px solid",borderColor:Y,borderBottom:0,background:"#fff"},children:(0,R.jsxs)(d.A,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{flexWrap:"wrap-reverse"},children:[(0,R.jsx)(d.A,{direction:"row",spacing:.75,sx:{flex:1,overflowX:"auto",py:.5,px:.25,"&::-webkit-scrollbar":{height:6},"&::-webkit-scrollbar-thumb":{backgroundColor:Y,borderRadius:4}},children:_.map((e=>{var o;const r=X[e],n=r.icon,t=$===e,i=null!==(o=null===le||void 0===le?void 0:le[r.countKey])&&void 0!==o?o:0;return(0,R.jsxs)(h.A,{onClick:()=>{ee(e),V(0)},sx:{display:"inline-flex",alignItems:"center",gap:{xs:.625,md:.875},pl:.5,pr:{xs:1,md:1.25},py:.5,flexShrink:0,cursor:"pointer",borderRadius:999,border:"1.5px solid ".concat(t?r.color:O(r.color)),bgcolor:t?r.color:K(r.color),color:t?"#fff":r.color,fontWeight:700,boxShadow:t?"0 6px 18px ".concat(N(r.color)):"none",transition:"all 0.18s","&:hover":{borderColor:r.color,boxShadow:t?"0 6px 18px ".concat(N(r.color)):"0 0 0 3px ".concat(N(r.color))}},children:[(0,R.jsx)(l.A,{sx:{width:{xs:22,md:26},height:{xs:22,md:26},bgcolor:t?"rgba(255,255,255,0.22)":H(r.color),color:t?"#fff":r.color},children:(0,R.jsx)(n,{size:13})}),(0,R.jsx)(x.A,{variant:"caption",sx:{fontWeight:800,fontSize:{xs:11.5,md:13},lineHeight:1},children:r.label}),(0,R.jsx)(h.A,{sx:{minWidth:{xs:22,md:26},height:{xs:18,md:22},px:.625,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:999,fontSize:{xs:10,md:11},fontWeight:800,bgcolor:t?"rgba(255,255,255,0.22)":"#fff",color:t?"#fff":r.color,border:t?"none":"1px solid ".concat(O(r.color))},children:i})]},e)}))}),(0,R.jsx)(h.A,{sx:{width:{xs:"100%",sm:240,lg:280},flex:{xs:"1 1 100%",sm:"0 0 auto"}},children:(0,R.jsx)(I.A,{value:ne,onChange:te,onDebouncedChange:ce,placeholder:"Search invoices (ctrl+k)",sx:{m:0,width:"100%",borderRadius:999,bgcolor:K(U),"& fieldset":{borderColor:O(U),borderWidth:1.5},"&:hover fieldset":{borderColor:U},"&.Mui-focused fieldset":{borderColor:U,borderWidth:2},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(N(U))}}})})]})}),(0,R.jsxs)(a.A,{elevation:0,sx:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:M/8,borderBottomRightRadius:M/8,border:"1px solid",borderColor:Y,overflow:"hidden",background:"#fff"},children:[(0,R.jsx)(g.A,{sx:{maxHeight:{xs:"calc(100vh - 220px)",md:"calc(100vh - 190px)"},"&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:O(U),borderRadius:8,"&:hover":{backgroundColor:U}},"&::-webkit-scrollbar-track":{backgroundColor:E}},children:(0,R.jsxs)(p.A,{stickyHeader:!0,sx:{minWidth:{xs:880,md:1060}},children:[(0,R.jsx)(m.A,{children:(0,R.jsxs)(f.A,{sx:{"& th":{backgroundColor:E,color:L,fontSize:{xs:10,md:11},fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(Y),py:{xs:1,md:1.25},px:{xs:1,md:2}}},children:[(0,R.jsx)(b.A,{children:"#"}),(0,R.jsx)(b.A,{children:"Client"}),(0,R.jsx)(b.A,{children:"Invoice ID"}),(0,R.jsx)(b.A,{children:"Invoice Date"}),(0,R.jsx)(b.A,{children:"Due Date"}),(0,R.jsx)(b.A,{align:"center",children:"Items"}),(0,R.jsx)(b.A,{align:"right",children:"Amount"}),(0,R.jsx)(b.A,{align:"center",children:"Action"})]})}),(0,R.jsxs)(j.A,{children:[ue&&(0,R.jsx)(W.r,{col:4}),ue||0!==ve.length?ve.map(((e,o)=>{var r;const n=2===$||e.duedate&&c()(e.duedate).isBefore(c()(),"day")&&3!==$;return(0,R.jsxs)(f.A,{sx:{transition:"background-color 0.15s","& td":{borderBottom:"1px solid ".concat(B),py:{xs:1,md:1.5},px:{xs:1,md:2},verticalAlign:"top"},"&:hover":{backgroundColor:E}},children:[(0,R.jsx)(b.A,{children:(0,R.jsx)(x.A,{variant:"caption",sx:{fontWeight:700,color:D},children:String(Ae*Z+o+1).padStart(2,"0")})}),(0,R.jsx)(b.A,{children:(0,R.jsxs)(d.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,R.jsx)(G,{color:U,size:36,children:(0,R.jsx)(k.Itr,{size:18})}),(0,R.jsxs)(d.A,{spacing:.25,sx:{minWidth:0},children:[(0,R.jsx)(x.A,{variant:"subtitle2",sx:{fontWeight:700,color:P,whiteSpace:"nowrap"},children:e.tenantname||"\u2014"}),e.contactperson&&(0,R.jsx)(x.A,{variant:"caption",sx:{color:L},children:e.contactperson})]})]})}),(0,R.jsx)(b.A,{children:(0,R.jsxs)(h.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:K("#0ea5e9"),border:"1px solid ".concat(O("#0ea5e9")),color:"#0ea5e9",fontSize:11,fontWeight:800},children:[(0,R.jsx)(k.GdF,{size:12})," ",e.invoiceno||"\u2014"]})}),(0,R.jsx)(b.A,{children:(0,R.jsxs)(d.A,{spacing:.25,children:[(0,R.jsxs)(d.A,{direction:"row",alignItems:"center",spacing:.5,children:[(0,R.jsx)(k.auT,{size:12,color:D}),(0,R.jsx)(x.A,{variant:"caption",sx:{fontWeight:700,color:P,whiteSpace:"nowrap"},children:e.transactiondate?c()(e.transactiondate).format("DD/MM/YYYY"):"\u2014"})]}),(0,R.jsx)(x.A,{variant:"caption",sx:{color:L,pl:2},children:e.transactiondate?c()(e.transactiondate).utc().format("hh:mm A"):""})]})}),(0,R.jsx)(b.A,{children:(0,R.jsxs)(d.A,{spacing:.25,children:[(0,R.jsxs)(d.A,{direction:"row",alignItems:"center",spacing:.5,children:[(0,R.jsx)(k.auT,{size:12,color:n&&3!==$?"#ef4444":D}),(0,R.jsx)(x.A,{variant:"caption",sx:{fontWeight:700,color:n&&3!==$?"#ef4444":P,whiteSpace:"nowrap"},children:e.duedate?c()(e.duedate).format("DD/MM/YYYY"):"\u2014"})]}),(0,R.jsx)(x.A,{variant:"caption",sx:{color:L,pl:2},children:e.duedate?c()(e.duedate).utc().format("hh:mm A"):""})]})}),(0,R.jsx)(b.A,{align:"center",children:(0,R.jsxs)(h.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:.875,py:.25,borderRadius:999,bgcolor:K("#14b8a6"),border:"1px solid ".concat(O("#14b8a6")),color:"#14b8a6",fontSize:11,fontWeight:800,minWidth:44,justifyContent:"center"},children:[(0,R.jsx)(k.gsJ,{size:11})," ",null!==(r=e.itemcount)&&void 0!==r?r:0]})}),(0,R.jsx)(b.A,{align:"right",children:(0,R.jsxs)(h.A,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,py:.375,borderRadius:999,bgcolor:K(U),border:"1px solid ".concat(O(U)),color:U,fontSize:11,fontWeight:800,minWidth:110,justifyContent:"center"},children:[(0,R.jsx)(k.YHz,{size:11}),J(e.totalamount).replace("\u20b9","").trim()]})}),(0,R.jsx)(b.A,{align:"center",children:(0,R.jsx)(A.A,{title:"Preview invoice",placement:"left",children:(0,R.jsx)(v.A,{size:"small",onClick:()=>{re(!0),setTimeout((()=>{re(!1),z("/nearle/invoice/preview",{state:e})}),500)},sx:{bgcolor:H(U),color:U,border:"1px solid ".concat(O(U)),"&:hover":{bgcolor:U,color:"#fff"}},children:(0,R.jsx)(k.U3x,{size:16})})})})]},e.invoiceno||o)})):(0,R.jsx)(f.A,{children:(0,R.jsx)(b.A,{colSpan:8,sx:{py:6},children:(0,R.jsxs)(d.A,{alignItems:"center",spacing:1.5,children:[(0,R.jsx)(l.A,{sx:{width:64,height:64,bgcolor:H("#94a3b8"),color:D},children:(0,R.jsx)(k.GdF,{size:28})}),(0,R.jsx)(x.A,{variant:"subtitle1",sx:{fontWeight:700,color:P},children:"No invoices to show"}),(0,R.jsx)(x.A,{variant:"caption",sx:{color:L},children:ne?"Try a different keyword.":"No ".concat(Ce.label.toLowerCase()," invoices for this filter.")})]})})})]})]})}),(0,R.jsx)(w.A,{}),(0,R.jsxs)(d.A,{direction:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",sx:{px:2,py:1,background:"linear-gradient(135deg, ".concat(K(U)," 0%, ").concat(K(q)," 100%)")},children:[(0,R.jsxs)(x.A,{variant:"caption",sx:{fontWeight:800,color:L,letterSpacing:.6,textTransform:"uppercase"},children:["Page total \xb7 ",J(ye)]}),(0,R.jsx)(y.A,{rowsPerPageOptions:[5,10,25,100],component:"div",count:je.length,rowsPerPage:Z,page:Ae,onPageChange:(e,o)=>V(o),onRowsPerPageChange:e=>{var o;Q(+(null===e||void 0===e||null===(o=e.target)||void 0===o?void 0:o.value)),V(0)},sx:{"& .MuiTablePagination-toolbar":{minHeight:40,px:0},"& .MuiTablePagination-selectLabel, & .MuiTablePagination-displayedRows":{fontWeight:700,color:L}}})]})]}),(0,R.jsx)(t.sv,{})]})}},56311:(e,o,r)=>{r.d(o,{A:()=>u});var n=r(89379),t=r(9950),i=r(2660),s=r(2046),c=r(83274),l=r(25333),a=r(97125),d=r(7762),x=r(52097),h=r(44414);const u=e=>{let{value:o,onChange:r,onDebouncedChange:u,debounceTime:g=500,placeholder:p="Search (ctrl+k)",sx:m}=e;const f=(0,t.useRef)(null),[b]=(0,x.d7)(o,g);return(0,t.useEffect)((()=>{u&&u(b)}),[b,u]),(0,t.useEffect)((()=>{const e=e=>{var o;"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),null===(o=f.current)||void 0===o||o.focus());"Escape"===e.key&&document.activeElement===f.current&&f.current.blur()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[]),(0,h.jsx)(i.A,{sx:(0,n.A)({},m),inputRef:f,placeholder:p,autoComplete:"off",value:o,fullWidth:!0,onChange:e=>r(e.target.value),startAdornment:(0,h.jsx)(s.A,{position:"start",sx:{mr:-.5},children:(0,h.jsx)(a.A,{})}),endAdornment:(0,h.jsx)(c.A,{title:"Clear",children:(0,h.jsx)(l.A,{sx:{visibility:o?"visible":"hidden"},onClick:()=>r(""),children:(0,h.jsx)(d.A,{})})})})}},96646:(e,o,r)=>{r.d(o,{r:()=>l});var n=r(9213),t=r(21671),i=r(82917),s=r(93230),c=r(44414);const l=e=>{let{rowsPerPage:o=5,col:r=1}=e;return(0,c.jsx)(c.Fragment,{children:Array.from(new Array(o)).map(((e,o)=>(0,c.jsxs)(n.A,{children:[(0,c.jsx)(t.A,{children:(0,c.jsx)(i.A,{variant:"circular",width:24,height:24})}),(0,c.jsx)(t.A,{children:(0,c.jsx)(i.A,{variant:"text",width:30})}),Array.from({length:r}).map(((e,o)=>(0,c.jsx)(t.A,{children:(0,c.jsxs)(s.A,{spacing:.5,children:[(0,c.jsx)(i.A,{variant:"text",width:100}),(0,c.jsx)(i.A,{variant:"text",width:80})]})},o))),(0,c.jsx)(t.A,{children:(0,c.jsx)(i.A,{variant:"text",width:150})}),(0,c.jsx)(t.A,{children:(0,c.jsx)(i.A,{variant:"rounded",width:60,height:24})}),(0,c.jsx)(t.A,{align:"center",children:(0,c.jsxs)(s.A,{direction:"row",spacing:1,justifyContent:"flex-end",children:[(0,c.jsx)(i.A,{variant:"circular",width:28,height:28}),(0,c.jsx)(i.A,{variant:"circular",width:28,height:28})]})})]},o)))})}}}]);