Feat restrict calendar editing to last 3 days#88
Merged
Conversation
…le dates - Introduced functions to parse local dates, check if a date is editable within a 3-day window, and retrieve the oldest editable date. - Enhanced date handling to ensure accurate local timezone representation, improving user experience when managing date-related features.
- Introduced tests for canEditDay and getOldestEditableDate functions to ensure correct behavior for editable and non-editable dates. - Mocked current date for consistent testing, covering various scenarios including month boundaries and date objects.
- Added new entries in English and Spanish localization files for habit editing, including messages for edit restrictions, habit marking, and toggle errors. - Enhanced user guidance with descriptions and titles for the edit mode, improving the overall user experience when managing habits.
- Implemented a check in the useToggleHabitLog hook to ensure that users can only edit habit logs for the last 3 days, enhancing data integrity and user experience. - Introduced the canEditDay utility to validate the editability of dates, preventing unauthorized modifications.
- Added functionality to toggle habit completion within the calendar, allowing users to edit habits for the last 3 days. - Introduced visual indicators and feedback for editable days, enhancing user interaction. - Implemented a button to enable/disable edit mode, improving user experience when managing habits.
- Updated the calendar page to restrict habit editing based on the habit's creation date, ensuring users can only edit logs from the date of creation onward. - Added new localization messages for improved user feedback regarding editing restrictions. - Enhanced the user experience by providing clear notifications when attempting to edit logs outside the allowed timeframe.
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
This PR implements the restriction of calendar editing to the last 3 calendar days (today, yesterday, and the day before yesterday) as requested in issue #87. It also enhances the Calendar UI by making it interactive, allowing users to toggle habit logs directly from the calendar view when "Edit Mode" is active.
🔗 Related Issue
Closes #87
🏷️ Type of Change
🔄 Changes Made
lib/dates.tsandcanEditDayutility to centralize the 3-day editable window logic using calendar days (not a 72h window).useToggleHabitLoghook to ensure no logs can be updated outside the allowed window, even if UI checks are bypassed.canEditDayutility covering various edge cases and month boundaries.🧪 Testing
canEditDaypass.✅ Checklist
📸 Screenshots (if applicable)
2026-01-19.18-36-52.mp4
📌 Additional Notes
The Edit Mode section includes user-friendly copy: "Missed tracking a day? Enable editing to update your progress for the past 3 days." which simplifies the technical restriction for the user.