UNPKG

@accounter/client

Version:
1 lines 1.6 kB
import{t as e}from"./Progress-D-3fpAW-.js";import{Al as t,Cu as n,Id as r,No as i,Zu as a,er as o,ia as s,jd as c,tr as l}from"./index-CSYTUOOk.js";import{t as u}from"./use-url-query-CA_xnIYM.js";import{t as d}from"./page-layout-DE94O32j.js";import{t as f}from"./charges-filters-DJEsPkiV.js";var p=r(c(),1),m=n(),h=()=>{let{setFiltersContext:n}=(0,p.useContext)(o),{get:r}=u(),{userContext:c}=(0,p.useContext)(l),[h,g]=(0,p.useState)(r(`chargesFilters`)?JSON.parse(decodeURIComponent(r(`chargesFilters`))):{byOwners:c?.context.adminBusinessId?[c?.context.adminBusinessId]:[],sortBy:{field:i.Date,asc:!1},toAnyDate:null,fromAnyDate:null}),[{data:_,fetching:v}]=t({query:s,variables:{filters:h,page:1,limit:999999}}),y=_?.allCharges?.nodes.length??0,b=0,x=0,S=0;_?.allCharges?.nodes.map(e=>{switch(e.accountantApproval){case`APPROVED`:b+=1;break;case`PENDING`:x+=1;break;case`UNAPPROVED`:S+=1;break}});let C=100*b/y,w=100*x/y,T=100*S/y;return(0,p.useEffect)(()=>{n((0,m.jsx)(`div`,{className:`flex flex-row gap-x-5`,children:(0,m.jsx)(f,{filter:h,setFilter:g,activePage:0,setPage:()=>{},totalPages:1})}))},[_,v,h,n,g]),(0,m.jsx)(d,{title:`Accountant Approvals Status`,children:v?(0,m.jsx)(a,{className:`h-10 w-10 animate-spin mr-2 self-center`}):(0,m.jsxs)(`div`,{className:`mx-10 mt-5 flex flex-col gap-5`,children:[`Total charges: ${y}`,(0,m.jsx)(e,{color:`green`,radius:`xl`,size:`xl`,sections:[{value:C,color:`green`,label:`${C.toFixed(1)}% (${b})`},{value:w,color:`orange`,label:`${w.toFixed(1)}% (${x})`},{value:T,color:`red`,label:`${T.toFixed(1)}% (${S})`}]})]})})};export{h as AccountantApprovals};