78 lines
2.6 KiB
Svelte
78 lines
2.6 KiB
Svelte
<script lang="ts">
|
|
import { page } from '$app/stores';
|
|
import type { PageData } from './$types';
|
|
|
|
import Loader from 'lucide-svelte/icons/loader-circle';
|
|
import { toast } from 'svelte-sonner';
|
|
import { zodClient } from 'sveltekit-superforms/adapters';
|
|
import { superForm } from 'sveltekit-superforms/client';
|
|
|
|
import * as Form from '$lib/components/ui/form';
|
|
import Input from '$lib/components/ui/input/input.svelte';
|
|
import Label from '$lib/components/ui/label/label.svelte';
|
|
|
|
import { settingSchema } from '$lib/validations/auth';
|
|
|
|
export let data: PageData;
|
|
|
|
const form = superForm(data.form, {
|
|
validators: zodClient(settingSchema),
|
|
delayMs: 500,
|
|
multipleSubmits: 'prevent',
|
|
onResult({ result }) {
|
|
if (result.type === 'success') {
|
|
toast.message('Succès', { description: 'Vos informations ont été mises à jour.' });
|
|
}
|
|
}
|
|
});
|
|
|
|
const { form: formData, enhance, delayed } = form;
|
|
|
|
// TODO: Handle overflow X on small screens
|
|
</script>
|
|
|
|
<section>
|
|
<form class="flex flex-col gap-2" method="POST" use:enhance>
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-xl font-bold">Paramètres généraux</h2>
|
|
<Form.Button disabled={$delayed}>
|
|
{#if $delayed}
|
|
<Loader class="mr-2 h-4 w-4 animate-spin" />
|
|
{/if}
|
|
Modifier
|
|
</Form.Button>
|
|
</div>
|
|
<Label>Email</Label>
|
|
<Input
|
|
type="email"
|
|
value={$page.data.user?.email}
|
|
disabled
|
|
placeholder="philiphzcwbarlow@peerat.dev"
|
|
/>
|
|
<p class="text-sm text-muted-foreground">Votre email ne peut pas être modifié.</p>
|
|
<Form.Field {form} name="firstname">
|
|
<Form.Control let:attrs>
|
|
<Form.Label>Prénom</Form.Label>
|
|
<Input {...attrs} bind:value={$formData.firstname} placeholder="Philip" />
|
|
<Form.Description>Votre prénom de famille ne sera pas visible par les autres utilisateurs.</Form.Description>
|
|
</Form.Control>
|
|
<Form.FieldErrors />
|
|
</Form.Field>
|
|
<Form.Field {form} name="lastname">
|
|
<Form.Control let:attrs>
|
|
<Form.Label>Nom de famille</Form.Label>
|
|
<Input {...attrs} bind:value={$formData.lastname} placeholder="Barlow" />
|
|
<Form.Description>Votre nom de famille ne sera pas visible par les autres utilisateurs.</Form.Description>
|
|
</Form.Control>
|
|
<Form.FieldErrors />
|
|
</Form.Field>
|
|
<Form.Field {form} name="pseudo">
|
|
<Form.Control let:attrs>
|
|
<Form.Label>Nom d'utilisateur</Form.Label>
|
|
<Input {...attrs} bind:value={$formData.pseudo} placeholder="Cypherwolf" />
|
|
</Form.Control>
|
|
<Form.Description>Votre nom d'utilisateur sera visible par les autres utilisateurs.</Form.Description>
|
|
<Form.FieldErrors />
|
|
</Form.Field>
|
|
</form>
|
|
</section>
|