import { getContextData } from "waku/middleware/context"; import { getState } from "@/lib/db"; import { startStudySession } from "@/actions/srs"; import StudySession from "@/components/Flashcard/StudySession"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import LessonSelector from "@/components/srs/LessonSelector"; // 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; // const state = getState(null); // If not logged in, show login required message if (!userId) { return (

Login Required

You need to be logged in to use the study session feature.

); } const lessonId = searchParams?.lessonId ? parseInt(searchParams.lessonId, 10) : null; // If no lesson ID provided, show lesson selector // Get initial data for the study session return (
); } async function Inner({ userId, lessonId, }: { userId: number; lessonId: number | null; }) { return ( <> {lessonId ? ( ) : ( )} ); } async function StudySessionOuter({ userId, lessonId, }: { userId: number; lessonId: number; }) { const initialData = await startStudySession(userId, lessonId, true); if ("ok" in initialData) return ( <> ); else return

idk

; }