aboutsummaryrefslogtreecommitdiff
path: root/src/logic/EditorActions.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/logic/EditorActions.ts')
-rw-r--r--src/logic/EditorActions.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/logic/EditorActions.ts b/src/logic/EditorActions.ts
new file mode 100644
index 0000000..4a83fbc
--- /dev/null
+++ b/src/logic/EditorActions.ts
@@ -0,0 +1,33 @@
+import { parseDatabase, parseLabSchedule, parsePTSchedule } from "../util/parser";
+
+export async function parsePTFile(file: File) {
+ try {
+ const text = await file.text();
+ return parsePTSchedule(text);
+ } catch (error) {
+ console.error(file.name, error);
+ throw error;
+ }
+}
+
+export async function parseLabScheduleFile(file: File) {
+ const text = await file.text();
+ try {
+ const labSchedule = JSON.parse(text);
+ return parseLabSchedule(labSchedule);
+ } catch (error) {
+ console.error(file.name, error);
+ throw error;
+ }
+}
+
+export async function parseDatabaseFile(file: File) {
+ const text = await file.text();
+ try {
+ const database = JSON.parse(text);
+ return parseDatabase(database);
+ } catch (error) {
+ console.error(file.name, error);
+ throw error;
+ }
+}