"use client";

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

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

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

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

  if (loading) {
    return <Loading />;
  } else {
    return <DashboardPage username={username} name={name} />;
  }
}