From f2fab13260cbef2e29741a70bea22da6efc5064a Mon Sep 17 00:00:00 2001 From: David Vicente Date: Fri, 29 Mar 2024 21:17:10 +0100 Subject: [PATCH] Question tags in creation menu and model --- .../QuestionCreator/ChoiceQuestionCreator.tsx | 22 ++++------- .../CompleteQuestionCreator.tsx | 18 +++------ .../QuestionCreator/SimpleQuestionCreator.tsx | 15 +++----- src/pages/game/GameController.tsx | 3 +- src/pages/game/LobbyPlayers.tsx | 2 - src/services/games-store.ts | 21 +++++++++- src/services/questions-store.ts | 38 ++++++++++--------- src/utils/types.ts | 4 +- src/utils/utils.ts | 5 ++- 9 files changed, 67 insertions(+), 61 deletions(-) diff --git a/src/pages/QuestionCreator/ChoiceQuestionCreator.tsx b/src/pages/QuestionCreator/ChoiceQuestionCreator.tsx index abfc6e1..0dae66b 100644 --- a/src/pages/QuestionCreator/ChoiceQuestionCreator.tsx +++ b/src/pages/QuestionCreator/ChoiceQuestionCreator.tsx @@ -6,12 +6,14 @@ export const ChoiceQuestionCreator = () => { const [title, setTitle] = useState("") const [choices, setChoices] = useState("") const [answers, setAnswers] = useState("") + const [tags, setTags] = useState("") const createQuestionHandler = () => { const question = { title, - choices: splitAndTrim(choices, ","), - answers: splitAndTrim(answers, ","), + choices: splitAndTrim(choices), + answers: splitAndTrim(answers), + tags: splitAndTrim(tags), ...initializeEmptyQuestionFields(), } @@ -20,18 +22,10 @@ export const ChoiceQuestionCreator = () => { return (
- setTitle(e.target.value)} - /> - setChoices(e.target.value)} - /> - setAnswers(e.target.value)} - /> + setTitle(e.target.value)} /> + setChoices(e.target.value)} /> + setAnswers(e.target.value)} /> + setTags(e.target.value)} />
) diff --git a/src/pages/QuestionCreator/CompleteQuestionCreator.tsx b/src/pages/QuestionCreator/CompleteQuestionCreator.tsx index 69525b8..cdded32 100644 --- a/src/pages/QuestionCreator/CompleteQuestionCreator.tsx +++ b/src/pages/QuestionCreator/CompleteQuestionCreator.tsx @@ -6,12 +6,14 @@ export const CompleteQuestionCreator = () => { const [title, setTitle] = useState("") const [description, setDescription] = useState("") const [answers, setAnswers] = useState("") + const [tags, setTags] = useState("") const createQuestionHandler = () => { const question = { title, description, answers: splitAndTrim(answers, ","), + tags: splitAndTrim(tags), ...initializeEmptyQuestionFields(), } @@ -20,18 +22,10 @@ export const CompleteQuestionCreator = () => { return (
- setTitle(e.target.value)} - /> - setDescription(e.target.value)} - /> - setAnswers(e.target.value)} - /> + setTitle(e.target.value)} /> + setDescription(e.target.value)} /> + setAnswers(e.target.value)} /> + setTags(e.target.value)} />
) diff --git a/src/pages/QuestionCreator/SimpleQuestionCreator.tsx b/src/pages/QuestionCreator/SimpleQuestionCreator.tsx index 9c087c7..74fd156 100644 --- a/src/pages/QuestionCreator/SimpleQuestionCreator.tsx +++ b/src/pages/QuestionCreator/SimpleQuestionCreator.tsx @@ -5,11 +5,13 @@ import { initializeEmptyQuestionFields, splitAndTrim } from "../../utils/utils" export const SimpleQuestionCreator = () => { const [title, setTitle] = useState("") const [answers, setAnswers] = useState("") + const [tags, setTags] = useState("") const createQuestionHandler = () => { const question = { title, - answers: splitAndTrim(answers, ","), + answers: splitAndTrim(answers), + tags: splitAndTrim(tags), ...initializeEmptyQuestionFields(), } @@ -18,14 +20,9 @@ export const SimpleQuestionCreator = () => { return (
- setTitle(e.target.value)} - /> - setAnswers(e.target.value)} - /> + setTitle(e.target.value)} /> + setAnswers(e.target.value)} /> + setTags(e.target.value)} />
) diff --git a/src/pages/game/GameController.tsx b/src/pages/game/GameController.tsx index b7709db..08ae002 100644 --- a/src/pages/game/GameController.tsx +++ b/src/pages/game/GameController.tsx @@ -65,6 +65,7 @@ export const GameController = () => { setQuestionIndex(game.questionIndex) } }) + // eslint-disable-next-line react-hooks/exhaustive-deps }, []) if (gameId === undefined) { @@ -82,7 +83,7 @@ export const GameController = () => {

Nouvelle partie

- +
)} diff --git a/src/pages/game/LobbyPlayers.tsx b/src/pages/game/LobbyPlayers.tsx index 5968fe9..7925770 100644 --- a/src/pages/game/LobbyPlayers.tsx +++ b/src/pages/game/LobbyPlayers.tsx @@ -1,5 +1,4 @@ type LobbyPlayersProps = { - gameId: string usernames: string[] } @@ -7,7 +6,6 @@ export const LobbyPlayers = (props: LobbyPlayersProps) => { return (

Joueurs

-
Game id : {props.gameId}