Changes to SubmitWeeklyReport
This commit is contained in:
parent
386f7c3a94
commit
d57fe55074
1 changed files with 14 additions and 17 deletions
|
@ -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",
|
||||
});
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue