import React, { useEffect } from 'react'; import { Location } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { CalendarDaysIcon, InboxIcon, ListBulletIcon, ClockIcon, } from '@heroicons/react/24/solid'; import { useStore } from '../../store/useStore'; import { loadInboxItemsToStore } from '../../utils/inboxService'; interface SidebarNavProps { handleNavClick: (path: string, title: string, icon: JSX.Element) => void; location: Location; isDarkMode: boolean; } const SidebarNav: React.FC = ({ handleNavClick, location, }) => { const { t } = useTranslation(); const store = useStore(); // Get inbox items count for badge const inboxItemsCount = store.inboxStore.inboxItems.length; // Load inbox items when component mounts to ensure badge shows correct count useEffect(() => { loadInboxItemsToStore(false).catch(console.error); }, []); const navLinks = [ { path: '/inbox', title: t('sidebar.inbox', 'Inbox'), icon: , }, { path: '/today', title: t('sidebar.today', 'Today'), icon: , query: 'type=today', }, { path: '/tasks?type=upcoming', title: t('sidebar.upcoming', 'Upcoming'), icon: , query: 'type=upcoming', }, { path: '/tasks', title: t('sidebar.allTasks', 'All Tasks'), icon: , }, ]; const isActive = (path: string, query?: string) => { // Handle special case for paths without query parameters if (path === '/inbox' || path === '/today') { const isPathMatch = location.pathname === path; return isPathMatch ? 'bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white' : 'text-gray-700 dark:text-gray-300'; } // Regular case for /tasks with query params const isPathMatch = location.pathname === '/tasks'; const isQueryMatch = query ? location.search.includes(query) : location.search === ''; return isPathMatch && isQueryMatch ? 'bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white' : 'text-gray-700 dark:text-gray-300'; }; return (
    {navLinks.map((link) => (
  • ))}
); }; export default SidebarNav;