fix: fixed issues involving course meeting objects not being recognized as course meeting objects (#132)
* fix: coursemeeting objects now created properly. course popup works on calendar * refactor: removed duplicated getTimeString method in useFlattenedHook * refactor: meeting constructor --------- Co-authored-by: Razboy20 <razboy20@gmail.com>
This commit is contained in:
@@ -7,13 +7,17 @@ import { CourseMeeting, DAY_MAP } from './CourseMeeting';
|
||||
* This represents the schedule for a course, which includes all the meeting times for the course, as well as helper functions for parsing, serializing, and deserializing the schedule
|
||||
*/
|
||||
export class CourseSchedule {
|
||||
meetings: CourseMeeting[] = [];
|
||||
meetings: CourseMeeting[];
|
||||
|
||||
constructor(courseSchedule?: Serialized<CourseSchedule>) {
|
||||
if (!courseSchedule) {
|
||||
return;
|
||||
}
|
||||
Object.assign(this, courseSchedule);
|
||||
this.meetings = [];
|
||||
for (let meeting of courseSchedule.meetings) {
|
||||
this.meetings.push(new CourseMeeting(meeting));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,22 +10,12 @@ export class UserSchedule {
|
||||
name: string;
|
||||
hours: number;
|
||||
|
||||
constructor(schedule: Serialized<UserSchedule>);
|
||||
constructor(courses: Course[], name: string, hours: number);
|
||||
constructor(coursesOrSchedule: Course[] | Serialized<UserSchedule>, name?: string, hours?: number) {
|
||||
if (Array.isArray(coursesOrSchedule)) {
|
||||
this.courses = coursesOrSchedule;
|
||||
this.name = name || '';
|
||||
this.hours = hours || 0;
|
||||
} else {
|
||||
this.courses = coursesOrSchedule?.courses.map(c => new Course(c)) || [];
|
||||
this.name = coursesOrSchedule?.name || 'new schedule';
|
||||
this.hours = 0;
|
||||
if (this.courses && this.courses.length > 0) {
|
||||
for (const course of this.courses) {
|
||||
this.hours += course.creditHours;
|
||||
}
|
||||
}
|
||||
constructor(schedule: Serialized<UserSchedule>) {
|
||||
this.courses = schedule.courses.map(c => new Course(c));
|
||||
this.name = schedule.name;
|
||||
this.hours = 0;
|
||||
for (const course of this.courses) {
|
||||
this.hours += course.creditHours;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user