import { useState, useEffect } from "react"; import { PrimaryButton } from "../../../components/button/PrimaryButton"; import { Input } from "../../../components/input/Input"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { Link, useNavigate } from "react-router-dom"; import { loginUser } from "../../../redux/slices/auth"; import { cn } from "../../../lib/cn"; import { setMenuActivePage } from "../../../redux/slices/store"; import { Balloon } from "../../../assets/icons/auth"; import { SecondaryButton } from "../../../components/button/SecondaryButton"; import { googleLogo } from "../../../assets/icons/input"; const Login = () => { const dispatch = useAppDispatch(); const navigate = useNavigate(); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [submitClicked, setSubmitClicked] = useState(false); const { status, error, jwt } = useAppSelector((state) => state.auth); const [err, setErr] = useState(""); // После успешного логина useEffect(() => { dispatch(setMenuActivePage("account")) if (jwt) { navigate("/home/offices"); // или другая страница после входа } }, [jwt]); const handleLogin = () => { // setErr(err == "" ? "Неверная почта и/или пароль" : ""); // console.log(123); setSubmitClicked(true); if (!username || !password) return; dispatch(loginUser({ username, password })); }; return (
С возвращением
Вход в аккаунт
{setUsername(v)}} placeholder="login"/> {setPassword(v)}} placeholder="abCD1234" />
Забыли пароль?
{}} >
Вход с Google
Нет аккаунта? Регистрация
); }; export default Login;