aboutsummaryrefslogtreecommitdiff
path: root/src/models/Lab.ts
blob: c3e21bb3036285adb1078bf126a2696e2884b2e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { assign } from "svelte/internal";
import EventInfo from "./EventInfo";

interface LabSerializeInfo {
    course: number,
    section: number,
    event: {
        days: string,
        start: number,
        end: number
    },
    building: string,
    room: string,
    assigned: boolean,
    faculty: {
        bannerId: string,
        courseReferenceNumber: string,
        displayName: string,
        emailAddress: string,

    }[]
}

export default class Lab {
    id: number;
    course: number;
    section: number;
    event: EventInfo;
    building: string;
    room: string;
    assigned: boolean;
    faculty: {
        bannerId: string;
        courseReferenceNumber: string;
        displayName: string;
        emailAddress: string;

    }[]

    constructor(course: number | string, section: number | string, event: EventInfo, building = "", room = "", assigned = false, faculty = []) {
        if (typeof course === "string") {
            course = parseInt(course, 10);
        }
        if (typeof section === "string") {
            section = parseInt(section, 10);
        }

        this.id = parseInt(`${course}${section}`, 10);
        this.course = course;
        this.section = section;
        this.event = event;
        this.building = building;
        this.room = room;
        this.assigned = assigned;
        this.faculty = faculty;
    }

    static fromJSON({ course, section, event, building, room, assigned, faculty }: LabSerializeInfo) {
        return new Lab(course, section, EventInfo.fromJSON(event), building, room, assigned, faculty);
    }

    get time() {
        return this.event.info;
    }

    get location() {
        return `${this.building} ${this.room}`;
    }

    get pay_hours() {
        return this.event.duration_mins / 50;
    }
}