From a1c9f37081f15a0753e45d9e1c32b3658be3cb88 Mon Sep 17 00:00:00 2001 From: Gerald Schmittinger Date: Wed, 14 May 2025 09:41:09 +0200 Subject: [PATCH 1/2] fix(frontend): Leerpaden voor thema's opvragen in de juiste taal --- frontend/src/controllers/learning-paths.ts | 4 ++-- frontend/src/queries/learning-paths.ts | 7 ++++--- frontend/src/views/SingleTheme.vue | 5 +++-- .../tests/controllers/learning-paths-controller.test.ts | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend/src/controllers/learning-paths.ts b/frontend/src/controllers/learning-paths.ts index bad54286..09a30feb 100644 --- a/frontend/src/controllers/learning-paths.ts +++ b/frontend/src/controllers/learning-paths.ts @@ -26,8 +26,8 @@ export class LearningPathController extends BaseController { }); return LearningPath.fromDTO(single(dtos)); } - async getAllByTheme(theme: string): Promise { - const dtos = await this.get("/", { theme }); + async getAllByThemeAndLanguage(theme: string, language: Language): Promise { + const dtos = await this.get("/", { theme, language }); return dtos.map((dto) => LearningPath.fromDTO(dto)); } diff --git a/frontend/src/queries/learning-paths.ts b/frontend/src/queries/learning-paths.ts index 1f088c9d..9f2424d7 100644 --- a/frontend/src/queries/learning-paths.ts +++ b/frontend/src/queries/learning-paths.ts @@ -22,12 +22,13 @@ export function useGetLearningPathQuery( }); } -export function useGetAllLearningPathsByThemeQuery( +export function useGetAllLearningPathsByThemeAndLanguageQuery( theme: MaybeRefOrGetter, + language: MaybeRefOrGetter ): UseQueryReturnType { return useQuery({ - queryKey: [LEARNING_PATH_KEY, "getAllByTheme", theme], - queryFn: async () => learningPathController.getAllByTheme(toValue(theme)), + queryKey: [LEARNING_PATH_KEY, "getAllByTheme", theme, language], + queryFn: async () => learningPathController.getAllByThemeAndLanguage(toValue(theme), toValue(language)), enabled: () => Boolean(toValue(theme)), }); } diff --git a/frontend/src/views/SingleTheme.vue b/frontend/src/views/SingleTheme.vue index 6924cc1c..23b0145b 100644 --- a/frontend/src/views/SingleTheme.vue +++ b/frontend/src/views/SingleTheme.vue @@ -2,10 +2,11 @@ import type { LearningPath } from "@/data-objects/learning-paths/learning-path.ts"; import LearningPathsGrid from "@/components/LearningPathsGrid.vue"; import UsingQueryResult from "@/components/UsingQueryResult.vue"; - import { useGetAllLearningPathsByThemeQuery } from "@/queries/learning-paths.ts"; + import { useGetAllLearningPathsByThemeAndLanguageQuery } from "@/queries/learning-paths.ts"; import { computed, ref } from "vue"; import { useI18n } from "vue-i18n"; import { useThemeQuery } from "@/queries/themes.ts"; +import type { Language } from "@/data-objects/language"; const props = defineProps<{ theme: string }>(); @@ -16,7 +17,7 @@ const currentThemeInfo = computed(() => themeQueryResult.data.value?.find((it) => it.key === props.theme)); - const learningPathsForThemeQueryResult = useGetAllLearningPathsByThemeQuery(() => props.theme); + const learningPathsForThemeQueryResult = useGetAllLearningPathsByThemeAndLanguageQuery(() => props.theme, () => locale.value as Language); const { t } = useI18n(); const searchFilter = ref(""); diff --git a/frontend/tests/controllers/learning-paths-controller.test.ts b/frontend/tests/controllers/learning-paths-controller.test.ts index 28e4cda2..c987c3a4 100644 --- a/frontend/tests/controllers/learning-paths-controller.test.ts +++ b/frontend/tests/controllers/learning-paths-controller.test.ts @@ -15,7 +15,7 @@ describe("Test controller learning paths", () => { }); it("Can get learning path by id", async () => { - const data = await controller.getAllByTheme("kiks"); + const data = await controller.getAllByThemeAndLanguage("kiks", Language.Dutch); expect(data).to.have.length.greaterThan(0); }); }); From 0d6e9020623676c51f095862658523b9fdedfc1f Mon Sep 17 00:00:00 2001 From: Lint Action Date: Wed, 14 May 2025 07:48:01 +0000 Subject: [PATCH 2/2] style: fix linting issues met Prettier --- frontend/src/queries/learning-paths.ts | 2 +- frontend/src/views/SingleTheme.vue | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/queries/learning-paths.ts b/frontend/src/queries/learning-paths.ts index 9f2424d7..6cccc37c 100644 --- a/frontend/src/queries/learning-paths.ts +++ b/frontend/src/queries/learning-paths.ts @@ -24,7 +24,7 @@ export function useGetLearningPathQuery( export function useGetAllLearningPathsByThemeAndLanguageQuery( theme: MaybeRefOrGetter, - language: MaybeRefOrGetter + language: MaybeRefOrGetter, ): UseQueryReturnType { return useQuery({ queryKey: [LEARNING_PATH_KEY, "getAllByTheme", theme, language], diff --git a/frontend/src/views/SingleTheme.vue b/frontend/src/views/SingleTheme.vue index 23b0145b..c858ac26 100644 --- a/frontend/src/views/SingleTheme.vue +++ b/frontend/src/views/SingleTheme.vue @@ -6,7 +6,7 @@ import { computed, ref } from "vue"; import { useI18n } from "vue-i18n"; import { useThemeQuery } from "@/queries/themes.ts"; -import type { Language } from "@/data-objects/language"; + import type { Language } from "@/data-objects/language"; const props = defineProps<{ theme: string }>(); @@ -17,7 +17,10 @@ import type { Language } from "@/data-objects/language"; const currentThemeInfo = computed(() => themeQueryResult.data.value?.find((it) => it.key === props.theme)); - const learningPathsForThemeQueryResult = useGetAllLearningPathsByThemeAndLanguageQuery(() => props.theme, () => locale.value as Language); + const learningPathsForThemeQueryResult = useGetAllLearningPathsByThemeAndLanguageQuery( + () => props.theme, + () => locale.value as Language, + ); const { t } = useI18n(); const searchFilter = ref("");