From 9e51a45233337bb02990ebd77bf60ee11f499792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cadenas?= <77900120+andrrsin@users.noreply.github.com> Date: Fri, 15 Mar 2024 01:31:10 +0100 Subject: [PATCH 1/2] Warning removal and correct extensions --- webapp/public/index.html | 47 ++++++++++--------- webapp/public/manifest.json | 4 +- webapp/src/App.jsx | 39 ++------------- .../components/{AddUser.js => AddUser.jsx} | 0 webapp/src/components/{Login.js => Login.jsx} | 0 5 files changed, 32 insertions(+), 58 deletions(-) rename webapp/src/components/{AddUser.js => AddUser.jsx} (100%) rename webapp/src/components/{Login.js => Login.jsx} (100%) diff --git a/webapp/public/index.html b/webapp/public/index.html index 5f84e37..0923e97 100644 --- a/webapp/public/index.html +++ b/webapp/public/index.html @@ -1,21 +1,24 @@ - - - - - - - - - - - WIQ - - - -
- - - + + + \ No newline at end of file diff --git a/webapp/public/manifest.json b/webapp/public/manifest.json index 080d6c7..9c6df9d 100644 --- a/webapp/public/manifest.json +++ b/webapp/public/manifest.json @@ -1,6 +1,6 @@ { - "short_name": "React App", - "name": "Create React App Sample", + "short_name": "WIQ", + "name": "WIQ by HappySW", "icons": [ { "src": "favicon.ico", diff --git a/webapp/src/App.jsx b/webapp/src/App.jsx index 4547e92..d967959 100644 --- a/webapp/src/App.jsx +++ b/webapp/src/App.jsx @@ -1,25 +1,16 @@ -import React, { useState } from 'react'; +import React from 'react'; import {BrowserRouter, Routes, Route} from 'react-router-dom' import AddUser from './components/AddUser'; import Navbar from './components/Navbar'; import Login from './components/Login'; import Rankings from './components/Rankings'; -import CssBaseline from '@mui/material/CssBaseline'; -import Container from '@mui/material/Container'; -import Typography from '@mui/material/Typography'; -import Link from '@mui/material/Link'; -import { useEffect } from 'react'; -import axios from 'axios'; import Game from './components/Game'; -import useAuthUser from 'react-auth-kit/hooks/useAuthUser'; -import useIsAuthenticated from 'react-auth-kit/hooks/useIsAuthenticated' import MainPage from './components/MainPage'; function App() { - const [showLogin, setShowLogin] = useState(true); - const [user, setUser] = useState({}); - const isAuthenticated = useIsAuthenticated() - const auth = useAuthUser(); + // const isAuthenticated = useIsAuthenticated() // True if user has logged in + // const auth = useAuthUser(); // User data: {username,emial,createdAt} To add fields go to Login + // IDK how it works @@ -34,28 +25,6 @@ function App() { } /> - - - - - /* - - - Welcome to the 2024 edition of the Software Architecture course hola - - {showLogin ? : } - - {showLogin ? ( - - Don't have an account? Register here. - - ) : ( - - Already have an account? Login here. - - )} - - */ ) } diff --git a/webapp/src/components/AddUser.js b/webapp/src/components/AddUser.jsx similarity index 100% rename from webapp/src/components/AddUser.js rename to webapp/src/components/AddUser.jsx diff --git a/webapp/src/components/Login.js b/webapp/src/components/Login.jsx similarity index 100% rename from webapp/src/components/Login.js rename to webapp/src/components/Login.jsx From 2d1f3084f597b01fb2eb35e8a8c98f00fc6745f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cadenas?= <77900120+andrrsin@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:40:41 +0100 Subject: [PATCH 2/2] fix #68 and #69 --- users/authservice/auth-service.js | 2 +- users/userservice/user-service.js | 2 +- webapp/src/components/Game.jsx | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/users/authservice/auth-service.js b/users/authservice/auth-service.js index fb2b1bd..c6a21df 100644 --- a/users/authservice/auth-service.js +++ b/users/authservice/auth-service.js @@ -11,7 +11,7 @@ const port = 8002; app.use(express.json()); // Connect to MongoDB -const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; +const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/wiq-en1a-users'; mongoose.connect(mongoUri); // Function to validate required fields in the request body diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index bfb7912..85d43c8 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -13,7 +13,7 @@ const port = 8001; app.use(bodyParser.json()); // Connect to MongoDB -const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; +const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/wiq-en1a-users'; mongoose.connect(mongoUri); diff --git a/webapp/src/components/Game.jsx b/webapp/src/components/Game.jsx index 0572206..e19e95b 100644 --- a/webapp/src/components/Game.jsx +++ b/webapp/src/components/Game.jsx @@ -12,17 +12,15 @@ const Game = () => { const startGame = () => { setGameStarted(!gameStarted); }; - useEffect(() => { - if(isAuthenticated()===false) { - navigate('/login'); + if (!isAuthenticated()) { + navigate("/login"); } - } - , [isAuthenticated]); + }, [isAuthenticated, navigate]); return (
- {gameStarted ? ( + {isAuthenticated()?gameStarted ? ( ) : (
@@ -32,7 +30,7 @@ const Game = () => { Play
- )} + ):""}
) };