'use client'; import { useSetupCheck } from "@/hooks/use-setup-check"; import { Hero } from "@/components/landing/hero"; import { InstallModal } from "@/components/modals/install-modal"; import { StoppedCard } from "@/components/landing/stopped-card"; import { WelcomeNotification } from "@/components/notifications/welcome-notification"; import { Loader2 } from "lucide-react"; import { useRouter } from "next/navigation"; import { useEffect, startTransition } from "react"; export default function Home() { const { status, ollamaStatus, checkingStep, recheck } = useSetupCheck(); const router = useRouter(); // Redirecionar automaticamente se tudo estiver pronto useEffect(() => { if (status === 'ready') { const setupComplete = localStorage.getItem("ollahub_setup_complete"); // Se setup não foi marcado como completo, marcar agora if (!setupComplete) { localStorage.setItem("ollahub_setup_complete", "true"); } // Redirecionar para chat após um breve delay para mostrar feedback const timer = setTimeout(() => { startTransition(() => { router.push("/chat"); }); }, 500); return () => clearTimeout(timer); } }, [status, router]); const handleStart = () => { const setupComplete = localStorage.getItem("ollahub_setup_complete"); if (setupComplete) { startTransition(() => { router.push("/chat"); }); } else { startTransition(() => { router.push("/setup"); }); } }; // Mostrar loading durante verificação if (status === 'checking') { return (
{checkingStep} Aguarde um momento...
); } return (
{/* Notificação de boas-vindas */} {/* Layout for Ready State - Redirecionamento automático */} {status === 'ready' && (
Tudo pronto! Redirecionando para o chat...
)} {/* Layout for Needs Setup State */} {status === 'needs_setup' && ollamaStatus === 'running' && ( )} {/* Layout for Stopped State */} {status === 'needs_setup' && ollamaStatus === 'installed_stopped' && (

OllaHub

Detectamos o Ollama, mas ele não está rodando.

)} {/* Layout for Not Installed State (Background + Modal) */} {status === 'needs_ollama' && ( <>
{}} />
{/* Hero is shown in background, modal is open */} )}
); }