- Chapitres
-
Puzzles
@@ -61,10 +57,6 @@
{/if}
Aucun puzzle trouvé
+Vos badges sont affichés ici, vous pouvez les partager avec vos amis
++ Vos badges sont affichés ici, vous pouvez les partager avec vos amis +
- Aucun groupe n'a encore de score + Aucun groupe n'a encore été créé + | +||||
+ Aucune équipe n'a encore de score | ||||
{group.rank} | {group.name} | @@ -56,7 +80,7 @@ {#if group.players?.length} {group.players.map((player) => player?.pseudo).join(', ')} {:else} - Aucun joueur + Aucun joueur {/if}{group.players.reduce((a, b) => a + b.score, 0)} | diff --git a/src/routes/(app)/chapters/[chapterId]/puzzle/+page.server.ts b/src/routes/(app)/chapters/[chapterId=id]/puzzle/+page.server.ts similarity index 51% rename from src/routes/(app)/chapters/[chapterId]/puzzle/+page.server.ts rename to src/routes/(app)/chapters/[chapterId=id]/puzzle/+page.server.ts index 5d22be6..f79421a 100644 --- a/src/routes/(app)/chapters/[chapterId]/puzzle/+page.server.ts +++ b/src/routes/(app)/chapters/[chapterId=id]/puzzle/+page.server.ts @@ -4,7 +4,7 @@ import type { PageServerLoad } from './$types'; import { handleRedirect } from '$lib/utils'; -export const load = (async ({ url, locals: { user }, params: { chapterId } }) => { +export const load: PageServerLoad = async ({ url, locals: { user }, params: { chapterId } }) => { if (!user) redirect(302, handleRedirect('login', url)); - redirect(302, chapterId ? `/chapters/${chapterId}` : `/chapters`); -}) satisfies PageServerLoad; + redirect(302, isNaN(parseInt(chapterId)) ? `/chapters/${chapterId}` : `/chapters`); +} diff --git a/src/routes/(app)/chapters/[chapterId]/puzzle/[puzzleId]/+page.server.ts b/src/routes/(app)/chapters/[chapterId=id]/puzzle/[puzzleId=id]/+page.server.ts similarity index 50% rename from src/routes/(app)/chapters/[chapterId]/puzzle/[puzzleId]/+page.server.ts rename to src/routes/(app)/chapters/[chapterId=id]/puzzle/[puzzleId=id]/+page.server.ts index d5983df..b2f961d 100644 --- a/src/routes/(app)/chapters/[chapterId]/puzzle/[puzzleId]/+page.server.ts +++ b/src/routes/(app)/chapters/[chapterId=id]/puzzle/[puzzleId=id]/+page.server.ts @@ -1,13 +1,18 @@ import { API_URL } from '$env/static/private'; -import { error, redirect, type Actions } from '@sveltejs/kit'; -import { compile } from 'mdsvex'; -import type { PageServerLoad } from './$types'; +import { error, redirect } from '@sveltejs/kit'; +import type { Actions, PageServerLoad } from './$types'; -import type Puzzle from '$lib/components/puzzle.svelte'; -import type { Chapter } from '$lib/types'; +import { superValidate } from 'sveltekit-superforms'; +import { zod } from 'sveltekit-superforms/adapters'; + +import { compile } from 'mdsvex'; + +import type { Chapter, Puzzle } from '$lib/types'; import { handleRedirect } from '$lib/utils'; -export const load = (async ({ url, locals: { user }, fetch, cookies, params: { chapterId, puzzleId } }) => { +import { formSchema } from './schema'; + +export const load: PageServerLoad = async ({ url, locals: { user }, fetch, cookies, params: { chapterId, puzzleId } }) => { if (!user) redirect(302, handleRedirect('login', url)); const session = cookies.get('session'); @@ -22,7 +27,7 @@ export const load = (async ({ url, locals: { user }, fetch, cookies, params: { c redirect(302, `/chapters`); } - const chapter = (await res.json()) as Chapter; + const chapter: Chapter = await res.json(); if (!chapter || !chapter.show) { redirect(302, `/chapters`); @@ -55,20 +60,37 @@ export const load = (async ({ url, locals: { user }, fetch, cookies, params: { c const content = await compile(puzzle.content); - puzzle.content = content?.code - .replace(/>{@html `