From 9ba6a59d18c9ab7d7690e556d7f9aedf0c370e52 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 24 Nov 2023 11:36:56 -0300 Subject: using monitor api --- packages/demobank-ui/src/pages/RegistrationPage.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'packages/demobank-ui/src/pages/RegistrationPage.tsx') diff --git a/packages/demobank-ui/src/pages/RegistrationPage.tsx b/packages/demobank-ui/src/pages/RegistrationPage.tsx index 9c3b21097..2de6de373 100644 --- a/packages/demobank-ui/src/pages/RegistrationPage.tsx +++ b/packages/demobank-ui/src/pages/RegistrationPage.tsx @@ -38,7 +38,7 @@ export function RegistrationPage({ onCancel: () => void; }): VNode { const { i18n } = useTranslationContext(); - const {config} = useBankCoreApiContext(); + const { config } = useBankCoreApiContext(); if (!config.allow_registrations) { return (

{i18n.str`Currently, the bank is not accepting new registrations!`}

@@ -70,9 +70,9 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on const { i18n } = useTranslationContext(); const errors = undefinedIfEmpty({ - // name: !name - // ? i18n.str`Missing name` - // : undefined, + name: !name + ? i18n.str`Missing name` + : undefined, username: !username ? i18n.str`Missing username` : !USERNAME_REGEX.test(username) @@ -96,9 +96,9 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on : undefined, }); - async function doRegistrationAndLogin(name: string | undefined, username: string, password: string) { + async function doRegistrationAndLogin(name: string, username: string, password: string) { await handleError(async () => { - const creationResponse = await api.createAccount("" as AccessToken, { name: name ?? "", username, password }); + const creationResponse = await api.createAccount("" as AccessToken, { name, username, password }); if (creationResponse.type === "fail") { switch (creationResponse.case) { case "invalid-phone-or-email": return notify({ @@ -169,7 +169,7 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on } async function doRegistrationStep() { - if (!username || !password) return; + if (!username || !password || !name) return; await doRegistrationAndLogin(name, username, password) setUsername(undefined); setPassword(undefined); @@ -179,9 +179,10 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on async function doRandomRegistration(tries: number = 3) { const user = getRandomUsername(); - + const pass = settings.simplePasswordForRandomAccounts ? "123" : getRandomPassword(); const username = `_${user.first}-${user.second}_` + const name = `${user.first}, ${user.second}` await doRegistrationAndLogin(name, username, pass) onComplete(); } -- cgit v1.2.3