mirror of
https://github.com/harivansh-afk/Habit-Tracker.git
synced 2026-04-20 00:02:17 +00:00
user settings debugged
This commit is contained in:
parent
1cd3445bd6
commit
20e91dae4c
7 changed files with 282 additions and 224 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { Trash2 } from 'lucide-react';
|
||||
import { Habit } from '../types';
|
||||
import { useThemeContext } from '../contexts/ThemeContext';
|
||||
|
|
@ -22,7 +22,15 @@ export function HabitList({
|
|||
onUpdateHabit,
|
||||
onDeleteHabit,
|
||||
}: HabitListProps) {
|
||||
const { showStreaks } = useThemeContext();
|
||||
const { habitSort, showStreaks } = useThemeContext();
|
||||
|
||||
const sortedHabits = useMemo(() => {
|
||||
if (habitSort === 'alphabetical') {
|
||||
return [...habits].sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
// Default to dateCreated sort
|
||||
return habits;
|
||||
}, [habits, habitSort]);
|
||||
|
||||
// Helper function to get day name
|
||||
const getDayName = (dateStr: string) => {
|
||||
|
|
@ -53,7 +61,7 @@ export function HabitList({
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{habits.map((habit) => (
|
||||
{sortedHabits.map((habit) => (
|
||||
<tr key={habit.id} className="border-t dark:border-gray-700">
|
||||
<td className="px-4 py-2 dark:text-white">
|
||||
<input
|
||||
|
|
@ -106,6 +114,13 @@ export function HabitList({
|
|||
<Trash2 className="h-4 w-4" />
|
||||
</button>
|
||||
</td>
|
||||
{showStreaks && (
|
||||
<>
|
||||
<td className="px-4 py-2 text-center">
|
||||
{/* ... streak content ... */}
|
||||
</td>
|
||||
</>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue