faltaba redireccion cuando te logeas
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
import { useState, type FormEvent } from 'react';
|
import { useState, type FormEvent } from 'react';
|
||||||
|
import { useNavigate } from 'react-router';
|
||||||
|
|
||||||
const Login = ({setUsuario}:any) => {
|
const Login = ({setUsuario}:any) => {
|
||||||
|
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const handleSubmit = async (e:FormEvent) => {
|
const handleSubmit = async (e:FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -20,10 +22,11 @@ const Login = ({setUsuario}:any) => {
|
|||||||
permissionLevel: ["ADMIN"],
|
permissionLevel: ["ADMIN"],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
navigate("/home");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
} finally {
|
} finally {
|
||||||
//simulamos latencia
|
//simulamos latencia
|
||||||
setTimeout(()=>setLoading(false), 1000)
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export function AppRouter({usuario, setUsuario}: prop) {
|
|||||||
estaPermitido={
|
estaPermitido={
|
||||||
!!usuario && usuario.permissionLevel.includes("ADMIN")
|
!!usuario && usuario.permissionLevel.includes("ADMIN")
|
||||||
}
|
}
|
||||||
redirectTo="/login"
|
redirectTo="/home"
|
||||||
>
|
>
|
||||||
<ComponenteAdmin></ComponenteAdmin>
|
<ComponenteAdmin></ComponenteAdmin>
|
||||||
</RutaProtegida>
|
</RutaProtegida>
|
||||||
|
|||||||
Reference in New Issue
Block a user