diff options
Diffstat (limited to 'packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx | 39 |
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(); |