aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/UpdateAccountPassword.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-10-19 15:10:18 -0300
committerSebastian <sebasjm@gmail.com>2023-10-19 15:10:18 -0300
commit7582855e2723e11de25f10b6d5ba8a0757616765 (patch)
tree320f30c7202c88ba63542b93de1cbda533a73356 /packages/demobank-ui/src/pages/UpdateAccountPassword.tsx
parent9e925a2f56677600973c4659f82776a6a56339bb (diff)
downloadwallet-core-7582855e2723e11de25f10b6d5ba8a0757616765.tar.xz
some ui fixes
Diffstat (limited to 'packages/demobank-ui/src/pages/UpdateAccountPassword.tsx')
-rw-r--r--packages/demobank-ui/src/pages/UpdateAccountPassword.tsx36
1 files changed, 11 insertions, 25 deletions
diff --git a/packages/demobank-ui/src/pages/UpdateAccountPassword.tsx b/packages/demobank-ui/src/pages/UpdateAccountPassword.tsx
index ac6e9fa9b..d82dac4b1 100644
--- a/packages/demobank-ui/src/pages/UpdateAccountPassword.tsx
+++ b/packages/demobank-ui/src/pages/UpdateAccountPassword.tsx
@@ -3,7 +3,7 @@ import { HttpResponsePaginated, RequestError, notify, notifyError, useTranslatio
import { Fragment, VNode, h } from "preact";
import { useState } from "preact/hooks";
import { ShowInputErrorLabel } from "../components/ShowInputErrorLabel.js";
-import { buildRequestErrorMessage, undefinedIfEmpty } from "../utils.js";
+import { buildRequestErrorMessage, undefinedIfEmpty, withRuntimeErrorHandling } from "../utils.js";
import { doAutoFocus } from "./PaytoWireTransferForm.js";
import { useBankCoreApiContext } from "../context/config.js";
import { assertUnreachable } from "./HomePage.js";
@@ -39,7 +39,7 @@ export function UpdateAccountPassword({
async function doChangePassword() {
if (!!errors || !password || !creds) return;
- try {
+ await withRuntimeErrorHandling(i18n, async () => {
const resp = await api.updatePassword(creds, {
new_password: password,
});
@@ -47,32 +47,18 @@ export function UpdateAccountPassword({
onUpdateSuccess();
} else {
switch (resp.case) {
- case "unauthorized": {
- notify({
- type: "error",
- title: i18n.str`Not authorized to change the password, maybe the session is invalid.`
- })
- break;
- }
- case "not-found": {
- notify({
- type: "error",
- title: i18n.str`Account not found`
- })
- break;
- }
+ case "unauthorized": return notify({
+ type: "error",
+ title: i18n.str`Not authorized to change the password, maybe the session is invalid.`
+ })
+ case "not-found": return notify({
+ type: "error",
+ title: i18n.str`Account not found`
+ })
default: assertUnreachable(resp)
}
}
- } catch (error) {
- if (error instanceof TalerError) {
- notify(buildRequestErrorMessage(i18n, error))
- } else {
- notifyError(i18n.str`Operation failed, please report`, (error instanceof Error
- ? error.message
- : JSON.stringify(error)) as TranslatedString)
- }
- }
+ })
}
return (