boredgame/src/routes/(protected)/profile/+page.svelte

110 lines
2.6 KiB
Svelte
Raw Normal View History

<script lang="ts">
import { superForm } from 'sveltekit-superforms/client';
//import SuperDebug from 'sveltekit-superforms/client/SuperDebug.svelte';
import { userSchema } from '$lib/config/zod-schemas';
import { AlertTriangle } from 'lucide-svelte';
export let data;
const signUpSchema = userSchema.pick({
firstName: true,
lastName: true,
email: true
});
const { form, errors, enhance, delayed, message } = superForm(data.form, {
taintedMessage: null,
validators: signUpSchema,
delayMs: 0
});
</script>
<form method="POST" use:enhance>
<!--<SuperDebug data={$form} />-->
<h3>Profile</h3>
<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}
{#if $errors._errors}
<aside class="alert variant-filled-error mt-6">
<!-- Icon -->
<div><AlertTriangle size="42" /></div>
<!-- Message -->
<div class="alert-message">
<h3 class="h3">Sign In Problem</h3>
<p>{$errors._errors}</p>
</div>
</aside>
{/if}
<div class="mt-6">
<label class="label">
<span class="">First Name</span>
<input
id="firstName"
name="firstName"
type="text"
placeholder="First Name"
autocomplete="given-name"
data-invalid={$errors.firstName}
bind:value={$form.firstName}
class="input"
class:input-error={$errors.firstName}
/>
{#if $errors.firstName}
<small>{$errors.firstName}</small>
{/if}
</label>
</div>
<div class="mt-6">
<label class="label">
<span class="">Last Name</span>
<input
id="lastName"
name="lastName"
type="text"
placeholder="Last Name"
autocomplete="family-name"
data-invalid={$errors.lastName}
bind:value={$form.lastName}
class="input"
class:input-error={$errors.lastName}
/>
{#if $errors.lastName}
<small>{$errors.lastName}</small>
{/if}
</label>
</div>
<div class="mt-6">
<label class="label">
<span class="">Email address</span>
<input
id="email"
name="email"
type="email"
placeholder="Email address"
autocomplete="email"
data-invalid={$errors.email}
bind:value={$form.email}
class="input"
class:input-error={$errors.email}
/>
{#if $errors.email}
<small>{$errors.email}</small>
{/if}
</label>
</div>
<div class="mt-6">
<a href="/auth/password/reset">Change Password</a>
</div>
<div class="mt-6">
<!-- <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>
</form>