Deskripsi: - load page project - pencarian project - filter group project - update label status pada project home No Issues
239 lines
8.6 KiB
TypeScript
239 lines
8.6 KiB
TypeScript
import axios from 'axios';
|
|
|
|
const api = axios.create({
|
|
baseURL: 'http://10.0.2.2:3000/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 res = await axios.get(`https://wa.wibudev.com/code?nom=${body.phone}&text=*DARMASABA*%0A%0A
|
|
JANGAN BERIKAN KODE RAHASIA ini kepada siapa pun TERMASUK PIHAK DARMASABA. Masukkan otentikasi: *${encodeURIComponent(body.otp)}*`)
|
|
return res.status
|
|
}
|
|
|
|
export const apiGetProfile = async ({ id }: { id: string }) => {
|
|
const response = await api.get(`mobile/user/${id}`);
|
|
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) => {
|
|
await api.post('/banner', data, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
}).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
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 }) => {
|
|
await api.post('mobile/group', data).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
export const apiEditGroup = async (data: { user: string, name: string }, id: string) => {
|
|
await api.put(`mobile/group/${id}`, data).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
export const apiDeleteGroup = async (data: { user: string, isActive: boolean }, id: string) => {
|
|
await api.delete(`mobile/group/${id}`, { data }).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
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 }) => {
|
|
await api.post('mobile/position', data).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
|
|
export const apiDeletePosition = async (data: { user: string, isActive: boolean }, id: string) => {
|
|
await api.delete(`mobile/position/${id}`, { data }).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
export const apiEditPosition = async (data: { user: string, name: string, idGroup: string }, id: string) => {
|
|
await api.put(`mobile/position/${id}`, data).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
export const apiGetUser = async ({ user, active, search, group }: { user: string, active: string, search: string, group?: string }) => {
|
|
const response = await api.get(`mobile/user?user=${user}&active=${active}&group=${group}&search=${search}`);
|
|
return response.data;
|
|
};
|
|
|
|
|
|
export const apiCreateUser = async (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) => {
|
|
await api.delete(`mobile/user/${id}`, { data }).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
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 }: { user: string, active: string, search: string, group?: string }) => {
|
|
const response = await api.get(`mobile/discussion-general?user=${user}&active=${active}&group=${group}&search=${search}`);
|
|
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 apiDeleteMemberDiscussionGeneral = async (data: { user: string, idUser: string }, id: string) => {
|
|
await api.delete(`mobile/discussion-general/${id}/member`, { data }).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
|
|
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) => {
|
|
await api.delete(`mobile/discussion-general/${id}`, { data }).then(response => {
|
|
return response.data;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
};
|
|
|
|
export const apiEditDiscussionGeneral = async (data: { user: string, title: string, desc: string }, id: string) => {
|
|
const response = await api.put(`/mobile/discussion-general/${id}`, 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 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 }: { user: string, search: string }) => {
|
|
const response = await api.get(`mobile/announcement?user=${user}&search=${search}`);
|
|
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 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[] }, id: string) => {
|
|
const response = await api.put(`/mobile/announcement/${id}`, 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 apiGetProject = async ({ user, status, search, group, kategori }: { user: string, status: string, search: string, group?: string, kategori?: string }) => {
|
|
const response = await api.get(`mobile/project?user=${user}&status=${status}&group=${group}&search=${search}&cat=${kategori}`);
|
|
return response.data;
|
|
}; |