Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions client/src/components/manageProjects/createNewEvent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,6 @@ const CreateNewEvent = ({
};
return (
<div>
<button
type="button"
className="meeting-cancel-button"
onClick={() => {
setFormValues(initialFormValues);
setFormErrors(null);
setIsCreateNew(false);
}}
>
X
</button>
<EventForm
handleInputChange={handleInputChange}
formValues={formValues}
Expand Down
116 changes: 51 additions & 65 deletions client/src/components/manageProjects/editMeetingTimes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,92 +17,78 @@ const EditMeetingTimes = ({
}) => {
const [formErrors, setFormErrors] = useState({});
const { showSnackbar } = useSnackbar();
const handleEventUpdate = (
eventID,
values,
startTimeOriginal,
durationOriginal
) => async () => {
const errors = validateEventForm(values, projectToEdit);
if (!errors) {
let theUpdatedEvent = {};
const handleEventUpdate =
(eventID, values, startTimeOriginal, durationOriginal) => async () => {
const errors = validateEventForm(values, projectToEdit);
if (!errors) {
let theUpdatedEvent = {};

if (values.name) {
theUpdatedEvent = {
...theUpdatedEvent,
name: values.name,
};
}
if (values.name) {
theUpdatedEvent = {
...theUpdatedEvent,
name: values.name,
};
}

if (values.eventType) {
theUpdatedEvent = {
...theUpdatedEvent,
eventType: values.eventType,
};
}

if (values.eventType) {
theUpdatedEvent = {
...theUpdatedEvent,
eventType: values.eventType,
description: values.description,
};
}

theUpdatedEvent = {
...theUpdatedEvent,
description: values.description,
};
if (values.videoConferenceLink) {
theUpdatedEvent = {
...theUpdatedEvent,
videoConferenceLink: values.videoConferenceLink,
};
}

if (values.videoConferenceLink) {
// Set updated date to today and add it to the object
const updatedDate = new Date().toISOString();
theUpdatedEvent = {
...theUpdatedEvent,
videoConferenceLink: values.videoConferenceLink,
updatedDate,
};
}

// Set updated date to today and add it to the object
const updatedDate = new Date().toISOString();
theUpdatedEvent = {
...theUpdatedEvent,
updatedDate,
};
// 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);

// 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);
// Revert timestamps to GMT
const startDateTimeGMT = new Date(startTimeDate).toISOString();
const endTimeGMT = new Date(endTime).toISOString();

// 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
};
theUpdatedEvent = {
...theUpdatedEvent,
date: startDateTimeGMT,
startTime: startDateTimeGMT,
endTime: endTimeGMT,
duration: values.duration,
};

updateRecurringEvent(theUpdatedEvent, eventID);
showSnackbar("Recurring event updated", 'info')
setSelectedEvent(null);
}
setFormErrors(errors);
};
updateRecurringEvent(theUpdatedEvent, eventID);
showSnackbar('Recurring event updated', 'info');
setSelectedEvent(null);
}
setFormErrors(errors);
};

const handleEventDelete = (eventID) => async () => {
deleteRecurringEvent(eventID);
setSelectedEvent(null);
showSnackbar("Recurring event deleted", 'info');
showSnackbar('Recurring event deleted', 'info');
};

return (
<div>
<button
type="button"
className="meeting-cancel-button"
onClick={() => {
setFormErrors(null);
setSelectedEvent(null);
}}
>
X
</button>
{selectedEvent && (
<EditableMeeting
key={selectedEvent.event_id}
Expand All @@ -123,4 +109,4 @@ const EditMeetingTimes = ({
</div>
);
};
export default EditMeetingTimes;
export default EditMeetingTimes;
Loading
Loading