2023-05-21 05:18:04 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { superForm } from 'sveltekit-superforms/client';
|
|
|
|
|
import { userSchema } from '$lib/config/zod-schemas.js';
|
2023-06-30 22:08:45 +00:00
|
|
|
import Label from '$components/ui/label/Label.svelte';
|
|
|
|
|
import Input from '$components/ui/input/Input.svelte';
|
|
|
|
|
import Button from '$components/ui/button/Button.svelte';
|
2023-05-21 05:18:04 +00:00
|
|
|
|
|
|
|
|
export let data;
|
2023-06-16 06:28:49 +00:00
|
|
|
|
2023-05-21 05:18:04 +00:00
|
|
|
const signInSchema = userSchema.pick({ username: true, password: true });
|
|
|
|
|
const { form, errors, enhance, delayed } = superForm(data.form, {
|
|
|
|
|
taintedMessage: null,
|
|
|
|
|
validators: signInSchema,
|
2023-05-29 06:34:39 +00:00
|
|
|
validationMethod: 'oninput',
|
2023-05-21 05:18:04 +00:00
|
|
|
delayMs: 0,
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
2023-05-24 06:28:23 +00:00
|
|
|
<form method="POST" use:enhance>
|
2023-05-21 05:18:04 +00:00
|
|
|
{#if $errors._errors}
|
|
|
|
|
<aside class="alert">
|
|
|
|
|
<div class="alert-message">
|
|
|
|
|
<h3>There was an error signing in</h3>
|
|
|
|
|
<p>{$errors._errors}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</aside>
|
|
|
|
|
{/if}
|
2023-06-30 22:08:45 +00:00
|
|
|
<div class="grid w-full max-w-sm items-center gap-2">
|
|
|
|
|
<h2
|
|
|
|
|
class="scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0"
|
|
|
|
|
>
|
|
|
|
|
Sign into your account
|
|
|
|
|
</h2>
|
|
|
|
|
<Label for="username">Username</Label>
|
|
|
|
|
<Input type="text" id="username" name="username" placeholder="Username" autocomplete="username" data-invalid={$errors.username} bind:value={$form.username} />
|
2023-05-21 05:18:04 +00:00
|
|
|
{#if $errors.username}
|
2023-06-30 22:08:45 +00:00
|
|
|
<p class="text-sm text-muted-foreground">{$errors.username}</p>
|
2023-05-21 05:18:04 +00:00
|
|
|
{/if}
|
2023-06-30 22:08:45 +00:00
|
|
|
<Label for="password">Password</Label>
|
|
|
|
|
<Input type="password" id="password" name="password" placeholder="Password" autocomplete="new-password" data-invalid={$errors.password} bind:value={$form.password} />
|
2023-05-21 05:18:04 +00:00
|
|
|
{#if $errors.password}
|
2023-06-30 22:08:45 +00:00
|
|
|
<p class="text-sm text-muted-foreground">{$errors.password}</p>
|
2023-05-21 05:18:04 +00:00
|
|
|
{/if}
|
2023-06-30 22:08:45 +00:00
|
|
|
<Button type="submit">Sign In</Button>
|
2023-05-21 05:18:04 +00:00
|
|
|
</div>
|
|
|
|
|
</form>
|