Merge remote-tracking branch 'origin/dev' into feat/endpoints-in-backend-om-eigen-leerpaden-en-leerobjecten-toe-te-voegen-aan-de-databank-#248
This commit is contained in:
		
						commit
						ebc4c16c89
					
				
					 7 changed files with 67 additions and 15 deletions
				
			
		|  | @ -29,8 +29,8 @@ export class LearningPathController extends BaseController { | |||
|         } | ||||
|         return LearningPath.fromDTO(dtos[0]); | ||||
|     } | ||||
|     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)); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,12 +30,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(""); | ||||
|  |  | |||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger