summaryrefslogtreecommitdiffstats
path: root/apps/accounts/src/app/pages/forgot.svelte
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-06-02 23:02:22 +0200
committerivarlovlie <git@ivarlovlie.no>2022-06-02 23:02:22 +0200
commit83b11393da8f733c0ffc5abed5d1e0e827d04b61 (patch)
tree0b8f1062cc7435576165c7eb1d8745842acc6c32 /apps/accounts/src/app/pages/forgot.svelte
parent53865dad18012512f90d235f4d2833469dcc1685 (diff)
downloadgreatoffice-83b11393da8f733c0ffc5abed5d1e0e827d04b61.tar.xz
greatoffice-83b11393da8f733c0ffc5abed5d1e0e827d04b61.zip
refactor: Rename accounts to portal
Diffstat (limited to 'apps/accounts/src/app/pages/forgot.svelte')
-rw-r--r--apps/accounts/src/app/pages/forgot.svelte99
1 files changed, 0 insertions, 99 deletions
diff --git a/apps/accounts/src/app/pages/forgot.svelte b/apps/accounts/src/app/pages/forgot.svelte
deleted file mode 100644
index f22d664..0000000
--- a/apps/accounts/src/app/pages/forgot.svelte
+++ /dev/null
@@ -1,99 +0,0 @@
-<script>
- import {onMount} from "svelte";
- import {link} from "svelte-spa-router";
- import {create_forgot_password_request} from "$shared/lib/api/user";
- import {is_email} from "$shared/lib/helpers";
- import Alert from "$shared/components/alert.svelte";
- import Button from "$shared/components/button.svelte";
- import Layout from "./_layout.svelte";
-
- let isLoading = false;
- let username;
-
- const alert = {
- title: "",
- type: "",
- message: "",
- isVisible: false,
- show(type, obj) {
- alert.title = obj.title;
- alert.message = obj.text;
- alert.type = type;
- alert.isVisible = true;
- isLoading = false;
- },
- hide() {
- alert.isVisible = false;
- alert.title = "";
- alert.message = "";
- alert.type = "";
- isLoading = false;
- },
- };
-
- function is_valid() {
- return is_email(username);
- }
-
- async function submit_form() {
- if (isLoading) {
- return;
- }
- if (is_valid()) {
- isLoading = true;
- const response = await create_forgot_password_request(username);
- if (response.ok) {
- alert.show("success", {
- title: "Request is sent",
- text: "If we find an account associated with this email address, you will receive an email with a reset link very soon.",
- });
- } else {
- console.error(response.data);
- alert.show("error", {
- title: response.data?.title ?? "An error occured",
- text: response.data?.text ?? "Please try again soon",
- });
- }
- }
- }
-
- onMount(() => {
- document.addEventListener("DOMContentLoaded", () => {
- document.getElementById("email-address").focus();
- });
- });
-</script>
-
-<Layout>
- <form on:submit|preventDefault={submit_form}
- class="margin-bottom-md max-width-xxs">
- <fieldset>
- <legend class="form-legend">
- <span class="margin-bottom-xs">Send reset link</span> <br/>
- <span class="text-sm">... or <a href="/login"
- use:link>log in</a></span>
- </legend>
- <div class="margin-bottom-xs">
- <p>Provide your email address, and we'll send you a link to set your new password.</p>
- </div>
- <div class="margin-bottom-xxs max-width-xxs">
- <Alert visible={alert.isVisible}
- title={alert.title}
- message={alert.message}
- type={alert.type}/>
- </div>
- <div class="margin-bottom-xs">
- <input type="email"
- id="email-address"
- placeholder="Email address"
- class="form-control width-100%"
- bind:value={username}/>
- </div>
- <div class="flex justify-end">
- <Button text="Send reset link"
- type="primary"
- loading={isLoading}/>
- </div>
- </fieldset>
- </form>
-</Layout>