From 2401217a4019938d1c1cc61b6e33ccb233eb6e74 Mon Sep 17 00:00:00 2001 From: polwex Date: Tue, 3 Jun 2025 09:34:29 +0700 Subject: this is golden thanks claude --- src/pages/lesson/[slug].tsx | 3 +-- src/pages/study/thai.tsx | 53 +++++++++++++++++++++++++++++++++++++++++++++ src/pages/tones.tsx | 20 ++++++++--------- 3 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 src/pages/study/thai.tsx (limited to 'src/pages') diff --git a/src/pages/lesson/[slug].tsx b/src/pages/lesson/[slug].tsx index 991859b..e9c7b93 100644 --- a/src/pages/lesson/[slug].tsx +++ b/src/pages/lesson/[slug].tsx @@ -36,8 +36,7 @@ export default async function HomePage(props: PageProps<"/lesson/[slug]">) { const data = await getData(Number(props.slug), user.id); if ("error" in data) return

Error

; const cardComponents = data.ok.cards.map((card) => ({ - id: card.id, - front: , + front: , back: , })); diff --git a/src/pages/study/thai.tsx b/src/pages/study/thai.tsx new file mode 100644 index 0000000..272aecb --- /dev/null +++ b/src/pages/study/thai.tsx @@ -0,0 +1,53 @@ +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"; +import type { PageProps } from "waku/router"; +import pdb from "@/lib/db/prosodydb"; +import Deck from "@/components/Flashcard/Deck3"; +import { CardFront, CardBack } from "@/components/Flashcard/ServerCard2"; + +// This is a server component that gets the initial data +export default async function StudyPage(props: PageProps<"/study/[slug]">) { + const lessonId = props.slug; + const ctx = getContextData() as any; + const userId = ctx?.user?.id; + const data = await getData(); + console.log({ data }); + const cardComponents = data.map((card) => { + const syls = JSON.parse(card.syllables); + const syllables = syls.map((s: any) => { + const long = s.long === 1 ? true : s.long === 0 ? false : null; + return { ...s, long }; + }); + const data = { ...card, syllables }; + return { + id: card.id, + front: , + back: , + }; + }); + + return ( +
+ +
+ ); +} + +const getData = async () => { + const res = pdb.fetchFrequent("th"); + return res; +}; + +export const getConfig = async () => { + return { + render: "dynamic", + } as const; +}; diff --git a/src/pages/tones.tsx b/src/pages/tones.tsx index 1a1e908..96ed56c 100644 --- a/src/pages/tones.tsx +++ b/src/pages/tones.tsx @@ -1,18 +1,19 @@ -import { Suspense } from 'react'; -import { fetchWordsByToneAndSyllables } from '@/actions/tones'; -import ToneSelectorClient from '@/components/tones/ToneSelectorClient'; -import { Skeleton } from '@/components/ui/skeleton'; // For Suspense fallback +import { Suspense } from "react"; +import { fetchWordsByToneAndSyllables } from "@/actions/tones"; +import ToneSelectorClient from "@/components/tones/ToneSelectorClient"; +import { Skeleton } from "@/components/ui/skeleton"; // For Suspense fallback export const getConfig = async () => { return { - render: 'static', // Or 'dynamic' if you prefer SSR for every request + render: "static", // Or 'dynamic' if you prefer SSR for every request }; }; // Function to fetch the initial word on the server async function InitialWordLoader() { // Fetch a random 1-syllable Thai word with any tone initially - const initialWord = await fetchWordsByToneAndSyllables(1, [null]); + const initialWord = await fetchWordsByToneAndSyllables(["rising", "mid"]); + console.log({ initialWord }); return ; } @@ -23,7 +24,7 @@ function TonePageSkeleton() {
- +
@@ -45,7 +46,6 @@ function TonePageSkeleton() { ); } - export default function TonesPage() { return (
@@ -57,6 +57,6 @@ export default function TonesPage() { } export const metadata = { - title: 'Thai Tone Explorer', - description: 'Explore Thai words by syllable count and tones.', + title: "Thai Tone Explorer", + description: "Explore Thai words by syllable count and tones.", }; -- cgit v1.2.3