From 69b66e715eae039330898f470a8993d1d154b583 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 26 May 2023 16:52:30 -0300 Subject: account as hook --- .../src/pages/CreateAccount.tsx | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx (limited to 'packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx') diff --git a/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx b/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx new file mode 100644 index 000000000..41a1d20ff --- /dev/null +++ b/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx @@ -0,0 +1,89 @@ +import { TranslatedString } from "@gnu-taler/taler-util"; +import { useTranslationContext } from "@gnu-taler/web-util/browser"; +import { VNode, h } from "preact"; +import { createNewForm } from "../handlers/forms.js"; + +export function CreateAccount({ + onNewAccount, +}: { + onNewAccount: (password: string) => void; +}): VNode { + const { i18n } = useTranslationContext(); + const Form = createNewForm<{ + password: string; + repeat: string; + }>(); + + return ( +
+
+

+ Create account +

+
+ +
+
+ { + return { + password: { + error: !v.password + ? i18n.str`required` + : v.password.length < 8 + ? i18n.str`should have at least 8 characters` + : !v.password.match(/[a-z]/) && v.password.match(/[A-Z]/) + ? i18n.str`should have lowercase and uppercase characters` + : !v.password.match(/\d/) + ? i18n.str`should have numbers` + : !v.password.match(/[^a-zA-Z\d]/) + ? i18n.str`should have at least one character which is not a number or letter` + : undefined, + }, + repeat: { + // error: !v.repeat + // ? i18n.str`required` + // // : v.repeat !== v.password + // // ? i18n.str`doesn't match` + // : undefined, + }, + }; + }} + onSubmit={async (v) => { + onNewAccount(v.password); + }} + > +
+ +
+
+ +
+ +
+ +
+
+
+
+
+ ); +} -- cgit v1.2.3