import { useTranslation } from 'react-i18next'; import { Home, Calendar, List, LayoutGrid, Settings, CheckSquare, Target, Trophy, LogOut, Award, Bot, CalendarOff, Bell, Clock, Brain } from 'lucide-react'; import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query'; import { useToast } from "@/hooks/use-toast"; import { Button } from "@/components/ui/button"; import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarRail, useSidebar, SidebarTrigger, SidebarSeparator, } from "@/components/ui/sidebar" import { Task, User } from '@shared/schema'; import ThemeToggle from './ThemeToggle'; import { useLocation } from "wouter"; import { GamificationBar } from './GamificationBar'; interface AppSidebarProps extends React.ComponentProps { user: User | undefined; } export function AppSidebar({ user, ...props }: AppSidebarProps) { const { t } = useTranslation(); const { state } = useSidebar(); const { toast } = useToast(); const queryClient = useQueryClient(); const [location, setLocation] = useLocation(); // Fetch unscheduled count // const { data: unscheduledCount = 0 } = useQuery({ // queryKey: ['/api/tasks'], // select: (tasks: Task[]) => tasks.filter(t => !t.dueDate && t.status !== 'done').length, // enabled: !!user // }); const logoutMutation = useMutation({ mutationFn: async () => { await fetch("/api/logout", { method: "POST" }); }, onSuccess: () => { queryClient.clear(); // toast({ title: "Logged out successfully" }); window.location.href = "/auth?mode=login"; }, }); const items = [ { title: t('navigation.focus'), id: 'focus', path: '/', icon: Target, color: 'text-red-500' }, { title: t('navigation.tasks'), id: 'tasks', path: '/tasks', icon: Home, color: 'text-blue-500' }, { title: t('navigation.calendar'), id: 'calendar', path: '/calendar', icon: Calendar, color: 'text-violet-500' }, { title: t('navigation.weekList'), id: 'weeklist', path: '/weeklist', icon: List, color: 'text-pink-500' }, { title: t('unscheduled.title', 'Unscheduled'), id: 'unscheduled', path: '/unscheduled', icon: CalendarOff, color: 'text-slate-500' }, { title: t('navigation.kanban'), id: 'kanban', path: '/kanban', icon: LayoutGrid, color: 'text-orange-500' }, { title: t('navigation.adhd', 'ADHD Mode'), id: 'adhd', path: '/adhd', icon: Brain, color: 'text-purple-500' }, { title: t('navigation.achievements'), id: 'achievements', path: '/achievements', icon: Trophy, color: 'text-yellow-500' }, { title: t('navigation.leaderboard'), id: 'leaderboard', path: '/leaderboard', icon: Award, color: 'text-yellow-500' }, { title: t('analytics.timeTracking'), id: 'time-tracking', path: '/time-tracking', icon: Clock, color: 'text-teal-500' }, ...(user?.aiEnabled ? [{ title: t('navigation.aiChat', 'AI Chat'), id: 'ai-chat', path: '/ai', icon: Bot, color: 'text-indigo-500' }] : []), { title: t('navigation.settings'), id: 'settings', path: '/settings', icon: Settings, color: 'text-gray-500' }, ] return (
Logo
{state !== 'collapsed' && (
{t('app.title')} Personal
)}
{items.map((item) => ( setLocation(item.path)} tooltip={item.title} className={`h-12 transition-all duration-200 ${location === item.path || (item.path !== '/' && location.startsWith(item.path)) ? 'bg-gradient-to-r from-violet-600 to-indigo-600 text-white shadow-md hover:from-violet-500 hover:to-indigo-500 hover:text-white' : 'hover:bg-sidebar-accent hover:pl-4' }`} > {state !== 'collapsed' && ( {item.title} )} ))} {state !== 'collapsed' && user && ( )}
) }