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,
|
token: string,
|
||||||
): Promise<APIResponse<Project>> {
|
): Promise<APIResponse<Project>> {
|
||||||
try {
|
try {
|
||||||
return fetch("/api/submitWeeklyReport", {
|
const response = await fetch("/api/submitWeeklyReport", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Authorization: "Bearer " + token,
|
Authorization: "Bearer " + token,
|
||||||
},
|
},
|
||||||
body: JSON.stringify(project),
|
body: JSON.stringify(project),
|
||||||
})
|
});
|
||||||
.then((response) => {
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Failed to submit weekly report",
|
message: "Failed to submit weekly report",
|
||||||
};
|
};
|
||||||
} else {
|
}
|
||||||
return response.json();
|
|
||||||
}
|
const data = (await response.json()) as Project;
|
||||||
})
|
return { success: true, data };
|
||||||
.then((data: Project) => {
|
|
||||||
return { success: true, data };
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.resolve({
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Failed to submit weekly report",
|
message: "Failed to submit weekly report",
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue