forked from mirrors/homebox
22 lines
396 B
TypeScript
22 lines
396 B
TypeScript
|
const cache = {
|
||
|
currency: "",
|
||
|
};
|
||
|
|
||
|
export function ResetCurrency() {
|
||
|
cache.currency = "";
|
||
|
}
|
||
|
|
||
|
export async function useFormatCurrency() {
|
||
|
if (!cache.currency) {
|
||
|
const client = useUserApi();
|
||
|
|
||
|
const { data: group } = await client.group.get();
|
||
|
|
||
|
if (group) {
|
||
|
cache.currency = group.currency;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return (value: number | string) => fmtCurrency(value, cache.currency);
|
||
|
}
|