summaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-01-10 14:25:39 -0300
committerSebastian <sebasjm@gmail.com>2024-01-10 14:25:39 -0300
commit2c7db170a45fcb82deae3892d610b6b2805ee46c (patch)
tree09a4218a05e18784e3dfb2dfe211836185769924 /packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx
parentb609f48ae664618b6f4e75e42221f1240c8f61f0 (diff)
downloadwallet-core-2c7db170a45fcb82deae3892d610b6b2805ee46c.tar.gz
wallet-core-2c7db170a45fcb82deae3892d610b6b2805ee46c.tar.bz2
wallet-core-2c7db170a45fcb82deae3892d610b6b2805ee46c.zip
bank: handles 2fa response
Diffstat (limited to 'packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx')
-rw-r--r--packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx39
1 files changed, 23 insertions, 16 deletions
diff --git a/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx b/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx
index 7a94f5486..2ef93d35c 100644
--- a/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx
+++ b/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx
@@ -146,50 +146,57 @@ export function PaytoWireTransferForm({
const puri = payto_uri;
await handleError(async () => {
- const res = await api.createTransaction(credentials, {
+ const resp = await api.createTransaction(credentials, {
payto_uri: puri,
amount: sendingAmount,
});
mutate(() => true)
- if (res.type === "fail") {
- switch (res.case) {
+ if (resp.type === "fail") {
+ switch (resp.case) {
case HttpStatusCode.BadRequest: return notify({
type: "error",
title: i18n.str`The request was invalid or the payto://-URI used unacceptable features.`,
- description: res.detail.hint as TranslatedString,
- debug: res.detail,
+ description: resp.detail.hint as TranslatedString,
+ debug: resp.detail,
})
case HttpStatusCode.Unauthorized: return notify({
type: "error",
title: i18n.str`Not enough permission to complete the operation.`,
- description: res.detail.hint as TranslatedString,
- debug: res.detail,
+ description: resp.detail.hint as TranslatedString,
+ debug: resp.detail,
})
case TalerErrorCode.BANK_UNKNOWN_CREDITOR: return notify({
type: "error",
title: i18n.str`The destination account "${puri}" was not found.`,
- description: res.detail.hint as TranslatedString,
- debug: res.detail,
+ description: resp.detail.hint as TranslatedString,
+ debug: resp.detail,
})
case TalerErrorCode.BANK_SAME_ACCOUNT: return notify({
type: "error",
title: i18n.str`The origin and the destination of the transfer can't be the same.`,
- description: res.detail.hint as TranslatedString,
- debug: res.detail,
+ description: resp.detail.hint as TranslatedString,
+ debug: resp.detail,
})
case TalerErrorCode.BANK_UNALLOWED_DEBIT: return notify({
type: "error",
title: i18n.str`Your balance is not enough.`,
- description: res.detail.hint as TranslatedString,
- debug: res.detail,
+ description: resp.detail.hint as TranslatedString,
+ debug: resp.detail,
})
case HttpStatusCode.NotFound: return notify({
type: "error",
title: i18n.str`The origin account "${puri}" was not found.`,
- description: res.detail.hint as TranslatedString,
- debug: res.detail,
+ description: resp.detail.hint as TranslatedString,
+ debug: resp.detail,
})
- default: assertUnreachable(res)
+ case HttpStatusCode.Accepted: {
+ resp.body.challenge_id;
+ return notify({
+ type: "info",
+ title: i18n.str`The operation needs a confirmation to complete.`,
+ });
+ }
+ default: assertUnreachable(resp)
}
}
onSuccess();