Add user name to share screen
This commit is contained in:
parent
b2e0cdf3d5
commit
7a83557dc9
2 changed files with 14 additions and 4 deletions
|
|
@ -16,6 +16,7 @@ interface SharedQuizData {
|
||||||
gameConfig: GameConfig | null;
|
gameConfig: GameConfig | null;
|
||||||
questions: Question[];
|
questions: Question[];
|
||||||
questionCount: number;
|
questionCount: number;
|
||||||
|
sharedBy?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SharedQuizViewProps {
|
interface SharedQuizViewProps {
|
||||||
|
|
@ -156,7 +157,9 @@ export const SharedQuizView: React.FC<SharedQuizViewProps> = ({ onHostQuiz, shar
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="text-center mb-6">
|
<div className="text-center mb-6">
|
||||||
<p className="text-gray-400 font-bold text-sm uppercase tracking-wider mb-1">Shared Quiz</p>
|
<p className="text-gray-400 font-bold text-sm uppercase tracking-wider mb-1">
|
||||||
|
{quizData.sharedBy ? `Shared by ${quizData.sharedBy}` : 'Shared Quiz'}
|
||||||
|
</p>
|
||||||
<h1 className="text-3xl md:text-4xl font-black text-gray-800 mb-2">{quizData.title}</h1>
|
<h1 className="text-3xl md:text-4xl font-black text-gray-800 mb-2">{quizData.title}</h1>
|
||||||
<p className="text-gray-500 font-medium">
|
<p className="text-gray-500 font-medium">
|
||||||
{quizData.questionCount} question{quizData.questionCount !== 1 ? 's' : ''}
|
{quizData.questionCount} question{quizData.questionCount !== 1 ? 's' : ''}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ interface QuizRow {
|
||||||
gameConfig: string | null;
|
gameConfig: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
|
sharedByUsername: string | null;
|
||||||
|
sharedByDisplayName: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface QuestionRow {
|
interface QuestionRow {
|
||||||
|
|
@ -36,9 +38,13 @@ router.get('/:token', (req: Request, res: Response) => {
|
||||||
const { token } = req.params;
|
const { token } = req.params;
|
||||||
|
|
||||||
const quiz = db.prepare(`
|
const quiz = db.prepare(`
|
||||||
SELECT id, title, source, ai_topic as aiTopic, game_config as gameConfig, created_at as createdAt, updated_at as updatedAt
|
SELECT
|
||||||
FROM quizzes
|
q.id, q.title, q.source, q.ai_topic as aiTopic, q.game_config as gameConfig,
|
||||||
WHERE share_token = ? AND is_shared = 1
|
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;
|
`).get(token) as QuizRow | undefined;
|
||||||
|
|
||||||
if (!quiz) {
|
if (!quiz) {
|
||||||
|
|
@ -86,6 +92,7 @@ router.get('/:token', (req: Request, res: Response) => {
|
||||||
gameConfig: parsedConfig,
|
gameConfig: parsedConfig,
|
||||||
questions: questionsWithOptions,
|
questions: questionsWithOptions,
|
||||||
questionCount: questions.length,
|
questionCount: questions.length,
|
||||||
|
sharedBy: quiz.sharedByDisplayName || quiz.sharedByUsername || null,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue