2025-11-24 01:00:50 +01:00
|
|
|
<script lang="ts">
|
2023-08-02 19:35:27 +01:00
|
|
|
import { goto } from '$app/navigation';
|
|
|
|
|
import TextField from '$lib/components/Form/TextField.svelte';
|
|
|
|
|
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
|
|
|
|
|
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
|
|
|
|
|
import { ROUTE } from '$lib/utils/constants/routes';
|
|
|
|
|
import AuthUI from '$lib/components/AuthUI/index.svelte';
|
|
|
|
|
import EmailSentIcon from '$lib/components/Icons/EmailSentIcon.svelte';
|
2025-11-24 01:00:50 +01:00
|
|
|
import { forgotApi } from '$lib/features/auth/api/forgot.svelte';
|
|
|
|
|
import type { TForgotPasswordForm } from '$lib/features/auth/utils/types';
|
2022-12-03 22:45:01 +01:00
|
|
|
|
2025-11-24 01:00:50 +01:00
|
|
|
let fields: TForgotPasswordForm = $state({ email: '' });
|
2022-12-03 22:45:01 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<svelte:head>
|
2025-11-24 01:00:50 +01:00
|
|
|
<title>Forgot Password - ClassroomIO</title>
|
2022-12-03 22:45:01 +01:00
|
|
|
</svelte:head>
|
|
|
|
|
|
2025-11-24 01:00:50 +01:00
|
|
|
<AuthUI handleSubmit={() => forgotApi.submit(fields)} showOnlyContent={true} showLogo={!forgotApi.success}>
|
|
|
|
|
{#if forgotApi.success}
|
2025-11-01 15:49:29 +01:00
|
|
|
<div class="mt-4 flex w-full flex-col items-center justify-center">
|
2025-11-24 01:00:50 +01:00
|
|
|
<EmailSentIcon />
|
2025-11-01 15:49:29 +01:00
|
|
|
<h3 class="my-3 text-xl font-semibold dark:text-white">Email Sent!</h3>
|
|
|
|
|
<p class="text-md mb-6 text-center dark:text-white">
|
|
|
|
|
We have sent a confirmation email to <span class="text-primary-700">{fields.email}</span>. Kindly check your
|
|
|
|
|
inbox to reset password or spam to reset your password.
|
2022-12-03 22:45:01 +01:00
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
<div class="my-4 flex w-full flex-col items-center justify-end">
|
|
|
|
|
<PrimaryButton label="Okay" type="button" className="sm:w-full w-full mb-4" onClick={() => goto(ROUTE.LOGIN)} />
|
2022-12-03 22:45:01 +01:00
|
|
|
</div>
|
|
|
|
|
{:else}
|
|
|
|
|
<div class="mt-4 w-full">
|
2025-11-01 15:49:29 +01:00
|
|
|
<h3 class="my-3 text-xl font-semibold dark:text-white">Forgot Password</h3>
|
|
|
|
|
<p class="mb-6 text-sm dark:text-white">We will send you a reset link to your email</p>
|
2022-12-03 22:45:01 +01:00
|
|
|
<TextField
|
|
|
|
|
label="Your email"
|
|
|
|
|
bind:value={fields.email}
|
|
|
|
|
type="email"
|
|
|
|
|
autoFocus={true}
|
|
|
|
|
placeholder="you@domain.com"
|
|
|
|
|
className="mb-6"
|
|
|
|
|
inputClassName="w-full"
|
2025-11-24 01:00:50 +01:00
|
|
|
isDisabled={forgotApi.isLoading}
|
|
|
|
|
errorMessage={forgotApi.errors.email}
|
2022-12-03 22:45:01 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
<div class="my-4 flex w-full flex-col items-center justify-end">
|
2022-12-03 22:45:01 +01:00
|
|
|
<PrimaryButton
|
|
|
|
|
label="Reset Password"
|
|
|
|
|
type="submit"
|
|
|
|
|
className="sm:w-full w-full mb-4"
|
2025-11-24 01:00:50 +01:00
|
|
|
isLoading={forgotApi.isLoading}
|
2022-12-03 22:45:01 +01:00
|
|
|
/>
|
|
|
|
|
<PrimaryButton
|
|
|
|
|
label="Cancel"
|
|
|
|
|
type="button"
|
2023-08-20 19:08:48 +00:00
|
|
|
className="sm:w-full w-full text-primary-700"
|
2022-12-03 22:45:01 +01:00
|
|
|
variant={VARIANTS.NONE}
|
|
|
|
|
onClick={() => goto(ROUTE.LOGIN)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</AuthUI>
|