aboutsummaryrefslogtreecommitdiffstats
path: root/code/app/src/routes
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-11-26 15:07:00 +0100
committerivarlovlie <git@ivarlovlie.no>2022-11-26 15:07:00 +0100
commitb4a8720f6ddb1fb8bf9ee41628982e704852e699 (patch)
tree61148c601d52f71c978a2e7b164653fc2ee54354 /code/app/src/routes
parent854c36d9ab757fe3e5c87ecbb84fd7357e794796 (diff)
downloadgreatoffice-b4a8720f6ddb1fb8bf9ee41628982e704852e699.tar.xz
greatoffice-b4a8720f6ddb1fb8bf9ee41628982e704852e699.zip
refactor: Final touches for move to service
Diffstat (limited to 'code/app/src/routes')
-rw-r--r--code/app/src/routes/(main)/(public)/reset-password/+page.svelte25
1 files changed, 12 insertions, 13 deletions
diff --git a/code/app/src/routes/(main)/(public)/reset-password/+page.svelte b/code/app/src/routes/(main)/(public)/reset-password/+page.svelte
index eb02b45..2b34dfc 100644
--- a/code/app/src/routes/(main)/(public)/reset-password/+page.svelte
+++ b/code/app/src/routes/(main)/(public)/reset-password/+page.svelte
@@ -12,16 +12,16 @@
};
const formError = new FormError();
-
const resetRequests = new PasswordResetService();
let loading = false;
let showSuccessAlert = false;
- $: showErrorAlert = formError.has_error() && !showSuccessAlert;
+ let showErrorAlert = false;
async function submit_form_async() {
formError.set();
showSuccessAlert = false;
+ showErrorAlert = false;
loading = true;
const response = await resetRequests.create_request_async(formData.email.value);
loading = false;
@@ -31,13 +31,16 @@
formError.set_from_known_problem(response.knownProblem);
for (const error of Object.entries(response.knownProblem.errors)) {
if (error[0] === "email") {
- error[1].forEach(formData.email.errors.push);
+ let errors = [];
+ error[1].forEach((e) => errors.push(e));
+ formData.email.errors = errors;
}
}
} else {
formError.title = $LL.unexpectedError();
formError.subtitle = $LL.tryAgainSoon();
}
+ showErrorAlert = formError.has_error() && !showSuccessAlert;
}
</script>
@@ -57,23 +60,19 @@
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
<div class="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
<form class="space-y-6" on:submit|preventDefault={submit_form_async}>
- <Alert title={formError.title} message={formError.subtitle} type="error" visible={showErrorAlert} />
-
- <Alert
- type="success"
- title={$LL.success()}
- message={$LL.resetPasswordPage.requestSentMessage()}
- visible={showSuccessAlert}
- />
-
+ {#if showErrorAlert}
+ <Alert title={formError.title} message={formError.subtitle} type="error" />
+ {:else if showSuccessAlert}
+ <Alert type="success" title={$LL.success()} message={$LL.resetPasswordPage.requestSentMessage()} />
+ {/if}
<Input
id="email"
name="email"
type="email"
autocomplete="email"
errors={formData.email.errors}
- required
bind:value={formData.email.value}
+ required
label={$LL.emailAddress()}
/>
<Button text={$LL.submit()} type="submit" {loading} fullWidth />