fix: removed viewType from browser Settings Atom, converted to using path to identify pages

This commit is contained in:
2025-05-18 02:03:54 +02:00
parent 49a0ea8804
commit d9fa0426ce
9 changed files with 37 additions and 65 deletions

View File

@@ -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() {
</Button>
</span>
</div>
<div className='py-4'>
<ViewToggle />
</div>
{/* Search and Sort Controls */}
<div className="flex flex-col sm:flex-row items-center gap-4 my-4">