'use client'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { useJobs } from '@/contexts/JobsContext'; export default function Sidebar() { const pathname = usePathname(); const { jobs } = useJobs(); const navItems = [ { href: '/dashboard', icon: ( ), label: 'Home', matchPaths: ['/dashboard'], }, { href: '/new', icon: ( ), label: 'New', matchPaths: ['/new'], }, { href: '/jobs', icon: ( ), label: 'Jobs', matchPaths: ['/jobs'], badge: jobs.length > 0 ? jobs.length : undefined, }, { href: '/reports', icon: ( ), label: 'Reports', matchPaths: ['/reports'], }, { href: '/analytics', icon: ( ), label: 'Analytics', matchPaths: ['/analytics'], }, { href: '/pipelines', icon: ( ), label: 'Pipelines', matchPaths: ['/pipelines'], }, { href: '/dashboard/scrapers', icon: ( ), label: 'Scrapers', matchPaths: ['/dashboard/scrapers'], }, { href: '/taxonomy/urt/v5-1', icon: ( ), label: 'Taxonomy', matchPaths: ['/taxonomy'], }, { href: '/categories', icon: ( ), label: 'GBP Cats', matchPaths: ['/categories'], }, ]; const isActive = (item: typeof navItems[0]) => { // Check if current path starts with any of the match paths return item.matchPaths.some(path => pathname.startsWith(path)); }; return (
{navItems.map((item) => ( {item.icon} {item.label} {item.badge !== undefined && ( {item.badge > 99 ? '99+' : item.badge} )} ))}
); }