@accounter/client
Version:
Accounter client application
1 lines • 1.77 kB
JavaScript
import{s as e}from"./dist-C51EwTaa.js";import{i as t,o as n}from"./utils-DdVdMk8X.js";import{Lo as r,en as i,o as a}from"./error-handling-Dpfd9svJ.js";import{ft as o}from"./select-CrsvQyhZ.js";import{K as s}from"./table--bF0wbxq.js";import{t as c}from"./Progress-CjIxJViS.js";import{cn as l}from"./index-CL8-JoMZ.js";import{t as u}from"./use-url-query-BCNbSvLg.js";import{t as d}from"./page-layout-DoLDsSrs.js";import{t as f}from"./charges-filters-CENHQ5jv.js";var p=e(n(),1),m=t(),h=()=>{let{setFiltersContext:e}=(0,p.useContext)(l),{get:t}=u(),{userContext:n}=(0,p.useContext)(s),[h,g]=(0,p.useState)(t(`chargesFilters`)?JSON.parse(decodeURIComponent(t(`chargesFilters`))):{byOwners:n?.context.adminBusinessId?[n?.context.adminBusinessId]:[],sortBy:{field:i.Date,asc:!1},toAnyDate:null,fromAnyDate:null}),[{data:_,fetching:v}]=r({query:a,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)(()=>{e((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,e,g]),(0,m.jsx)(d,{title:`Accountant Approvals Status`,children:v?(0,m.jsx)(o,{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)(c,{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};