2023-05-21 05:18:04 +00:00
|
|
|
<script lang="ts">
|
2023-06-30 22:08:45 +00:00
|
|
|
import Button from '$components/ui/button/Button.svelte';
|
|
|
|
|
import Input from '$components/ui/input/Input.svelte';
|
|
|
|
|
import Label from '$components/ui/label/Label.svelte';
|
|
|
|
|
import { userSchema } from '$lib/config/zod-schemas.js';
|
2023-05-21 05:18:04 +00:00
|
|
|
import { superForm } from 'sveltekit-superforms/client';
|
|
|
|
|
|
|
|
|
|
export let data;
|
|
|
|
|
|
|
|
|
|
const signUpSchema = userSchema.pick({
|
|
|
|
|
firstName: true,
|
|
|
|
|
lastName: true,
|
|
|
|
|
username: true,
|
|
|
|
|
email: true,
|
2023-06-20 18:55:21 +00:00
|
|
|
password: true,
|
|
|
|
|
confirm_password: true
|
2023-05-21 05:18:04 +00:00
|
|
|
});
|
|
|
|
|
|
2023-05-24 06:28:23 +00:00
|
|
|
const { form, errors, constraints, enhance, delayed } = superForm(data.form, {
|
2023-05-21 05:18:04 +00:00
|
|
|
taintedMessage: null,
|
|
|
|
|
validators: signUpSchema,
|
|
|
|
|
delayMs: 0,
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="page">
|
|
|
|
|
<form method="POST" action="/auth/signup" use:enhance>
|
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"
|
|
|
|
|
>
|
|
|
|
|
Signup for an account
|
|
|
|
|
</h2>
|
|
|
|
|
<Label for="firstName">First Name</Label>
|
|
|
|
|
<Input type="text" id="firstName" name="firstName" placeholder="First Name" autocomplete="given-name" data-invalid={$errors.firstName} bind:value={$form.firstName} />
|
2023-05-21 05:18:04 +00:00
|
|
|
{#if $errors.firstName}
|
2023-06-30 22:08:45 +00:00
|
|
|
<p class="text-sm text-muted-foreground">{$errors.firstName}</p>
|
2023-05-21 05:18:04 +00:00
|
|
|
{/if}
|
2023-06-30 22:08:45 +00:00
|
|
|
<Label for="firstName">Last Name</Label>
|
|
|
|
|
<Input type="text" id="lastName" name="lastName" placeholder="Last Name" autocomplete="family-name" data-invalid={$errors.lastName} bind:value={$form.lastName} />
|
2023-05-21 05:18:04 +00:00
|
|
|
{#if $errors.lastName}
|
2023-06-30 22:08:45 +00:00
|
|
|
<p class="text-sm text-muted-foreground">{$errors.lastName}</p>
|
2023-05-21 05:18:04 +00:00
|
|
|
{/if}
|
2023-06-30 22:08:45 +00:00
|
|
|
<Label for="email">Email</Label>
|
|
|
|
|
<Input type="email" id="email" name="email" placeholder="Email" autocomplete="email" data-invalid={$errors.email} bind:value={$form.email} />
|
2023-05-21 05:18:04 +00:00
|
|
|
{#if $errors.email}
|
2023-06-30 22:08:45 +00:00
|
|
|
<p class="text-sm text-muted-foreground">{$errors.email}</p>
|
2023-05-21 05:18:04 +00:00
|
|
|
{/if}
|
2023-06-30 22:08:45 +00:00
|
|
|
<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
|
|
|
<Label for="confirm_password">Confirm Password</Label>
|
|
|
|
|
<Input type="password" id="confirm_password" name="confirm_password" placeholder="Confirm Password" autocomplete="new-password" data-invalid={$errors.confirm_password} bind:value={$form.confirm_password} />
|
2023-06-20 18:55:21 +00:00
|
|
|
{#if $errors.confirm_password}
|
2023-06-30 22:08:45 +00:00
|
|
|
<p class="text-sm text-muted-foreground">{$errors.confirm_password}</p>
|
2023-06-20 18:55:21 +00:00
|
|
|
{/if}
|
2023-06-30 22:08:45 +00:00
|
|
|
<div class="flex place-content-">
|
|
|
|
|
<Button type="submit">Signup</Button>
|
|
|
|
|
<Button variant="link" href="/">or Cancel</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-05-21 05:18:04 +00:00
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
</style>
|