'use client'; import { useEffect, useState } from 'react'; import { authApi } from '@/lib/api'; interface HeaderProps { title: string; subtitle?: string; imageUrl?: string; actions?: React.ReactNode; maxWidth?: 'max-w-5xl' | 'max-w-7xl'; } export default function Header({ title, subtitle, imageUrl, actions, maxWidth = 'max-w-7xl' }: HeaderProps) { const [isAdmin, setIsAdmin] = useState(false); useEffect(() => { let cancelled = false; (async () => { try { const who = await authApi.whoami(); if (!cancelled) setIsAdmin(who.role === 'admin'); } catch { if (!cancelled) setIsAdmin(false); } })(); return () => { cancelled = true; }; }, []); return ( <> {isAdmin && (
⚠️ Atenção: visualizar listas públicas pode estragar surpresas
{subtitle}
)} {actions && (