"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useEffect, useState } from "react"; function OnyvaLogo() { return (
{/* 5-pointed star SVG */}
OnyvaLeads
); } export function Topbar() { const pathname = usePathname(); const [newLeadsCount, setNewLeadsCount] = useState(0); useEffect(() => { function fetchNewLeads() { fetch("/api/leads/stats") .then((r) => r.json()) .then((d: { new?: number }) => setNewLeadsCount(d.new ?? 0)) .catch(() => {}); } fetchNewLeads(); const t = setInterval(fetchNewLeads, 30000); return () => clearInterval(t); }, []); const tabs = [ { href: "/suche", label: "Suche" }, { href: "/leadspeicher", label: "Leadspeicher" }, ]; return (
{/* Logo */} {/* Tab switcher */}
{tabs.map((tab) => { const isActive = pathname === tab.href || pathname.startsWith(tab.href + "/"); return ( {tab.label} {tab.href === "/leadspeicher" && newLeadsCount > 0 && ( {newLeadsCount > 99 ? "99+" : newLeadsCount} )} ); })}
); }