Files
classroomio/src/routes/courses/[id]/people.svelte
T

64 lines
1.6 KiB
Svelte
Raw Normal View History

<script context="module">
export async function preload({ params }) {
2021-07-13 16:27:02 +00:00
let [courseId] = params.id;
2021-07-13 16:27:02 +00:00
const res = await this.fetch(`api/course?id=${courseId}`);
const data = await res.json();
if (res.status === 200) {
return { courseId, courseData: data };
} else {
this.error(res.status, data.message);
}
}
</script>
<script>
2021-07-13 16:27:02 +00:00
import { stores } from "@sapper/app";
import CourseContainer from "../../../components/CourseContainer/index.svelte";
import PageNav from "../../../components/PageNav/index.svelte";
import UserCard from "../../../components/UserCard/index.svelte";
export let courseData = {};
const { page } = stores();
2021-07-13 16:27:02 +00:00
const teachers = courseData.people;
const students = [...teachers, ...teachers, ...teachers];
</script>
2021-07-13 16:27:02 +00:00
<CourseContainer {courseData}>
<PageNav title="People" disableSticky={true} />
<div class="m-3">
<h3>
<a id="teachers" name="teachers" href="{$page.path}#teachers">Teachers</a>
</h3>
<div class="flex flex-wrap">
{#each teachers as teacher}
<UserCard
name={teacher.name}
avatarUrl={teacher.avatar}
title={teacher.title}
telegramLink={teacher.telegramLink}
mailLink={teacher.mailLink}
/>
{/each}
</div>
</div>
<div class="m-3">
<h3>
<a id="students" name="students" href="{$page.path}#students">Students</a>
</h3>
<div class="flex flex-wrap">
{#each students as student}
<UserCard
name={student.name}
avatarUrl={student.avatar}
title={student.title}
/>
{/each}
</div>
</div>
</CourseContainer>