Skip to content

Commit

Permalink
Updated project’s file and folder names to follow consistent naming c…
Browse files Browse the repository at this point in the history
…onventions
  • Loading branch information
emmanueposu committed May 31, 2024
1 parent 52ecaf2 commit 494ee4e
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 99 deletions.
16 changes: 8 additions & 8 deletions trivia-forge/frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useState } from 'react';
import './App.css';
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Home from "./Pages/HomePage";
import Navigation from "./Components/Nav";
import TriviaGenPage from './Pages/TriviaGenPage';
import TriviaReviewPage from './Pages/TriviaReviewPage';
import MyTrivia from './Pages/MyTrivia';
import LoginPage from './Pages/LoginPage';
import SignUpPage from './Pages/SignUpPage';
import Home from "./pages/homePage";
import Navigation from "./components/Navigation";
import TriviaGenPage from './pages/triviaGenPage';
import TriviaReviewPage from './pages/triviaReviewPage';
import MyTriviaPage from './pages/myTriviaPage';
import LoginPage from './pages/loginPage';
import SignUpPage from './pages/signUpPage';
import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';

Expand All @@ -28,7 +28,7 @@ function App() {
<Route path="/" element={<Home />} />
<Route path="/triviaGen" element={<TriviaGenPage />} />
<Route path="/review" element={<TriviaReviewPage />} />
<Route path="/myTrivia" element={<MyTrivia />} />
<Route path="/myTrivia" element={<MyTriviaPage />} />
<Route path="/signUp" element={<SignUpPage />} />
<Route path="/login" element={<LoginPage />} />
</Routes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Button from 'react-bootstrap/Button';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Tooltip from 'react-bootstrap/Tooltip';

function GenBtnTooltip() {
function GenerateButtonTooltip() {
return (
<OverlayTrigger overlay={<Tooltip id="tooltip-disabled">Log in to generate a game.</Tooltip>}>
<span className="d-inline-block">
Expand All @@ -14,4 +14,4 @@ function GenBtnTooltip() {
);
};

export default GenBtnTooltip;
export default GenerateButtonTooltip;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Navbar } from "react-bootstrap";
import { Nav, Button} from "react-bootstrap";
import { useNavigate } from "react-router-dom";
import useStore from './useStore';
import useStore from '../hooks/useStore';

function Navigation() {
const currentUser = useStore(state => state.currentUser);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { React} from "react";

function GameQuestions(game) {
function QuestionsCount(game) {
let categories = game?.data.categories || [];
function questionCount() {
let count = 0;
Expand All @@ -17,4 +17,4 @@ function GameQuestions(game) {
)
}

export default GameQuestions;
export default QuestionsCount;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import Questions from "../Components/Questions";
import ReviewQuestions from "../components/ReviewQuestions";

function Categories({ category, index, changeValue, isMultipleChoice }) {
function ReviewCategories({ category, index, changeValue, isMultipleChoice }) {
let questions = category.questions;
const path = ['categories', index];

Expand All @@ -10,10 +10,10 @@ function Categories({ category, index, changeValue, isMultipleChoice }) {
<h2>{category.title || category.name}</h2>
{questions.map((question, index) => {
return (
<Questions key={index} data={question} path={path} index={index} changeValue={changeValue} isMultipleChoice={isMultipleChoice}/>
<ReviewQuestions key={index} data={question} path={path} index={index} changeValue={changeValue} isMultipleChoice={isMultipleChoice}/>
);
})}
</div>
);
}
export default Categories;
export default ReviewCategories;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";


function Choices({ data, path, index, changeValue }) {
function ReviewChoices({ data, path, index, changeValue }) {
let newPath = structuredClone(path)
newPath.push('choices', index)

Expand All @@ -11,4 +11,4 @@ function Choices({ data, path, index, changeValue }) {
</div>
);
}
export default Choices;
export default ReviewChoices;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";
import Choices from "../Components/Choices";
import ReviewChoices from "../components/ReviewChoices";
import { Card } from "react-bootstrap";

import { Question } from "../Models/Question";
import { Question } from "../models/question";
//logic for button to generate new question
//
//
Expand All @@ -11,25 +11,26 @@ import { Question } from "../Models/Question";



function Questions({ data, path, index, changeValue, isMultipleChoice }) {
function ReviewQuestions({ data, path, index, changeValue, isMultipleChoice }) {
let choices = data.choices;
let newPath = structuredClone(path)
newPath.push('questions', index)
let newPath = structuredClone(path);
const key = data.problem ? "problem" : "question";
newPath.push('questions', index);

return (
<div>
<Card className="CardPadding">
<h2 className="centered">Question</h2>
{/* //Button to generate new question somewhere in here */}
<div className="card-body">
<textarea className="form-control" defaultValue={data.problem || data.question} onChange={(e) => {changeValue(newPath, "problem", e.target.value)}}></textarea>
<textarea className="form-control" defaultValue={data.problem || data.question} onChange={(e) => {changeValue(newPath, key, e.target.value)}}></textarea>
</div>
{isMultipleChoice && (
<>
<h2>Choices</h2>
{choices.map((choice, index) => {
return (
<Choices key={index} data={choice} path={newPath} index={index} changeValue={changeValue}/>
<ReviewChoices key={index} data={choice} path={newPath} index={index} changeValue={changeValue}/>
);
})}
</>
Expand All @@ -47,4 +48,4 @@ function Questions({ data, path, index, changeValue, isMultipleChoice }) {
</div >
)
}
export default Questions;
export default ReviewQuestions;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { React} from "react";

function GameCategories(game) {
function UnorderedCategoriesList(game) {
const categories = game.data.categories;

return (
Expand All @@ -14,4 +14,4 @@ function GameCategories(game) {
)
}

export default GameCategories;
export default UnorderedCategoriesList;
29 changes: 0 additions & 29 deletions trivia-forge/frontend/src/Models/State.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion trivia-forge/frontend/src/Pages/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions trivia-forge/frontend/src/Pages/LoginPage.jsx
Original file line number Diff line number Diff line change
@@ -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('');
Expand Down
4 changes: 2 additions & 2 deletions trivia-forge/frontend/src/Pages/SignUpPage.jsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions trivia-forge/frontend/src/Pages/TriviaGenPage.jsx
Original file line number Diff line number Diff line change
@@ -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";



Expand Down Expand Up @@ -243,7 +243,7 @@ function TriviaGenPage() {
{submitBtnLabel}
</Button>
) : (
<GenBtnTooltip />
<GenerateButtonTooltip />
)}
</div>
</form >
Expand Down
12 changes: 7 additions & 5 deletions trivia-forge/frontend/src/Pages/TriviaReviewPage.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import { useLocation } from 'react-router-dom'; // used to access passed state
import Categories from '../Components/Categories';
import ReviewCategories from '../components/ReviewCategories';
import { Button } from 'react-bootstrap';
import { AddAllForGame, UpdateAllForGame } from '../Services/Services';
import { AddAllForGame, UpdateAllForGame } from '../services/saveGameService';
import { useNavigate } from "react-router-dom";
import useStore from '../Components/useStore';
import useStore from '../hooks/useStore';
import '../App.css';

function TriviaReviewPage() {
Expand All @@ -15,6 +15,7 @@ function TriviaReviewPage() {
let categories = game.categories;
const navigate = useNavigate();
const updateGame = useStore(state => state.updateGame);
const addGame = useStore(state => state.updateGame);

console.log(game)

Expand All @@ -25,9 +26,10 @@ function TriviaReviewPage() {
};

const HandleCreateGame = async () => {
// console.log("new:", game)
// addGame(game);
await AddAllForGame(game);
navigate('/myTrivia');

};

function changeValue(path, key, value) {
Expand All @@ -53,7 +55,7 @@ function TriviaReviewPage() {
<div key={index} className="category-container">
<label className="input-label">Category Name:</label>
<input type="text" className="input-field" value={cat.title || cat.name} readOnly />
<Categories category={cat} index={index} changeValue={changeValue} isMultipleChoice={isMultipleChoice}/>
<ReviewCategories category={cat} index={index} changeValue={changeValue} isMultipleChoice={isMultipleChoice}/>
</div>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { React, useState, useEffect } from "react";
import { getGames, getGamesWithDetails, deleteGame } from "../Services/TF-db_services";
import { getGames, getGamesWithDetails, deleteGame } from "../services/triviaForgeApiService";
import Card from 'react-bootstrap/Card';
import Col from 'react-bootstrap/Col';
import Row from 'react-bootstrap/Row';
import Button from 'react-bootstrap/Button';
import Spinner from 'react-bootstrap/Spinner';
import GameCategories from "../Components/GameCategories";
import GameQuestions from "../Components/GameQuestions";
import Slideshow from "../Components/Slideshow";
import UnorderedCategoriesList from "../components/UnorderedCategoriesList";
import QuestionsCount from "../components/QuestionsCount";
import Slideshow from "../components/Slideshow";
import Modal from 'react-bootstrap/Modal';
import { Link, useNavigate } from "react-router-dom";
import useStore from '../Components/useStore';
import useStore from '../hooks/useStore';

function MyTrivia() {
function MyTriviaPage() {
// const [games, setGames] = useState(null); // store list of games
const [showGame, setShowGame] = useState(false); // visibility of game modal

Expand Down Expand Up @@ -51,7 +51,7 @@ function MyTrivia() {
console.log("loaded:", loaded)
if (currentUser && loaded === false) {
setLoaded(true);
//console.log("calling getGamesWithDetails");
console.log("calling getGamesWithDetails");
getGamesWithDetails(currentUser.id).then(res => {
setSpinnerDisplay("none")
if (res.length > 0) {
Expand Down Expand Up @@ -111,11 +111,11 @@ function MyTrivia() {
<Card.Body>
<Card.Title as="h6">Categories:</Card.Title>
<Card.Text>
<GameCategories data={game} />
<UnorderedCategoriesList data={game} />
</Card.Text>
<Card.Title as="h6">Questions:</Card.Title>
<Card.Text>
<GameQuestions data={game} />
<QuestionsCount data={game} />
</Card.Text>
<div className="text-center">
<Button onClick={() => handleGameShow(game)} variant="success">Play</Button>
Expand Down Expand Up @@ -160,4 +160,4 @@ function MyTrivia() {
);
};

export default MyTrivia;
export default MyTriviaPage;
Loading

0 comments on commit 494ee4e

Please sign in to comment.