@@ -22,14 +23,14 @@ function Questions({ data, path, index, changeValue, isMultipleChoice }) {
Question
{/* //Button to generate new question somewhere in here */}
-
+
{isMultipleChoice && (
<>
Choices
{choices.map((choice, index) => {
return (
-
+
);
})}
>
@@ -47,4 +48,4 @@ function Questions({ data, path, index, changeValue, isMultipleChoice }) {
)
}
-export default Questions;
\ No newline at end of file
+export default ReviewQuestions;
\ No newline at end of file
diff --git a/trivia-forge/frontend/src/Components/GameCategories.jsx b/trivia-forge/frontend/src/Components/UnorderedCategoriesList.jsx
similarity index 79%
rename from trivia-forge/frontend/src/Components/GameCategories.jsx
rename to trivia-forge/frontend/src/Components/UnorderedCategoriesList.jsx
index b590dbec..c4562a5c 100644
--- a/trivia-forge/frontend/src/Components/GameCategories.jsx
+++ b/trivia-forge/frontend/src/Components/UnorderedCategoriesList.jsx
@@ -1,6 +1,6 @@
import { React} from "react";
-function GameCategories(game) {
+function UnorderedCategoriesList(game) {
const categories = game.data.categories;
return (
@@ -14,4 +14,4 @@ function GameCategories(game) {
)
}
-export default GameCategories;
+export default UnorderedCategoriesList;
diff --git a/trivia-forge/frontend/src/Models/State.jsx b/trivia-forge/frontend/src/Models/State.jsx
deleted file mode 100644
index 675bd747..00000000
--- a/trivia-forge/frontend/src/Models/State.jsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { create } from 'zustand';
-
-const useStore = create((set) => ({
- currentUser: null,
- userGames: [],
- currentGame: null,
-
- setCurrentUser: (user) => set({ currentUser: user }),
- setUserGames: (games) => set({ userGames: games }),
- setCurrentGame: (game) => set({ currentGame: game }),
-
- addGame: (game) => set((state) => ({
- userGames: [...state.userGames, game],
- })),
- updateGame: (game) => set((state) => ({
- userGames: state.userGames.map((g) => {
- if (g.id === game.id) {
- return game;
- }
- return g;
- }),
- })),
- deleteGame: (game) => set((state) => ({
- userGames: state.userGames.filter((g) => g.id !== game.id),
- })),
-}));
-
-
-export default useStore;
\ No newline at end of file
diff --git a/trivia-forge/frontend/src/Pages/HomePage.jsx b/trivia-forge/frontend/src/Pages/HomePage.jsx
index 1d4cfcde..8407fec5 100644
--- a/trivia-forge/frontend/src/Pages/HomePage.jsx
+++ b/trivia-forge/frontend/src/Pages/HomePage.jsx
@@ -3,7 +3,7 @@ import { Button, Container, Row, Col} from 'react-bootstrap';
import '../App.css';
import { FaRegFolderOpen, FaPlusCircle, FaUserCircle, FaUserPlus } from "react-icons/fa";
import { useNavigate } from 'react-router-dom';
-import useStore from "../Components/useStore";
+import useStore from "../hooks/useStore";
function Home() {
const navigate = useNavigate();
diff --git a/trivia-forge/frontend/src/Pages/LoginPage.jsx b/trivia-forge/frontend/src/Pages/LoginPage.jsx
index 22c97b0e..00387c12 100644
--- a/trivia-forge/frontend/src/Pages/LoginPage.jsx
+++ b/trivia-forge/frontend/src/Pages/LoginPage.jsx
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { Link, useNavigate } from "react-router-dom";
import { Form, Button, Card } from "react-bootstrap";
-import { getUser, getGames } from '../Services/TF-db_services';
-import useStore from '../Components/useStore';
+import { getUser, getGames } from '../services/triviaForgeApiService';
+import useStore from '../hooks/useStore';
function LoginPage() {
const [email, setEmail] = useState('');
diff --git a/trivia-forge/frontend/src/Pages/SignUpPage.jsx b/trivia-forge/frontend/src/Pages/SignUpPage.jsx
index 939cf331..0c7fd9a8 100644
--- a/trivia-forge/frontend/src/Pages/SignUpPage.jsx
+++ b/trivia-forge/frontend/src/Pages/SignUpPage.jsx
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { useNavigate } from "react-router-dom";
import { Form, Button, Card } from "react-bootstrap";
-import { addUser } from '../Services/TF-db_services';
-import { User } from '../Models/User';
+import { addUser } from '../services/triviaForgeApiService';
+import { User } from '../models/user';
function SignUpPage() {
// initialize variables as empty strings
diff --git a/trivia-forge/frontend/src/Pages/TriviaGenPage.jsx b/trivia-forge/frontend/src/Pages/TriviaGenPage.jsx
index e4f74dc6..98f0125a 100644
--- a/trivia-forge/frontend/src/Pages/TriviaGenPage.jsx
+++ b/trivia-forge/frontend/src/Pages/TriviaGenPage.jsx
@@ -1,15 +1,15 @@
import React, { useState } from "react"; // variables that cause the component to re-render when they change
import OpenAI from "openai";
-import { Game } from "../Models/Game";
+import { Game } from "../models/game";
import { useNavigate } from "react-router-dom";
-import { Question } from "../Models/Question";
-import { Choice } from "../Models/Choice";
-import { Category } from "../Models/Category";
+import { Question } from "../models/question";
+import { Choice } from "../models/choice";
+import { Category } from "../models/category";
import { Card } from "react-bootstrap";
-import useStore from '../Components/useStore'; // global state management
+import useStore from '../hooks/useStore'; // global state management
import Spinner from 'react-bootstrap/Spinner';
import Button from 'react-bootstrap/Button';
-import GenBtnTooltip from "../Components/GenBtnTooltip";
+import GenerateButtonTooltip from "../components/GenerateButtonTooltip";
@@ -243,7 +243,7 @@ function TriviaGenPage() {
{submitBtnLabel}
) : (
-
Categories:
-
+
Questions:
-
+
@@ -160,4 +160,4 @@ function MyTrivia() {
);
};
-export default MyTrivia;
\ No newline at end of file
+export default MyTriviaPage;
\ No newline at end of file
diff --git a/trivia-forge/frontend/src/Components/useStore.jsx b/trivia-forge/frontend/src/hooks/useStore.jsx
similarity index 100%
rename from trivia-forge/frontend/src/Components/useStore.jsx
rename to trivia-forge/frontend/src/hooks/useStore.jsx
diff --git a/trivia-forge/frontend/src/Services/Services.jsx b/trivia-forge/frontend/src/services/saveGameService.jsx
similarity index 78%
rename from trivia-forge/frontend/src/Services/Services.jsx
rename to trivia-forge/frontend/src/services/saveGameService.jsx
index 3a1a4755..dedcd844 100644
--- a/trivia-forge/frontend/src/Services/Services.jsx
+++ b/trivia-forge/frontend/src/services/saveGameService.jsx
@@ -1,32 +1,32 @@
-import * as db from './TF-db_services';
+import * as api from './triviaForgeApiService';
export const AddAllForGame = async (game) => {
try {
// Add the game to the database
//console.log("Adding game:", game);
- const newGame = await db.addGame(game);
+ const newGame = await api.addGame(game);
//console.log("Added game with ID:", newGame.id);
// Process each category in the game's categories
for (const category of game.categories) {
category.gameID = newGame.id; // Link category to the game
//console.log("Adding category:", category);
- const newCategory = await db.addCategory(category);
+ const newCategory = await api.addCategory(category);
//console.log("Added category with ID:", newCategory.id);
// Process each question in the category's questions
for (const question of category.questions) {
question.categoryID = newCategory.id; // Link question to the category
//console.log("Adding question:", question);
- const newQuestion = await db.addQuestion(question);
+ const newQuestion = await api.addQuestion(question);
//console.log("Added question with ID:", newQuestion.id);
// Process each choice in the question's choices
for (const choice of question.choices) {
choice.questionID = newQuestion.id; // Link choice to the question
//console.log("Adding choice:", choice);
- const newChoice = await db.addChoice(choice);
+ const newChoice = await api.addChoice(choice);
//console.log("Added choice with ID:", newChoice.id);
}
}
@@ -41,13 +41,13 @@ export const AddAllForGame = async (game) => {
};
export const UpdateAllForGame = async (game) => {
- await db.editGame(game);
+ await api.editGame(game);
game.categories.forEach(async (category) => {
- await db.editCategory(category);
+ await api.editCategory(category);
category.questions.forEach(async (question) => {
- await db.editQuestion(question);
+ await api.editQuestion(question);
question.choices.forEach(async (choice) => {
- await db.editChoice(choice);
+ await api.editChoice(choice);
});
});
});
diff --git a/trivia-forge/frontend/src/Services/TF-db_services.jsx b/trivia-forge/frontend/src/services/triviaForgeApiService.jsx
similarity index 97%
rename from trivia-forge/frontend/src/Services/TF-db_services.jsx
rename to trivia-forge/frontend/src/services/triviaForgeApiService.jsx
index 7716b0f5..54d15e1f 100644
--- a/trivia-forge/frontend/src/Services/TF-db_services.jsx
+++ b/trivia-forge/frontend/src/services/triviaForgeApiService.jsx
@@ -1,9 +1,9 @@
import axios from 'axios';
-import { User } from '../Models/User';
-import { Game } from '../Models/Game';
-import { Question } from '../Models/Question';
-import { Category } from '../Models/Category';
-import { Choice } from '../Models/Choice';
+import { User } from '../models/user';
+import { Game } from '../models/game';
+import { Question } from '../models/question';
+import { Category } from '../models/category';
+import { Choice } from '../models/choice';
const API_URL = 'http://127.0.0.1:5000';