Skip to content

Commit

Permalink
Merge pull request #1592 from Spiteless/ts.frontEndTimingBug
Browse files Browse the repository at this point in the history
feat: Have editMeetingTimes use same funcs as createMeetingTimes
  • Loading branch information
trillium authored Feb 27, 2024
2 parents 4d4825a + bcb977f commit 8a9bafd
Showing 1 changed file with 20 additions and 50 deletions.
70 changes: 20 additions & 50 deletions client/src/components/manageProjects/editMeetingTimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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')
Expand Down

0 comments on commit 8a9bafd

Please sign in to comment.