import { useEffect } from "react";
import { useAuth } from "@/_core/hooks/useAuth";
import { Loader2, FileText } from "lucide-react";
import { useLocation } from "wouter";
import { Button } from "@/components/ui/button";

export default function Home() {
  const [, setLocation] = useLocation();
  const { user, loading } = useAuth();

  useEffect(() => {
    if (!loading) {
      if (user) {
        setLocation("/dashboard");
      } else {
        setLocation("/login");
      }
    }
  }, [user, loading, setLocation]);

  return (
    <div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-blue-50 to-indigo-100">
      <div className="text-center">
        <div className="mx-auto mb-6 w-20 h-20 bg-blue-600 rounded-lg flex items-center justify-center">
          <FileText className="w-12 h-12 text-white" />
        </div>
        <h1 className="text-3xl font-bold mb-2">Invoice Analyzer</h1>
        <p className="text-gray-600 mb-6">Dématérialisation de la facturation</p>
        <Loader2 className="w-8 h-8 animate-spin text-blue-600 mx-auto" />
      </div>
    </div>
  );
}
