'use client' import { useRouter } from 'next/navigation' import { useEffect } from 'react' import useAuth from '@/hooks/useAuth' /** * Handles accounts that are still `pending` profile completion. * - Consumer users keep the current page visible; AuthGate modal collects profile. * - Admins are redirected to `/auth?step=profile` and the shell is hidden meanwhile. */ const PendingUserGuard = ({ children }: { children: React.ReactNode }) => { const { user } = useAuth() const router = useRouter() const isPending = user?.status === 'pending' const isAdmin = user?.role === 'admin' useEffect(() => { if (isPending && isAdmin) { router.replace('/auth?step=profile') } }, [isAdmin, isPending, router]) if (isPending && isAdmin) { return null } return <>{children} } export default PendingUserGuard