diff --git a/client/src/components/manageProjects/editMeetingTimes.jsx b/client/src/components/manageProjects/editMeetingTimes.jsx index 655fabb8b..ad225cf2d 100644 --- a/client/src/components/manageProjects/editMeetingTimes.jsx +++ b/client/src/components/manageProjects/editMeetingTimes.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; import '../../sass/ManageProjects.scss'; import { useSnackbar } from '../../context/snackbarContext'; import EditableMeeting from './editableMeeting'; @@ -6,6 +6,7 @@ import { findNextOccuranceOfDay } from './utilities/findNextDayOccuranceOfDay'; import { addDurationToTime } from './utilities/addDurationToTime'; import { timeConvertFromForm } from './utilities/timeConvertFromForm'; import validateEventForm from './utilities/validateEventForm'; +import { Box, Button, Modal } from '@mui/material'; // This component displays current meeting times for selected project and offers the option to edit those times. const EditMeetingTimes = ({ @@ -16,13 +17,15 @@ const EditMeetingTimes = ({ updateRecurringEvent, }) => { const [formErrors, setFormErrors] = useState({}); + const open = Boolean(selectedEvent); const { showSnackbar } = useSnackbar(); - const handleEventUpdate = ( - eventID, - values, - startTimeOriginal, - durationOriginal - ) => async () => { + + const handleClose = () => { + setFormErrors(null); + setSelectedEvent(null); + }; + + const handleEventUpdate = (eventID, values) => async () => { const errors = validateEventForm(values, projectToEdit); if (!errors) { let theUpdatedEvent = {}; @@ -60,7 +63,7 @@ const EditMeetingTimes = ({ updatedDate, }; - // Find next occurance of Day in the future + // Find next occurrence of Day in the future // Assign new start time and end time const date = findNextOccuranceOfDay(values.day); const startTimeDate = timeConvertFromForm(date, values.startTime); @@ -69,58 +72,66 @@ const EditMeetingTimes = ({ // 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 + duration: values.duration, }; updateRecurringEvent(theUpdatedEvent, eventID); - showSnackbar("Recurring event updated", 'info') - setSelectedEvent(null); + showSnackbar('Recurring event updated', 'info'); + handleClose(); } setFormErrors(errors); }; const handleEventDelete = (eventID) => async () => { deleteRecurringEvent(eventID); - setSelectedEvent(null); - showSnackbar("Recurring event deleted", 'info'); + showSnackbar('Recurring event deleted', 'info'); + handleClose(); }; return ( -
- - {selectedEvent && ( - - )} -
+ {selectedEvent && ( + + )} + + + ); }; -export default EditMeetingTimes; \ No newline at end of file +export default EditMeetingTimes;