From e4b32c6bf2784d38e738ae5e8908aaf33a9d4e3e Mon Sep 17 00:00:00 2001 From: Elijah Date: Sun, 28 Jun 2026 12:04:19 -0700 Subject: [PATCH] feat: Add list view for shared flashcards and fix restart button layout --- .../[type]/[token]/SharedViewer.tsx | 65 ++++++++++++++----- src/components/flashcards/CardList.tsx | 56 ++++++++++++++++ 2 files changed, 105 insertions(+), 16 deletions(-) create mode 100644 src/components/flashcards/CardList.tsx diff --git a/src/app/shared/[classSlug]/[type]/[token]/SharedViewer.tsx b/src/app/shared/[classSlug]/[type]/[token]/SharedViewer.tsx index dce55ab..87d77ce 100644 --- a/src/app/shared/[classSlug]/[type]/[token]/SharedViewer.tsx +++ b/src/app/shared/[classSlug]/[type]/[token]/SharedViewer.tsx @@ -3,6 +3,7 @@ import { useState } from "react"; import { FlashcardViewer } from "@/components/flashcards/FlashcardViewer"; import { QuizViewer } from "@/components/quizzes/QuizViewer"; +import { CardList } from "@/components/flashcards/CardList"; interface SharedViewerProps { type: string; @@ -11,6 +12,7 @@ interface SharedViewerProps { export function SharedViewer({ type, data }: SharedViewerProps) { const [restartKey, setRestartKey] = useState(0); + const [view, setView] = useState<"study" | "list">("study"); return (
@@ -29,26 +31,57 @@ export function SharedViewer({ type, data }: SharedViewerProps) { )}
-
- +
+ {view === "study" && ( + + )} + + {type === "flashcards" && ( +
+ + +
+ )}
{type === "flashcards" ? ( - + view === "study" ? ( + + ) : ( + + ) ) : ( +
+ {cards.length} {cards.length === 1 ? "card" : "cards"} +
+ + {cards.map((card, index) => ( +
+
+
+
+ + {index + 1} + + Front +
+
+ {card.front} +
+
+
+
+ + {index + 1} + + Back +
+
+ {card.back} +
+
+
+
+ ))} + + ); +}