import { useState, useEffect } from "react";

import LoginPage from "./LoginPage";
import { useNavigate } from "react-router-dom";

function App(): JSX.Element {
  const navigate = useNavigate();
  const [authority, setAuthority] = useState(0);

  useEffect(() => {
    if (authority === 1) {
      navigate("/admin");
    } else if (authority === 2) {
      navigate("/yourProjects");
    }
  }, [authority, navigate]);

  return <LoginPage setAuthority={setAuthority} />;
}

export default App;
