Skip to content

Comments

Feat restrict calendar editing to last 3 days#88

Merged
BrayanMQ merged 6 commits intomainfrom
feat-restrict-calendar-editing-to-last-3-days
Jan 20, 2026
Merged

Feat restrict calendar editing to last 3 days#88
BrayanMQ merged 6 commits intomainfrom
feat-restrict-calendar-editing-to-last-3-days

Conversation

@BrayanMQ
Copy link
Owner

📝 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Dependency update

🔄 Changes Made

  • Date Utility: Created lib/dates.ts and canEditDay utility to centralize the 3-day editable window logic using calendar days (not a 72h window).
  • Interactive Calendar:
    • Added habit log toggling functionality to the calendar cells.
    • Implemented a new Edit Mode toggle to prevent accidental edits and improve UX.
    • Added an explanatory section at the bottom of the calendar card to guide users on how editing works.
  • Visual Feedback:
    • When Edit Mode is active, editable days (last 3) feature hover animations, rings, and cursor pointer.
    • Non-editable days are dimmed (opacity 40%) to clearly communicate the restriction.
  • Defensive Validation: Added a check in useToggleHabitLog hook to ensure no logs can be updated outside the allowed window, even if UI checks are bypassed.
  • Translations: Added comprehensive English and Spanish translation keys for the new UI elements and restriction messages.
  • Testing: Added 13 unit tests for the canEditDay utility covering various edge cases and month boundaries.

🧪 Testing

  • Manual testing completed: Verified that clicking days in Edit Mode correctly toggles habits only for the last 3 days.
  • Unit tests added/updated: All 13 tests for canEditDay pass.
  • Integration tests added/updated

✅ Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (if applicable)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

📸 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.

…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.
@BrayanMQ BrayanMQ linked an issue Jan 20, 2026 that may be closed by this pull request
@BrayanMQ BrayanMQ merged commit ad3b354 into main Jan 20, 2026
1 check failed
@BrayanMQ BrayanMQ deleted the feat-restrict-calendar-editing-to-last-3-days branch January 20, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restrict Calendar Editing to Last 3 Days

1 participant