diff options
author | Sebastian <sebasjm@gmail.com> | 2023-05-26 17:32:33 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-05-26 17:32:33 -0300 |
commit | f5f3d3e23cac9c425c20019cb89baa212154f2ed (patch) | |
tree | 621a8dec89dd227c66121a871330259a5973b1cf /packages/exchange-backoffice-ui/src/pages | |
parent | 8d85426f0e0ceec5297f43f5688d0d9bc4aa4a71 (diff) | |
download | wallet-core-f5f3d3e23cac9c425c20019cb89baa212154f2ed.tar.xz |
compute some error on submit
Diffstat (limited to 'packages/exchange-backoffice-ui/src/pages')
-rw-r--r-- | packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx | 29 | ||||
-rw-r--r-- | packages/exchange-backoffice-ui/src/pages/UnlockAccount.tsx | 2 |
2 files changed, 22 insertions, 9 deletions
diff --git a/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx b/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx index 41a1d20ff..5dcb8b21d 100644 --- a/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx +++ b/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx @@ -1,5 +1,8 @@ import { TranslatedString } from "@gnu-taler/taler-util"; -import { useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + notifyError, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { VNode, h } from "preact"; import { createNewForm } from "../handlers/forms.js"; @@ -41,16 +44,26 @@ export function CreateAccount({ : undefined, }, repeat: { - // error: !v.repeat - // ? i18n.str`required` - // // : v.repeat !== v.password - // // ? i18n.str`doesn't match` - // : undefined, + error: !v.repeat + ? i18n.str`required` + : v.repeat !== v.password + ? i18n.str`doesn't match` + : undefined, }, }; }} - onSubmit={async (v) => { - onNewAccount(v.password); + onSubmit={async (v, s) => { + console.log(v, s); + const error = s?.password?.error ?? s?.repeat?.error; + console.log(error); + if (error) { + notifyError( + "Can't create account" as TranslatedString, + error as TranslatedString, + ); + } else { + onNewAccount(v.password!); + } }} > <div class="mb-4"> diff --git a/packages/exchange-backoffice-ui/src/pages/UnlockAccount.tsx b/packages/exchange-backoffice-ui/src/pages/UnlockAccount.tsx index 74cb0d056..2ebac0718 100644 --- a/packages/exchange-backoffice-ui/src/pages/UnlockAccount.tsx +++ b/packages/exchange-backoffice-ui/src/pages/UnlockAccount.tsx @@ -32,7 +32,7 @@ export function UnlockAccount({ <Form.Provider onSubmit={async (v) => { try { - await onAccountUnlocked(v.password); + await onAccountUnlocked(v.password!); notifyInfo("Account unlocked" as TranslatedString); } catch (e) { |