From 2457bfcb39bf430128abaf6c981c4ce18eaa7e0a Mon Sep 17 00:00:00 2001 From: Elijah Date: Sun, 28 Jun 2026 12:32:43 -0700 Subject: [PATCH] fix: Resolve redundant quiz titles by merging them into the page header --- .../[classSlug]/quizzes/[quizId]/page.tsx | 34 +++++++++++++++-- .../[type]/[token]/SharedViewer.tsx | 37 +++++++++++++++++-- src/components/quizzes/QuizViewer.tsx | 27 -------------- 3 files changed, 64 insertions(+), 34 deletions(-) diff --git a/src/app/(protected)/[classSlug]/quizzes/[quizId]/page.tsx b/src/app/(protected)/[classSlug]/quizzes/[quizId]/page.tsx index e050800..184b87c 100644 --- a/src/app/(protected)/[classSlug]/quizzes/[quizId]/page.tsx +++ b/src/app/(protected)/[classSlug]/quizzes/[quizId]/page.tsx @@ -107,6 +107,11 @@ export default function QuizStudyPage() { fetchQuizAndAttempts(); }, [fetchQuizAndAttempts]); + const [showTopics, setShowTopics] = useState(false); + const categories = quiz + ? Array.from(new Set(quiz.questions.map(q => q.category.toUpperCase()))).join(" · ") + : ""; + if (loading || !quiz) { return (
@@ -121,25 +126,46 @@ export default function QuizStudyPage() { return (
{/* Header */} -
+
-

{quiz.name}

+ + + + {showTopics && ( +
+ {categories} +
+ )} + {quiz.description && (

{quiz.description}

)}
{/* View toggle & Share */} -
+
{view === "take" && ( + + {showTopics && ( +
+ {categories} +
+ )} + + ) : ( +

+ {data.name} +

+ )} +

From class: {data.class.name}

diff --git a/src/components/quizzes/QuizViewer.tsx b/src/components/quizzes/QuizViewer.tsx index 90f55f0..583f3f3 100644 --- a/src/components/quizzes/QuizViewer.tsx +++ b/src/components/quizzes/QuizViewer.tsx @@ -47,7 +47,6 @@ export function QuizViewer({ quiz, retakeIds, isShared = false, onFinished }: Qu const [loading, setLoading] = useState(true); const [resultsData, setResultsData] = useState(null); - const [showTopics, setShowTopics] = useState(false); // Initialize session useEffect(() => { @@ -268,35 +267,9 @@ export function QuizViewer({ quiz, retakeIds, isShared = false, onFinished }: Qu return
Question not found.
; } - const categories = Array.from(new Set(quiz.questions.map(q => q.category.toUpperCase()))).join(" · "); - return (
- {/* Title & Meta */} -
- - - {showTopics && ( -
- {categories} -
- )} -
- {/* Main Unified Card */}