Add updateWeeklyReport function to API.ts
This commit is contained in:
parent
7df1654bdc
commit
b3e363f391
1 changed files with 43 additions and 0 deletions
|
@ -2,6 +2,7 @@ import { NewProjMember } from "../Components/AddMember";
|
||||||
import { ProjectRoleChange } from "../Components/ChangeRole";
|
import { ProjectRoleChange } from "../Components/ChangeRole";
|
||||||
import { ProjectMember } from "../Components/GetUsersInProject";
|
import { ProjectMember } from "../Components/GetUsersInProject";
|
||||||
import {
|
import {
|
||||||
|
UpdateWeeklyReport,
|
||||||
NewWeeklyReport,
|
NewWeeklyReport,
|
||||||
NewUser,
|
NewUser,
|
||||||
User,
|
User,
|
||||||
|
@ -86,6 +87,17 @@ interface API {
|
||||||
token: string,
|
token: string,
|
||||||
): Promise<APIResponse<string>>;
|
): Promise<APIResponse<string>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a weekly report.
|
||||||
|
* @param {UpdateWeeklyReport} weeklyReport The updated weekly report object.
|
||||||
|
* @param {string} token The authentication token.
|
||||||
|
* @returns {Promise<APIResponse<string>>} A promise containing the API response with the updated report.
|
||||||
|
*/
|
||||||
|
updateWeeklyReport(
|
||||||
|
weeklyReport: UpdateWeeklyReport,
|
||||||
|
token: string,
|
||||||
|
): Promise<APIResponse<string>>;
|
||||||
|
|
||||||
/** Gets a weekly report for a specific user, project and week
|
/** Gets a weekly report for a specific user, project and week
|
||||||
* @param {string} projectName The name of the project.
|
* @param {string} projectName The name of the project.
|
||||||
* @param {string} week The week number.
|
* @param {string} week The week number.
|
||||||
|
@ -416,6 +428,37 @@ export const api: API = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async updateWeeklyReport(
|
||||||
|
weeklyReport: UpdateWeeklyReport,
|
||||||
|
token: string,
|
||||||
|
): Promise<APIResponse<string>> {
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/updateWeeklyReport", {
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: "Bearer " + token,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(weeklyReport),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Failed to update weekly report",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.text();
|
||||||
|
return { success: true, message: data };
|
||||||
|
} catch (e) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Failed to update weekly report",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async getWeeklyReport(
|
async getWeeklyReport(
|
||||||
projectName: string,
|
projectName: string,
|
||||||
week: string,
|
week: string,
|
||||||
|
|
Loading…
Reference in a new issue