|
3 | 3 | import { accountV1Api } from '$lib/api'; |
4 | 4 | import Container from '$lib/components/Container.svelte'; |
5 | 5 | import Turnstile from '$lib/components/Turnstile.svelte'; |
6 | | - import TextInput from '$lib/components/input/TextInput.svelte'; |
| 6 | + import EmailInput from '$lib/components/input/EmailInput.svelte'; |
7 | 7 | import { Button } from '$lib/components/ui/button'; |
8 | | - import * as Card from '$lib/components/ui/card'; |
9 | 8 | import { handleApiError } from '$lib/errorhandling/apiErrorHandling'; |
10 | 9 |
|
11 | | - let emailAddress = $state<string>(''); |
| 10 | + let email = $state<string>(''); |
| 11 | + let emailValid = $state(false); |
| 12 | +
|
12 | 13 | let turnstileResponse = $state<string | null>(null); |
13 | 14 |
|
14 | 15 | function handleSubmission(e: SubmitEvent) { |
15 | 16 | e.preventDefault(); |
16 | 17 |
|
17 | | - if (!emailAddress || !turnstileResponse) { |
| 18 | + if (!email || !turnstileResponse) { |
18 | 19 | return; |
19 | 20 | } |
20 | 21 |
|
21 | 22 | accountV1Api |
22 | | - .accountPasswordResetInitiate({ email: emailAddress }) |
| 23 | + .accountPasswordResetInitiate({ email }) |
23 | 24 | .then(() => { |
24 | 25 | goto('/login'); |
25 | 26 | }) |
26 | 27 | .catch(handleApiError); |
27 | 28 | } |
28 | 29 |
|
29 | | - let canSubmit = $derived(emailAddress.length > 0 && turnstileResponse != null); |
| 30 | + let canSubmit = $derived(emailValid && turnstileResponse != null); |
30 | 31 | </script> |
31 | 32 |
|
32 | | -<Container> |
33 | | - <Card.Header> |
34 | | - <Card.Title class="text-3xl">Forgot Password</Card.Title> |
35 | | - </Card.Header> |
36 | | - <Card.Content> |
37 | | - <form class="flex flex-col space-y-4" onsubmit={handleSubmission}> |
38 | | - <TextInput label="Email" placeholder="Email" autocomplete="on" bind:value={emailAddress} /> |
| 33 | +<Container class="items-center"> |
| 34 | + <form class="flex flex-col space-y-4" onsubmit={handleSubmission}> |
| 35 | + <div class="text-3xl font-semibold">Forgot Password</div> |
| 36 | + |
| 37 | + <EmailInput |
| 38 | + label="Email" |
| 39 | + placeholder="Email" |
| 40 | + autocomplete="on" |
| 41 | + bind:value={email} |
| 42 | + bind:valid={emailValid} |
| 43 | + /> |
39 | 44 |
|
40 | | - <Turnstile action="forgot-password" bind:response={turnstileResponse} /> |
| 45 | + <Turnstile action="forgot-password" bind:response={turnstileResponse} /> |
41 | 46 |
|
42 | | - <Button type="submit" disabled={!canSubmit}>I forgot my passord</Button> |
43 | | - </form> |
44 | | - </Card.Content> |
| 47 | + <Button type="submit" disabled={!canSubmit}>I forgot my passord</Button> |
| 48 | + </form> |
45 | 49 | </Container> |
0 commit comments