Implemented system to track member qualifications from training reports
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Discharge } from "@shared/schemas/dischargeSchema";
|
||||
import { memberSettings, Member, MemberLight, MemberCardDetails, PaginatedMembers, MemberState, UserCacheBustResult } from "@shared/types/member";
|
||||
import { MemberQualificationView } from "@shared/types/qualification";
|
||||
|
||||
// @ts-ignore
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
@@ -117,6 +118,18 @@ export async function getFullMembers(ids: number[]): Promise<MemberCardDetails[]
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function getMemberQualifications(memberID: number): Promise<MemberQualificationView[]> {
|
||||
const response = await fetch(`${addr}/members/${memberID}/qualifications`, {
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch member qualifications");
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests for the given member to be discharged
|
||||
* @param data discharge packet
|
||||
|
||||
@@ -91,3 +91,19 @@ export async function postTrainingReport(report: CourseEventDetails) {
|
||||
|
||||
return res.json(); // expected to return the inserted report or new ID
|
||||
}
|
||||
|
||||
export async function putTrainingReport(reportId: number, report: CourseEventDetails): Promise<void> {
|
||||
const res = await fetch(`${addr}/courseEvent/${reportId}`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(report),
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const errorText = await res.text();
|
||||
throw new Error(`Failed to update training report: ${res.status} ${errorText}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user