import Button from "@/components/ui/Button";
import Input from "@/components/ui/Input";
import { UrlsTitle } from "@/enums/urls";
import { useAppContext } from "@/providers/AuthProvider";
import { FunctionComponent } from "preact";
import { useLocation } from "preact-iso";
import { useEffect } from "preact/hooks";
import classes from "./login.module.scss";
const LoginPage: FunctionComponent = () => {
  const { isLoggedIn } = useAppContext();
  const { route } = useLocation();
  useEffect(() => {
    document.title = UrlsTitle.LOGIN;
  }, []);
  return (
    <div class={classes.login_container}>
      <div class={classes.login_card}>
        <p class={classes.login_card_name}>Антихвост</p>
        <Input placeholder="Логин" textAlign="center" />
        <Input isPassword placeholder="Пароль" textAlign="center" />
        <Button
          color="secondary"
          onClick={() => {
            isLoggedIn.value = true;
            localStorage.setItem("loggedIn", "true");
            route("/profile/tasks", true);
          }}
        >
          Войти
        </Button>
      </div>
    </div>
  );
};

export default LoginPage;
