diff --git a/client/src/components/manageProjects/editMeetingTimes.js b/client/src/components/manageProjects/editMeetingTimes.js index 03b490d8..655fabb8 100644 --- a/client/src/components/manageProjects/editMeetingTimes.js +++ b/client/src/components/manageProjects/editMeetingTimes.js @@ -41,13 +41,10 @@ const EditMeetingTimes = ({ }; } - //if there is a description or a blank description - if (values.description || !values.description) { - theUpdatedEvent = { - ...theUpdatedEvent, - description: values.description, - }; - } + theUpdatedEvent = { + ...theUpdatedEvent, + description: values.description, + }; if (values.videoConferenceLink) { theUpdatedEvent = { @@ -63,50 +60,23 @@ const EditMeetingTimes = ({ updatedDate, }; - // If the day has been changed, find the next occurence of the changed day - if (values.day) { - const date = findNextOccuranceOfDay(values.day); - const dateGMT = new Date(date).toISOString(); - - theUpdatedEvent = { - ...theUpdatedEvent, - date: dateGMT, - }; - } - - // Set start time, End time and Duration if either start time or duration is changed - if (values.startTime || values.duration) { - /* - We need a start time and a duration to calculate everything we need. - If only the start time or only the duration is changing, - we use the previous time or duration for the calculation. - */ + // Find next occurance of Day in the future + // Assign new start time and end time + const date = findNextOccuranceOfDay(values.day); + const startTimeDate = timeConvertFromForm(date, values.startTime); + const endTime = addDurationToTime(startTimeDate, values.duration); - let startTimeToUse = startTimeOriginal; - let durationToUse = durationOriginal; - - if (values.startTime) { - startTimeToUse = values.startTime; - } - - if (values.duration) { - durationToUse = values.duration; - } - - const timeDate = timeConvertFromForm(new Date(), startTimeToUse); - const endTime = addDurationToTime(timeDate, durationToUse); - - // convert to ISO and GMT - const startTimeGMT = new Date(timeDate).toISOString(); - const endTimeGMT = new Date(endTime).toISOString(); - - theUpdatedEvent = { - ...theUpdatedEvent, - startTime: startTimeGMT, - endTime: endTimeGMT, - hours: durationToUse, - }; - } + // Revert timestamps to GMT + const startDateTimeGMT = new Date(startTimeDate).toISOString(); + const endTimeGMT = new Date(endTime).toISOString(); + + theUpdatedEvent = { + ...theUpdatedEvent, + date: startDateTimeGMT, + startTime: startDateTimeGMT, + endTime: endTimeGMT, + duration: values.duration + }; updateRecurringEvent(theUpdatedEvent, eventID); showSnackbar("Recurring event updated", 'info')