From 3157b1d69d20452a83fc2da2de40d93df69ef730 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20BRAMILLE?=
<2752200+oktapodia@users.noreply.github.com>
Date: Thu, 5 Dec 2024 10:14:07 +0000
Subject: [PATCH] fix: Handle errors when quest does not exists
---
src/app/[lng]/quests/[slug]/page.tsx | 5 +++++
src/app/[lng]/superfest/[slug]/page.tsx | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/src/app/[lng]/quests/[slug]/page.tsx b/src/app/[lng]/quests/[slug]/page.tsx
index 316a36e2d..2ce43adae 100644
--- a/src/app/[lng]/quests/[slug]/page.tsx
+++ b/src/app/[lng]/quests/[slug]/page.tsx
@@ -9,9 +9,14 @@
import { getQuestBySlug } from '../../../lib/getQuestBySlug';
import QuestPage from '../../../ui/quests/QuestMissionPage';
+import { notFound } from 'next/navigation';
export default async function Page({ params }: { params: { slug: string } }) {
const { data, url } = await getQuestBySlug(params.slug);
+ if (!data?.data?.[0]) {
+ return notFound();
+ }
+
return ;
}
diff --git a/src/app/[lng]/superfest/[slug]/page.tsx b/src/app/[lng]/superfest/[slug]/page.tsx
index e06b0357a..a53cf54a6 100644
--- a/src/app/[lng]/superfest/[slug]/page.tsx
+++ b/src/app/[lng]/superfest/[slug]/page.tsx
@@ -1,5 +1,6 @@
import { getQuestBySlug } from 'src/app/lib/getQuestBySlug';
import SuperfestPage from 'src/app/ui/superfest/SuperfestMissionPage';
+import { notFound } from 'next/navigation';
// export async function generateMetadata({
// params,
@@ -44,5 +45,9 @@ import SuperfestPage from 'src/app/ui/superfest/SuperfestMissionPage';
export default async function Page({ params }: { params: { slug: string } }) {
const { data, url } = await getQuestBySlug(params.slug);
+ if (!data?.data?.[0]) {
+ return notFound();
+ }
+
return ;
}