feat: interface toevoegingen voor het type any te vermijden

This commit is contained in:
Gabriellvl 2025-03-01 18:03:14 +01:00
parent ae4d76a84b
commit 13f563bb56
2 changed files with 48 additions and 8 deletions

View file

@ -0,0 +1,46 @@
export interface LearningPathResponse {
success: boolean;
source: string;
data: any[] | null;
message?: string;
}
export interface LearningPath {
_id: string;
language: string;
hruid: string;
title: string;
description: string;
image?: string; // Image might be missing, so it's optional
num_nodes: number;
num_nodes_left: number;
nodes: LearningObjectNode[];
keywords: string;
target_ages: number[];
min_age: number;
max_age: number;
__order: number;
}
interface LearningObjectNode {
_id: string;
learningobject_hruid: string;
version: number;
language: string;
start_node?: boolean;
transitions: Transition[];
created_at: string;
updatedAt: string;
}
interface Transition {
default: boolean;
_id: string;
next: {
_id: string;
hruid: string;
version: number;
language: string;
};
}

View file

@ -1,12 +1,6 @@
import { fetchWithLogging } from "../util/apiHelper.js"; import { fetchWithLogging } from "../util/apiHelper.js";
import { DWENGO_API_BASE } from "../config/config.js"; import { DWENGO_API_BASE } from "../config/config.js";
import {LearningPath, LearningPathResponse} from "../interfaces/learningPath.js";
interface LearningPathResponse {
success: boolean;
source: string;
data: any[] | null;
message?: string;
}
export async function fetchLearningPaths( export async function fetchLearningPaths(
hruids: string[], hruids: string[],
@ -25,7 +19,7 @@ export async function fetchLearningPaths(
const apiUrl = `${DWENGO_API_BASE}/learningPath/getPathsFromIdList`; const apiUrl = `${DWENGO_API_BASE}/learningPath/getPathsFromIdList`;
const params = { pathIdList: JSON.stringify({ hruids }), language }; const params = { pathIdList: JSON.stringify({ hruids }), language };
const learningPaths = await fetchWithLogging<any>(apiUrl, `Learning paths for ${source}`, params); const learningPaths = await fetchWithLogging<LearningPath[]>(apiUrl, `Learning paths for ${source}`, params);
if (!learningPaths || learningPaths.length === 0) { if (!learningPaths || learningPaths.length === 0) {
console.error(`⚠️ WARNING: No learning paths found for ${source}.`); console.error(`⚠️ WARNING: No learning paths found for ${source}.`);