aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/account
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-01-09 18:51:49 -0300
committerSebastian <sebasjm@gmail.com>2024-01-09 18:51:49 -0300
commitf5771cc7b99dc938fd606dcbee350b66ec8027c9 (patch)
tree95c1aa5b8a5e6067c7689b0caf161c50d1f694ed /packages/demobank-ui/src/pages/account
parent1826b9121a0308aa0a7ac39a89ad7dc8ea2ae965 (diff)
downloadwallet-core-f5771cc7b99dc938fd606dcbee350b66ec8027c9.tar.xz
prepare for 2fa impl
Diffstat (limited to 'packages/demobank-ui/src/pages/account')
-rw-r--r--packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx21
-rw-r--r--packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx9
2 files changed, 16 insertions, 14 deletions
diff --git a/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx b/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx
index 4b66c0d8d..98fb72283 100644
--- a/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx
+++ b/packages/demobank-ui/src/pages/account/ShowAccountDetails.tsx
@@ -1,4 +1,4 @@
-import { TalerCorebankApi, TalerError, TranslatedString } from "@gnu-taler/taler-util";
+import { HttpStatusCode, TalerCorebankApi, TalerError, TalerErrorCode, TranslatedString } from "@gnu-taler/taler-util";
import { Loading, LocalNotificationBanner, notifyInfo, useLocalNotification, useTranslationContext } from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
import { useState } from "preact/hooks";
@@ -40,8 +40,8 @@ export function ShowAccountDetails({
}
if (result.type === "fail") {
switch (result.case) {
- case "not-found": return <LoginForm currentUser={account} />
- case "unauthorized": return <LoginForm currentUser={account} />
+ case HttpStatusCode.Unauthorized:
+ case HttpStatusCode.NotFound: return <LoginForm currentUser={account} />
default: assertUnreachable(result)
}
}
@@ -52,6 +52,7 @@ export function ShowAccountDetails({
const resp = await api.updateAccount({
token: creds.token,
username: account,
+
}, submitAccount);
if (resp.type === "ok") {
@@ -59,39 +60,39 @@ export function ShowAccountDetails({
onUpdateSuccess();
} else {
switch (resp.case) {
- case "unauthorized": return notify({
+ case HttpStatusCode.Unauthorized: return notify({
type: "error",
title: i18n.str`The rights to change the account are not sufficient`,
description: resp.detail.hint as TranslatedString,
debug: resp.detail,
})
- case "not-found": return notify({
+ case HttpStatusCode.NotFound: return notify({
type: "error",
title: i18n.str`The username was not found`,
description: resp.detail.hint as TranslatedString,
debug: resp.detail,
})
- case "user-cant-change-name": return notify({
+ case TalerErrorCode.BANK_NON_ADMIN_PATCH_LEGAL_NAME: return notify({
type: "error",
title: i18n.str`You can't change the legal name, please contact the your account administrator.`,
description: resp.detail.hint as TranslatedString,
debug: resp.detail,
})
- case "user-cant-change-debt": return notify({
+ case TalerErrorCode.BANK_NON_ADMIN_PATCH_DEBT_LIMIT: return notify({
type: "error",
title: i18n.str`You can't change the debt limit, please contact the your account administrator.`,
description: resp.detail.hint as TranslatedString,
debug: resp.detail,
})
- case "user-cant-change-cashout": return notify({
+ case TalerErrorCode.BANK_NON_ADMIN_PATCH_CASHOUT: return notify({
type: "error",
title: i18n.str`You can't change the cashout address, please contact the your account administrator.`,
description: resp.detail.hint as TranslatedString,
debug: resp.detail,
})
- case "missing-contact-data": return notify({
+ case TalerErrorCode.BANK_NON_ADMIN_PATCH_CONTACT: return notify({
type: "error",
- title: i18n.str`You need contact data to enable 2FA.`,
+ title: i18n.str`You can't change the contact data, please contact the your account administrator.`,
description: resp.detail.hint as TranslatedString,
debug: resp.detail,
})
diff --git a/packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx b/packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx
index ece1f63e7..95c425dc7 100644
--- a/packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx
+++ b/packages/demobank-ui/src/pages/account/UpdateAccountPassword.tsx
@@ -9,6 +9,7 @@ import { doAutoFocus } from "../PaytoWireTransferForm.js";
import { ProfileNavigation } from "../ProfileNavigation.js";
import { assertUnreachable } from "../WithdrawalOperationPage.js";
import { LocalNotificationBanner } from "@gnu-taler/web-util/browser";
+import { HttpStatusCode, TalerErrorCode } from "@gnu-taler/taler-util";
export function UpdateAccountPassword({
account: accountName,
@@ -57,19 +58,19 @@ export function UpdateAccountPassword({
onUpdateSuccess();
} else {
switch (resp.case) {
- case "unauthorized": return notify({
+ case HttpStatusCode.Unauthorized: return notify({
type: "error",
title: i18n.str`Not authorized to change the password, maybe the session is invalid.`
})
- case "not-found": return notify({
+ case HttpStatusCode.NotFound: return notify({
type: "error",
title: i18n.str`Account not found`
})
- case "user-require-old-password": return notify({
+ case TalerErrorCode.BANK_NON_ADMIN_PATCH_MISSING_OLD_PASSWORD: return notify({
type: "error",
title: i18n.str`Old password need to be provided in order to change new one. If you don't have it contact your account administrator.`
})
- case "wrong-old-password": return notify({
+ case TalerErrorCode.BANK_PATCH_BAD_OLD_PASSWORD: return notify({
type: "error",
title: i18n.str`Your current password doesn't match, can't change to a new password.`
})