"use client"; import { motion } from "motion/react"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useEffect } from "react"; import { SofaLogo } from "@/components/sofa-logo"; import { useSession } from "@/lib/auth/client"; /** Check whether the server has TMDB configured. */ async function fetchSetupStatus(): Promise { try { const res = await fetch("/api/setup/status"); if (!res.ok) return true; // assume configured on error const data = await res.json(); return !!data.tmdbConfigured; } catch { return true; } } // Poster positions arranged in angled columns behind the hero const posterLayout = [ // Left column { x: "8%", y: "5%", rotate: -8, delay: 0 }, { x: "5%", y: "38%", rotate: -12, delay: 0.1 }, { x: "10%", y: "68%", rotate: -6, delay: 0.2 }, // Left-center column { x: "24%", y: "12%", rotate: 4, delay: 0.05 }, { x: "22%", y: "50%", rotate: -3, delay: 0.15 }, { x: "26%", y: "78%", rotate: 6, delay: 0.25 }, // Right-center column { x: "62%", y: "8%", rotate: -5, delay: 0.08 }, { x: "64%", y: "42%", rotate: 7, delay: 0.18 }, { x: "60%", y: "72%", rotate: -4, delay: 0.28 }, // Right column { x: "80%", y: "3%", rotate: 10, delay: 0.03 }, { x: "82%", y: "36%", rotate: -8, delay: 0.13 }, { x: "78%", y: "66%", rotate: 5, delay: 0.23 }, ]; export function LandingPage({ posterUrls, freshInstall, registrationOpen, }: { posterUrls: string[]; freshInstall: boolean; registrationOpen: boolean; }) { const { data: session, isPending } = useSession(); const router = useRouter(); useEffect(() => { if (isPending) return; if (session?.user) { router.replace("/dashboard"); return; } // If not logged in, check whether TMDB is configured fetchSetupStatus().then((configured) => { if (!configured) router.replace("/setup"); }); }, [session, isPending, router]); if (isPending) return null; return (
{/* Background grain texture */}
{/* Floating poster collage */}
{posterUrls.map((url, i) => { const pos = posterLayout[i]; return (
); })}
{/* Radial fade over posters to keep center clear */}
{/* Warm primary glow */}
Self-hosted movie & TV tracker Track what you watch. Know what's next.
Your library, your data, your rules.
{freshInstall ? ( Get Started
) : ( <> Sign In
{registrationOpen && ( Register )} )}
{/* Bottom fade */}
); }