diff options
Diffstat (limited to 'packages/demobank-ui/src/pages/RegistrationPage.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/RegistrationPage.tsx | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/packages/demobank-ui/src/pages/RegistrationPage.tsx b/packages/demobank-ui/src/pages/RegistrationPage.tsx index 2de6de373..e1d32002b 100644 --- a/packages/demobank-ui/src/pages/RegistrationPage.tsx +++ b/packages/demobank-ui/src/pages/RegistrationPage.tsx @@ -96,7 +96,7 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on : undefined, }); - async function doRegistrationAndLogin(name: string, username: string, password: string) { + async function doRegistrationAndLogin(name: string, username: string, password: string, onComplete: () => void) { await handleError(async () => { const creationResponse = await api.createAccount("" as AccessToken, { name, username, password }); if (creationResponse.type === "fail") { @@ -137,6 +137,12 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on description: creationResponse.detail.hint as TranslatedString, debug: creationResponse.detail, }) + case "user-cant-set-debt": return notify({ + type: "error", + title: i18n.str`Only admin is allow to set debt limit.`, + description: creationResponse.detail.hint as TranslatedString, + debug: creationResponse.detail, + }) default: assertUnreachable(creationResponse) } } @@ -165,16 +171,18 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on default: assertUnreachable(resp) } } + onComplete() }) } async function doRegistrationStep() { if (!username || !password || !name) return; - await doRegistrationAndLogin(name, username, password) - setUsername(undefined); - setPassword(undefined); - setRepeatPassword(undefined); - onComplete(); + await doRegistrationAndLogin(name, username, password, () => { + setUsername(undefined); + setPassword(undefined); + setRepeatPassword(undefined); + onComplete(); + }) } async function doRandomRegistration(tries: number = 3) { @@ -183,8 +191,8 @@ function RegistrationForm({ onComplete, onCancel }: { onComplete: () => void, on const pass = settings.simplePasswordForRandomAccounts ? "123" : getRandomPassword(); const username = `_${user.first}-${user.second}_` const name = `${user.first}, ${user.second}` - await doRegistrationAndLogin(name, username, pass) - onComplete(); + await doRegistrationAndLogin(name, username, pass, onComplete) + } return ( |