Conversation
- Refactored date validation logic in useHabitLogs to improve error handling for invalid dates. - Added a new custom hook, useHabitHasLogs, to check if a habit has any logs, facilitating better management of habit-related operations.
…tates - Added cloning confirmation dialog to handle cases where a habit's title changes and it has associated logs. - Integrated useCreateHabit hook to facilitate habit creation during cloning. - Improved loading state management by introducing isProcessing to track ongoing updates and creations. - Updated UI to reflect new states and ensure a smooth user experience during habit editing and cloning.
- Introduced cloning confirmation dialog in English and Spanish to inform users about the implications of changing a habit's name. - Added success toast messages for the creation of new habits, ensuring users are notified when their actions are successful. - Enhanced localization files to support new messages related to habit cloning functionality.
- Introduced an archived_at column to the habits table to support soft versioning, allowing for the archiving of habits when renamed. - Added an index on the archived_at column for efficient filtering between active and archived habits. - Included a comment on the archived_at column to clarify its purpose and usage.
- Added an optional archived_at field to the habits table for soft deletion functionality, allowing habits to be archived without permanent removal. - Updated type definitions to accommodate the new field in Insert and Update operations.
- Added support for managing archived habits through new custom hooks: useArchivedHabits and useArchiveHabit. - Updated useHabits to filter out archived habits by checking the archived_at field. - Enhanced data fetching for both active and archived habits, improving user experience in habit management.
- Added useArchiveHabit hook to manage archiving of habits within the EditHabitModal. - Updated the cloning confirmation logic to archive the original habit after creating a new one, enhancing habit management functionality. - Improved loading state handling to include archiving processes, ensuring a smoother user experience.
- Introduced ArchivedHabitsSection component to show a collapsible section for archived habits at the bottom of the habits page. - Integrated useArchivedHabits hook to fetch and manage archived habits, enhancing user experience. - Added loading and empty states for better feedback when viewing archived habits.
… section - Modified English and Spanish localization files to reflect changes in habit archiving terminology, clarifying that original habits will be archived rather than unchanged. - Added new entries for managing archived habits, including titles and messages for empty states, enhancing user experience when viewing archived habits.
- Updated test data in CalendarPage, StatsPage, and HabitCard tests to include the archived_at field, ensuring alignment with recent changes in habit management functionality.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
Implement soft versioning for habits to prevent data integrity issues when renaming habits with existing logs. When a user attempts to rename a habit that has recorded history, instead of modifying the original habit, the system creates a new habit with the new name and archives the original one, preserving all historical data.
🔗 Related Issue
Closes #83
🏷️ Type of Change
🔄 Changes Made
archived_atcolumn to habits table via SQL migrationuseHabitshook to filter out archived habits from the main listuseArchivedHabitsanduseArchiveHabitfor managing archived habitsuseHabitHasLogshook to check if a habit has existing logs before allowing renameEditHabitModalto show confirmation dialog when renaming habits with logsArchivedHabitsSectioncomponent with collapsible UI to display archived habits🧪 Testing
Test steps:
✅ Checklist
📸 Screenshots (if applicable)
N/A - UI changes are minimal (collapsible archived section and confirmation modal)
📌 Additional Notes
Database Migration Required:
Run
npx supabase db pushto apply the migration before testing.Files Changed:
supabase/migrations/20260113100000_add_habits_archived_at.sql(new)types/database.tshooks/useHabits.tshooks/useHabitLogs.tscomponents/habits/EditHabitModal.tsxcomponents/habits/ArchivedHabitsSection.tsx(new)app/dashboard/habits/page.tsxi18n/locales/en.jsoni18n/locales/es.jsonarchived_atproperty