'use client'; import { useEffect, type ReactNode } from 'react'; import { useRouter } from 'next/navigation'; import { Loader2 } from 'lucide-react'; import { useUser } from '@/contexts/user-context'; type RequireAuthProps = { children: ReactNode; fallback?: ReactNode; minHeightClassName?: string; }; /** * Guards page content until the session user is available. * Redirect to login is handled by the parent layout; this only covers the content slot. */ export function RequireAuth({ children, fallback, minHeightClassName = 'min-h-[400px]', }: RequireAuthProps) { const { user, loading } = useUser(); if (loading) { return ( fallback ?? (