Skip to content

Commit

Permalink
agregar redireccion tras loggin a empezar
Browse files Browse the repository at this point in the history
  • Loading branch information
bidof committed Mar 11, 2024
1 parent e1c7983 commit f14e001
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"mysql": "^2.18.1",
"mysql2": "^3.9.2",
"node-cron": "^3.0.3",
"react-bootstrap": "^2.10.1"
"react-bootstrap": "^2.10.1",
"react-router-dom": "^6.22.3"
}
}
26 changes: 13 additions & 13 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"react": "^18.2.0",
"react-bootstrap": "^2.10.1",
"react-dom": "^18.2.0",
"react-router-dom": "^6.1.0",
"react-router-dom": "^6.22.3",
"react-scripts": "5.0.1",
"web-vitals": "^3.5.1"
},
Expand Down
6 changes: 6 additions & 0 deletions webapp/src/components/login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import axios from 'axios';
import { Container, Typography, TextField, Button, Snackbar } from '@mui/material';
import Game from '../game/Game';
import { AuthContext } from '../authcontext';

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{handleLogin}=useContext(AuthContext);


Expand All @@ -19,12 +21,16 @@ 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
window.location.assign('/');


}
}, [loginSuccess,username, handleLogin]); // Este efecto se ejecutará cada vez que loginSuccess cambie
Expand Down
4 changes: 1 addition & 3 deletions webapp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>

<Game></Game>
{/*

<AuthProvider>
<Router>
<Navbar />
Expand Down Expand Up @@ -48,7 +47,6 @@ root.render(


</AuthProvider>
*/}
</React.StrictMode>
);

Expand Down

0 comments on commit f14e001

Please sign in to comment.