From c2a882dd652936207b02fc31a62ec7d7c1ec4e3f Mon Sep 17 00:00:00 2001 From: Alex Del Gallego Date: Sat, 7 May 2022 15:43:41 +0200 Subject: [PATCH] Solucionado bug con pedidos y redireccionado tras registro --- webapp/src/components/Login/LoginUsrPsswd.tsx | 1 - webapp/src/components/Login/Register.tsx | 5 ++--- webapp/src/components/Requests/ListRequests.tsx | 2 +- webapp/src/shared/shareddtypes.ts | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/webapp/src/components/Login/LoginUsrPsswd.tsx b/webapp/src/components/Login/LoginUsrPsswd.tsx index 29cee52..74eeee4 100644 --- a/webapp/src/components/Login/LoginUsrPsswd.tsx +++ b/webapp/src/components/Login/LoginUsrPsswd.tsx @@ -54,7 +54,6 @@ const LoginUsrPsswd = () => { // Lo guardamos en sesion (solo el usuario, la contraseña no la necesitamos para nada) sessionStorage.setItem('user', parsedUser.username); // Redirigimos a inicio - //window.location.href='http://localhost:3000/'; window.location.href = window.location.protocol + '//' + window.location.host + '/' } } diff --git a/webapp/src/components/Login/Register.tsx b/webapp/src/components/Login/Register.tsx index 89f25b1..d8b257f 100644 --- a/webapp/src/components/Login/Register.tsx +++ b/webapp/src/components/Login/Register.tsx @@ -50,8 +50,8 @@ const Register = () => { if(add){ const item = {"username":userName,"password":password}; // Almacenamos el usuario en sesión - sessionStorage.setItem('user',JSON.stringify(item)); - alert("Usuario añadido"); + sessionStorage.setItem('user', item.username); + alert('Usuario registrado.'); window.location.href = window.location.protocol + '//' + window.location.host + '/' } else{ @@ -65,7 +65,6 @@ const Register = () => { else{ alert("Las contraseñas no coinciden"); } - window.location.reload(); } return ( <> diff --git a/webapp/src/components/Requests/ListRequests.tsx b/webapp/src/components/Requests/ListRequests.tsx index dfdb6ab..d642b7e 100644 --- a/webapp/src/components/Requests/ListRequests.tsx +++ b/webapp/src/components/Requests/ListRequests.tsx @@ -17,7 +17,7 @@ const ListRequests = () => { React.useEffect(()=>{ refreshPedidos(); },[]); - + return (