diff --git a/client/src/components/MainNavigationBar.vue b/client/src/components/MainNavigationBar.vue index 55f3d4d7..51b3ac17 100644 --- a/client/src/components/MainNavigationBar.vue +++ b/client/src/components/MainNavigationBar.vue @@ -6,7 +6,7 @@ import IconSettings from "@/components/icons/IconSettings.vue"; import MobileMenu from "@/components/MobileMenu.vue"; import ItDropdown from "@/components/ui/ItDropdown.vue"; import { useAppStore } from "@/stores/app"; -import { useLearningPathStore } from "@/stores/learningPath"; +import { useCourseSessionsStore } from "@/stores/courseSessions"; import { useUserStore } from "@/stores/user"; import type { DropdownListItem } from "@/types"; import type { Component } from "vue"; @@ -26,8 +26,9 @@ const route = useRoute(); const router = useRouter(); const userStore = useUserStore(); const appStore = useAppStore(); +const courseSessionsStore = useCourseSessionsStore(); + const { t } = useI18n(); -const learningPathStore = useLearningPathStore(); const state = reactive({ showMenu: false }); function toggleNav() { @@ -35,6 +36,7 @@ function toggleNav() { } function isInRoutePath(checkPaths: string[]) { + log.debug("isInRoutePath", checkPaths, route.path); return checkPaths.some((path) => route.path.startsWith(path)); } @@ -42,20 +44,6 @@ function inCourse() { return isInRoutePath(["/learn", "/competence"]); } -function getLearningPathStringProp(prop: "title" | "slug"): string { - return inCourse() && learningPathStore.learningPath - ? learningPathStore.learningPath[prop] - : ""; -} - -function learningPathName(): string { - return getLearningPathStringProp("title"); -} - -function learninPathSlug(): string { - return getLearningPathStringProp("slug"); -} - function handleDropdownSelect(data: DropdownData) { switch (data.action) { case "settings": @@ -75,6 +63,9 @@ function logout() { onMounted(() => { log.debug("MainNavigationBar mounted"); + if (userStore.loggedIn) { + courseSessionsStore.loadCourseSessionsData(); + } }); const profileDropdownData: DropdownListItem[] = [ @@ -100,8 +91,7 @@ const profileDropdownData: DropdownListItem[] = [ @@ -156,8 +146,8 @@ const profileDropdownData: DropdownListItem[] = [ class="flex-auto mt-8 lg:flex lg:space-y-0 lg:flex-row lg:items-center lg:space-x-10 lg:mt-0" > @@ -165,8 +155,8 @@ const profileDropdownData: DropdownListItem[] = [ diff --git a/client/src/components/MobileMenu.vue b/client/src/components/MobileMenu.vue index c6a9e145..3b50fadd 100644 --- a/client/src/components/MobileMenu.vue +++ b/client/src/components/MobileMenu.vue @@ -3,6 +3,7 @@ import IconLogout from "@/components/icons/IconLogout.vue"; import IconSettings from "@/components/icons/IconSettings.vue"; import ItFullScreenModal from "@/components/ui/ItFullScreenModal.vue"; import { useUserStore } from "@/stores/user"; +import type { CourseSession } from "@/types"; import { useRouter } from "vue-router"; const router = useRouter(); @@ -10,15 +11,16 @@ const userStore = useUserStore(); const props = defineProps<{ show: boolean; - learningPathName: string; - learningPathSlug: string; + courseSession: CourseSession | undefined; }>(); const emits = defineEmits(["closemodal"]); -const clickLink = (to: string) => { - router.push(to); - emits("closemodal"); +const clickLink = (to: string | undefined) => { + if (to) { + router.push(to); + emits("closemodal"); + } }; @@ -48,18 +50,16 @@ const clickLink = (to: string) => {
-
-

Kurs: Versicherungsvermittler/in

+
+

{{ courseSession.course.title }}

  • -
  • -
  • diff --git a/client/src/components/learningPath/LearningPathDiagram.vue b/client/src/components/learningPath/LearningPathDiagram.vue index 499b48b9..643da115 100644 --- a/client/src/components/learningPath/LearningPathDiagram.vue +++ b/client/src/components/learningPath/LearningPathDiagram.vue @@ -1,24 +1,21 @@ + + diff --git a/client/src/components/learningPath/LearningPathViewVertical.vue b/client/src/components/learningPath/LearningPathViewVertical.vue index 9aea5c1d..787c291c 100644 --- a/client/src/components/learningPath/LearningPathViewVertical.vue +++ b/client/src/components/learningPath/LearningPathViewVertical.vue @@ -1,6 +1,5 @@ @@ -25,9 +23,10 @@ const emits = defineEmits(["closemodal"]);
    diff --git a/client/src/components/mediaLibrary/MediaLink.vue b/client/src/components/mediaLibrary/MediaLink.vue index e17edcdb..5d0c9f87 100644 --- a/client/src/components/mediaLibrary/MediaLink.vue +++ b/client/src/components/mediaLibrary/MediaLink.vue @@ -6,6 +6,8 @@ import { computed } from "vue"; import { RouterLink } from "vue-router"; const props = defineProps({ + // Vue-TypeScript make special things with `defineProps` so it's hard + // to make this without @ts-ignore... // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore ...RouterLink.props, diff --git a/client/src/fetchHelpers.ts b/client/src/fetchHelpers.ts index e57a75c8..ce5835dc 100644 --- a/client/src/fetchHelpers.ts +++ b/client/src/fetchHelpers.ts @@ -56,3 +56,26 @@ export const itPost = (url: RequestInfo, data: unknown, options: RequestInit = { export const itGet = (url: RequestInfo) => { return itPost(url, {}, { method: "GET" }); }; + +const itGetPromiseCache = new Map>(); + +export function bustItGetCache(key?: string) { + if (key) { + itGetPromiseCache.delete(key); + } else { + itGetPromiseCache.clear(); + } +} + +export const itGetCached = ( + url: RequestInfo, + options = { + reload: false, + } +): Promise => { + if (!itGetPromiseCache.has(url.toString()) || options.reload) { + itGetPromiseCache.set(url.toString(), itGet(url)); + } + + return itGetPromiseCache.get(url.toString()) as Promise; +}; diff --git a/client/src/pages/CockpitPage.vue b/client/src/pages/CockpitPage.vue index 72c0b806..3300308a 100644 --- a/client/src/pages/CockpitPage.vue +++ b/client/src/pages/CockpitPage.vue @@ -1,16 +1,25 @@