+ {question && (
+ {question}
+ )}
-
{loadingMessage && ({loadingMessage})}
{/* Muestra la pregunta y las respuesta si existen */}
- {question && (
-
- Question:
- {question}
-
- )}
- { answers?.map((answer, index) => (
-
+
+
+ {answers?.map((answer, index) => (
+
handleAnswerButtonClick(answer.correct)}
+ variant="contained"
+ fullWidth
+ style={{
+ backgroundColor: buttonColors[index % 4], color: '#ffffff',
+ padding:'0.8em',
+ fontSize:'1.5em',
+ }}
+ onClick={() => handleAnswerButtonClick(answer.correct)}
>
- {answer.answer}
+ {answer.answer}
-
- ))}
+
+ ))}
+
- {/* ... */}
- {category && (
- Category: {category}
- )}
- {type && (
- Type: {type}
- )}
+
{/* ... */}
{
+ return (
+
+
+
+
+
+
+ );
+};
+
+export default Home;
\ No newline at end of file
diff --git a/webapp/src/components/home/home.css b/webapp/src/components/home/home.css
new file mode 100644
index 0000000..d177342
--- /dev/null
+++ b/webapp/src/components/home/home.css
@@ -0,0 +1,14 @@
+body {
+ margin: 0;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
+ sans-serif;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ }
+
+ code {
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
+ monospace;
+ }
+
\ No newline at end of file
diff --git a/webapp/src/components/login/Login.js b/webapp/src/components/login/Login.js
index 95a135e..f717b85 100644
--- a/webapp/src/components/login/Login.js
+++ b/webapp/src/components/login/Login.js
@@ -4,9 +4,15 @@ import axios from 'axios';
import { Container, Typography, TextField, Button, Snackbar } from '@mui/material';
import Game from '../game/Game';
import { AuthContext } from '../authcontext';
+
+import { useNavigate } from 'react-router-dom';
+
const Login = () => {
//hacer que el navbar guarde el contexo de si estas loggeado o no
//ademas metes en localStorage que es como una cookie , el usuario para poder sacar sus datos en historial etc
+
+ const navigate = useNavigate();
+
const{handleLogin}=useContext(AuthContext);
@@ -19,12 +25,19 @@ const Login = () => {
const [createdAt, setCreatedAt] = useState('');
const [openSnackbar, setOpenSnackbar] = useState(false);
+
const apiEndpoint = process.env.REACT_APP_API_URI ||'http://localhost:8000';
useEffect(() => {
if (loginSuccess) {
handleLogin();
localStorage.setItem('username', username);
+
+
+ //REDIRIJIR A LA PAG PRINCIPAL
+
+ navigate('/');
+ console.log(loginSuccess); // Log the value of isLoggedIn after login
}
}, [loginSuccess,username, handleLogin]); // Este efecto se ejecutará cada vez que loginSuccess cambie
@@ -39,6 +52,8 @@ const Login = () => {
setCreatedAt(userCreatedAt);
setLoginSuccess(true);
+
+
setOpenSnackbar(true);
} catch (error) {
setError(error.response.data.error);
diff --git a/webapp/src/components/startbutton/StartButton.js b/webapp/src/components/startbutton/StartButton.js
index 48b944c..631804e 100644
--- a/webapp/src/components/startbutton/StartButton.js
+++ b/webapp/src/components/startbutton/StartButton.js
@@ -6,6 +6,9 @@ const StartButton = () => {
const { isLoggedIn } = useContext(AuthContext);
const navigate = useNavigate();
+ console.log(isLoggedIn); // Log the value of isLoggedIn
+
+
const handleClick = () => {
navigate(isLoggedIn ? "/game" : "/login");
};
diff --git a/webapp/src/index.js b/webapp/src/index.js
index 8bc30f4..3ea19f1 100644
--- a/webapp/src/index.js
+++ b/webapp/src/index.js
@@ -1,53 +1,16 @@
import React from 'react';
-import ReactDOM from 'react-dom/client';
+import ReactDOM from 'react-dom';
import './index.css';
+import App from './App';
import reportWebVitals from './reportWebVitals';
-import Navbar from './components/navbar/NavBar';
-import AddUser from './components/adduser/AddUser';
-import Login from './components/login/Login';
-import { AuthProvider } from './components/authcontext';
-import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
-import CssBaseline from '@mui/material/CssBaseline';
-import Typography from '@mui/material/Typography';
-import StartButton from './components/startbutton/StartButton';
-import Game from './components/game/Game';
-const root = ReactDOM.createRoot(document.getElementById('root'));
-root.render(
+ReactDOM.render(
-
-
-
-
-
- Bienvenidos al curso 2024 de arquitectura de software somos el grupo :
-
- wiq_es04c
-
- } />
- } />
- } />
- } />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+ ,
+ document.getElementById('root')
);
reportWebVitals();
\ No newline at end of file