@accounter/client
Version:
Accounter client application
1 lines • 1.77 kB
JavaScript
import{s as e}from"./dist-ypP48_Ax.js";import{i as t,o as n}from"./utils-CbS-oR5I.js";import{t as r}from"./loader-circle-CfW9jOIr.js";import{c as i}from"./separator-BvKylNhK.js";import{$c as a}from"./table-AJA7Uyxy.js";import{Qo as o,an as s,r as c}from"./graphql-DC5GYCFE.js";import{t as l}from"./Progress-BtYnBwCI.js";import{t as u}from"./use-url-query-Bb8ddrDs.js";import{t as d}from"./page-layout-DfY10rJx.js";import{t as f}from"./charges-filters-jQtrB7Ny.js";var p=e(n(),1),m=t(),h=()=>{let{setFiltersContext:e}=(0,p.useContext)(i),{get:t}=u(),{userContext:n}=(0,p.useContext)(a),[h,g]=(0,p.useState)(t(`chargesFilters`)?JSON.parse(decodeURIComponent(t(`chargesFilters`))):{byOwners:n?.context.adminBusinessId?[n?.context.adminBusinessId]:[],sortBy:{field:s.Date,asc:!1},toAnyDate:null,fromAnyDate:null}),[{data:_,fetching:v}]=o({query:c,variables:{filters:h,page:0,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}});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)(r,{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)(l,{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};