"use client"; import Link from "next/link"; import Image from "next/image"; import { usePathname } from "next/navigation"; import { useAuth } from "@/hooks/useAuth"; import { useSiteSettings } from "@/contexts/SiteSettingsContext"; import { BottomNav } from "./BottomNav"; import churchLogo from "@/app/church_logo.jpg"; import { appName } from "@/lib/siteConfig"; import { resolveToApiOrigin } from "@/lib/api"; type NavLink = { href: string; label: string; onClick?: () => void; }; export const Navbar = () => { const { user, loading: authLoading, logout } = useAuth(); const { settings, loading: settingsLoading } = useSiteSettings(); const pathname = usePathname(); const displayName = settings.org_name || appName; const logoSrc = settings.logo_url ? resolveToApiOrigin(settings.logo_url) : null; const isActive = (href: string) => { if (href.includes("#")) return false; if (href === "/") return pathname === "/"; return pathname?.startsWith(href) ?? false; }; const handleLogout = () => { logout(); window.location.href = "/"; }; const navLinks: NavLink[] = [ { href: "/", label: "Home" }, { href: "/events", label: "Events" }, { href: "/contact", label: "Contact" }, ]; const authLinks: NavLink[] = user ? [ { href: "/dashboard", label: "Dashboard" }, { href: "#", label: "Logout", onClick: handleLogout, }, ] : [ { href: "/login", label: "Login" }, { href: "/register", label: "Register" }, ]; return ( <>
); };