From 8c8aad4c21fde2cd37e25ccd4c723a308b79439b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 20 Dec 2022 10:16:39 -0300 Subject: fix #7524: do not break if the account is in an invalid state --- packages/demobank-ui/src/pages/AccountPage.tsx | 57 ++++++++++++++++---------- 1 file changed, 36 insertions(+), 21 deletions(-) (limited to 'packages/demobank-ui/src/pages/AccountPage.tsx') diff --git a/packages/demobank-ui/src/pages/AccountPage.tsx b/packages/demobank-ui/src/pages/AccountPage.tsx index 5dd820b53..8d29bd933 100644 --- a/packages/demobank-ui/src/pages/AccountPage.tsx +++ b/packages/demobank-ui/src/pages/AccountPage.tsx @@ -174,7 +174,8 @@ function Account({ accountLabel }: { accountLabel: string }): VNode { } } } - const balance = !data ? undefined : Amounts.parseOrThrow(data.balance.amount); + const balance = !data ? undefined : Amounts.parse(data.balance.amount); + const errorParsingBalance = data && !balance; const accountNumber = !data ? undefined : getIbanFromPayto(data.paytoUri); const balanceIsDebit = data && data.balance.credit_debit_indicator == "debit"; @@ -216,28 +217,42 @@ function Account({ accountLabel }: { accountLabel: string }): VNode { -
-
-

{i18n.str`Bank account balance`}

- {!balance ? ( -
- Waiting server response... + + {errorParsingBalance ? ( +
+
+

+ Server Error: invalid balance +

+
+

Your account is in an invalid state.

+
+ ) : ( + +
+
+

{i18n.str`Bank account balance`}

+ {!balance ? ( +
+ Waiting server response... +
+ ) : ( +
+ {balanceIsDebit ? - : null} + {`${balanceValue}`}  + {`${balance.currency}`} +
+ )}
- ) : ( -
- {balanceIsDebit ? - : null} - {`${balanceValue}`}  - {`${balance.currency}`} +
+
+
+

{i18n.str`Payments`}

+
- )} -
-
-
-
-

{i18n.str`Payments`}

- -
-
+ + + )}

{i18n.str`Latest transactions:`}

-- cgit v1.2.3