Before fuck up
This commit is contained in:
parent
2b41085865
commit
74285dc1cf
1 changed files with 33 additions and 0 deletions
|
@ -24,6 +24,7 @@ interface API {
|
||||||
login(NewUser: NewUser): Promise<APIResponse<string>>;
|
login(NewUser: NewUser): Promise<APIResponse<string>>;
|
||||||
/** Renew the token */
|
/** Renew the token */
|
||||||
renewToken(token: string): Promise<APIResponse<string>>;
|
renewToken(token: string): Promise<APIResponse<string>>;
|
||||||
|
/** Promote user to admin */
|
||||||
/** Create a project */
|
/** Create a project */
|
||||||
createProject(
|
createProject(
|
||||||
project: NewProject,
|
project: NewProject,
|
||||||
|
@ -41,6 +42,10 @@ interface API {
|
||||||
week: string,
|
week: string,
|
||||||
token: string,
|
token: string,
|
||||||
): Promise<APIResponse<NewWeeklyReport>>;
|
): Promise<APIResponse<NewWeeklyReport>>;
|
||||||
|
getWeeklyReportsForProject(
|
||||||
|
projectName: string,
|
||||||
|
token: string,
|
||||||
|
): Promise<APIResponse<NewWeeklyReport[]>>;
|
||||||
/** Gets all the projects of a user*/
|
/** Gets all the projects of a user*/
|
||||||
getUserProjects(token: string): Promise<APIResponse<Project[]>>;
|
getUserProjects(token: string): Promise<APIResponse<Project[]>>;
|
||||||
/** Gets a project from id*/
|
/** Gets a project from id*/
|
||||||
|
@ -232,6 +237,34 @@ export const api: API = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getWeeklyReportsForProject(projectName: string, token: string) {
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/getWeeklyReportsForProject", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: "Bearer " + token,
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ projectName }),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Failed to get weekly reports for project",
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const data = (await response.json()) as NewWeeklyReport[];
|
||||||
|
return { success: true, data };
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Failed to get weekly reports for project",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async login(NewUser: NewUser): Promise<APIResponse<string>> {
|
async login(NewUser: NewUser): Promise<APIResponse<string>> {
|
||||||
try {
|
try {
|
||||||
const response = await fetch("/api/login", {
|
const response = await fetch("/api/login", {
|
||||||
|
|
Loading…
Reference in a new issue