From d177c615ff6349df96bfc9a5067f4447d763bce0 Mon Sep 17 00:00:00 2001 From: David Haukeness Date: Mon, 4 Nov 2024 22:21:49 +0000 Subject: [PATCH] update page load data to svelte 5 paradigms, change reactive to effect runes. --- src/routes/login/+page.svelte | 13 ++++++++----- src/routes/password/+page.svelte | 17 +++++++---------- src/routes/profile/+page.svelte | 17 +++++++---------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index 767e2d5..bf0f1d5 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -8,8 +8,11 @@ import { loginFormSchema, type LoginFormSchema } from './schema'; import * as m from '$lib/paraglide/messages.js'; import { toast } from "svelte-sonner"; + import type { PageData } from "./$types"; - export let data: SuperValidated>; + //export let data: SuperValidated>; + + let { data }: { data: SuperValidated> } = $props(); const form = superForm(data, { validators: zodClient(loginFormSchema), @@ -18,13 +21,13 @@ const { form: formData, errors, enhance } = form; - $: ((errors) => { - if (errors) { - errors.forEach(error => { + $effect(() => { + if ($errors._errors) { + $errors._errors.forEach(error => { toast.error(error); }); } - })($errors._errors); + }); diff --git a/src/routes/password/+page.svelte b/src/routes/password/+page.svelte index 8239ccb..57e19d1 100644 --- a/src/routes/password/+page.svelte +++ b/src/routes/password/+page.svelte @@ -10,7 +10,7 @@ import type { PageData } from "./$types"; import { toast } from "svelte-sonner"; - export let data: PageData; + let { data }: { data: PageData } = $props(); const form = superForm(data.form, { validators: zodClient(passwordFormSchema), @@ -20,19 +20,16 @@ const { form: formData, enhance, errors, message } = form; - $: ((errors) => { - if (errors) { - errors.forEach(error => { + $effect(() => { + if ($errors._errors) { + $errors._errors.forEach(error => { toast.error(error); }); } - })($errors._errors); - - $: ((message) => { - if (message) { - toast.success(message); + if ($message) { + toast.success($message); } - })($message); + }); diff --git a/src/routes/profile/+page.svelte b/src/routes/profile/+page.svelte index a50a3b9..e9acc61 100644 --- a/src/routes/profile/+page.svelte +++ b/src/routes/profile/+page.svelte @@ -10,7 +10,7 @@ import type { PageData } from "./$types"; import { toast } from "svelte-sonner"; - export let data: PageData; + let { data }: { data: PageData } = $props(); const form = superForm(data.form, { validators: zodClient(profileFormSchema), @@ -22,19 +22,16 @@ const { form: formData, enhance, tainted, errors, message } = form; - $: ((errors) => { - if (errors) { - errors.forEach(error => { + $effect(() => { + if ($errors._errors) { + $errors._errors.forEach(error => { toast.error(error); }); } - })($errors._errors); - - $: ((message) => { - if (message) { - toast.success(message); + if ($message) { + toast.success($message); } - })($message); + });