TS Api for getAllWeeklyReport

This commit is contained in:
Imbus 2024-04-03 17:32:07 +02:00 committed by Peter KW
parent 0a951ecd2b
commit 2ca8c60418

View file

@ -122,9 +122,10 @@ interface API {
* @param {string} token The token of the user * @param {string} token The token of the user
* @returns {APIResponse<WeeklyReport[]>} A list of weekly reports * @returns {APIResponse<WeeklyReport[]>} A list of weekly reports
*/ */
getWeeklyReportsForUser( getAllWeeklyReportsForUser(
projectName: string, projectName: string,
token: string, token: string,
targetUser?: string,
): Promise<APIResponse<WeeklyReport[]>>; ): Promise<APIResponse<WeeklyReport[]>>;
/** Gets all the projects of a user /** Gets all the projects of a user
@ -560,18 +561,22 @@ export const api: API = {
} }
}, },
async getWeeklyReportsForUser( async getAllWeeklyReportsForUser(
projectName: string, projectName: string,
token: string, token: string,
targetUser?: string,
): Promise<APIResponse<WeeklyReport[]>> { ): Promise<APIResponse<WeeklyReport[]>> {
try { try {
const response = await fetch(`/api/getWeeklyReportsUser/${projectName}`, { const response = await fetch(
method: "GET", `/api/getAllWeeklyReports/${projectName}?targetUser=${targetUser}`,
headers: { {
"Content-Type": "application/json", method: "GET",
Authorization: "Bearer " + token, headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
},
}, },
}); );
if (!response.ok) { if (!response.ok) {
return { return {