"use client";

import { QuoteCard } from "@/components/quote-card";
import { CalendarWidget } from "@/components/calendar-widget";
import { News } from "@/components/news";
import { Duties } from "@/components/flow";
import { Parole } from "@/components/parole";
import { useSession } from "next-auth/react";
import { useEffect, useState } from "react";

export default function Home() {
  const { data: session, status } = useSession();
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    if (status !== "loading") {
      setIsLoading(false);
    }
  }, [status]);

  if (isLoading) {
    return (
      <main className="h-screen flex items-center justify-center">
        <div className="animate-spin rounded-full h-32 w-32 border-t-2 border-b-2 border-gray-900"></div>
      </main>
    );
  }

  return (
    <main className="h-screen overflow-auto">
      <div className="container mx-auto p-4 mt-12">
        {/* First row */}
        <div className="grid grid-cols-12 gap-4 mb-4">
          <div className="col-span-3">
            <QuoteCard />
          </div>
          <div className="col-span-3">
            <CalendarWidget />
          </div>
          <div className="col-span-3">
            <News />
          </div>
          <div className="col-span-3">
            <Duties />
          </div>
          <div className="col-span-3">
            <Parole />
          </div>
        </div>
      </div>
    </main>
  );
}
