import { useEffect } from "react";
import ServerList from "./Components/ServerList/ServerList";
import Cookies from "js-cookie";
import { useNavigate } from "react-router-dom";

const Index = () => {
  const navigate = useNavigate();
  const sessionCookie = Cookies.get("session");

  useEffect(() => {
    if (!sessionCookie) {
      navigate("/login");
    }
  }, [navigate, sessionCookie]);

  return (
    <div style={{ width: "100%", padding: "20px", display: "flex", flexDirection: "column", alignItems: "center" }}>
      <h1>Available Servers</h1>
      <ServerList />
    </div>
  )
}

export default Index
