fix: errors & semantic #9
4 changed files with 16 additions and 6 deletions
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
|
|
||||||
|
import Toaster from '$lib/components/Toaster.svelte';
|
||||||
|
|
||||||
$: origin = $page.url.origin;
|
$: origin = $page.url.origin;
|
||||||
$: domain = $page.url.hostname;
|
$: domain = $page.url.hostname;
|
||||||
</script>
|
</script>
|
||||||
|
@ -38,4 +40,6 @@
|
||||||
<script defer data-domain={domain} src="https://plosibl.peerat.dev/js/script.js"></script>
|
<script defer data-domain={domain} src="https://plosibl.peerat.dev/js/script.js"></script>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
|
<Toaster />
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
<Sidenav bind:isOpen />
|
<Sidenav bind:isOpen />
|
||||||
<div class="flex flex-1 flex-col">
|
<div class="flex flex-1 flex-col">
|
||||||
<Navbar bind:isOpen />
|
<Navbar bind:isOpen />
|
||||||
<Toaster />
|
|
||||||
<div
|
<div
|
||||||
class="flex w-full flex-1 transform flex-col overflow-y-scroll p-4 duration-300 ease-in-out sm:p-8"
|
class="flex w-full flex-1 transform flex-col overflow-y-scroll p-4 duration-300 ease-in-out sm:p-8"
|
||||||
>
|
>
|
||||||
|
|
|
@ -134,8 +134,8 @@ export const actions = {
|
||||||
if (res.status === 400) {
|
if (res.status === 400) {
|
||||||
const { email_valid, username_valid } = await res.json();
|
const { email_valid, username_valid } = await res.json();
|
||||||
|
|
||||||
if (!email_valid) form.errors.email = ['Un compte avec cette adresse email existe déjà'];
|
if (email_valid) form.errors.email = ['Un compte avec cette adresse email existe déjà'];
|
||||||
if (!username_valid) form.errors.pseudo = ['Ce pseudo est déjà utilisé'];
|
if (username_valid) form.errors.pseudo = ['Ce pseudo est déjà utilisé'];
|
||||||
|
|
||||||
return fail(400, { form });
|
return fail(400, { form });
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import { superForm } from 'sveltekit-superforms/client';
|
import { superForm } from 'sveltekit-superforms/client';
|
||||||
|
import { Loader2 } from 'lucide-svelte';
|
||||||
|
|
||||||
import type { PageData, Snapshot } from './$types';
|
import type { PageData, Snapshot } from './$types';
|
||||||
|
|
||||||
import Button from '$lib/components/ui/Button.svelte';
|
import Button from '$lib/components/ui/Button.svelte';
|
||||||
import Input from '$lib/components/ui/Input.svelte';
|
import Input from '$lib/components/ui/Input.svelte';
|
||||||
import { Loader2 } from 'lucide-svelte';
|
import { addToast } from '$lib/components/Toaster.svelte';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
|
@ -20,6 +21,12 @@
|
||||||
onResult({ result }) {
|
onResult({ result }) {
|
||||||
switch (result.type) {
|
switch (result.type) {
|
||||||
case 'success':
|
case 'success':
|
||||||
|
addToast({
|
||||||
|
data: {
|
||||||
|
title: 'Demande de confirmation',
|
||||||
|
description: `Un code vous à été ${confirmation ? 'renvoyé' : 'envoyé'}.`
|
||||||
|
}
|
||||||
|
});
|
||||||
confirmation = true;
|
confirmation = true;
|
||||||
break;
|
break;
|
||||||
case 'error':
|
case 'error':
|
||||||
|
@ -124,9 +131,9 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Button class="mt-2" variant="brand" disabled={submitting}>
|
<Button class="mt-2 flex items-center gap-2" variant="brand" disabled={submitting}>
|
||||||
{#if submitting}
|
{#if submitting}
|
||||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
<Loader2 className="h-4 w-4 animate-spin" />
|
||||||
{/if}
|
{/if}
|
||||||
{confirmation ? "S'inscrire" : 'Continuer'}
|
{confirmation ? "S'inscrire" : 'Continuer'}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Loading…
Add table
Reference in a new issue