Skip to content

Commit

Permalink
fix al centro
Browse files Browse the repository at this point in the history
  • Loading branch information
pesto13 committed Nov 3, 2024
1 parent ee70b47 commit 63e5b9c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Scoprimi/src/components/newGame/NewGameModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export enum ModalUse {

const BottomGameModal: React.FC<NewGameModalProps> = ({ isOpen, onClose, playerName, image, modalUse }) => {
const [gameLenght, setGameLenght] = useState<string>('Corta');
const [numQuestions, setNumQuestions] = useState(5);
const [categories, setCategories] = useState<string[]>([]);
const [selectedCategories, setSelectedCategories] = useState<boolean[]>([]);
const [showAlert, setShowAlert] = useState<boolean>(false);
Expand Down Expand Up @@ -86,9 +85,6 @@ const BottomGameModal: React.FC<NewGameModalProps> = ({ isOpen, onClose, playerN
setShowAlert(true);
return;
}
if (modalUse === ModalUse.new) {
const code = generateLobbyCode();

let numberOfQuestion: number;
switch (gameLenght) {
case 'Corta':
Expand All @@ -102,9 +98,12 @@ const BottomGameModal: React.FC<NewGameModalProps> = ({ isOpen, onClose, playerN
numberOfQuestion = 30;
}

socket.emit(SocketEvents.CREATE_LOBBY, { code, numQuestionsParam: numberOfQuestion, categories: selected, admin: currentPlayer });
if (modalUse === ModalUse.new) {
const code = generateLobbyCode();

socket.emit(SocketEvents.CREATE_LOBBY, { code, numQuestionsParam: numberOfQuestion, categories: selected, admin: currentPlayer });
} else if (modalUse === ModalUse.modify) {
socket.emit(SocketEvents.MODIFY_GAME_CONFIG, { code: currentLobby, numQuestionsParam: numQuestions, categories: selected });
socket.emit(SocketEvents.MODIFY_GAME_CONFIG, { code: currentLobby, numQuestionsParam: numberOfQuestion, categories: selected });
}
onClose();
};
Expand Down

0 comments on commit 63e5b9c

Please sign in to comment.