import{t as e}from"./Progress-H9AtEFHT.js";import{Eu as t,Nl as n,Pd as r,Po as i,aa as a,ed as o,nr as s,tr as c,zd as l}from"./index-Q5R6-AeA.js";import{t as u}from"./use-url-query-Cos8nKH-.js";import{t as d}from"./page-layout-Cl29SycZ.js";import{t as f}from"./charges-filters-CY1Akgqt.js";var p=l(r(),1),m=t(),h=()=>{let{setFiltersContext:t}=(0,p.useContext)(c),{get:r}=u(),{userContext:l}=(0,p.useContext)(s),[h,g]=(0,p.useState)(r(`chargesFilters`)?JSON.parse(decodeURIComponent(r(`chargesFilters`))):{byOwners:l?.context.adminBusinessId?[l?.context.adminBusinessId]:[],sortBy:{field:i.Date,asc:!1},toAnyDate:null,fromAnyDate:null}),[{data:_,fetching:v}]=n({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)(()=>{t((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,t,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)(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};