diff options
Diffstat (limited to 'packages/demobank-ui/src/hooks/access.ts')
-rw-r--r-- | packages/demobank-ui/src/hooks/access.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/demobank-ui/src/hooks/access.ts b/packages/demobank-ui/src/hooks/access.ts index 750b95fa0..ee8566efe 100644 --- a/packages/demobank-ui/src/hooks/access.ts +++ b/packages/demobank-ui/src/hooks/access.ts @@ -183,18 +183,26 @@ export function useAccountDetails( //FIXME: remove optional when libeufin sandbox has implemented the feature if (data && typeof data.data.debitThreshold === "undefined") { - data.data.debitThreshold = "100"; + data.data.debitThreshold = "0"; } //FIXME: sandbox server should return amount string if (data) { - const d = structuredClone(data); + const isAmount = Amounts.parse(data.data.debitThreshold); + if (isAmount) { + //server response with correct format + return data; + } const { currency } = Amounts.parseOrThrow(data.data.balance.amount); - d.data.debitThreshold = Amounts.stringify({ + const clone = structuredClone(data); + + const theNumber = Number.parseInt(data.data.debitThreshold, 10); + const value = Number.isNaN(theNumber) ? 0 : theNumber; + clone.data.debitThreshold = Amounts.stringify({ currency, - value: Number.parseInt(d.data.debitThreshold, 10), + value: value, fraction: 0, }); - return d; + return clone; } if (error) return error.info; return { loading: true }; |