Merge pull request #265 from SELab-2/fix/op-thema-paginas-worden-enkel-nederlandstalige-leerpaden-getoond-#264
fix: Leerpaden voor thema's opvragen in de juiste taal
This commit is contained in:
commit
fe7798b0d0
4 changed files with 13 additions and 8 deletions
|
@ -26,8 +26,8 @@ export class LearningPathController extends BaseController {
|
|||
});
|
||||
return LearningPath.fromDTO(single(dtos));
|
||||
}
|
||||
async getAllByTheme(theme: string): Promise<LearningPath[]> {
|
||||
const dtos = await this.get<LearningPathDTO[]>("/", { theme });
|
||||
async getAllByThemeAndLanguage(theme: string, language: Language): Promise<LearningPath[]> {
|
||||
const dtos = await this.get<LearningPathDTO[]>("/", { theme, language });
|
||||
return dtos.map((dto) => LearningPath.fromDTO(dto));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,13 @@ export function useGetLearningPathQuery(
|
|||
});
|
||||
}
|
||||
|
||||
export function useGetAllLearningPathsByThemeQuery(
|
||||
export function useGetAllLearningPathsByThemeAndLanguageQuery(
|
||||
theme: MaybeRefOrGetter<string>,
|
||||
language: MaybeRefOrGetter<Language>,
|
||||
): UseQueryReturnType<LearningPath[], Error> {
|
||||
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)),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,10 @@
|
|||
|
||||
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("");
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue