Skip to content

Commit

Permalink
fix: minor issues due to the merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jjgancfer committed Apr 19, 2024
1 parent 3d4054e commit 7eb7b29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions webapp/src/components/dashboard/CustomGameMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ const CustomGameMenu = ({ isOpen, onClose }) => {
async function fetchCategories() {
try {
let lang = i18n.language;
if (lang.includes("en"))
if (lang.includes("en")) {
lang = "en";
else if (lang.includes("es"))
} else if (lang.includes("es")) {
lang = "es"
else
} else {
lang = "en";
const categoriesData = await gameCategories(lang);
}

const categoriesData = (await gameCategories(lang)).data;
const formattedCategories = categoriesData.map(category => category.name);
setCategories(formattedCategories);
} catch (error) {
Expand All @@ -49,26 +51,30 @@ const CustomGameMenu = ({ isOpen, onClose }) => {
const initializeCustomGameMode = async () => {
try {
let lang = i18n.language;
if (lang.includes("en"))
if (lang.includes("en")) {
lang = "en";
else if (lang.includes("es"))
} else if (lang.includes("es")) {
lang = "es"
else
} else {
lang = "en";
}

const gamemode = 'CUSTOM';
let uppercaseCategories = selectedCategories.map(category => category.toUpperCase());
if (uppercaseCategories.length === 0)
if (uppercaseCategories.length === 0) {
uppercaseCategories = ["GEOGRAPHY", "SPORTS", "MUSIC", "ART", "VIDEOGAMES"];
}

const customGameDto = {
rounds: rounds,
categories: uppercaseCategories,
round_duration: time

}
const newGameResponse = await newGame(lang, gamemode, customGameDto);
if (newGameResponse)
if (newGameResponse) {
navigate("/dashboard/game");
}
} catch (error) {
console.error("Error initializing game:", error);
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/pages/Game.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default function Game() {
const result = await answerQuestion(gameId, answer.id);
let isCorrect = result.data.was_correct;
if (isCorrect) {
setCorrectAnswers(correctAnswers + (isCorrect ? 1 : 0));
setCorrectAnswers(correctAnswers + 1);
setShowConfetti(true);
}
setNextDisabled(true);
Expand Down

0 comments on commit 7eb7b29

Please sign in to comment.