This commit is contained in:
al8763be 2024-03-20 19:37:07 +01:00
commit eff14516b4
8 changed files with 260 additions and 36 deletions

View file

@ -48,8 +48,8 @@ interface API {
projectName: string,
week: string,
token: string,
): Promise<APIResponse<NewWeeklyReport>>;
getWeeklyReportsForProject(
): Promise<APIResponse<WeeklyReport>>;
getWeeklyReportsForUser(
username: string,
projectName: string,
token: string,
@ -252,7 +252,7 @@ export const api: API = {
projectName: string,
week: string,
token: string,
): Promise<APIResponse<NewWeeklyReport>> {
): Promise<APIResponse<WeeklyReport>> {
try {
const response = await fetch("/api/getWeeklyReport", {
method: "GET",
@ -266,7 +266,7 @@ export const api: API = {
if (!response.ok) {
return { success: false, message: "Failed to get weekly report" };
} else {
const data = (await response.json()) as NewWeeklyReport;
const data = (await response.json()) as WeeklyReport;
return { success: true, data };
}
} catch (e) {
@ -274,6 +274,7 @@ export const api: API = {
}
},
<<<<<<< HEAD
async getWeeklyReportsForProject(
username: string,
projectName: string,
@ -281,12 +282,24 @@ export const api: API = {
) {
try {
const response = await fetch("/api/getWeeklyReportsUser", {
=======
async getWeeklyReportsForUser(
username: string,
projectName: string,
token: string,
): Promise<APIResponse<WeeklyReport[]>> {
try {
const response = await fetch(`/api/getWeeklyReportsUser?username=${username}&projectName=${projectName}`, {
>>>>>>> af5813681d11500c0cfe723af1b8d2522bf277d2
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
},
<<<<<<< HEAD
body: JSON.stringify({ username, projectName }),
=======
>>>>>>> af5813681d11500c0cfe723af1b8d2522bf277d2
});
if (!response.ok) {
@ -301,7 +314,7 @@ export const api: API = {
} catch (e) {
return {
success: false,
message: "Failed to get weekly reports for project",
message: "fucked again",
};
}
},