From 490388360a0852bcf8ee054e96fa90e166df5792 Mon Sep 17 00:00:00 2001 From: polwex Date: Thu, 29 May 2025 14:52:38 +0700 Subject: fucker actually solved the cookies, love ya man --- src/pages/study.tsx | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'src/pages') diff --git a/src/pages/study.tsx b/src/pages/study.tsx index db7dde7..f818b4b 100644 --- a/src/pages/study.tsx +++ b/src/pages/study.tsx @@ -1,3 +1,4 @@ +import { getContextData } from "waku/middleware/context"; import { useState } from "react"; import { getState } from "@/lib/db"; import { startStudySession } from "@/actions/srs"; @@ -8,17 +9,24 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; // This is a server component that gets the initial data -export default async function StudyPage({ searchParams }: { searchParams: { lessonId?: string } }) { - const state = getState(null); - const userId = state.user?.id; - +export default async function StudyPage({ + searchParams, +}: { + searchParams: { lessonId?: string }; +}) { + const { user } = getContextData() as any; + // const state = getState(null); + const userId = user?.id; + // 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.

+

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

@@ -26,14 +34,16 @@ export default async function StudyPage({ searchParams }: { searchParams: { less
); } - - const lessonId = searchParams.lessonId ? parseInt(searchParams.lessonId, 10) : null; - + + const lessonId = searchParams.lessonId + ? parseInt(searchParams.lessonId, 10) + : null; + // If no lesson ID provided, show lesson selector if (!lessonId) { return ; } - + // Get initial data for the study session let initialData; try { @@ -41,13 +51,15 @@ export default async function StudyPage({ searchParams }: { searchParams: { less } catch (error) { console.error("Error starting study session:", error); } - + return (
); @@ -56,12 +68,12 @@ export default async function StudyPage({ searchParams }: { searchParams: { less // Client component for selecting a lesson function LessonSelector({ userId }: { userId: number }) { const [lessonId, setLessonId] = useState(""); - + return (

Start Study Session

- +
@@ -75,13 +87,13 @@ function LessonSelector({ userId }: { userId: number }) { required />
- +
- +

Available Lessons

@@ -110,14 +122,9 @@ function LessonSelector({ userId }: { userId: number }) { Lesson 5

- + @@ -125,4 +132,4 @@ function LessonSelector({ userId }: { userId: number }) {
); -} \ No newline at end of file +} -- cgit v1.2.3