fix: signup errors ?
This commit is contained in:
parent
efe4f1569f
commit
17bff677ac
4 changed files with 16 additions and 6 deletions
|
@ -3,6 +3,8 @@
|
|||
|
||||
import { page } from '$app/stores';
|
||||
|
||||
import Toaster from '$lib/components/Toaster.svelte';
|
||||
|
||||
$: origin = $page.url.origin;
|
||||
$: domain = $page.url.hostname;
|
||||
</script>
|
||||
|
@ -38,4 +40,6 @@
|
|||
<script defer data-domain={domain} src="https://plosibl.peerat.dev/js/script.js"></script>
|
||||
</svelte:head>
|
||||
|
||||
<Toaster />
|
||||
|
||||
<slot />
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
<Sidenav bind:isOpen />
|
||||
<div class="flex flex-1 flex-col">
|
||||
<Navbar bind:isOpen />
|
||||
<Toaster />
|
||||
<div
|
||||
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) {
|
||||
const { email_valid, username_valid } = await res.json();
|
||||
|
||||
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 (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é'];
|
||||
|
||||
return fail(400, { form });
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<script lang="ts">
|
||||
import { fade } from 'svelte/transition';
|
||||
import { superForm } from 'sveltekit-superforms/client';
|
||||
import { Loader2 } from 'lucide-svelte';
|
||||
|
||||
import type { PageData, Snapshot } from './$types';
|
||||
|
||||
import Button from '$lib/components/ui/Button.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;
|
||||
|
||||
|
@ -20,6 +21,12 @@
|
|||
onResult({ result }) {
|
||||
switch (result.type) {
|
||||
case 'success':
|
||||
addToast({
|
||||
data: {
|
||||
title: 'Demande de confirmation',
|
||||
description: `Un code vous à été ${confirmation ? 'renvoyé' : 'envoyé'}.`
|
||||
}
|
||||
});
|
||||
confirmation = true;
|
||||
break;
|
||||
case 'error':
|
||||
|
@ -124,9 +131,9 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
<Button class="mt-2" variant="brand" disabled={submitting}>
|
||||
<Button class="mt-2 flex items-center gap-2" variant="brand" disabled={submitting}>
|
||||
{#if submitting}
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
{/if}
|
||||
{confirmation ? "S'inscrire" : 'Continuer'}
|
||||
</Button>
|
||||
|
|
Loading…
Add table
Reference in a new issue