2023-08-01 21:01:24 +00:00
|
|
|
<script lang="ts">
|
2024-02-26 06:59:29 +00:00
|
|
|
import { zodClient } from 'sveltekit-superforms/adapters';
|
2023-08-01 21:01:24 +00:00
|
|
|
import { superForm } from 'sveltekit-superforms/client';
|
2023-09-20 00:46:32 +00:00
|
|
|
import { AlertTriangle, KeyRound } from 'lucide-svelte';
|
2024-02-26 06:59:29 +00:00
|
|
|
import { profileSchema } from '$lib/validations/account';
|
2023-12-20 01:54:39 +00:00
|
|
|
import * as Alert from "$lib/components/ui/alert";
|
|
|
|
|
import { Label } from '$lib/components/ui/label';
|
2023-09-12 00:29:15 +00:00
|
|
|
import { Input } from '$components/ui/input';
|
2023-09-08 23:30:32 +00:00
|
|
|
import { Button } from '$components/ui/button';
|
2023-12-20 01:54:39 +00:00
|
|
|
|
2023-08-01 21:01:24 +00:00
|
|
|
export let data;
|
|
|
|
|
|
2023-12-20 01:54:39 +00:00
|
|
|
const { form, errors, enhance, message } = superForm(data.form, {
|
2023-08-01 21:01:24 +00:00
|
|
|
taintedMessage: null,
|
2024-02-26 06:59:29 +00:00
|
|
|
validators: zodClient(profileSchema),
|
2023-08-01 21:01:24 +00:00
|
|
|
delayMs: 0
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<form method="POST" use:enhance>
|
|
|
|
|
<!--<SuperDebug data={$form} />-->
|
2023-09-20 01:05:35 +00:00
|
|
|
<h3>Your Profile</h3>
|
2023-08-01 21:01:24 +00:00
|
|
|
<hr class="!border-t-2 mt-2 mb-6" />
|
|
|
|
|
{#if $message}
|
|
|
|
|
<aside class="alert variant-filled-success mt-6">
|
|
|
|
|
<!-- Message -->
|
|
|
|
|
<div class="alert-message">
|
|
|
|
|
<p>{$message}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</aside>
|
|
|
|
|
{/if}
|
|
|
|
|
<div class="mt-6">
|
2023-08-04 23:40:22 +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} />
|
|
|
|
|
{#if $errors.username}
|
|
|
|
|
<small>{$errors.username}</small>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-6">
|
|
|
|
|
<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} />
|
|
|
|
|
{#if $errors.firstName}
|
|
|
|
|
<small>{$errors.firstName}</small>
|
|
|
|
|
{/if}
|
2023-08-01 21:01:24 +00:00
|
|
|
</div>
|
|
|
|
|
<div class="mt-6">
|
2023-08-04 23:40:22 +00:00
|
|
|
<Label for="lastName">Last Name</Label>
|
|
|
|
|
<Input type="text" id="lastName" name="lastName" placeholder="Last Name" autocomplete="family-name" data-invalid={$errors.lastName} bind:value={$form.lastName} />
|
|
|
|
|
{#if $errors.lastName}
|
|
|
|
|
<small>{$errors.lastName}</small>
|
|
|
|
|
{/if}
|
2023-08-01 21:01:24 +00:00
|
|
|
</div>
|
2023-09-20 01:05:35 +00:00
|
|
|
<div class="grid gap-2 mt-6">
|
2023-08-04 23:40:22 +00:00
|
|
|
<Label for="email">Email address</Label>
|
|
|
|
|
<Input type="email" id="email" name="email" placeholder="Email Address" autocomplete="email" data-invalid={$errors.email} bind:value={$form.email} />
|
|
|
|
|
{#if $errors.email}
|
|
|
|
|
<small>{$errors.email}</small>
|
|
|
|
|
{/if}
|
2023-12-20 01:54:39 +00:00
|
|
|
{#if !$form.email}
|
2023-09-20 01:05:35 +00:00
|
|
|
<Alert.Root variant="destructive">
|
|
|
|
|
<AlertTriangle class="h-4 w-4" />
|
|
|
|
|
<Alert.Title>Heads up!</Alert.Title>
|
|
|
|
|
<Alert.Description>
|
|
|
|
|
Without an email, you won't be able to reset your password if you forget it.
|
|
|
|
|
</Alert.Description>
|
|
|
|
|
</Alert.Root>
|
|
|
|
|
{/if}
|
2023-08-01 21:01:24 +00:00
|
|
|
</div>
|
|
|
|
|
<div class="mt-6">
|
2023-09-20 00:46:32 +00:00
|
|
|
<Button variant="link" class="text-secondary-foreground" href="/password/change">
|
|
|
|
|
<KeyRound class="mr-2 h-4 w-4" />
|
|
|
|
|
Change Password
|
|
|
|
|
</Button>
|
2023-08-01 21:01:24 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="mt-6">
|
2023-08-04 23:40:22 +00:00
|
|
|
<Button type="submit" class="w-full">Update Profile</Button>
|
2023-08-01 21:01:24 +00:00
|
|
|
<!-- <button type="submit" class="btn variant-filled-primary w-full"
|
|
|
|
|
>{#if $delayed}<ConicGradient stops={conicStops} spin width="w-6" />{:else}Update Profile{/if}</button
|
|
|
|
|
> -->
|
|
|
|
|
</div>
|
2023-09-20 01:05:35 +00:00
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
<style lang="postcss">
|
|
|
|
|
form {
|
2024-02-18 08:03:08 +00:00
|
|
|
width: 20rem;
|
2023-09-20 01:05:35 +00:00
|
|
|
}
|
|
|
|
|
</style>
|