upd: edit divisi

No Issues
This commit is contained in:
amel
2024-08-12 17:44:57 +08:00
parent 9a000d3387
commit 3ba348ad38
8 changed files with 275 additions and 63 deletions

View File

@@ -1,4 +1,4 @@
import { IFormFixDivision, IFormMemberDivision } from "./type_division";
import { IFormDivision, IFormFixDivision, IFormMemberDivision } from "./type_division";
export const funGetAllDivision = async (path?: string) => {
const response = await fetch(`/api/division${(path) ? path : ''}`, { next: { tags: ['division'] } });
@@ -26,6 +26,17 @@ export const funCreateDivision = async (data: IFormFixDivision) => {
return await response.json().catch(() => null);
}
export const funEditDivision = async (path: string, data: IFormDivision) => {
const response = await fetch(`/api/division/${path}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
}
export const funDeleteMemberDivision = async (path: string, data: { id: string }) => {
const response = await fetch(`/api/division/${path}/detail`, {
method: "DELETE",
@@ -47,4 +58,16 @@ export const funEditStatusAdminDivision = async (path: string, data: { id: strin
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
};
};
export const funAddDivisionMember = async (path: string, data: IFormMemberDivision) => {
const response = await fetch(`/api/division/${path}/detail`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
}