"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useEffect, useState } from "react"; import { LayoutDashboard, Users, CalendarCheck, CreditCard, Settings, LogOut, Brain, } from "lucide-react"; import { UserButton, useUser } from "@clerk/nextjs"; interface Recommendation { id: string; status: string; } export function Sidebar() { const pathname = usePathname(); const { user } = useUser(); const [pendingCount, setPendingCount] = useState(0); useEffect(() => { const fetchPending = async () => { try { const res = await fetch("/api/recommendations"); if (res.ok) { const data = await res.json(); const pending = (data.recommendations || []).filter( (r: Recommendation) => r.status === "pending" ); setPendingCount(pending.length); } } catch (e) { console.error("Failed to fetch pending recommendations", e); } }; fetchPending(); }, []); const menuItems = [ { icon: LayoutDashboard, label: "Dashboard", href: "/" }, { icon: Users, label: "Users", href: "/users" }, { icon: Brain, label: ( AI Recommendations {pendingCount > 0 && ( {pendingCount} )} ), href: "/recommendations", }, { icon: CalendarCheck, label: "Attendance", href: "/attendance" }, { icon: CreditCard, label: "Payments", href: "/payments" }, { icon: Settings, label: "Settings", href: "/settings" }, ]; return ( ); }