diff options
author | Sebastian <sebasjm@gmail.com> | 2022-12-20 10:16:39 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-12-20 10:17:02 -0300 |
commit | 8c8aad4c21fde2cd37e25ccd4c723a308b79439b (patch) | |
tree | bb331bb101e31afca0144b1df82e75dc12a741f6 /packages/demobank-ui/src/pages/AccountPage.tsx | |
parent | 5ae63982c3d0e31ddc7c4df389fe2ec2e0062906 (diff) | |
download | wallet-core-8c8aad4c21fde2cd37e25ccd4c723a308b79439b.tar.xz |
fix #7524: do not break if the account is in an invalid state
Diffstat (limited to 'packages/demobank-ui/src/pages/AccountPage.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/AccountPage.tsx | 57 |
1 files changed, 36 insertions, 21 deletions
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.Translate> </h1> </div> - <section id="assets"> - <div class="asset-summary"> - <h2>{i18n.str`Bank account balance`}</h2> - {!balance ? ( - <div class="large-amount" style={{ color: "gray" }}> - Waiting server response... + + {errorParsingBalance ? ( + <div class="informational informational-fail" style={{ marginTop: 8 }}> + <div style={{ display: "flex", justifyContent: "space-between" }}> + <p> + <b>Server Error: invalid balance</b> + </p> + </div> + <p>Your account is in an invalid state.</p> + </div> + ) : ( + <Fragment> + <section id="assets"> + <div class="asset-summary"> + <h2>{i18n.str`Bank account balance`}</h2> + {!balance ? ( + <div class="large-amount" style={{ color: "gray" }}> + Waiting server response... + </div> + ) : ( + <div class="large-amount amount"> + {balanceIsDebit ? <b>-</b> : null} + <span class="value">{`${balanceValue}`}</span> + <span class="currency">{`${balance.currency}`}</span> + </div> + )} </div> - ) : ( - <div class="large-amount amount"> - {balanceIsDebit ? <b>-</b> : null} - <span class="value">{`${balanceValue}`}</span> - <span class="currency">{`${balance.currency}`}</span> + </section> + <section id="payments"> + <div class="payments"> + <h2>{i18n.str`Payments`}</h2> + <PaymentOptions currency={balance?.currency} /> </div> - )} - </div> - </section> - <section id="payments"> - <div class="payments"> - <h2>{i18n.str`Payments`}</h2> - <PaymentOptions currency={balance?.currency} /> - </div> - </section> + </section> + </Fragment> + )} <section id="main"> <article> <h2>{i18n.str`Latest transactions:`}</h2> |