"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[2476],{82476:function(e,o,n){n.r(o);var r=n(1413),t=n(74165),i=n(15861),c=n(29439),s=n(47313),a=n(70501),l=n(42832),d=n(48119),x=n(61113),u=n(57829),h=n(9019),f=n(84488),p=n(54882),g=n(47131),b=n(51629),m=n(66835),v=n(23477),Z=n(24076),j=n(67478),w=n(57861),S=n(61689),y=n(62323),k=n(56573),C=n(10658),R=n.n(C),W=n(58467),z=n(22539),I=n(11577),P=n(46417),T=16,B="0 8px 24px rgba(15, 23, 42, 0.08)",K="#0f172a",L="#64748b",H="#94a3b8",D="#e2e8f0",E="#f1f5f9",Y="#f8fafc",A=function(e,o){return"".concat(e).concat(o)},M=function(e){return A(e,"08")},N=function(e){return A(e,"18")},V=function(e){return A(e,"26")},_=function(e){return A(e,"55")},F="#662582",O=[{idx:0,billStatus:0,label:"All",color:F,icon:z.VHP,countKey:"totalcount"},{idx:1,billStatus:1,label:"Open",color:"#f59e0b",icon:z.Ley,countKey:"pendingcount"},{idx:2,billStatus:2,label:"Overdue",color:"#ef4444",icon:z.C1n,countKey:"overduecount"},{idx:3,billStatus:3,label:"Paid",color:"#10b981",icon:z.ZSR,countKey:"paidcount"}];function U(e){return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:2}).format(e||0)}o.default=function(){var e=(0,W.s0)(),o=(0,s.useState)(0),n=(0,c.Z)(o,2),C=n[0],A=n[1],X=(0,s.useState)(10),q=(0,c.Z)(X,2),G=q[0],J=q[1],Q=(0,s.useState)(0),$=(0,c.Z)(Q,2),ee=$[0],oe=$[1],ne=(0,s.useState)([]),re=(0,c.Z)(ne,2),te=re[0],ie=re[1],ce=(0,s.useState)(0),se=(0,c.Z)(ce,2),ae=se[0],le=se[1],de=(0,s.useState)(!1),xe=(0,c.Z)(de,2),ue=xe[0],he=xe[1],fe=(0,s.useState)({}),pe=(0,c.Z)(fe,2),ge=pe[0],be=pe[1],me=(0,s.useState)(""),ve=(0,c.Z)(me,2),Ze=ve[0],je=ve[1],we=(0,s.useState)(""),Se=(0,c.Z)(we,2),ye=Se[0],ke=Se[1],Ce=localStorage.getItem("tenantid"),Re=(0,s.useRef)(null);(0,s.useEffect)((function(){var e=function(e){"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),Re.current&&Re.current.focus()),"Escape"===e.key&&document.activeElement===Re.current&&Re.current.blur()};return document.addEventListener("keydown",e),function(){return document.removeEventListener("keydown",e)}}),[]),(0,s.useEffect)((function(){var e=setTimeout((function(){return ke(Ze)}),350);return function(){return clearTimeout(e)}}),[Ze]);var We=function(){var e=(0,i.Z)((0,t.Z)().mark((function e(){var o;return(0,t.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,k.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/invoice/getinvoiceinsight/?tenantid=").concat(Ce));case 3:o=e.sent,be(o.data.details||{}),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.log("insightResponse",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();(0,s.useEffect)((function(){We()}),[]);var ze=function(){var e=(0,i.Z)((0,t.Z)().mark((function e(){var o,n;return(0,t.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return he(!0),e.prev=1,o="".concat("https://jupiter.nearle.app/live/api/v1","/invoice/getallinvoice/?billstatus=").concat(ae,"&tenantid=").concat(Ce),e.next=5,k.Z.get(o);case 5:n=e.sent,ie(n.data.details||[]),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),console.log("fetchdeliverylist",e.t0);case 12:return e.prev=12,he(!1),e.finish(12);case 15:case"end":return e.stop()}}),e,null,[[1,9,12,15]])})));return function(){return e.apply(this,arguments)}}();(0,s.useEffect)((function(){ze(),A(0)}),[ae]);var Ie=(te||[]).filter((function(e){return String(e.invoiceno||"").toLowerCase().includes(String(ye||"").toLowerCase())})),Pe=function(e){var o=O[e];oe(e),le(o.billStatus),je("")},Te=O.map((function(e){var o;return(0,r.Z)((0,r.Z)({},e),{},{value:null!==(o=null===ge||void 0===ge?void 0:ge[e.countKey])&&void 0!==o?o:0})}));return(0,P.jsxs)(P.Fragment,{children:[ue&&(0,P.jsx)(I.Z,{}),(0,P.jsx)(a.Z,{elevation:0,sx:{mb:{xs:1.5,md:2},p:{xs:1.5,sm:2,md:2.5},borderRadius:T/8,border:"1px solid",borderColor:D,background:"linear-gradient(135deg, ".concat(M(F)," 0%, ").concat(M("#9255AB")," 100%)"),boxShadow:B},children:(0,P.jsxs)(l.Z,{direction:"row",alignItems:"center",spacing:{xs:1.25,sm:1.75},children:[(0,P.jsx)(d.Z,{sx:{width:{xs:40,sm:48},height:{xs:40,sm:48},bgcolor:F,color:"#fff",boxShadow:"0 6px 18px ".concat(V(F))},children:(0,P.jsx)(z.VHP,{size:22})}),(0,P.jsxs)(l.Z,{children:[(0,P.jsx)(x.Z,{variant:"h3",sx:{fontWeight:800,color:K,lineHeight:1.1,fontSize:{xs:"1.25rem",sm:"1.5rem",md:"1.75rem"}},children:"Invoices"}),(0,P.jsxs)(l.Z,{direction:"row",alignItems:"center",spacing:.75,sx:{mt:.5},children:[(0,P.jsx)(u.Z,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:"#10b981",boxShadow:"0 0 0 4px rgba(16,185,129,0.18)"}}),(0,P.jsxs)(x.Z,{variant:"caption",sx:{color:L,fontWeight:600},children:["Live \xb7 ",O[ee].label]})]})]})]})}),(0,P.jsx)(h.ZP,{container:!0,spacing:{xs:1.25,sm:1.5,md:2},children:Te.map((function(e){var o=e.icon,n=ee===e.idx;return(0,P.jsx)(h.ZP,{item:!0,xs:6,sm:6,md:3,children:(0,P.jsxs)(a.Z,{elevation:0,onClick:function(){return Pe(e.idx)},sx:{cursor:"pointer",position:"relative",overflow:"hidden",p:{xs:1.25,sm:1.75,md:2.25},borderRadius:T/8,border:"1px solid",borderColor:n?_(e.color):D,background:"#fff",boxShadow:n?"0 6px 24px ".concat(V(e.color)):"none",transition:"transform 0.2s, box-shadow 0.2s, border-color 0.2s","&:hover":{transform:"translateY(-3px)",boxShadow:B,borderColor:_(e.color)}},children:[(0,P.jsx)(u.Z,{sx:{position:"absolute",top:0,left:0,right:0,height:3,background:"linear-gradient(90deg, ".concat(e.color," 0%, ").concat(N(e.color)," 100%)")}}),(0,P.jsxs)(l.Z,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",spacing:1,children:[(0,P.jsxs)(l.Z,{spacing:.5,sx:{minWidth:0,flex:1},children:[(0,P.jsxs)(x.Z,{variant:"caption",sx:{color:L,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",fontSize:{xs:10,sm:11}},children:[e.label," Invoices"]}),(0,P.jsx)(x.Z,{sx:{fontWeight:800,color:K,lineHeight:1.1,fontSize:{xs:"1.25rem",sm:"1.5rem",md:"1.75rem"}},children:ge&&null!=ge[e.countKey]?ge[e.countKey]:(0,P.jsx)(f.Z,{sx:{width:40},animation:"wave"})})]}),(0,P.jsx)(d.Z,{sx:{width:{xs:36,sm:42,md:48},height:{xs:36,sm:42,md:48},bgcolor:N(e.color),color:e.color,boxShadow:"inset 0 0 0 1px ".concat(_(e.color)),flexShrink:0},children:(0,P.jsx)(o,{size:20})})]})]})},e.label)}))}),(0,P.jsx)(a.Z,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1,md:1.5},borderTopLeftRadius:T/8,borderTopRightRadius:T/8,borderBottomLeftRadius:0,borderBottomRightRadius:0,border:"1px solid",borderColor:D,borderBottom:0,background:"#fff"},children:(0,P.jsxs)(l.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{flexWrap:"wrap-reverse"},children:[(0,P.jsx)(l.Z,{direction:"row",spacing:.75,sx:{flex:1,overflowX:"auto",py:.5,px:.25,"&::-webkit-scrollbar":{height:6},"&::-webkit-scrollbar-thumb":{backgroundColor:D,borderRadius:4}},children:O.map((function(e){var o,n=e.icon,r=ee===e.idx,t=null!==(o=null===ge||void 0===ge?void 0:ge[e.countKey])&&void 0!==o?o:0;return(0,P.jsxs)(u.Z,{onClick:function(){return Pe(e.idx)},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(r?e.color:_(e.color)),bgcolor:r?e.color:M(e.color),color:r?"#fff":e.color,fontWeight:700,boxShadow:r?"0 6px 18px ".concat(V(e.color)):"none",transition:"all 0.18s","&:hover":{borderColor:e.color,boxShadow:r?"0 6px 18px ".concat(V(e.color)):"0 0 0 3px ".concat(V(e.color))}},children:[(0,P.jsx)(d.Z,{sx:{width:{xs:22,md:26},height:{xs:22,md:26},bgcolor:r?"rgba(255,255,255,0.22)":N(e.color),color:r?"#fff":e.color},children:(0,P.jsx)(n,{size:13})}),(0,P.jsx)(x.Z,{variant:"caption",sx:{fontWeight:800,fontSize:{xs:11.5,md:13},lineHeight:1},children:e.label}),(0,P.jsx)(u.Z,{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:r?"rgba(255,255,255,0.22)":"#fff",color:r?"#fff":e.color,border:r?"none":"1px solid ".concat(_(e.color))},children:t})]},e.label)}))}),(0,P.jsx)(u.Z,{sx:{width:{xs:"100%",sm:260,lg:300},flex:{xs:"1 1 100%",sm:"0 0 auto"}},children:(0,P.jsxs)(u.Z,{sx:{display:"flex",alignItems:"center",gap:.75,px:1.25,py:.5,borderRadius:999,bgcolor:M(F),border:"1.5px solid ".concat(_(F)),transition:"all 0.18s","&:focus-within":{borderColor:F,boxShadow:"0 0 0 3px ".concat(V(F))}},children:[(0,P.jsx)(z.vU7,{size:16,style:{color:F,flexShrink:0}}),(0,P.jsx)(p.ZP,{inputRef:Re,placeholder:"Search invoice no (ctrl+k)",value:Ze,onChange:function(e){return je(e.target.value)},autoComplete:"off",sx:{flex:1,fontSize:13,fontWeight:600,color:K,"& input::placeholder":{color:H,opacity:1}}}),Ze&&(0,P.jsx)(g.Z,{size:"small",onClick:function(){return je("")},sx:{p:.25,color:F},children:(0,P.jsx)(z.lUB,{size:14})})]})})]})}),(0,P.jsxs)(a.Z,{elevation:0,sx:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:T/8,borderBottomRightRadius:T/8,border:"1px solid",borderColor:D,overflow:"hidden",background:"#fff"},children:[(0,P.jsx)(b.Z,{sx:{maxHeight:460,overflow:"auto","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:_(F),borderRadius:8,"&:hover":{backgroundColor:F}},"&::-webkit-scrollbar-track":{backgroundColor:Y}},children:(0,P.jsxs)(m.Z,{stickyHeader:!0,sx:{minWidth:880},children:[(0,P.jsx)(v.Z,{children:(0,P.jsxs)(Z.Z,{sx:{"& th":{backgroundColor:Y,color:L,fontSize:{xs:10,md:11},fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(D),py:{xs:1,md:1.25},px:{xs:1,md:1.5}}},children:[(0,P.jsx)(j.Z,{children:"#"}),(0,P.jsx)(j.Z,{children:"Client"}),(0,P.jsx)(j.Z,{children:"Invoice Id"}),(0,P.jsx)(j.Z,{children:"Invoice Date"}),(0,P.jsx)(j.Z,{children:"Due Date"}),(0,P.jsx)(j.Z,{align:"center",children:"Count"}),(0,P.jsx)(j.Z,{align:"right",children:"Amount"}),(0,P.jsx)(j.Z,{align:"center",children:"Action"})]})}),(0,P.jsxs)(w.Z,{children:[ue&&0===Ie.length&&[0,1,2,3,4].map((function(e,o){return(0,P.jsx)(Z.Z,{children:Array.from({length:8}).map((function(e,o){return(0,P.jsx)(j.Z,{sx:{borderBottom:"1px solid ".concat(E)},children:(0,P.jsx)(f.Z,{animation:"wave"})},o)}))},"sk-".concat(o))})),!ue&&0===Ie.length&&(0,P.jsx)(Z.Z,{children:(0,P.jsx)(j.Z,{colSpan:8,sx:{py:6,borderBottom:"none"},children:(0,P.jsxs)(l.Z,{alignItems:"center",spacing:1.5,children:[(0,P.jsx)(d.Z,{sx:{width:64,height:64,bgcolor:N("#94a3b8"),color:H},children:(0,P.jsx)(z.VHP,{size:28})}),(0,P.jsxs)(x.Z,{variant:"subtitle1",sx:{fontWeight:700,color:K},children:["No ",O[ee].label.toLowerCase()," invoices"]}),(0,P.jsx)(x.Z,{variant:"caption",sx:{color:L},children:Ze?"Try a different invoice number.":"Switch tabs above to load invoices."})]})})}),Ie.slice(C*G,C*G+G).map((function(o,n){var r,t=O[ee];return(0,P.jsxs)(Z.Z,{sx:{cursor:"pointer",transition:"background-color 0.15s","& td":{borderBottom:"1px solid ".concat(E),py:{xs:1,md:1.25},px:{xs:1,md:1.5}},"&:hover":{backgroundColor:Y}},onClick:function(){he(!0),setTimeout((function(){he(!1),e("/nearle/invoice/preview",{state:o})}),300)},children:[(0,P.jsx)(j.Z,{children:(0,P.jsx)(x.Z,{sx:{fontWeight:700,color:L},children:C*G+n+1})}),(0,P.jsxs)(j.Z,{children:[(0,P.jsx)(x.Z,{variant:"subtitle2",sx:{fontWeight:700,color:K},noWrap:!0,children:o.tenantname}),(0,P.jsx)(x.Z,{variant:"caption",sx:{color:L},noWrap:!0,children:o.contactperson})]}),(0,P.jsx)(j.Z,{children:(0,P.jsxs)(u.Z,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:.875,py:.25,borderRadius:999,bgcolor:M(F),border:"1px solid ".concat(_(F)),color:F,fontSize:11,fontWeight:800,whiteSpace:"nowrap"},children:[(0,P.jsx)(z.VHP,{size:11})," ",o.invoiceno]})}),(0,P.jsx)(j.Z,{children:(0,P.jsxs)(l.Z,{direction:"row",alignItems:"center",spacing:.5,children:[(0,P.jsx)(z.sHf,{size:12,style:{color:H,flexShrink:0}}),(0,P.jsxs)(l.Z,{children:[(0,P.jsx)(x.Z,{variant:"caption",sx:{fontWeight:700,color:K},noWrap:!0,children:o.transactiondate?R()(o.transactiondate).format("DD MMM YYYY"):"\u2014"}),(0,P.jsx)(x.Z,{variant:"caption",sx:{color:H,fontSize:10},noWrap:!0,children:o.transactiondate?R()(o.transactiondate).format("hh:mm A"):""})]})]})}),(0,P.jsx)(j.Z,{children:(0,P.jsxs)(l.Z,{direction:"row",alignItems:"center",spacing:.5,children:[(0,P.jsx)(z.dKE,{size:12,style:{color:H,flexShrink:0}}),(0,P.jsxs)(l.Z,{children:[(0,P.jsx)(x.Z,{variant:"caption",sx:{fontWeight:700,color:K},noWrap:!0,children:o.duedate?R()(o.duedate).format("DD MMM YYYY"):"\u2014"}),(0,P.jsx)(x.Z,{variant:"caption",sx:{color:H,fontSize:10},noWrap:!0,children:o.duedate?R()(o.duedate).format("hh:mm A"):""})]})]})}),(0,P.jsx)(j.Z,{align:"center",children:(0,P.jsxs)(u.Z,{sx:{display:"inline-flex",alignItems:"center",gap:.5,px:.875,py:.25,borderRadius:999,bgcolor:M("#0ea5e9"),border:"1px solid ".concat(_("#0ea5e9")),color:"#0ea5e9",fontSize:12,fontWeight:800},children:[(0,P.jsx)(z.ByW,{size:11})," ",null!==(r=o.itemcount)&&void 0!==r?r:0]})}),(0,P.jsx)(j.Z,{align:"right",children:(0,P.jsx)(x.Z,{sx:{fontWeight:800,color:t.color,fontSize:13,whiteSpace:"nowrap"},children:U(o.totalamount)})}),(0,P.jsx)(j.Z,{align:"center",children:(0,P.jsx)(S.Z,{title:"Preview Invoice",children:(0,P.jsx)(g.Z,{size:"small",onClick:function(n){n.stopPropagation(),he(!0),setTimeout((function(){he(!1),e("/nearle/invoice/preview",{state:o})}),300)},sx:{bgcolor:M(F),border:"1px solid ".concat(_(F)),color:F,borderRadius:999,p:.75,"&:hover":{bgcolor:N(F),borderColor:F}},children:(0,P.jsx)(z.t2l,{size:14})})})})]},"".concat(o.invoiceno,"-").concat(n))}))]})]})}),(0,P.jsx)(y.Z,{rowsPerPageOptions:[5,10,25,100],component:"div",count:Ie.length,rowsPerPage:G,page:C,onPageChange:function(e,o){return A(o)},onRowsPerPageChange:function(e){J(+e.target.value),A(0)},sx:{borderTop:"1px solid ".concat(E),"& .MuiTablePagination-toolbar":{color:L,fontWeight:600}}})]})]})}}}]);