From 84c5b778039102a77b7fda2ddcab2bbf70085bdc Mon Sep 17 00:00:00 2001 From: polwex Date: Thu, 29 May 2025 15:49:50 +0700 Subject: good progress good progrss --- src/components/Flashcard/StudyCard.tsx | 94 +++++++++------ src/components/Navbar.tsx | 202 +++++++++++++++++++++++++++++++++ src/components/ui/avatar.tsx | 50 ++++++++ src/lib/db/seed.ts | 1 + 4 files changed, 312 insertions(+), 35 deletions(-) create mode 100644 src/components/Navbar.tsx create mode 100644 src/components/ui/avatar.tsx (limited to 'src') diff --git a/src/components/Flashcard/StudyCard.tsx b/src/components/Flashcard/StudyCard.tsx index 4e554b4..1c52de7 100644 --- a/src/components/Flashcard/StudyCard.tsx +++ b/src/components/Flashcard/StudyCard.tsx @@ -16,11 +16,16 @@ interface StudyCardProps { onSkip?: () => void; } -export default function StudyCard({ card, userId, onComplete, onSkip }: StudyCardProps) { +export default function StudyCard({ + card, + userId, + onComplete, + onSkip, +}: StudyCardProps) { const [isFlipped, setIsFlipped] = useState(false); const [startTime, setStartTime] = useState(0); const [isSubmitting, setIsSubmitting] = useState(false); - + // Reset the timer when a new card is shown useEffect(() => { setIsFlipped(false); @@ -42,13 +47,13 @@ export default function StudyCard({ card, userId, onComplete, onSkip }: StudyCar // Handle card grading (Good/Again) const handleGrade = async (isCorrect: boolean) => { if (isSubmitting) return; - + setIsSubmitting(true); - + try { const result = await gradeCard(userId, card.id, isCorrect); - - if ('error' in result) { + + if ("error" in result) { console.error("Error grading card:", result.error); } else { onComplete(result as CardResponse); @@ -63,14 +68,14 @@ export default function StudyCard({ card, userId, onComplete, onSkip }: StudyCar // Handle detailed grading with accuracy level const handleDetailedGrade = async (accuracy: number) => { if (isSubmitting) return; - + setIsSubmitting(true); - + try { const reviewTime = getReviewTime(); const result = await processReview(userId, card.id, accuracy, reviewTime); - - if ('error' in result) { + + if ("error" in result) { console.error("Error processing review:", result.error); } else { onComplete(result as CardResponse); @@ -102,7 +107,7 @@ export default function StudyCard({ card, userId, onComplete, onSkip }: StudyCar if (card.expression.ipa && card.expression.ipa.length > 0) { return (
- /{card.expression.ipa[0].ipa}/ + /{card.expression.ipa[0]!.ipa}/
); } @@ -116,14 +121,22 @@ export default function StudyCard({ card, userId, onComplete, onSkip }: StudyCar
{card.expression.senses.map((sense, index) => (
- {sense.pos && {sense.pos}} - {sense.senses && sense.senses.map((subsense, i) => ( -
- {subsense.glosses && subsense.glosses.map((gloss, j) => ( -
{j+1}. {gloss}
- ))} -
- ))} + {sense.pos && ( + + {sense.pos} + + )} + {sense.senses && + sense.senses.map((subsense, i) => ( +
+ {subsense.glosses && + subsense.glosses.map((gloss, j) => ( +
+ {j + 1}. {gloss} +
+ ))} +
+ ))}
))}
@@ -142,36 +155,47 @@ export default function StudyCard({ card, userId, onComplete, onSkip }: StudyCar return (
-
+
{/* Front of card */}
{renderBookmarked()} -
{card.expression.spelling}
+
+ {card.expression.spelling} +
{!isFlipped && renderIPA()}
{formatCardContent(card.text)}
- {card.note &&
{card.note}
} + {card.note && ( +
{card.note}
+ )} {!isFlipped && ( -
- Click to flip -
+
Click to flip
)}
- + {/* Back of card */}
{renderBookmarked()}
-
{card.expression.spelling}
+
+ {card.expression.spelling} +
{renderIPA()} -
{formatCardContent(card.text, true)}
- {card.note &&
{card.note}
} +
+ {formatCardContent(card.text, true)} +
+ {card.note && ( +
{card.note}
+ )} {renderSenses()}
- +
How well did you remember this? @@ -188,13 +212,13 @@ export default function StudyCard({ card, userId, onComplete, onSkip }: StudyCar
- + {/* Optional: Detailed grading */}
- + {/* Progress bar */}
@@ -248,7 +272,7 @@ export default function StudyCard({ card, userId, onComplete, onSkip }: StudyCar Ease: {card.progress.easeFactor.toFixed(1)}
- + {/* Skip button */} {onSkip && ( + + + My Account + + Signed in as {user.name} + + + + Profile + + + My Cards + + + Settings + + + + Sign out + + + + ) : ( +
+ + + + + + +
+ )} +
+ +
+ +
+
+
+ + {/* Mobile menu */} +
+
+ + + Home + + + + + Study + + + + + Parse Text + + + + + Text Explorer + + +
+
+ {user ? ( + <> +
+
+ + {getInitials(user.name)} + +
+
+
{user.name}
+
+
+
+ + + Profile + + + + + My Cards + + + + + Settings + + + + + Sign out + + +
+ + ) : ( +
+ + + + + + +
+ )} +
+
+ + ); +} \ No newline at end of file diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx new file mode 100644 index 0000000..98f925f --- /dev/null +++ b/src/components/ui/avatar.tsx @@ -0,0 +1,50 @@ +"use client" + +import * as React from "react" +import * as AvatarPrimitive from "@radix-ui/react-avatar" + +import { cn } from "@/lib/utils" + +const Avatar = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +Avatar.displayName = AvatarPrimitive.Root.displayName + +const AvatarImage = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarImage.displayName = AvatarPrimitive.Image.displayName + +const AvatarFallback = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName + +export { Avatar, AvatarImage, AvatarFallback } \ No newline at end of file diff --git a/src/lib/db/seed.ts b/src/lib/db/seed.ts index b776782..4780dc3 100644 --- a/src/lib/db/seed.ts +++ b/src/lib/db/seed.ts @@ -521,6 +521,7 @@ async function redump() { for await (const line of readWiktionaryDump()) { try { count++; + console.log({ count }); // if (count > 50) break; const j = JSON.parse(line); // console.log(Object.keys(j), j.word); -- cgit v1.2.3