Changes to SubmitWeeklyReport

This commit is contained in:
al8763be 2024-03-17 16:11:03 +01:00
parent 386f7c3a94
commit d57fe55074

View file

@ -167,32 +167,29 @@ export const api: API = {
token: string,
): Promise<APIResponse<Project>> {
try {
return fetch("/api/submitWeeklyReport", {
const response = await fetch("/api/submitWeeklyReport", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
},
body: JSON.stringify(project),
})
.then((response) => {
if (!response.ok) {
return {
success: false,
message: "Failed to submit weekly report",
};
} else {
return response.json();
}
})
.then((data: Project) => {
return { success: true, data };
});
});
if (!response.ok) {
return {
success: false,
message: "Failed to submit weekly report",
};
}
const data = (await response.json()) as Project;
return { success: true, data };
} catch (e) {
return Promise.resolve({
return {
success: false,
message: "Failed to submit weekly report",
});
};
}
},