From 7a83557dc9d6fcc1e7f3befb20fdd267f6fa49f2 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Fri, 16 Jan 2026 10:55:55 -0700 Subject: [PATCH] Add user name to share screen --- components/SharedQuizView.tsx | 5 ++++- server/src/routes/shared.ts | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/SharedQuizView.tsx b/components/SharedQuizView.tsx index 41d944a..3ba2ff2 100644 --- a/components/SharedQuizView.tsx +++ b/components/SharedQuizView.tsx @@ -16,6 +16,7 @@ interface SharedQuizData { gameConfig: GameConfig | null; questions: Question[]; questionCount: number; + sharedBy?: string | null; } interface SharedQuizViewProps { @@ -156,7 +157,9 @@ export const SharedQuizView: React.FC = ({ onHostQuiz, shar
-

Shared Quiz

+

+ {quizData.sharedBy ? `Shared by ${quizData.sharedBy}` : 'Shared Quiz'} +

{quizData.title}

{quizData.questionCount} question{quizData.questionCount !== 1 ? 's' : ''} diff --git a/server/src/routes/shared.ts b/server/src/routes/shared.ts index ba2a410..fe7f2fa 100644 --- a/server/src/routes/shared.ts +++ b/server/src/routes/shared.ts @@ -13,6 +13,8 @@ interface QuizRow { gameConfig: string | null; createdAt: string; updatedAt: string; + sharedByUsername: string | null; + sharedByDisplayName: string | null; } interface QuestionRow { @@ -36,9 +38,13 @@ router.get('/:token', (req: Request, res: Response) => { const { token } = req.params; const quiz = db.prepare(` - SELECT id, title, source, ai_topic as aiTopic, game_config as gameConfig, created_at as createdAt, updated_at as updatedAt - FROM quizzes - WHERE share_token = ? AND is_shared = 1 + SELECT + q.id, q.title, q.source, q.ai_topic as aiTopic, q.game_config as gameConfig, + q.created_at as createdAt, q.updated_at as updatedAt, + u.username as sharedByUsername, u.display_name as sharedByDisplayName + FROM quizzes q + LEFT JOIN users u ON q.user_id = u.id + WHERE q.share_token = ? AND q.is_shared = 1 `).get(token) as QuizRow | undefined; if (!quiz) { @@ -86,6 +92,7 @@ router.get('/:token', (req: Request, res: Response) => { gameConfig: parsedConfig, questions: questionsWithOptions, questionCount: questions.length, + sharedBy: quiz.sharedByDisplayName || quiz.sharedByUsername || null, }); });