aboutsummaryrefslogtreecommitdiff
path: root/src/components/TamuOutput.svelte
blob: 2ce93e671c18d0f3e6a5f81751cfa2c305b9c18a (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
74
75
76
77
78
79
80
81
<script lang="ts">
    import { ptStore } from "../stores";
    import type PeerTeacher from "../models/PeerTeacher";

    $: peerTeachers = [...$ptStore.values()].sort((a, b) =>
        a.lastname.toUpperCase() === b.lastname.toUpperCase()
            ? 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
    class="flex flex-col overflow-y-auto h-full overflow-x-hidden mx-[25%] pt-10"
>
    {#each peerTeachers as pt}
        <div class="pb-4">
            <hr />
            <p>
                <img
                    class="float-right"
                    alt={pt?.name}
                    src={pt?.drive_pic}
                    width="100"
                    height="125"
                />
            </p>
            <h1 class="text-xl font-bold">
                {pt?.name} |
                <a
                    href="mailto:{pt.email}"
                    rel="noopener"
                    target="_blank"
                    title="${pt?.name} email"
                >
                    Email {pt?.firstname}
                </a>
            </h1>
            {#if pt?.labs.size > 0}
                <p>
                    <strong class="text-lg">Courses:</strong>
                </p>
                <ul class="text-lg">
                    {#each Array.from(getCourses(pt)) as lab}
                        <li>
                            CSCE {lab[0]} - {lab[1]}
                        </li>
                    {/each}
                </ul>
            {/if}
            {#if pt.office_hours != undefined && pt.office_hours.length > 0}
                <p>
                    <strong class="text-lg">Office Hours:</strong>
                </p>
                <ul class="text-lg">
                    {#each pt.office_hours as ofh}
                        <li>{ofh.longInfo}</li>
                    {/each}
                </ul>
            {/if}
        </div>
    {/each}
</div>