diff options
Diffstat (limited to 'packages/demobank-ui/src/hooks/access.ts')
-rw-r--r-- | packages/demobank-ui/src/hooks/access.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/packages/demobank-ui/src/hooks/access.ts b/packages/demobank-ui/src/hooks/access.ts index 8282210d4..750b95fa0 100644 --- a/packages/demobank-ui/src/hooks/access.ts +++ b/packages/demobank-ui/src/hooks/access.ts @@ -31,6 +31,7 @@ import { // FIX default import https://github.com/microsoft/TypeScript/issues/49189 import _useSWR, { SWRHook } from "swr"; +import { Amounts } from "@gnu-taler/taler-util"; const useSWR = _useSWR as unknown as SWRHook; export function useAccessAPI(): AccessAPI { @@ -180,7 +181,21 @@ export function useAccountDetails( keepPreviousData: true, }); - if (data) return data; + //FIXME: remove optional when libeufin sandbox has implemented the feature + if (data && typeof data.data.debitThreshold === "undefined") { + data.data.debitThreshold = "100"; + } + //FIXME: sandbox server should return amount string + if (data) { + const d = structuredClone(data); + const { currency } = Amounts.parseOrThrow(data.data.balance.amount); + d.data.debitThreshold = Amounts.stringify({ + currency, + value: Number.parseInt(d.data.debitThreshold, 10), + fraction: 0, + }); + return d; + } if (error) return error.info; return { loading: true }; } |