From 8a4cd590689bd4e8780ff4ab536906dd37d3a1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o?= <43091603+glazk0@users.noreply.github.com> Date: Mon, 25 Sep 2023 10:25:03 +0200 Subject: [PATCH] hotfix: chapter puzzle show --- .../[chapterId]/puzzle/[puzzleId]/+page.server.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/routes/dashboard/chapters/[chapterId]/puzzle/[puzzleId]/+page.server.ts b/src/routes/dashboard/chapters/[chapterId]/puzzle/[puzzleId]/+page.server.ts index beb07ec..fbb21f2 100644 --- a/src/routes/dashboard/chapters/[chapterId]/puzzle/[puzzleId]/+page.server.ts +++ b/src/routes/dashboard/chapters/[chapterId]/puzzle/[puzzleId]/+page.server.ts @@ -30,7 +30,12 @@ export const load = (async ({ parent, fetch, cookies, params: { chapterId, puzzl throw redirect(303, `/dashboard/chapters`); } - if (!chapter.puzzles.some((puzzle) => puzzle.id === parseInt(puzzleId))) { + console.log(chapter); + + if ( + !chapter.puzzles.some((puzzle) => puzzle.id === parseInt(puzzleId)) || + !chapter.puzzles.find((puzzle) => puzzle.id === parseInt(puzzleId))?.show + ) { throw redirect(303, `/dashboard/chapters/${chapterId}`); } @@ -46,6 +51,8 @@ export const load = (async ({ parent, fetch, cookies, params: { chapterId, puzzl const puzzle = await res.json(); + console.log(puzzle); + if (!puzzle) { throw error(404, 'Puzzle not found'); }