summaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-10-25 18:26:36 -0300
committerSebastian <sebasjm@gmail.com>2023-10-25 18:26:36 -0300
commite812eae32daddad372c7629867298ca28678a44c (patch)
tree98b8de62d15e28c4b4cc94b6c42ec2ab1f20c631 /packages/demobank-ui/src/pages/WalletWithdrawForm.tsx
parentc31ce9bab8592c31b7c7d879f6daad7886b7486d (diff)
downloadwallet-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.tsx28
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)
}
}
})