From cea576e5e81b0fd68ecec09177bf645c1df94370 Mon Sep 17 00:00:00 2001 From: lenhanphung Date: Fri, 3 Oct 2025 10:46:34 +0700 Subject: [PATCH] fix: improve video conference link positioning and null safety - Fix calendarUtils.ts null safety for calendars[id] access - Update video conference link to be added on line 2 instead of line 3 - Update regex in handleDeleteVideoConference to match new format - Update all test cases for videoConferenceUtils to match new format - Add null checks in updateCalsDetails function --- .../Calendar/utils/calendarUtils.ts | 24 ++++++++++--------- src/features/Events/EventModal.tsx | 6 ++--- .../__test__/videoConferenceUtils.test.ts | 6 ++--- src/utils/videoConferenceUtils.ts | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/Calendar/utils/calendarUtils.ts b/src/components/Calendar/utils/calendarUtils.ts index 88dc632..70dd735 100644 --- a/src/components/Calendar/utils/calendarUtils.ts +++ b/src/components/Calendar/utils/calendarUtils.ts @@ -74,7 +74,7 @@ export const extractEvents = ( ) => { let filteredEvents: CalendarEvent[] = []; selectedCalendars.forEach((id) => { - if (calendars[id].events) { + if (calendars[id] && calendars[id].events) { filteredEvents = filteredEvents .concat( Object.keys(calendars[id].events).map( @@ -118,16 +118,18 @@ export const updateCalsDetails = ( if (rangeKey !== previousRangeKey) { selectedCalendars?.forEach((id) => { - dispatch( - getCalendarDetailAsync({ - calId: id, - match: { - start: formatDateToYYYYMMDDTHHMMSS(calendarRange.start), - end: formatDateToYYYYMMDDTHHMMSS(calendarRange.end), - }, - calType, - }) - ); + if (id) { + dispatch( + getCalendarDetailAsync({ + calId: id, + match: { + start: formatDateToYYYYMMDDTHHMMSS(calendarRange.start), + end: formatDateToYYYYMMDDTHHMMSS(calendarRange.end), + }, + calType, + }) + ); + } }); } }; diff --git a/src/features/Events/EventModal.tsx b/src/features/Events/EventModal.tsx index 328d5ea..a4674ee 100644 --- a/src/features/Events/EventModal.tsx +++ b/src/features/Events/EventModal.tsx @@ -270,7 +270,7 @@ function EventPopover({ const handleDeleteVideoConference = () => { // Remove video conference footer from description const updatedDescription = description.replace( - /\n\nVisio: https?:\/\/[^\s]+/, + /\nVisio: https?:\/\/[^\s]+/, "" ); setDescription(updatedDescription); @@ -500,7 +500,6 @@ function EventPopover({ /> } label="Mark as important" - sx={{ padding: "0 8px 0 0" }} /> } label="All day" - sx={{ padding: "0 8px 0 0" }} /> - +