import Cookies from "js-cookie";
import Router from "next/router";
import { useEffect } from "react";

import * as cookieNames from "../lib/cookieNames";

function Home(): JSX.Element {
  const token = Cookies.get(cookieNames.TOKEN);
  useEffect(() => {
    if (!token) {
      Router.push("/login");
    }
  }, [token]);

  if (!token) {
    return <></>;
  }

  return <p>Du bist eingeloggt!</p>;
}

export default Home;
