diff options
author | Sebastian <sebasjm@gmail.com> | 2023-10-25 18:26:36 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-10-25 18:26:36 -0300 |
commit | e812eae32daddad372c7629867298ca28678a44c (patch) | |
tree | 98b8de62d15e28c4b4cc94b6c42ec2ab1f20c631 /packages/demobank-ui/src/pages/WalletWithdrawForm.tsx | |
parent | c31ce9bab8592c31b7c7d879f6daad7886b7486d (diff) | |
download | wallet-core-e812eae32daddad372c7629867298ca28678a44c.tar.gz wallet-core-e812eae32daddad372c7629867298ca28678a44c.tar.bz2 wallet-core-e812eae32daddad372c7629867298ca28678a44c.zip |
update more error cases handling from bank-core-api
Diffstat (limited to 'packages/demobank-ui/src/pages/WalletWithdrawForm.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/WalletWithdrawForm.tsx | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx b/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx index f1ff49068..0637a8af4 100644 --- a/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx +++ b/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx @@ -89,26 +89,40 @@ function OldWithdrawalForm({ goToConfirmOperation, limit, onCancel, focus }: { async function doStart() { if (!parsedAmount || !creds) return; await withRuntimeErrorHandling(i18n, async () => { - const result = await api.createWithdrawal(creds, { + const resp = await api.createWithdrawal(creds, { amount: Amounts.stringify(parsedAmount), }); - if (result.type === "ok") { - const uri = parseWithdrawUri(result.body.taler_withdraw_uri); + if (resp.type === "ok") { + const uri = parseWithdrawUri(resp.body.taler_withdraw_uri); if (!uri) { return notifyError( i18n.str`Server responded with an invalid withdraw URI`, - i18n.str`Withdraw URI: ${result.body.taler_withdraw_uri}`); + i18n.str`Withdraw URI: ${resp.body.taler_withdraw_uri}`); } else { updateSettings("currentWithdrawalOperationId", uri.withdrawalOperationId) goToConfirmOperation(uri.withdrawalOperationId); } } else { - switch (result.case) { + switch (resp.case) { case "insufficient-funds": { - notify({ type: "error", title: i18n.str`The operation was rejected due to insufficient funds` }) + notify({ + type: "error", + title: i18n.str`The operation was rejected due to insufficient funds`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }) break; } - default: assertUnreachable(result.case) + case "unauthorized": { + notify({ + type: "error", + title: i18n.str`The operation was rejected due to insufficient funds`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }) + break; + } + default: assertUnreachable(resp) } } }) |