diff --git a/app/habits/page.tsx b/app/habits/page.tsx index db6bb0e..4ce0f9d 100644 --- a/app/habits/page.tsx +++ b/app/habits/page.tsx @@ -3,7 +3,7 @@ import HabitList from '@/components/HabitList' export default function HabitsPage() { return (
- +
) } diff --git a/app/tasks/page.tsx b/app/tasks/page.tsx new file mode 100644 index 0000000..1b53c84 --- /dev/null +++ b/app/tasks/page.tsx @@ -0,0 +1,10 @@ +import HabitList from '@/components/HabitList' + +export default function TasksPage() { + return ( +
+ +
+ ) +} + diff --git a/components/DailyOverview.tsx b/components/DailyOverview.tsx index 69091f6..de2f133 100644 --- a/components/DailyOverview.tsx +++ b/components/DailyOverview.tsx @@ -220,12 +220,6 @@ const ItemSection = ({ { - const newViewType = isTask ? 'tasks' : 'habits'; - if (browserSettings.viewType !== newViewType) { - setBrowserSettings(prev => ({ ...prev, viewType: newViewType })); - } - }} > {isTask && isTaskOverdue(habit, settings.system.timezone) && !isCompleted && ( @@ -314,12 +308,6 @@ const ItemSection = ({ { - const newViewType = isTask ? 'tasks' : 'habits'; - if (browserSettings.viewType !== newViewType) { - setBrowserSettings(prev => ({ ...prev, viewType: newViewType })); - } - }} > View diff --git a/components/HabitItem.tsx b/components/HabitItem.tsx index 21febf0..f99cbd6 100644 --- a/components/HabitItem.tsx +++ b/components/HabitItem.tsx @@ -6,7 +6,7 @@ import { DropdownMenuTrigger } from '@/components/ui/dropdown-menu' import { useHabits } from '@/hooks/useHabits' -import { browserSettingsAtom, settingsAtom, usersAtom } from '@/lib/atoms' +import { settingsAtom, usersAtom } from '@/lib/atoms' import { useHelpers } from '@/lib/client-helpers' import { Habit, User } from '@/lib/types' import { convertMachineReadableFrequencyToHumanReadable, getCompletionsForToday, isTaskOverdue } from '@/lib/utils' @@ -15,6 +15,7 @@ import { Check, Coins, Edit, MoreVertical, Pin, Undo2 } from 'lucide-react'; // import { useEffect, useState } from 'react' import { HabitContextMenuItems } from './HabitContextMenuItems' import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar' +import { usePathname } from 'next/navigation' interface HabitItemProps { habit: Habit @@ -53,9 +54,7 @@ export default function HabitItem({ habit, onEdit, onDelete }: HabitItemProps) { const { currentUser, hasPermission } = useHelpers() const canWrite = hasPermission('habit', 'write') const canInteract = hasPermission('habit', 'interact') - const [browserSettings] = useAtom(browserSettingsAtom) - const isTasksView = browserSettings.viewType === 'tasks' - const isRecurRule = !isTasksView + const pathname = usePathname(); useEffect(() => { const params = new URLSearchParams(window.location.search) @@ -83,7 +82,7 @@ export default function HabitItem({ habit, onEdit, onDelete }: HabitItemProps) { >
- +
{habit.pinned && ( @@ -108,7 +107,7 @@ export default function HabitItem({ habit, onEdit, onDelete }: HabitItemProps) {

When: {convertMachineReadableFrequencyToHumanReadable({ frequency: habit.frequency, - isRecurRule, + isRecurRule: pathname.includes("habits"), timezone: settings.system.timezone })}

diff --git a/components/HabitList.tsx b/components/HabitList.tsx index e1cfd70..ac9877a 100644 --- a/components/HabitList.tsx +++ b/components/HabitList.tsx @@ -5,7 +5,7 @@ import { Input } from '@/components/ui/input'; // Added import { Label } from '@/components/ui/label'; // Added import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; // Added import { useHabits } from '@/hooks/useHabits' -import { browserSettingsAtom, habitsAtom } from '@/lib/atoms' +import { habitsAtom } from '@/lib/atoms' import { HabitIcon, TaskIcon } from '@/lib/constants' import { Habit } from '@/lib/types' import { getHabitFreq } from '@/lib/utils'; // Added @@ -19,12 +19,9 @@ import EmptyState from './EmptyState' import HabitItem from './HabitItem' import { ViewToggle } from './ViewToggle' -export default function HabitList() { +export default function HabitList({ isTasksView }: { isTasksView: boolean}) { const { saveHabit, deleteHabit } = useHabits() const [habitsData] = useAtom(habitsAtom) // setHabitsData removed as it's not used - const [browserSettings] = useAtom(browserSettingsAtom) - const isTasksView = browserSettings.viewType === 'tasks' - // const [settings] = useAtom(settingsAtom); // settingsAtom is not directly used in HabitList itself. type SortableField = 'name' | 'coinReward' | 'dueDate' | 'frequency'; type SortOrder = 'asc' | 'desc'; @@ -131,9 +128,6 @@ export default function HabitList() {
-
- -
{/* Search and Sort Controls */}
diff --git a/components/Navigation.tsx b/components/Navigation.tsx index a745a38..7ba7a91 100644 --- a/components/Navigation.tsx +++ b/components/Navigation.tsx @@ -1,9 +1,7 @@ 'use client' -import { browserSettingsAtom } from '@/lib/atoms' import { useHelpers } from '@/lib/client-helpers' import { HabitIcon, TaskIcon } from '@/lib/constants' -import { useAtom } from 'jotai' import { Calendar, Coins, Gift, Home } from 'lucide-react' import Link from 'next/link' import { useEffect, useState } from 'react' @@ -12,32 +10,24 @@ import { usePathname } from 'next/navigation' type ViewPort = 'main' | 'mobile' -const navItems = (isTasksView: boolean) => [ +const navItems = () => [ { icon: Home, label: 'Dashboard', href: '/', position: 'main' }, - { - icon: isTasksView ? TaskIcon : HabitIcon, - label: isTasksView ? 'Tasks' : 'Habits', - href: '/habits', - position: 'main' - }, + { icon: HabitIcon, label: 'Habits', href: '/habits', position: 'main' }, + { icon: TaskIcon, label: 'Tasks', href: '/tasks', position: 'main' }, { icon: Calendar, label: 'Calendar', href: '/calendar', position: 'main' }, { icon: Gift, label: 'Wishlist', href: '/wishlist', position: 'main' }, { icon: Coins, label: 'Coins', href: '/coins', position: 'main' }, ] interface NavigationProps { - className?: string viewPort: ViewPort } -export default function Navigation({ className, viewPort }: NavigationProps) { +export default function Navigation({ viewPort }: NavigationProps) { const [showAbout, setShowAbout] = useState(false) const [isMobileView, setIsMobileView] = useState(false) - const [browserSettings] = useAtom(browserSettingsAtom) - const isTasksView = browserSettings.viewType === 'tasks' const { isIOS } = useHelpers() const pathname = usePathname(); - console.log(pathname, pathname === navItems(false)[1].href) useEffect(() => { const handleResize = () => { @@ -59,8 +49,8 @@ export default function Navigation({ className, viewPort }: NavigationProps) { <>
{/* Add padding at the bottom to prevent content from being hidden */}