"use client"; import Link from 'next/link'; import { Radio, Newspaper, Megaphone, Menu, CalendarDays, Tv, X, User } from 'lucide-react'; import { useState, useEffect } from 'react'; import { usePathname } from 'next/navigation'; export const Navbar = ({ entity }: { entity?: any }) => { const [scrolled, setScrolled] = useState(false); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const [user, setUser] = useState(null); const pathname = usePathname(); const ENDPOINT = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT || 'https://appwrite.almeira.com.co/v1'; const PROJECT_ID = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID || '69b84df5003bd8957c5c'; let logoUrl = entity?.logotipo || null; if (logoUrl && !logoUrl.startsWith('http') && !logoUrl.startsWith('/')) { logoUrl = `${ENDPOINT}/storage/buckets/media/files/${logoUrl}/view?project=${PROJECT_ID}`; } useEffect(() => { const handleScroll = () => setScrolled(window.scrollY > 20); window.addEventListener('scroll', handleScroll); fetch('/api/auth/me', { cache: 'no-store' }) .then(res => res.json()) .then(data => { if(data.user) setUser(data.user); }) .catch(e => console.error("No session API")); return () => window.removeEventListener('scroll', handleScroll); }, []); const navItems = [ { name: 'Noticias', href: '/', icon: Newspaper }, { name: 'Eventos', href: '/eventos', icon: CalendarDays }, { name: 'Clasificados', href: '/clasificados', icon: Megaphone }, { name: 'TV en Vivo', href: '/tv', icon: Tv, highlight: 'pink' }, { name: 'Radio en Vivo', href: '/radio', icon: Radio, highlight: 'cyan' }, ]; return ( ); };