'use client' import { cn } from '@/lib/utils' import { useAtom } from 'jotai' import { CheckSquare, ListChecks } from 'lucide-react' import { browserSettingsAtom, habitsAtom, settingsAtom } from '@/lib/atoms' import type { ViewType } from '@/lib/types' import { HabitIcon, TaskIcon } from '@/lib/constants' import { isHabitDueToday } from '@/lib/utils' import { NotificationBadge } from './ui/notification-badge' interface ViewToggleProps { defaultView?: ViewType className?: string } export function ViewToggle({ defaultView = 'habits', className }: ViewToggleProps) { const [browserSettings, setBrowserSettings] = useAtom(browserSettingsAtom) const [habits] = useAtom(habitsAtom) const [settings] = useAtom(settingsAtom) const handleViewChange = (checked: boolean) => { const newView = checked ? 'tasks' : 'habits' setBrowserSettings({ ...browserSettings, viewType: newView, }) } // Calculate due tasks count const dueTasksCount = habits.habits.filter(habit => habit.isTask && isHabitDueToday({ habit, timezone: settings.system.timezone }) ).length return (
0} variant={browserSettings.viewType === 'tasks' ? 'secondary' : 'default'} className="shadow-md" >
) }