diff options
author | polwex <polwex@sortug.com> | 2025-05-29 15:37:22 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-05-29 15:37:22 +0700 |
commit | f23f7d2f0106882183929c740e4862a1939900d0 (patch) | |
tree | 8f77b63ca7e65db828e3bada68d54513acfea777 /src/pages | |
parent | 8e0965f5274635f609972ef85802675af64df0f4 (diff) |
me again but it works!
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/study/[slug].tsx (renamed from src/pages/study.tsx) | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/pages/study.tsx b/src/pages/study/[slug].tsx index 68f781e..a5af523 100644 --- a/src/pages/study.tsx +++ b/src/pages/study/[slug].tsx @@ -5,15 +5,13 @@ import StudySession from "@/components/Flashcard/StudySession"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import LessonSelector from "@/components/srs/LessonSelector"; +import type { PageProps } from "waku/router"; // This is a server component that gets the initial data -export default async function StudyPage({ - searchParams, -}: { - searchParams: { lessonId?: string }; -}) { - const { user } = getContextData() as any; - const userId = user?.id; +export default async function StudyPage(props: PageProps<"/study/[slug]">) { + const lessonId = props.slug; + const ctx = getContextData() as any; + const userId = ctx?.user?.id; // const state = getState(null); // If not logged in, show login required message @@ -33,10 +31,6 @@ export default async function StudyPage({ ); } - const lessonId = searchParams?.lessonId - ? parseInt(searchParams.lessonId, 10) - : null; - // If no lesson ID provided, show lesson selector // Get initial data for the study session @@ -53,11 +47,11 @@ async function Inner({ lessonId, }: { userId: number; - lessonId: number | null; + lessonId: string; }) { return ( <> - {lessonId ? ( + {lessonId && Number(lessonId) ? ( <StudySessionOuter userId={userId} lessonId={Number(lessonId)} /> ) : ( <LessonSelector userId={userId} /> @@ -73,6 +67,7 @@ async function StudySessionOuter({ lessonId: number; }) { const initialData = await startStudySession(userId, lessonId, true); + console.log({ initialData }); if ("ok" in initialData) return ( <> |