Skip to content

Commit 19a15a4

Browse files
committed
Better forgot password page
1 parent abc530a commit 19a15a4

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

src/routes/(anonymous)/forgot-password/+page.svelte

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,47 @@
33
import { accountV1Api } from '$lib/api';
44
import Container from '$lib/components/Container.svelte';
55
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';
77
import { Button } from '$lib/components/ui/button';
8-
import * as Card from '$lib/components/ui/card';
98
import { handleApiError } from '$lib/errorhandling/apiErrorHandling';
109
11-
let emailAddress = $state<string>('');
10+
let email = $state<string>('');
11+
let emailValid = $state(false);
12+
1213
let turnstileResponse = $state<string | null>(null);
1314
1415
function handleSubmission(e: SubmitEvent) {
1516
e.preventDefault();
1617
17-
if (!emailAddress || !turnstileResponse) {
18+
if (!email || !turnstileResponse) {
1819
return;
1920
}
2021
2122
accountV1Api
22-
.accountPasswordResetInitiate({ email: emailAddress })
23+
.accountPasswordResetInitiate({ email })
2324
.then(() => {
2425
goto('/login');
2526
})
2627
.catch(handleApiError);
2728
}
2829
29-
let canSubmit = $derived(emailAddress.length > 0 && turnstileResponse != null);
30+
let canSubmit = $derived(emailValid && turnstileResponse != null);
3031
</script>
3132

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+
/>
3944

40-
<Turnstile action="forgot-password" bind:response={turnstileResponse} />
45+
<Turnstile action="forgot-password" bind:response={turnstileResponse} />
4146

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>
4549
</Container>

0 commit comments

Comments
 (0)