import type { ReactNode } from 'react'; import { Navigate } from 'react-router-dom'; import { useAuth } from '@/lib/auth'; /** Server still arbitrates — this is a UI gate so non-admins don't see admin routes. */ export function RequireAdmin({ children }: { children: ReactNode }) { const { state } = useAuth(); if (state.loading) { return

Loading session…

; } if (!state.user) { return ; } if (!state.user.is_admin) { return ; } return <>{children}; }