'use client' import { browserSettingsAtom, habitsAtom, settingsAtom } from '@/lib/atoms' import { HabitIcon, TaskIcon } from '@/lib/constants' import type { ViewType } from '@/lib/types' import { cn, isHabitDueToday } from '@/lib/utils' import { useAtom } from 'jotai' 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 (