Skip to content

Commit

Permalink
Made small edits, for type checking'
Browse files Browse the repository at this point in the history
  • Loading branch information
manhualu committed Oct 26, 2023
1 parent dd94172 commit 8d906fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions client/src/components/controls/CustomEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
}

Expand Down Expand Up @@ -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}
>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/timetable/CreateEventPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ const CreateEventPopover: React.FC<CreateEventPopoverProps> = ({
// 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']);
}

Expand Down

0 comments on commit 8d906fa

Please sign in to comment.