feat: handle navigation / redirect if user is not mentoring

This commit is contained in:
Livio Bieri 2024-03-15 11:57:20 +01:00
parent eea1e95572
commit 514649f358
2 changed files with 25 additions and 10 deletions

View File

@ -1,34 +1,49 @@
<script setup lang="ts"> <script setup lang="ts">
import { useRoute } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { useCurrentCourseSession } from "@/composables";
import { onMounted } from "vue";
const route = useRoute(); const route = useRoute();
const router = useRouter();
const courseSession = useCurrentCourseSession();
// if just a course session member -> hide navigation
// and automatically redirect to mentorsAndParticipants
const isMentoring = courseSession.value.actions.includes(
"learning-mentor::guide-members"
);
onMounted(() => {
if (!isMentoring) {
router.push({ name: "mentorsAndParticipants" });
}
});
</script> </script>
<template> <template>
<div class="bg-gray-200"> <div class="bg-gray-200">
<nav class="border-b bg-white px-4 lg:px-8"> <nav v-if="isMentoring" class="border-b bg-white px-4 lg:px-8">
<ul class="flex flex-col lg:flex-row"> <ul class="flex flex-col lg:flex-row">
<li <li
class="border-t-2 border-t-transparent" class="border-t-2 border-t-transparent"
:class="{ :class="{
'border-b-2 border-b-blue-900': 'border-b-2 border-b-blue-900': route.name
// all detail pages are under overview and prefixed ?.toString()
// except for participants .startsWith('learningMentor'),
route.name?.toString().startsWith('learningMentor') &&
route.name !== 'learningMentorParticipants',
}" }"
> >
<router-link :to="{ name: 'learningMentorOverview' }" class="block py-3"> <router-link :to="{ name: 'learningMentorOverview' }" class="block py-3">
{{ $t("a.Übersicht") }} {{ $t("a.Übersicht") }}
</router-link> </router-link>
</li> </li>
<li <li
class="border-t-2 border-t-transparent lg:ml-12" class="border-t-2 border-t-transparent lg:ml-12"
:class="{ :class="{
'border-b-2 border-b-blue-900': route.name === 'learningMentorParticipants', 'border-b-2 border-b-blue-900': route.name === 'mentorsAndParticipants',
}" }"
> >
<router-link :to="{ name: 'learningMentorParticipants' }" class="block py-3"> <router-link :to="{ name: 'mentorsAndParticipants' }" class="block py-3">
{{ $t("a.Personen") }} {{ $t("a.Personen") }}
</router-link> </router-link>
</li> </li>

View File

@ -185,7 +185,7 @@ const router = createRouter({
path: "participants", path: "participants",
component: () => component: () =>
import("@/pages/learningMentor/mentor/MentorParticipantsPage.vue"), import("@/pages/learningMentor/mentor/MentorParticipantsPage.vue"),
name: "learningMentorParticipants", name: "mentorsAndParticipants",
}, },
{ {
path: "self-evaluation-feedback/:learningUnitId", path: "self-evaluation-feedback/:learningUnitId",