"use client";

import SitePage from "./SitePage";
import Loading from "@/components/Loading";

import { useEffect } from "react";
import { useParams } from "next/navigation";
import useAuth from "@/hooks/useAuth";

export default function Dashboard() {
  const { siteId } = useParams();
  const { loading, username, name, validate } = useAuth();

  useEffect(() => {
    const runValidation = async () => {
      await validate();
    };
    
    runValidation();
  }, [validate]);

  if (loading) {
    return <Loading />;
  } else {
    return <SitePage username={username} name={name} siteId={siteId as string} />;
  }
}