Fix: Fake course

This commit is contained in:
philipp lang 2021-11-18 02:16:12 +01:00
parent 4753cbef2e
commit 2b7aca9b0d
2 changed files with 18 additions and 7 deletions

View File

@ -209,13 +209,15 @@ class Api {
$url = self::$url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/flist";
$response = $this->http()->get($url);
return collect($response->json()['data'])->map(function($course) {
return collect($response->json()['data'])->map(function($course) use ($memberId) {
$single = $this->http()->get(self::$url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$course['id']}")['data'];
return (object) [
'id' => $course['entries_id'],
'organizer' => $course['entries_veranstalter'],
'course_name' => $course['entries_baustein'],
'event_name' => $course['entries_vstgName'],
'completed_at' => $course['entries_vstgTag'],
'id' => $single['id'],
'organizer' => $single['veranstalter'],
'course_id' => $single['bausteinId'],
'event_name' => $single['vstgName'],
'completed_at' => $single['vstgTag'],
];
});
}

View File

@ -241,9 +241,18 @@ class FakeBackend {
return Http::response(json_encode([
'success' => true,
'totalEntries' => count($member['courses'] ?? []),
'data' => collect($member['courses'] ?? [])
'data' => collect($member['courses'])->map(fn ($course) => ['id' => $course['id']]),
]) ?: '{}', 200);
}
foreach ($member['courses'] ?? [] as $course) {
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$member['id']}/{$course['id']}") {
return Http::response(json_encode([
'success' => true,
'data' => $course,
]) ?: '{}', 200);
}
}
}
});