diff --git a/client/src/components/controls/CustomEvent.tsx b/client/src/components/controls/CustomEvent.tsx index 1df5ccc59..1db55fe8d 100644 --- a/client/src/components/controls/CustomEvent.tsx +++ b/client/src/components/controls/CustomEvent.tsx @@ -212,7 +212,8 @@ const CustomEvent: React.FC = () => { ); setLatestEndTime(Math.max(Math.ceil(latestEndTime), Math.ceil(endTime.getHours() + endTime.getMinutes() / 60))); - if (daysShort.indexOf(day) == 5 || daysShort.indexOf(day) == 6) { + // Update displayed days on timetable if new event time out of current displayed days + if (daysShort.indexOf(day) === 5 || daysShort.indexOf(day) === 6) { setDays((prev: string[]) => (daysShort.indexOf(day) ? [...prev] : resizeWeekArray(daysShort.indexOf(day)))); } @@ -296,8 +297,8 @@ const CustomEvent: React.FC = () => { color="primary" disableElevation disabled={ - (eventType === 'General' && (eventName === '' || location === '' || eventDays.length === 0)) || - (eventType === 'Tutoring' && (courseCode === '' || classCode === '')) + (eventType === 'General' && (!eventName || eventDays.length === 0)) || + (eventType === 'Tutoring' && (!courseCode || !classCode)) } onClick={createEvents} > diff --git a/client/src/components/timetable/CreateEventPopover.tsx b/client/src/components/timetable/CreateEventPopover.tsx index b58c48eba..40b57d831 100644 --- a/client/src/components/timetable/CreateEventPopover.tsx +++ b/client/src/components/timetable/CreateEventPopover.tsx @@ -59,11 +59,11 @@ const CreateEventPopover: React.FC = ({ // Updating the days of the week must be handled here otherwise // DroppedCards will not have the updated days and it will crash // (which is understandable since it's breaking React best practices by not being purely functional) - if (daysShort.indexOf(day) == 5) { + if (daysShort.indexOf(day) === 5) { const MondayToSaturday: string[] = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; setDays((prev: string[]) => (prev.length > MondayToSaturday.length ? [...prev] : MondayToSaturday)); - } else if (daysShort.indexOf(day) == 6) { + } else if (daysShort.indexOf(day) === 6) { setDays(['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']); }