mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-20 22:24:28 +01:00
support archiving habit and wishlist + wishlist redeem count (#49)
This commit is contained in:
@@ -231,11 +231,29 @@ export function useHabits() {
|
||||
}
|
||||
}
|
||||
|
||||
const archiveHabit = async (id: string) => {
|
||||
const updatedHabits = habitsData.habits.map(h =>
|
||||
h.id === id ? { ...h, archived: true } : h
|
||||
)
|
||||
await saveHabitsData({ habits: updatedHabits })
|
||||
setHabitsData({ habits: updatedHabits })
|
||||
}
|
||||
|
||||
const unarchiveHabit = async (id: string) => {
|
||||
const updatedHabits = habitsData.habits.map(h =>
|
||||
h.id === id ? { ...h, archived: undefined } : h
|
||||
)
|
||||
await saveHabitsData({ habits: updatedHabits })
|
||||
setHabitsData({ habits: updatedHabits })
|
||||
}
|
||||
|
||||
return {
|
||||
completeHabit,
|
||||
undoComplete,
|
||||
saveHabit,
|
||||
deleteHabit,
|
||||
completePastHabit
|
||||
completePastHabit,
|
||||
archiveHabit,
|
||||
unarchiveHabit
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user