summaryrefslogtreecommitdiff
path: root/src/pages/study.tsx
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-05-29 15:37:22 +0700
committerpolwex <polwex@sortug.com>2025-05-29 15:37:22 +0700
commitf23f7d2f0106882183929c740e4862a1939900d0 (patch)
tree8f77b63ca7e65db828e3bada68d54513acfea777 /src/pages/study.tsx
parent8e0965f5274635f609972ef85802675af64df0f4 (diff)
me again but it works!
Diffstat (limited to 'src/pages/study.tsx')
-rw-r--r--src/pages/study.tsx87
1 files changed, 0 insertions, 87 deletions
diff --git a/src/pages/study.tsx b/src/pages/study.tsx
deleted file mode 100644
index 68f781e..0000000
--- a/src/pages/study.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-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 (
- <div className="container mx-auto py-8">
- <Card className="p-6 text-center">
- <h1 className="text-2xl font-bold mb-4">Login Required</h1>
- <p className="mb-4">
- You need to be logged in to use the study session feature.
- </p>
- <Button asChild>
- <a href="/login">Login</a>
- </Button>
- </Card>
- </div>
- );
- }
-
- 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 (
- <div className="container mx-auto py-8">
- <Inner userId={userId} lessonId={lessonId} />
- </div>
- );
-}
-
-async function Inner({
- userId,
- lessonId,
-}: {
- userId: number;
- lessonId: number | null;
-}) {
- return (
- <>
- {lessonId ? (
- <StudySessionOuter userId={userId} lessonId={Number(lessonId)} />
- ) : (
- <LessonSelector userId={userId} />
- )}
- </>
- );
-}
-async function StudySessionOuter({
- userId,
- lessonId,
-}: {
- userId: number;
- lessonId: number;
-}) {
- const initialData = await startStudySession(userId, lessonId, true);
- if ("ok" in initialData)
- return (
- <>
- <StudySession
- userId={userId}
- lessonId={lessonId}
- initialData={initialData.ok}
- />
- </>
- );
- else return <p>idk</p>;
-}