feat: logged-in check toegevoegd in de router

This commit is contained in:
Joyelle Ndagijimana 2025-03-17 11:20:48 +01:00
parent 4f67b1e9fe
commit 0d15d068cd
2 changed files with 29 additions and 13 deletions

View file

@ -1,26 +1,24 @@
<script setup lang="ts">
import { ref } from "vue";
import { useRoute } from "vue-router";
import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg";
import { useI18n } from "vue-i18n";
const route = useRoute();
// Import assets
import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg";
const { t, locale } = useI18n();
// Instantiate variables to use in html to render right
// Links and content dependent on the role (student or teacher)
//TODO: use localStorage to know which one in logged in, teacher or student
const isTeacher = route.path.includes("teacher");
const path = "/user";
const userId = route.params.id as string;
const role = isTeacher ? "teacher" : "student";
const role = localStorage.getItem("activeRole");
const name = "Kurt Cobain";
const initials = name
.split(" ")
.map((n) => n[0])
.join("");
// Available languages
const languages = ref([
{ name: "English", code: "en" },
{ name: "Nederlands", code: "nl" },
@ -41,7 +39,7 @@
<ul>
<li>
<router-link
:to="`/${role}/${userId}`"
:to="`${path}`"
class="dwengo_home"
>
<img
@ -55,7 +53,7 @@
</li>
<li>
<router-link
:to="`/${role}/${userId}/assignment`"
:to="`/user/assignment`"
class="menu_item"
>
{{ t("assignments") }}
@ -63,14 +61,14 @@
</li>
<li>
<router-link
:to="`/${role}/${userId}/class`"
:to="`${path}/class`"
class="menu_item"
>{{ t("classes") }}</router-link
>
</li>
<li>
<router-link
:to="`/${role}/${userId}/discussion`"
:to="`${path}/discussion`"
class="menu_item"
>{{ t("discussions") }}
</router-link>