feat: Add subtle admin bar above header for logged-in users
This commit is contained in:
@@ -9,6 +9,7 @@ import { localeFlags, localeNames, type Locale } from '@/lib/i18n';
|
||||
export default function Header() {
|
||||
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
||||
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
|
||||
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||
const { theme, setTheme } = useTheme();
|
||||
const { locale, setLocale, t } = useLocale();
|
||||
const [mounted, setMounted] = useState(false);
|
||||
@@ -20,6 +21,15 @@ export default function Header() {
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
|
||||
// Verifica se está logado
|
||||
fetch('/api/auth/me')
|
||||
.then(res => {
|
||||
if (res.ok) {
|
||||
setIsLoggedIn(true);
|
||||
}
|
||||
})
|
||||
.catch(() => setIsLoggedIn(false));
|
||||
|
||||
// Busca o número do WhatsApp do CMS
|
||||
fetch('/api/contact-info')
|
||||
.then(res => res.json())
|
||||
@@ -48,7 +58,27 @@ export default function Header() {
|
||||
};
|
||||
|
||||
return (
|
||||
<header className="w-full bg-white dark:bg-secondary shadow-sm sticky top-0 z-50 transition-colors duration-300">
|
||||
<>
|
||||
{/* Admin Bar - aparece apenas para usuários logados */}
|
||||
{isLoggedIn && (
|
||||
<div className="w-full bg-secondary dark:bg-black py-1.5 px-4 z-[60] relative">
|
||||
<div className="container mx-auto flex items-center justify-between">
|
||||
<div className="flex items-center gap-2 text-xs text-gray-400">
|
||||
<i className="ri-shield-user-line text-primary"></i>
|
||||
<span className="hidden sm:inline">Você está logado como administrador</span>
|
||||
</div>
|
||||
<Link
|
||||
href="/admin"
|
||||
className="flex items-center gap-1.5 text-xs font-medium text-white bg-primary/90 hover:bg-primary px-3 py-1 rounded-full transition-colors cursor-pointer"
|
||||
>
|
||||
<i className="ri-dashboard-line"></i>
|
||||
<span>Painel Admin</span>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<header className={`w-full bg-white dark:bg-secondary shadow-sm sticky ${isLoggedIn ? 'top-0' : 'top-0'} z-50 transition-colors duration-300`}>
|
||||
<div className="container mx-auto px-4 h-20 flex items-center justify-between gap-4">
|
||||
<Link href={`${prefix}/`} className="flex items-center gap-3 shrink-0 group mr-auto z-50 relative">
|
||||
<i className="ri-building-2-fill text-4xl text-primary group-hover:scale-105 transition-transform"></i>
|
||||
@@ -238,5 +268,6 @@ export default function Header() {
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user