From fea56ae09cd612003e1bafd2459556b67a5950e9 Mon Sep 17 00:00:00 2001 From: Furkan Sahin Date: Sun, 5 Sep 2021 22:56:45 -0500 Subject: Add import/export functionality --- src/models/Lab.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/models/Lab.ts') diff --git a/src/models/Lab.ts b/src/models/Lab.ts index 8636f74..d23cffb 100644 --- a/src/models/Lab.ts +++ b/src/models/Lab.ts @@ -1,4 +1,16 @@ -import type EventInfo from "./EventInfo"; +import EventInfo from "./EventInfo"; + +interface LabSerializeInfo { + course: number, + section: number, + event: { + days: string, + start: number, + end: number + }, + building: string, + room: string +} export default class Lab { id: number; @@ -24,6 +36,10 @@ export default class Lab { this.room = room; } + static fromJSON({course, section, event, building, room}: LabSerializeInfo) { + return new Lab(course, section, EventInfo.fromJSON(event), building, room); + } + get time() { return this.event.info; } -- cgit v1.2.3