From f3ebeae9c6c72f907580abb63df1abec281696c6 Mon Sep 17 00:00:00 2001 From: emmanueposu Date: Thu, 30 May 2024 04:12:18 -0700 Subject: [PATCH] Updated HandleSaveGame function on TriviaReviewPage to be asynchronous --- .../frontend/src/Pages/TriviaReviewPage.jsx | 4 ++-- .../frontend/src/Services/Services.jsx | 22 ------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/trivia-forge/frontend/src/Pages/TriviaReviewPage.jsx b/trivia-forge/frontend/src/Pages/TriviaReviewPage.jsx index 2b028a1..8dd7765 100644 --- a/trivia-forge/frontend/src/Pages/TriviaReviewPage.jsx +++ b/trivia-forge/frontend/src/Pages/TriviaReviewPage.jsx @@ -18,9 +18,9 @@ function TriviaReviewPage() { console.log(game) - const HandleSaveGame = () => { - UpdateAllForGame(game); + const HandleSaveGame = async () => { updateGame(game) + await UpdateAllForGame(game); navigate('/myTrivia'); }; diff --git a/trivia-forge/frontend/src/Services/Services.jsx b/trivia-forge/frontend/src/Services/Services.jsx index 419fdf8..3a1a475 100644 --- a/trivia-forge/frontend/src/Services/Services.jsx +++ b/trivia-forge/frontend/src/Services/Services.jsx @@ -1,28 +1,6 @@ import * as db from './TF-db_services'; -import { Game } from '../Models/Game'; -import { Category } from '../Models/Category'; -import { Question } from '../Models/Question'; -import { Choice } from '../Models/Choice'; - -// export const AddAllForGame = async (game) => { -// const newGame = await db.addGame(game); -// game.categories.forEach(async (category) => { -// category.gameID = newGame.id; -// const newCategory = await db.addCategory(category); -// category.questions.forEach(async (question) => { -// console.log("Added Category ID", category.id); -// question.categoryID = newCategory.id; -// const newQuestion = await db.addQuestion(question); -// question.choices.forEach(async (choice) => { -// choice.questionID = newQuestion.id; -// await db.addChoice(choice); -// }); -// }); -// }); -// return newGame; -// } export const AddAllForGame = async (game) => { try { // Add the game to the database