chore: lint and format the repo
This commit is contained in:
@@ -5,8 +5,6 @@ import type { CalendarCourseCellProps } from '@views/components/calendar/Calenda
|
||||
|
||||
import useSchedules from './useSchedules';
|
||||
|
||||
|
||||
|
||||
const dayToNumber: { [day: string]: number } = {
|
||||
Monday: 0,
|
||||
Tuesday: 1,
|
||||
@@ -22,7 +20,7 @@ interface CalendarGridPoint {
|
||||
}
|
||||
|
||||
interface componentProps {
|
||||
calendarCourseCellProps: CalendarCourseCellProps;
|
||||
calendarCourseCellProps: CalendarCourseCellProps;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,25 +64,26 @@ export function useFlattenedCourseSchedule(): FlattenedCourseSchedule {
|
||||
if (activeSchedule.courses.length === 0) {
|
||||
return {
|
||||
courseCells: [] as CalendarGridCourse[],
|
||||
activeSchedule
|
||||
activeSchedule,
|
||||
} satisfies FlattenedCourseSchedule;
|
||||
|
||||
}
|
||||
|
||||
const { courses, name, hours } = activeSchedule;
|
||||
|
||||
const processedCourses = courses.flatMap((course: Course) => {
|
||||
const { status, courseDeptAndInstr, meetings } = extractCourseInfo(course);
|
||||
|
||||
if (meetings.length === 0) {
|
||||
return processAsyncCourses({ courseDeptAndInstr, status, course });
|
||||
}
|
||||
|
||||
return meetings.flatMap((meeting: CourseMeeting) =>
|
||||
processInPersonMeetings(meeting, { courseDeptAndInstr, status, course })
|
||||
);
|
||||
}).sort(sortCourses);
|
||||
|
||||
const processedCourses = courses
|
||||
.flatMap((course: Course) => {
|
||||
const { status, courseDeptAndInstr, meetings } = extractCourseInfo(course);
|
||||
|
||||
if (meetings.length === 0) {
|
||||
return processAsyncCourses({ courseDeptAndInstr, status, course });
|
||||
}
|
||||
|
||||
return meetings.flatMap((meeting: CourseMeeting) =>
|
||||
processInPersonMeetings(meeting, { courseDeptAndInstr, status, course })
|
||||
);
|
||||
})
|
||||
.sort(sortCourses);
|
||||
|
||||
return {
|
||||
courseCells: processedCourses as CalendarGridCourse[],
|
||||
activeSchedule: { name, courses, hours } as UserSchedule,
|
||||
@@ -106,29 +105,42 @@ function extractCourseInfo(course: Course) {
|
||||
/**
|
||||
* Function to process each in-person class into its distinct meeting objects for calendar grid
|
||||
*/
|
||||
function processAsyncCourses({ courseDeptAndInstr, status, course }: { courseDeptAndInstr: string, status: StatusType, course: Course }) {
|
||||
return [{
|
||||
calendarGridPoint: {
|
||||
dayIndex: 0,
|
||||
startIndex: 0,
|
||||
endIndex: 0,
|
||||
},
|
||||
componentProps: {
|
||||
courseDeptAndInstr,
|
||||
status,
|
||||
colors: {
|
||||
primaryColor: 'ut-gray',
|
||||
secondaryColor: 'ut-gray',
|
||||
function processAsyncCourses({
|
||||
courseDeptAndInstr,
|
||||
status,
|
||||
course,
|
||||
}: {
|
||||
courseDeptAndInstr: string;
|
||||
status: StatusType;
|
||||
course: Course;
|
||||
}) {
|
||||
return [
|
||||
{
|
||||
calendarGridPoint: {
|
||||
dayIndex: 0,
|
||||
startIndex: 0,
|
||||
endIndex: 0,
|
||||
},
|
||||
componentProps: {
|
||||
courseDeptAndInstr,
|
||||
status,
|
||||
colors: {
|
||||
primaryColor: 'ut-gray',
|
||||
secondaryColor: 'ut-gray',
|
||||
},
|
||||
},
|
||||
course,
|
||||
},
|
||||
course,
|
||||
}] satisfies CalendarGridCourse[];
|
||||
] satisfies CalendarGridCourse[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to process each in-person class into its distinct meeting objects for calendar grid
|
||||
*/
|
||||
function processInPersonMeetings( { days, startTime, endTime, location }: CourseMeeting, { courseDeptAndInstr, status, course }) {
|
||||
function processInPersonMeetings(
|
||||
{ days, startTime, endTime, location }: CourseMeeting,
|
||||
{ courseDeptAndInstr, status, course }
|
||||
) {
|
||||
const time = getTimeString({ separator: '-', capitalize: true }, startTime, endTime);
|
||||
const timeAndLocation = `${time} - ${location ? location.building : 'WB'}`;
|
||||
return days.map(day => ({
|
||||
@@ -150,7 +162,6 @@ function processInPersonMeetings( { days, startTime, endTime, location }: Course
|
||||
})) satisfies CalendarGridCourse[];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility function to sort courses for the calendar grid
|
||||
*/
|
||||
@@ -167,7 +178,6 @@ function sortCourses(a, b) {
|
||||
return endIndexA - endIndexB;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Utility function also present in CourseMeeting object. Wasn't being found at runtime, so I copied it over.
|
||||
*/
|
||||
@@ -217,4 +227,4 @@ type TimeStringOptions = {
|
||||
separator: string;
|
||||
/** capitalizes the AM/PM */
|
||||
capitalize?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user