761 lines
30 KiB
TypeScript
761 lines
30 KiB
TypeScript
import axios from 'axios';
|
|
import Constants from 'expo-constants';
|
|
|
|
const api = axios.create({
|
|
baseURL: Constants?.expoConfig?.extra?.URL_API
|
|
});
|
|
|
|
export const apiCheckPhoneLogin = async (body: { phone: string }) => {
|
|
const response = await api.post('/auth/login', body)
|
|
return response.data;
|
|
}
|
|
|
|
export const apiSendOtp = async (body: { phone: string, otp: number }) => {
|
|
const message = "Desa+\nMasukkan kode ini " + body.otp + " pada aplikasi Desa+ anda. Jangan berikan pada siapapun."
|
|
const textFix = encodeURIComponent(message)
|
|
// const res = await axios.get(`${Constants.expoConfig?.extra?.URL_OTP}/code?nom=${body.phone}&text=*Desa%2B*%0AMasukkan%20kode%20ini%20*${encodeURIComponent(body.otp)}*%20pada%20aplikasi%20Desa%2B%20anda.%20Jangan%20berikan%20pada%20siapapun.`)
|
|
const res = await fetch(
|
|
`${Constants.expoConfig?.extra?.URL_OTP}/code?nom=${body.phone}&text=${textFix}`,
|
|
{
|
|
cache: "no-cache",
|
|
headers: {
|
|
Authorization: `Bearer ${Constants.expoConfig?.extra?.WA_SERVER_TOKEN}`,
|
|
},
|
|
}
|
|
);
|
|
|
|
|
|
return res.status
|
|
}
|
|
|
|
export const apiGetProfile = async ({ id }: { id: string }) => {
|
|
const response = await api.get(`mobile/user/${id}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiEditProfile = async (data: FormData) => {
|
|
const response = await api.put(`/mobile/user/profile`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetSearch = async ({ text, user }: { text: string, user: string }) => {
|
|
const response = await api.get(`mobile/home/search?search=${text}&user=${user}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetBanner = async ({ user }: { user: string }) => {
|
|
const response = await api.get(`mobile/banner?user=${user}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCreateBanner = async (data: FormData) => {
|
|
const response = await api.post('mobile/banner', data,
|
|
{
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
}
|
|
)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteBanner = async (data: { user: string }, id: string) => {
|
|
const response = await api.delete(`mobile/banner/${id}`, { data })
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetBannerOne = async ({ user, id }: { user: string, id: string }) => {
|
|
const response = await api.get(`mobile/banner/${id}?user=${user}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiEditBanner = async (data: FormData, id: string) => {
|
|
const response = await api.put(`mobile/banner/${id}`, data,
|
|
{
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
}
|
|
)
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiGetDataHome = async ({ cat, user }: { cat: 'kegiatan' | 'division' | 'progress' | 'dokumen' | 'event' | 'discussion' | 'header' | 'check-late-project', user: string }) => {
|
|
const response = await api.get(`mobile/home?user=${user}&cat=${cat}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetGroup = async ({ user, active, search }: { user: string, active: string, search: string }) => {
|
|
const response = await api.get(`mobile/group?user=${user}&active=${active}&search=${search}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCreateGroup = async (data: { user: string, name: string }) => {
|
|
const response = await api.post('mobile/group', data);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiEditGroup = async (data: { user: string, name: string }, id: string) => {
|
|
const response = await api.put(`mobile/group/${id}`, data);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteGroup = async (data: { user: string, isActive: boolean }, id: string) => {
|
|
const response = await api.delete(`mobile/group/${id}`, { data });
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetPosition = async ({ user, active, search, group }: { user: string, active: string, search: string, group?: string }) => {
|
|
const response = await api.get(`mobile/position?user=${user}&active=${active}&group=${group}&search=${search}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCreatePosition = async (data: { user: string, name: string, idGroup: string }) => {
|
|
const response = await api.post('mobile/position', data);
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiDeletePosition = async (data: { user: string, isActive: boolean }, id: string) => {
|
|
const response = await api.delete(`mobile/position/${id}`, { data });
|
|
return response.data;
|
|
};
|
|
|
|
export const apiEditPosition = async (data: { user: string, name: string, idGroup: string }, id: string) => {
|
|
const response = await api.put(`mobile/position/${id}`, data)
|
|
return response.data
|
|
};
|
|
|
|
export const apiGetUser = async ({ user, active, search, group, page }: { user: string, active: string, search: string, group?: string, page?: number }) => {
|
|
const response = await api.get(`mobile/user?user=${user}&active=${active}&group=${group}&search=${search}&page=${page}`);
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiCreateUser = async ({ data }: { data: FormData }) => {
|
|
const response = await api.post('/mobile/user', data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteUser = async (data: { user: string, isActive: boolean }, id: string) => {
|
|
const response = await api.delete(`mobile/user/${id}`, { data })
|
|
return response.data
|
|
};
|
|
|
|
export const apiEditUser = async (data: FormData, id: string) => {
|
|
const response = await api.put(`/mobile/user/${id}`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDiscussionGeneral = async ({ user, active, search, group, page }: { user: string, active: string, search: string, group?: string, page?: number }) => {
|
|
const response = await api.get(`mobile/discussion-general?user=${user}&active=${active}&group=${group}&search=${search}&page=${page}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDiscussionGeneralOne = async ({ id, user, cat }: { id: string, user: string, cat: string }) => {
|
|
const response = await api.get(`mobile/discussion-general/${id}?user=${user}&cat=${cat}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiSendDiscussionGeneralCommentar = async ({ id, data }: { id: string, data: { desc: string, user: string } }) => {
|
|
const response = await api.post(`/mobile/discussion-general/${id}/comment`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteDiscussionGeneralCommentar = async ({ id, data }: { id: string, data: { user: string } }) => {
|
|
const response = await api.delete(`/mobile/discussion-general/${id}/comment`, { data })
|
|
return response.data;
|
|
};
|
|
|
|
export const apiUpdateDiscussionGeneralCommentar = async ({ id, data }: { id: string, data: { desc: string, user: string } }) => {
|
|
const response = await api.put(`/mobile/discussion-general/${id}/comment`, data)
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiDeleteMemberDiscussionGeneral = async (data: { user: string, idUser: string }, id: string) => {
|
|
const response = await api.delete(`mobile/discussion-general/${id}/member`, { data });
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiUpdateStatusDiscussionGeneral = async ({ id, data }: { id: string, data: { status: number, user: string } }) => {
|
|
const response = await api.post(`/mobile/discussion-general/${id}`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteDiscussionGeneral = async (data: { user: string, active: boolean }, id: string) => {
|
|
const response = await api.delete(`mobile/discussion-general/${id}`, { data });
|
|
return response.data;
|
|
};
|
|
|
|
export const apiEditDiscussionGeneral = async (data: FormData, id: string) => {
|
|
const response = await api.put(`/mobile/discussion-general/${id}`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
// export const apiCreateDiscussionGeneral = async ({ data }: { data: { idGroup: string, title: string, desc: string, user: string, member: [] } }) => {
|
|
// const response = await api.post(`/mobile/discussion-general`, data)
|
|
// return response.data;
|
|
// };
|
|
|
|
export const apiCreateDiscussionGeneral = async (data: FormData) => {
|
|
// const response = await api.post(`/mobile/discussion-general`, data)
|
|
const response = await api.post(`/mobile/discussion-general`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiAddMemberDiscussionGeneral = async ({ data, id }: { data: { user: string, member: any[] }, id: string }) => {
|
|
const response = await api.post(`/mobile/discussion-general/${id}/member`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetAnnouncement = async ({ user, search, page }: { user: string, search: string, page?: number }) => {
|
|
const response = await api.get(`mobile/announcement?user=${user}&search=${search}&page=${page}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDivisionGroup = async ({ user }: { user: string }) => {
|
|
const response = await api.get(`mobile/group/get-division?user=${user}`);
|
|
return response.data;
|
|
};
|
|
|
|
// export const apiCreateAnnouncement = async ({ data }: { data: { title: string, desc: string, user: string, groups: any[] } }) => {
|
|
// const response = await api.post(`/mobile/announcement`, data)
|
|
// return response.data;
|
|
// };
|
|
|
|
export const apiCreateAnnouncement = async (data: FormData) => {
|
|
const response = await api.post(`/mobile/announcement`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiGetAnnouncementOne = async ({ user, id }: { user: string, id: string }) => {
|
|
const response = await api.get(`mobile/announcement/${id}?user=${user}`);
|
|
return response.data;
|
|
};
|
|
|
|
// export const apiEditAnnouncement = async (data: { title: string, desc: string, user: string, groups: any[], oldFile: any[] }, id: string) => {
|
|
// const response = await api.put(`/mobile/announcement/${id}`, data)
|
|
// return response.data;
|
|
// };
|
|
|
|
export const apiEditAnnouncement = async (data: FormData, id: string) => {
|
|
const response = await api.put(`/mobile/announcement/${id}`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiDeleteAnnouncement = async (data: { user: string }, id: string) => {
|
|
const response = await api.delete(`mobile/announcement/${id}`, { data })
|
|
return response.data
|
|
};
|
|
|
|
export const apiGetTahunProject = async ({ user }: { user: string }) => {
|
|
const response = await api.get(`mobile/project/tahun?user=${user}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetProject = async ({ user, status, search, group, kategori, page, year }: { user: string, status: string, search: string, group?: string, kategori?: string, page?: number, year?: string }) => {
|
|
const response = await api.get(`mobile/project?user=${user}&status=${status}&group=${group}&search=${search}&cat=${kategori}&page=${page}&year=${year}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetProjectOne = async ({ user, cat, id }: { user: string, cat: 'data' | 'progress' | 'task' | 'file' | 'member' | 'link', id: string }) => {
|
|
const response = await api.get(`mobile/project/${id}?user=${user}&cat=${cat}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiEditProject = async (data: { name: string, user: string }, id: string) => {
|
|
const response = await api.put(`/mobile/project/${id}`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiReportProject = async (data: { report: string, user: string }, id: string) => {
|
|
const response = await api.put(`/mobile/project/${id}/lainnya`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCreateProjectTask = async ({ data, id }: { data: { name: string, dateStart: string, user: string, dateEnd: string, dataDetail: any[] }, id: string }) => {
|
|
const response = await api.post(`/mobile/project/${id}`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCancelProject = async (data: { user: string, reason: string }, id: string) => {
|
|
const response = await api.delete(`mobile/project/${id}`, { data })
|
|
return response.data
|
|
};
|
|
|
|
export const apiUpdateStatusProjectTask = async (data: { user: string, status: number, idProject: string }, id: string) => {
|
|
const response = await api.put(`mobile/project/detail/${id}`, data)
|
|
return response.data
|
|
};
|
|
|
|
export const apiDeleteProjectTask = async (data: { user: string, idProject: string }, id: string) => {
|
|
const response = await api.delete(`mobile/project/detail/${id}`, { data })
|
|
return response.data
|
|
};
|
|
|
|
export const apiGetProjectTask = async ({ user, id, cat }: { user: string, id: string, cat?: string }) => {
|
|
const response = await api.get(`mobile/project/detail/${id}?user=${user}${cat ? `&cat=${cat}` : ""}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiEditProjectTask = async ({ data, id }: { data: { title: string, dateStart: string, user: string, dateEnd: string, dataDetail: any[] }, id: string }) => {
|
|
const response = await api.post(`/mobile/project/detail/${id}`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteProjectMember = async (data: { user: string, idUser: string }, id: string) => {
|
|
const response = await api.delete(`mobile/project/${id}/member`, { data })
|
|
return response.data
|
|
};
|
|
|
|
|
|
export const apiAddMemberProject = async ({ data, id }: { data: { user: string, member: any[] }, id: string }) => {
|
|
const response = await api.post(`/mobile/project/${id}/member`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCreateProject = async (data: FormData) => {
|
|
const response = await api.post(`/mobile/project`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteProject = async (data: { user: string }, id: string) => {
|
|
const response = await api.delete(`/mobile/project/${id}/lainnya`, { data })
|
|
return response.data;
|
|
};
|
|
|
|
export const apiAddLinkProject = async (data: { user: string, link: string }, id: string) => {
|
|
const response = await api.post(`/mobile/project/${id}/link`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiAddFileProject = async ({ data, id }: { data: FormData, id: string }) => {
|
|
const response = await api.post(`/mobile/project/file/${id}`, data,
|
|
{
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
}
|
|
)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCheckFileProject = async ({ data, id }: { data: FormData, id: string }) => {
|
|
const response = await api.put(`/mobile/project/file/${id}`, data,
|
|
{
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
}
|
|
)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteFileProject = async (data: { user: string }, id: string) => {
|
|
const response = await api.delete(`/mobile/project/file/${id}`, { data })
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteLinkProject = async (data: { idLink: string, user: string }, id: string) => {
|
|
const response = await api.delete(`/mobile/project/${id}/link`, { data })
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDivision = async ({ user, search, group, kategori, active, page }: { user: string, search: string, group?: string, kategori?: string, active?: string, page?: number }) => {
|
|
const response = await api.get(`mobile/division?user=${user}&active=${active}&group=${group}&search=${search}&cat=${kategori}&page=${page}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDivisionReport = async ({ user, cat, date, dateEnd, division, group }: { user: string, cat: 'table-progress' | 'lainnya', date: string, dateEnd: string, division: string, group?: string }) => {
|
|
const response = await api.get(`mobile/division/report?user=${user}&cat=${cat}&date=${date}&date-end=${dateEnd}&division=${division}&group=${group}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDivisionOneFeature = async ({ user, cat, id }: { user: string, cat: 'jumlah' | 'today-task' | 'new-file' | 'new-discussion' | 'check-member' | 'check-admin', id: string }) => {
|
|
const response = await api.get(`mobile/division/${id}/detail?user=${user}&cat=${cat}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDivisionOneDetail = async ({ user, id }: { user: string, id: string }) => {
|
|
const response = await api.get(`mobile/division/${id}?user=${user}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiUpdateStatusAdminDivision = async (data: { user: string, id: string, isAdmin: boolean }, id: string) => {
|
|
const response = await api.put(`mobile/division/${id}/detail`, data)
|
|
return response.data
|
|
};
|
|
|
|
export const apiDeleteMemberDivision = async (data: { user: string, id: string }, id: string) => {
|
|
const response = await api.delete(`/mobile/division/${id}/detail`, { data })
|
|
return response.data;
|
|
};
|
|
|
|
export const apiAddMemberDivision = async ({ data, id }: { data: { user: string, member: any[] }, id: string }) => {
|
|
const response = await api.post(`/mobile/division/${id}/detail`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiEditDivision = async (data: { user: string, name: string, desc: string }, id: string) => {
|
|
const response = await api.put(`mobile/division/${id}`, data)
|
|
return response.data
|
|
};
|
|
|
|
export const apiUpdateStatusDivision = async ({ data, id }: { data: { user: string, isActive: boolean }, id: string }) => {
|
|
const response = await api.post(`/mobile/division/${id}/status`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDivisionMember = async ({ user, id, search }: { user: string, id: string, search: string }) => {
|
|
const response = await api.get(`mobile/division/${id}/member?user=${user}&search=${search}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetListDivisionByIdDivision = async ({ user, search, division }: { user: string, search: string, division: string }) => {
|
|
const response = await api.get(`mobile/division/more?user=${user}&search=${search}&division=${division}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCreateDivision = async (data: { data: { idGroup: string, name: string, desc: string }, member: [], admin: string[], user: string }) => {
|
|
const response = await api.post(`/mobile/division`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCheckDivisionName = async (data: { data: { idGroup: string, name: string, desc: string }, user: string }) => {
|
|
const response = await api.put(`/mobile/division`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDiscussion = async ({ user, search, division, active, page }: { user: string, search: string, division: string, active?: string, page?: number }) => {
|
|
const response = await api.get(`mobile/discussion?user=${user}&active=${active}&search=${search}&division=${division}&page=${page}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDiscussionOne = async ({ id, user, cat }: { id: string, user: string, cat: 'data' | 'comment' | 'file' }) => {
|
|
const response = await api.get(`mobile/discussion/${id}?user=${user}&cat=${cat}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiSendDiscussionCommentar = async ({ data, id }: { data: { user: string, comment: string }, id: string }) => {
|
|
const response = await api.post(`/mobile/discussion/${id}/comment`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiEditDiscussionCommentar = async ({ data, id }: { data: { user: string, comment: string }, id: string }) => {
|
|
const response = await api.put(`/mobile/discussion/${id}/comment`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteDiscussionCommentar = async ({ data, id }: { data: { user: string }, id: string }) => {
|
|
const response = await api.delete(`/mobile/discussion/${id}/comment`, { data })
|
|
return response.data;
|
|
};
|
|
|
|
// export const apiEditDiscussion = async ({ data, id }: { data: { user: string, desc: string }, id: string }) => {
|
|
// const response = await api.post(`/mobile/discussion/${id}`, data)
|
|
// return response.data;
|
|
// };
|
|
|
|
export const apiEditDiscussion = async (data: FormData, id: string) => {
|
|
const response = await api.post(`/mobile/discussion/${id}`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
export const apiArchiveDiscussion = async (data: { user: string, active: boolean }, id: string) => {
|
|
const response = await api.put(`mobile/discussion/${id}`, data)
|
|
return response.data
|
|
};
|
|
|
|
export const apiOpenCloseDiscussion = async (data: { user: string, status: number }, id: string) => {
|
|
const response = await api.delete(`mobile/discussion/${id}`, { data })
|
|
return response.data
|
|
};
|
|
|
|
// export const apiCreateDiscussion = async ({ data }: { data: { user: string, desc: string, idDivision: string } }) => {
|
|
// const response = await api.post(`/mobile/discussion`, data)
|
|
// return response.data;
|
|
// };
|
|
|
|
export const apiCreateDiscussion = async (data: FormData) => {
|
|
const response = await api.post(`/mobile/discussion`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetCalendarByDateDivision = async ({ user, date, division }: { user: string, date: string, division: string, }) => {
|
|
const response = await api.get(`mobile/calendar?user=${user}&date=${date}&division=${division}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetIndicatorCalendar = async ({ user, date, division }: { user: string, date: string, division: string, }) => {
|
|
const response = await api.get(`mobile/calendar/indicator?user=${user}&date=${date}&division=${division}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetCalendarOne = async ({ user, id, cat }: { user: string, id: string, cat: 'data' | 'member' }) => {
|
|
const response = await api.get(`mobile/calendar/${id}?user=${user}&cat=${cat}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteCalendarMember = async (data: { user: string, idUser: string }, id: string) => {
|
|
const response = await api.delete(`/mobile/calendar/${id}/member`, { data })
|
|
return response.data
|
|
};
|
|
|
|
export const apiAddMemberCalendar = async ({ data, id }: { data: { user: string, member: any[] }, id: string }) => {
|
|
const response = await api.post(`/mobile/calendar/${id}/member`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDeleteCalendar = async (data: { user: string }, id: string) => {
|
|
const response = await api.delete(`/mobile/calendar/${id}`, { data })
|
|
return response.data
|
|
};
|
|
|
|
export const apiGetCalendarHistory = async ({ user, search, division, page }: { user: string, search: string, division: string, page?: number }) => {
|
|
const response = await api.get(`mobile/calendar/history?user=${user}&search=${search}&division=${division}&page=${page}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCreateCalendar = async ({ data }: { data: { idDivision: string, title: string, desc: string, timeStart: string, timeEnd: string, dateStart: string, repeatEventTyper: string, repeatValue: string, linkMeet: string, member: any[], user: string } }) => {
|
|
const response = await api.post(`/mobile/calendar`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiUpdateCalendar = async ({ data, id }: { data: { title: string, desc: string, timeStart: string, timeEnd: string, dateStart: string, repeatEventTyper: string, repeatValue: number, linkMeet: string, user: string }, id: string }) => {
|
|
const response = await api.put(`/mobile/calendar/${id}`, data)
|
|
return response.data;
|
|
};
|
|
|
|
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 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 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 apiDeleteFileTask = async (data: { user: string }, id: string) => {
|
|
const response = await api.delete(`/mobile/task/file/${id}`, { 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 apiDeleteTaskMember = async (data: { user: string, idUser: string }, id: string) => {
|
|
const response = await api.delete(`mobile/task/${id}/member`, { data })
|
|
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 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 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 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 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 apiCreateTask = async (data: FormData) => {
|
|
const response = await api.post(`/mobile/task`, data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-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 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 apiGetDocument = async ({ user, path, division, category }: { user: string, path: string, division: string, category: 'all' | 'folder' }) => {
|
|
const response = await api.get(`mobile/document?user=${user}&path=${path}&division=${division}&category=${category}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetDocumentInformasi = async ({ user, item, cat }: { user: string, item: string, cat: 'share' | 'lainnya' }) => {
|
|
const response = await api.get(`mobile/document/more?user=${user}&item=${item}&cat=${cat}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDocumentRename = async (data: { name: string, user: string, id: string, path: string, idDivision: string, extension: string }) => {
|
|
const response = await api.put(`/mobile/document`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiDocumentDelete = async (data: { user: string, data: any[] }) => {
|
|
const response = await api.delete(`/mobile/document`, { data })
|
|
return response.data
|
|
};
|
|
|
|
export const apiCreateFolderDocument = async ({ data }: { data: { name: string, path: string, idDivision: string, user: string } }) => {
|
|
const response = await api.post(`/mobile/document`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiUploadFileDocument = async ({ data }: { data: FormData }) => {
|
|
const response = await api.post(`/mobile/document/upload`, data,
|
|
{
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
}
|
|
)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiMoveDocument = async (data: { path: string, dataItem: any[], user: string }) => {
|
|
const response = await api.post(`/mobile/document/more`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiCopyDocument = async (data: { path: string, dataItem: any[], user: string, idDivision: string }) => {
|
|
const response = await api.put(`/mobile/document/more`, data)
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiShareDocument = async (data: { dataDivision: any[], dataItem: any[], user: string }) => {
|
|
const response = await api.delete(`/mobile/document/more`, { data })
|
|
return response.data;
|
|
};
|
|
|
|
export const apiRegisteredToken = async (data: { user: string, token: string }) => {
|
|
const response = await api.post(`/mobile/auth-token`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiUnregisteredToken = async (data: { user: string, token: string }) => {
|
|
const response = await api.put(`/mobile/auth-token`, data)
|
|
return response.data;
|
|
};
|
|
|
|
export const apiGetNotification = async ({ user, page }: { user: string, page?: number }) => {
|
|
const response = await api.get(`mobile/home/notification?user=${user}&page=${page}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const apiReadOneNotification = async (data: { user: string, id: string }) => {
|
|
const response = await api.put(`/mobile/home/notification`, data)
|
|
return response.data;
|
|
}; |