Deskripsi: - list data lembaga desa - tambah data lembaga desa - edit data lembaga desa - pencarian data lembaga desa - delete data lembaga desa No Issues
98 lines
3.2 KiB
TypeScript
98 lines
3.2 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 updateEntityById = async (id: any, updatedEntity: any) => {
|
|
// const response = await api.put(`/entities/${id}`, updatedEntity);
|
|
// return response.data;
|
|
// };
|
|
|
|
// export const deleteEntityById = async (id: any) => {
|
|
// const response = await api.delete(`/entities/${id}`);
|
|
// return response.data;
|
|
// };
|
|
|
|
// export const checkAccount = async (newEntity: { phone: string }) => {
|
|
// const response = await api.post('/auth/login', newEntity);
|
|
// return response.data;
|
|
// };
|