import {useEffect} from 'react';
import {useNavigate} from 'react-router-dom';
import {LandingNav} from '@/components/landing/landing-nav';
import {LandingHero, LandingFeatures, LandingHighlight} from '@/components/landing/landing-sections';
import {LandingFooter} from '@/components/landing/landing-footer';
import {useUser} from '@/contexts/user-context';

export default function GitDataLandingPage() {
    const navigate = useNavigate();
    const {isAuthenticated} = useUser();
    const handleRegister = () => navigate('/auth/register');

    // Redirect authenticated users to workspace
    useEffect(() => {
        if (isAuthenticated) {
            navigate('/w/me', {replace: true});
        }
    }, [isAuthenticated, navigate]);

    // Don't render landing page for authenticated users
    if (isAuthenticated) {
        return null;
    }

    return (
        <div className="min-h-screen bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-100 font-sans antialiased">
            {/* Subtle background grid */}
            <div
                className="fixed inset-0 bg-[linear-gradient(to_right,#09090b08_1px,transparent_1px),linear-gradient(to_bottom,#09090b08_1px,transparent_1px)] bg-[size:24px_24px] pointer-events-none"/>

            <LandingNav/>
            <main>
                <LandingHero onRegister={handleRegister}/>
                <LandingFeatures/>
                <LandingHighlight/>
            </main>
            <LandingFooter onRegister={handleRegister}/>
        </div>
    );
}
