refactor: pecah lib/api.ts dan constants/Styles.ts per domain
- lib/api.ts (879 baris) → 13 file di lib/api/ per domain - constants/Styles.ts (1.275 baris) → 10 file di constants/styles/ per domain - tambah docs/FILE-HEALTH.md dan referensinya ke CLAUDE.md - kedua file lama tetap sebagai re-export — zero breaking changes
This commit is contained in:
144
lib/api/task.api.ts
Normal file
144
lib/api/task.api.ts
Normal file
@@ -0,0 +1,144 @@
|
||||
import api from './client';
|
||||
|
||||
export const apiGetTask = async ({ user, status, search, division, page, year }: { user: string, status: string, search: string, division: string, page?: number, year?: string }) => {
|
||||
const response = await api.get(`mobile/task?user=${user}&status=${status}&division=${division}&search=${search}&page=${page}&year=${year}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetTahunTask = async ({ user, division }: { user: string, division: string }) => {
|
||||
const response = await api.get(`mobile/task/tahun?user=${user}&division=${division}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetTaskOne = async ({ user, cat, id }: { user: string, cat: 'data' | 'progress' | 'task' | 'file' | 'member' | 'link', id: string }) => {
|
||||
const response = await api.get(`mobile/task/${id}?user=${user}&cat=${cat}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiCreateTask = async (data: FormData) => {
|
||||
const response = await api.post(`/mobile/task`, data, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiEditTask = async (data: { title: string, user: string }, id: string) => {
|
||||
const response = await api.put(`/mobile/task/${id}`, data)
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiReportTask = async (data: { report: string, user: string }, id: string) => {
|
||||
const response = await api.put(`/mobile/task/${id}/lainnya`, data)
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiCancelTask = async (data: { user: string, reason: string }, id: string) => {
|
||||
const response = await api.delete(`mobile/task/${id}`, { data })
|
||||
return response.data
|
||||
};
|
||||
|
||||
export const apiDeleteTask = async (data: { user: string }, id: string) => {
|
||||
const response = await api.delete(`/mobile/task/${id}/lainnya`, { data })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiAddMemberTask = async ({ data, id }: { data: { user: string, member: any[], idDivision: string }, id: string }) => {
|
||||
const response = await api.post(`/mobile/task/${id}/member`, data)
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiDeleteTaskMember = async (data: { user: string, idUser: string }, id: string) => {
|
||||
const response = await api.delete(`mobile/task/${id}/member`, { data })
|
||||
return response.data
|
||||
};
|
||||
|
||||
export const apiAddLinkTask = async (data: { user: string, link: string, idDivision: string }, id: string) => {
|
||||
const response = await api.post(`/mobile/task/${id}/link`, data)
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiDeleteLinkTask = async (data: { user: string, idLink: string }, id: string) => {
|
||||
const response = await api.delete(`/mobile/task/${id}/link`, { data })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiAddFileTask = async ({ data, id }: { data: FormData, id: string }) => {
|
||||
const response = await api.post(`/mobile/task/file/${id}`, data, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiCheckFileTask = async ({ data, id }: { data: FormData, id: string }) => {
|
||||
const response = await api.put(`/mobile/task/file/${id}`, data, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiDeleteFileTask = async (data: { user: string }, id: string) => {
|
||||
const response = await api.delete(`/mobile/task/file/${id}`, { data })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiUpdateStatusTaskDivision = async (data: { user: string, status: number, idProject: string }, id: string) => {
|
||||
const response = await api.put(`mobile/task/detail/${id}`, data)
|
||||
return response.data
|
||||
};
|
||||
|
||||
export const apiGetTaskTugas = async ({ user, id, cat }: { user: string, id: string, cat?: string }) => {
|
||||
const response = await api.get(`mobile/task/detail/${id}?user=${user}${cat ? `&cat=${cat}` : ""}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiCreateTaskTugas = async ({ data, id }: { data: { title: string, dateStart: string, user: string, dateEnd: string, idDivision: string, dataDetail: any[] }, id: string }) => {
|
||||
const response = await api.post(`/mobile/task/${id}`, data)
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiEditTaskTugas = async ({ data, id }: { data: { title: string, dateStart: string, user: string, dateEnd: string, dataDetail: any[] }, id: string }) => {
|
||||
const response = await api.post(`/mobile/task/detail/${id}`, data)
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiDeleteTaskTugas = async (data: { user: string, idProject: string }, id: string) => {
|
||||
const response = await api.delete(`mobile/task/detail/${id}`, { data })
|
||||
return response.data
|
||||
};
|
||||
|
||||
export const apiGetTugasTaskFile = async ({ user, id }: { user: string, id: string }) => {
|
||||
const response = await api.get(`/mobile/task/tugas/file/${id}`, { params: { user } })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiAddTugasTaskFile = async ({ data, id }: { data: FormData, id: string }) => {
|
||||
const response = await api.post(`/mobile/task/tugas/file/${id}`, data, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiLinkTugasTaskFile = async ({ user, idFile, id }: { user: string, idFile: string, id: string }) => {
|
||||
const response = await api.patch(`/mobile/task/tugas/file/${id}`, { user, idFile })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiDeleteTugasTaskFile = async (data: { user: string }, id: string) => {
|
||||
const response = await api.delete(`/mobile/task/tugas/file/${id}`, { data })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetTaskTugasApprovals = async ({ user, id }: { user: string, id: string }) => {
|
||||
const response = await api.get(`/mobile/task/tugas/${id}/approval`, { params: { user } })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiSubmitTaskTugas = async ({ user, id }: { user: string, id: string }) => {
|
||||
const response = await api.post(`/mobile/task/tugas/${id}/approval`, { user })
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiApproveRejectTaskTugas = async ({ user, id, action, note }: { user: string, id: string, action: 'approve' | 'reject', note?: string }) => {
|
||||
const response = await api.put(`/mobile/task/tugas/${id}/approval`, { user, action, note })
|
||||
return response.data;
|
||||
};
|
||||
Reference in New Issue
Block a user