hooked up UI to API
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user