feat : update project
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { IFormAddDetailproject, IFormAddMemberProject, IFormDateProject, IFormProject } from "./type_project";
|
||||
|
||||
|
||||
export const funGetAllProject = async (path?: string) => {
|
||||
@@ -5,7 +6,120 @@ export const funGetAllProject = async (path?: string) => {
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funCreateProject = async (data: IFormProject) => {
|
||||
const response = await fetch(`/api/project`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funGetOneProjectById = async (path: string, kategori: string) => {
|
||||
const response = await fetch(`/api/project/${path}?cat=${kategori}`);
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funGetAllMemberById = async (path?: string) => {
|
||||
const response = await fetch(`/api/project/${path}/member`);
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
|
||||
export const funDeleteDetailProject = async (path: string) => {
|
||||
const response = await fetch(`/api/project/detail/${path}`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
|
||||
export const funUpdateStatusProject = async (path: string, data: { status: number, idProject: string }) => {
|
||||
const response = await fetch(`/api/project/detail/${path}`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
|
||||
export const funGetDetailProject = async (path: string) => {
|
||||
const response = await fetch(`/api/project/detail/${path}`);
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funEditDetailProject = async (path: string, data: IFormDateProject) => {
|
||||
const response = await fetch(`/api/project/detail/${path}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
|
||||
export const funCreateDetailProject = async (path: string, data: IFormAddDetailproject) => {
|
||||
const response = await fetch(`/api/project/${path}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funAddMemberProject = async (path: string, data: IFormAddMemberProject) => {
|
||||
const response = await fetch(`/api/project/${path}/member`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
|
||||
export const funDeleteMemberProject = async (path: string, data: { idUser: string }) => {
|
||||
const response = await fetch(`/api/project/${path}/member`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funCancelProject = async (path: string, data: { reason: string }) => {
|
||||
const response = await fetch(`/api/project/${path}`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
export const funEditProject = async (path: string, data: { name: string }) => {
|
||||
const response = await fetch(`/api/project/${path}`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
Reference in New Issue
Block a user