feat(frontend): alle leerpaden en klasses worden gefetched via de controllers
This commit is contained in:
parent
23947ecd92
commit
1328771551
7 changed files with 113 additions and 83 deletions
|
@ -1,8 +1,8 @@
|
|||
import { type MaybeRefOrGetter, toValue } from "vue";
|
||||
import type { Language } from "@/data-objects/language.ts";
|
||||
import { useQuery, type UseQueryReturnType } from "@tanstack/vue-query";
|
||||
import { getLearningPathController } from "@/controllers/controllers";
|
||||
import type { LearningPath } from "@/data-objects/learning-paths/learning-path.ts";
|
||||
import {type MaybeRefOrGetter, toValue} from "vue";
|
||||
import type {Language} from "@/data-objects/language.ts";
|
||||
import {useQuery, type UseQueryReturnType} from "@tanstack/vue-query";
|
||||
import {getLearningPathController} from "@/controllers/controllers";
|
||||
import type {LearningPath} from "@/data-objects/learning-paths/learning-path.ts";
|
||||
|
||||
const LEARNING_PATH_KEY = "learningPath";
|
||||
const learningPathController = getLearningPathController();
|
||||
|
@ -44,3 +44,15 @@ export function useSearchLearningPathQuery(
|
|||
enabled: () => Boolean(toValue(query)),
|
||||
});
|
||||
}
|
||||
|
||||
export function useGetAllLearningPaths(language: MaybeRefOrGetter<string | undefined>
|
||||
): UseQueryReturnType<LearningPath[], Error> {
|
||||
return useQuery({
|
||||
queryKey: [LEARNING_PATH_KEY, "getAllLearningPaths", language],
|
||||
queryFn: async () => {
|
||||
const lang = toValue(language);
|
||||
return learningPathController.getAllLearningPaths(lang);
|
||||
},
|
||||
enabled: () => Boolean(toValue(language))
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue