upd: task divisi

Deskripsi:
- update task divisi
- delete detail task
- update status task
- edit detail task

No Issues
This commit is contained in:
amel
2024-08-19 13:22:02 +08:00
parent 390e13544a
commit e8fcf44558
11 changed files with 592 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
import { IFormTaskDivision } from "./type_task";
import { IFormDateTask, IFormTaskDivision } from "./type_task";
export const funGetAllTask = async (path?: string) => {
const response = await fetch(`/api/task${(path) ? path : ''}`, { next: { tags: ['task'] } });
@@ -23,4 +23,45 @@ export const funCreateTask = async (data: IFormTaskDivision) => {
export const funGetTaskDivisionById = async (path: string, kategori: string) => {
const response = await fetch(`/api/task/${path}?cat=${kategori}`);
return await response.json().catch(() => null);
}
}
export const funDeleteDetailTask = async (path: string) => {
const response = await fetch(`/api/task/detail/${path}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
});
return await response.json().catch(() => null);
};
export const funUpdateStatusDetailTask = async (path: string, data: { status: number }) => {
const response = await fetch(`/api/task/detail/${path}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
};
export const funGetDetailTask = async (path: string) => {
const response = await fetch(`/api/task/detail/${path}`);
return await response.json().catch(() => null);
}
export const funEditDetailTask = async (path: string, data: IFormDateTask) => {
const response = await fetch(`/api/task/detail/${path}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
return await response.json().catch(() => null);
};

View File

@@ -1,4 +1,16 @@
import { hookstate } from "@hookstate/core";
import { IFormMemberTask } from "./type_task";
export const globalMemberTask = hookstate<IFormMemberTask[]>([]);
export const globalMemberTask = hookstate<IFormMemberTask[]>([]);
export const globalRefreshTask = hookstate<boolean>(false);
export const valStatusDetailTask = [
{
name: "Belum Dikerjakan",
value: 0
},
{
name: "Selesai",
value: 1
}
]