From a4bd240abc1675ae22c431ed298a01ac6b231f53 Mon Sep 17 00:00:00 2001
From: Furkan Sahin <furkan-dev@proton.me>
Date: Tue, 16 Aug 2022 22:37:28 -0500
Subject: `feat`: Display PT's courses

Add func to output a map of `courses_can_teach : assigned_labs[]`
---
 src/components/TamuOutput.svelte | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

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

diff --git a/src/components/TamuOutput.svelte b/src/components/TamuOutput.svelte
index 2ce93e6..1d2d26d 100644
--- a/src/components/TamuOutput.svelte
+++ b/src/components/TamuOutput.svelte
@@ -7,25 +7,6 @@
             ? a.firstname.toUpperCase().localeCompare(b.firstname.toUpperCase())
             : a.lastname.toUpperCase().localeCompare(b.lastname.toUpperCase())
     );
-
-    function getCourses(pt: PeerTeacher) {
-        const courses = new Map<number, number[]>();
-        const getCourse = (x: number) => Math.floor(x / 1000);
-        pt.labs.forEach((lab_id) => {
-            const key = getCourse(lab_id);
-            const sec = lab_id % 1000;
-            if (courses.has(key)) {
-                courses.get(key).push(sec);
-            } else {
-                courses.set(key, [sec]);
-            }
-        });
-        pt.can_teach.forEach((course) => {
-            if (course == null || course == undefined) return;
-            if (!courses.has(course)) courses.set(course, []);
-        });
-        return courses;
-    }
 </script>
 
 <div
@@ -59,7 +40,7 @@
                     <strong class="text-lg">Courses:</strong>
                 </p>
                 <ul class="text-lg">
-                    {#each Array.from(getCourses(pt)) as lab}
+                    {#each Array.from(pt.coursesAndLabs()) as lab}
                         <li>
                             CSCE {lab[0]} - {lab[1]}
                         </li>
-- 
cgit v1.2.3

