Add user name to share screen
This commit is contained in:
parent
b2e0cdf3d5
commit
7a83557dc9
2 changed files with 14 additions and 4 deletions
|
|
@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue