From 6026bd959bbb7c484503d20d891b2bb008ed6b67 Mon Sep 17 00:00:00 2001 From: Craig Kaiser Date: Tue, 30 Jul 2024 10:30:43 -0400 Subject: [PATCH] fix settings page --- src/components/Settings.svelte | 10 +++++++--- src/routes/events/[slug]/+page.server.ts | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/Settings.svelte b/src/components/Settings.svelte index 2715b97..bf10374 100644 --- a/src/components/Settings.svelte +++ b/src/components/Settings.svelte @@ -38,12 +38,16 @@ onError({ result }) { error(result.error.message || 'Unknown error'); }, - onUpdated({ form }) { + async onUpdated({ form }) { if (form.valid) { success(`Tournament settings updated`); - data.tournament.load(data.eventId); + data.tournament.load(data.eventId).catch((err: any) => { + error(`Failed to load tournament: ${err}`); + }); + $formData = form.data; } - } + }, + dataType: 'json' }); let { form: formData, enhance } = form; diff --git a/src/routes/events/[slug]/+page.server.ts b/src/routes/events/[slug]/+page.server.ts index 2cee79d..5b3058d 100644 --- a/src/routes/events/[slug]/+page.server.ts +++ b/src/routes/events/[slug]/+page.server.ts @@ -36,10 +36,13 @@ export const actions: Actions = { const tournament = new Event(eventSupabaseDatabaseService); try { - await tournament.update(eventId, form.data); - // @ts-ignore - form.data = eventsUpdateSchema.parse(tournament); + const updatedTournament = await tournament.update(eventId, form.data); + // Parse the updated tournament data + const parsedData = eventsUpdateSchema.parse(updatedTournament); + + // Update the form data with the parsed and updated values + form.data = parsedData; return { form };