Files
sistem-desa-mandiri/src/module/project/lib/api_project.ts
amal 3ec93ffe02 upd: fitur baru
Dekripsi:
- update struktur database
- tambah task detail jam pada project
- get list modal detail jam task project
- api get list detail jam task
- api tambah task detail jam pada project

No Issues
2025-08-18 17:46:28 +08:00

195 lines
6.0 KiB
TypeScript

import { IFormAddDetailproject, IFormAddMemberProject, NewIFormDateProject } from "./type_project";
export const funGetAllProject = async (path?: string) => {
const response = await fetch(`/api/project${(path) ? path : ''}`, { next: { tags: ['project'] } });
return await response.json().catch(() => null);
}
export const funCreateProject = async (data: FormData) => {
const response = await fetch(`/api/project`, {
method: "POST",
body: 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, id?: string) => {
const response = await fetch(`/api/project/${id}/member/${path}`);
return await response.json().catch(() => null);
}
export const funDeleteDetailProject = async (path: string, data: { idProject: string }) => {
const response = await fetch(`/api/project/detail/${path}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
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, kat?: string) => {
const response = await fetch(`/api/project/detail/${path}${(kat) ? `?cat=${kat}` : ''}`);
return await response.json().catch(() => null);
}
export const funEditDetailProject = async (path: string, data: NewIFormDateProject) => {
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);
}
export const funEditReportProject = async (path: string, data: { report: string }) => {
const response = await fetch(`/api/project/${path}/lainnya`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
}
export const funDeleteFileProject = async (path: string) => {
const response = await fetch(`/api/project/file/${path}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
});
return await response.json().catch(() => null);
};
export const funCekNamFileUploadProject = async (path: string, data: FormData) => {
const response = await fetch(`/api/project/file/${path}`, {
method: "PUT",
body: data,
});
return await response.json().catch(() => null);
};
export const funAddFileProject = async (path: string, data: FormData) => {
const response = await fetch(`/api/project/file/${path}`, {
method: "POST",
body: data,
});
return await response.json().catch(() => null);
};
export const funDeleteLinkProject = async (path: string, data: { idLink: string }) => {
const response = await fetch(`/api/project/${path}/link`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
};
export const funDeleteProject = async (path: string) => {
const response = await fetch(`/api/project/${path}/lainnya`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
});
return await response.json().catch(() => null);
};
export const funAddLinkProject = async (path: string, data: { link: string }) => {
const response = await fetch(`/api/project/${path}/link`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
}