Files
dailygrubs_console_build/build/static/js/2476.bc5b9fbb.chunk.js

1 line
14 KiB
JavaScript

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