feat: Add useFlowsManagerStore to LoginPage for managing loading state during login

This commit is contained in:
cristhianzl 2024-06-13 17:45:27 -03:00
commit a1cd3be237

View file

@ -9,6 +9,7 @@ import { CONTROL_LOGIN_STATE } from "../../constants/constants";
import { AuthContext } from "../../contexts/authContext";
import { onLogin } from "../../controllers/API";
import useAlertStore from "../../stores/alertStore";
import useFlowsManagerStore from "../../stores/flowsManagerStore";
import { LoginType } from "../../types/api";
import {
inputHandlerEventType,
@ -23,6 +24,7 @@ export default function LoginPage(): JSX.Element {
const { login } = useContext(AuthContext);
const navigate = useNavigate();
const setErrorData = useAlertStore((state) => state.setErrorData);
const setLoading = useFlowsManagerStore((state) => state.setIsLoading);
function handleInput({
target: { name, value },
@ -37,6 +39,9 @@ export default function LoginPage(): JSX.Element {
};
onLogin(user)
.then((user) => {
console.log("login page");
setLoading(true);
login(user.access_token);
navigate("/");
})