Overview
Add the ability for users to archive habits. This feature will allow users to hide habits from their active list while preserving their historical data and logs.
Requirements
User Experience
- When in management mode (
mode === 'management'), add an "Archive" option to the existing actions menu in HabitCard
- The archive option should appear between "Edit" and "Delete" in the dropdown menu
- Include a confirmation dialog before archiving (similar to delete confirmation)
- Show loading state while archiving
- Display success/error messages using the existing toast system
Technical Implementation
Frontend Changes
-
HabitCard Component (components/habits/HabitCard.tsx)
- Import
useArchiveHabit from @/hooks/useHabits
- Add "Archive" button to the actions menu dropdown
- Use archive icon (Archive or similar from lucide-react)
- Add confirmation modal/dialog before archiving
- Handle loading states and error handling
- Use existing i18n keys or add new ones for "Archive" text
-
UI Store Integration (store/ui.ts)
- Add state management for archive confirmation modal if needed
- Or reuse existing delete confirmation modal with different messaging
-
Internationalization (i18n/locales/)
- Add translation keys for:
- "Archive" button text
- Archive confirmation message
- Success message
- Error message
Backend Integration
- The
useArchiveHabit hook already exists and handles:
- Authentication checks
- Database updates (sets
archived_at timestamp)
- Cache invalidation for both active and archived habits lists
- Error handling
Acceptance Criteria
Technical Notes
- The archive functionality differs from delete - archived habits retain their logs and can be restored
- Use existing patterns from delete functionality for consistency
- Ensure proper error boundaries and loading states
- Consider accessibility (keyboard navigation, screen reader support)
Related Files
components/habits/HabitCard.tsx - Add archive button to actions menu
hooks/useHabits.ts - useArchiveHabit hook (already implemented)
store/ui.ts - UI state management
components/habits/ArchivedHabitsSection.tsx - Where archived habits will be displayed
i18n/locales/en.json & es.json - Translation keys
Overview
Add the ability for users to archive habits. This feature will allow users to hide habits from their active list while preserving their historical data and logs.
Requirements
User Experience
mode === 'management'), add an "Archive" option to the existing actions menu in HabitCardTechnical Implementation
Frontend Changes
HabitCard Component (
components/habits/HabitCard.tsx)useArchiveHabitfrom@/hooks/useHabitsUI Store Integration (
store/ui.ts)Internationalization (
i18n/locales/)Backend Integration
useArchiveHabithook already exists and handles:archived_attimestamp)Acceptance Criteria
useArchiveHabithookTechnical Notes
Related Files
components/habits/HabitCard.tsx- Add archive button to actions menuhooks/useHabits.ts-useArchiveHabithook (already implemented)store/ui.ts- UI state managementcomponents/habits/ArchivedHabitsSection.tsx- Where archived habits will be displayedi18n/locales/en.json&es.json- Translation keys