Skip to content

Commit

Permalink
refactor: cl -> cls
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun969 committed Sep 25, 2024
1 parent f802dd6 commit 6f9d5a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/data/enrolled-courses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,21 @@ export const useDetailedEnrolledCourses = (): Array<DetailedEnrolledCourse> => {
return {
...course,
name: courseInfo.name,
classes: course.classes.map((cl) => {
classes: course.classes.map((cls) => {
const notFound = {
typeId: cl.id,
typeId: cls.id,
type: 'NOT_FOUND',
classNumber: '66666',
meetings: [],
};
const classInfo = courseInfo.class_list.find((c) => c.id === cl.id);
const classInfo = courseInfo.class_list.find((c) => c.id === cls.id);
if (!classInfo) return notFound;
const { type, classes } = classInfo;
const meetings = classes.find(
(c) => c.number === cl.classNumber,
(c) => c.number === cls.classNumber,
)?.meetings;
if (!meetings) return notFound;
return { typeId: cl.id, type, classNumber: cl.classNumber, meetings };
return { typeId: cls.id, type, classNumber: cls.classNumber, meetings };
}),
};
});
Expand Down
20 changes: 10 additions & 10 deletions src/helpers/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ export const getWeekCourses = (
const courses: WeekCourses = [[], [], [], [], []];

enrolledCourses.forEach((c) => {
c.classes.forEach((cl) => {
cl.meetings.forEach((m) => {
c.classes.forEach((cls) => {
cls.meetings.forEach((m) => {
const isMeetingInWeek = checkDateRangeInWeek(weekStart, m.date);
if (!isMeetingInWeek) return;
const course = courses[WEEK_DAYS.indexOf(m.day)];
const newCourse: WeekCourse = {
id: c.id,
name: c.name,
classTypeId: cl.typeId,
classType: cl.type,
classTypeId: cls.typeId,
classType: cls.type,
location: m.location,
classNumber: cl.classNumber,
classNumber: cls.classNumber,
};
const existingTime = course.find(
(t) => t.time.start === m.time.start && t.time.end === m.time.end,
Expand Down Expand Up @@ -126,7 +126,7 @@ export const useCalendar = () => {
const enrolledCourses = useDetailedEnrolledCourses();

const dates = enrolledCourses.flatMap((c) =>
c.classes.flatMap((cl) => cl.meetings.flatMap((m) => m.date)),
c.classes.flatMap((cls) => cls.meetings.flatMap((m) => m.date)),
);
const [startWeek, endWeek] = getStartEndWeek(dates);

Expand Down Expand Up @@ -191,16 +191,16 @@ export const useOtherWeekCourseTimes = ({
);
if (!classes) return [];
const times: OtherWeekCoursesTimes = [[], [], [], [], []];
classes.forEach((cl) => {
cl.meetings.forEach((m) => {
if (cl.number === currentClassNumber) return;
classes.forEach((cls) => {
cls.meetings.forEach((m) => {
if (cls.number === currentClassNumber) return;
const isMeetingInWeek = checkDateRangeInWeek(currentWeek, m.date);
if (!isMeetingInWeek) return;
const time = times[WEEK_DAYS.indexOf(m.day)];
const existingTime = time.find(
(t) => t.time.start === m.time.start && t.time.end === m.time.end,
);
const newClass = { number: cl.number, location: m.location };
const newClass = { number: cls.number, location: m.location };
if (existingTime) {
existingTime.classes.push(newClass);
return;
Expand Down

0 comments on commit 6f9d5a6

Please sign in to comment.