UNPKG

@accounter/client

Version:
1 lines 640 B
import{s as e}from"./dist-ypP48_Ax.js";import{o as t}from"./utils-CbS-oR5I.js";import{r as n}from"./error-handling-CKe_iwSC.js";import{O as r,us as i}from"./graphql-BIob9ctl.js";var a=e(t(),1),o=()=>{let[{data:e,fetching:t,error:o},s]=i({query:r});o&&(console.error(`Error fetching financial accounts: ${o}`),n.error(`Error`,{description:`Unable to fetch financial accounts`}));let c=(0,a.useMemo)(()=>e?.allFinancialAccounts?.sort((e,t)=>e.name>t.name?1:-1)??[],[e]);return{fetching:t,refresh:()=>s(),financialAccounts:c,selectableFinancialAccounts:(0,a.useMemo)(()=>c.map(e=>({value:e.id,label:e.name,type:e.type})),[c])}};export{o as t};