feat(frontend): Navigatie voor leerpad geïmplementeerd.

This commit is contained in:
Gerald Schmittinger 2025-03-23 19:20:56 +01:00
parent 3c3fddb7d0
commit 07340de2e3
13 changed files with 216 additions and 54 deletions

View file

@ -1,13 +1,23 @@
import {GetEndpoint} from "@/services/api-client/endpoints/get-endpoint.ts";
import {LearningPath, type LearningPathDTO} from "@/services/learning-content/learning-path.ts";
import type {RemoteResource} from "@/services/api-client/remote-resource.ts";
import type {Language} from "@/services/learning-content/language.ts";
import {single} from "@/utils/response-assertions.ts";
const searchLearningPathsEndpoint = new GetEndpoint<{}, {query: string}, LearningPathDTO[]>(
"/learningObjects/:query"
const learningPathEndpoint = new GetEndpoint<{}, {search?: string, hruid?: string, language?: Language}, LearningPathDTO[]>(
"/learningPath"
);
export function searchLearningPaths(query: string): RemoteResource<LearningPath[]> {
return searchLearningPathsEndpoint
.get({}, {query: query})
return learningPathEndpoint
.get({}, {search: query})
.map(dtos => dtos.map(dto => LearningPath.fromDTO(dto)));
}
export function getLearningPath(hruid: string, language: Language): RemoteResource<LearningPath> {
console.log({hruid, language})
return learningPathEndpoint
.get({}, {hruid, language})
.map(it => {console.log(it); return it;})
.map(dtos => LearningPath.fromDTO(single(dtos)));
}