fix: resolve infinite loop and week calculation issues in EventModal

- Fix infinite loop in EventModal useEffect by using useRef for userPersonnalCalendars
- Fix weekStart calculation in putEventAsync to use Monday as first day (consistent with FullCalendar firstDay=1)
- Add computeWeekRange utility function for consistent week calculations
- Improve state reset logic when closing EventModal popup
- Ensure repeat checkbox state is properly reset to prevent stale repetition data
This commit is contained in:
lenhanphung
2025-10-03 17:22:19 +07:00
parent f245991816
commit 4ef3a887ee
3 changed files with 122 additions and 62 deletions
+7
View File
@@ -52,3 +52,10 @@ export const computeStartOfTheWeek = (date: Date): Date => {
startOfWeek.setHours(0, 0, 0, 0);
return startOfWeek;
};
export const computeWeekRange = (date: Date): { start: Date; end: Date } => {
const weekStart = computeStartOfTheWeek(date);
const weekEnd = new Date(weekStart);
weekEnd.setDate(weekStart.getDate() + 7);
return { start: weekStart, end: weekEnd };
};