From a19894369bc759c31cde45493f1c41548c0e55d8 Mon Sep 17 00:00:00 2001
From: Furkan Sahin <furkan-dev@proton.me>
Date: Sat, 30 Jul 2022 17:21:29 -0500
Subject: parsing labs for faculty information, begin displaying lab's faculuty
 information (in Labs page for example)

---
 src/components/Labs.svelte | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

(limited to 'src/components/Labs.svelte')

diff --git a/src/components/Labs.svelte b/src/components/Labs.svelte
index 9f6e781..4df2184 100644
--- a/src/components/Labs.svelte
+++ b/src/components/Labs.svelte
@@ -7,7 +7,16 @@
 
   $: labs = [...$labStore.values()].sort((a, b) => a.id - b.id);
 
-  let headers = ["", "Course", "Sec", "Time", "Location", "Assigned PT", ""];
+  let headers = [
+    "",
+    "Course",
+    "Sec",
+    "Time",
+    "Location",
+    "Instructor",
+    "Assigned PT",
+    "",
+  ];
 
   $: pts = [...$ptStore.values()];
 
@@ -23,6 +32,17 @@
     ];
   });
 
+  function displayFaculty(lab: Lab): string {
+    if (lab.faculty.length > 0) {
+      let s: string[] = [];
+      lab.faculty.forEach((f) => {
+        s.push(f.displayName);
+      });
+      return s.join(",");
+    } else {
+      return "N/A";
+    }
+  }
   function download() {
     // prepare data in CSV format
     let cols = headers.slice(1, -1);
@@ -78,6 +98,7 @@
           <th>{l.lab?.section}</th>
           <th>{l.lab?.time}</th>
           <th>{l.lab?.location}</th>
+          <th>{displayFaculty(l.lab)}</th>
           <th>{l.pt?.name ?? "UNASSIGNED"}</th>
           <th><button class="btn btn-ghost btn-xs">Delete</button></th>
         </tr>
-- 
cgit v1.2.3

