hooked up UI to API

This commit is contained in:
2025-11-19 13:58:37 -05:00
parent 403a8b394c
commit 7850767967
4 changed files with 47 additions and 30 deletions

View File

@@ -45,4 +45,21 @@ export async function getAllAttendeeRoles(): Promise<CourseAttendeeRole[]> {
console.error("Something went wrong");
throw new Error("Failed to load attendee roles");
}
}
}
export async function postTrainingReport(report: CourseEventDetails) {
const res = await fetch(`${addr}/courseEvent`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(report),
});
if (!res.ok) {
const errorText = await res.text();
throw new Error(`Failed to post training report: ${res.status} ${errorText}`);
}
return res.json(); // expected to return the inserted report or new ID
}