pertama dan terakhir

This commit is contained in:
Tazyeuu
2026-06-10 22:07:47 +07:00
commit cd376094df
143 changed files with 12090 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
export const BASE_URL = '';
const createService = (endpoint) => ({
getAll: async () => {
const res = await fetch(`${BASE_URL}/${endpoint}`);
const json = await res.json();
return json.data;
},
create: async (data) => {
const res = await fetch(`${BASE_URL}/${endpoint}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
const json = await res.json();
return json.data;
},
delete: async (id) => {
const res = await fetch(`${BASE_URL}/${endpoint}?id=${id}`, {
method: 'DELETE'
});
const json = await res.json();
return json.data;
}
});
// P01
export const spbuService = createService('01/backend/api/spbu.php');
export const jalanService = createService('01/backend/api/jalan.php');
export const kavlingService = createService('01/backend/api/kavling.php');
// P02
export const rumahIbadahService = createService('02/backend/api/rumah_ibadah.php');
export const wargaMiskinService = createService('02/backend/api/warga_miskin.php');
export const haversineService = {
getDalamRadius: async (id, radius) => {
const res = await fetch(`${BASE_URL}/02/backend/api/haversine.php?rumah_ibadah_id=${id}&radius_km=${radius}`);
const json = await res.json();
return json.data;
}
};
@@ -0,0 +1,22 @@
import { CONFIG } from '../config.js';
export const rumahIbadahService = {
getAll: async () => {
const res = await fetch(`${CONFIG.BASE_URL}/rumah_ibadah.php`);
return await res.json();
},
save: async (data) => {
const res = await fetch(`${CONFIG.BASE_URL}/rumah_ibadah.php`, {
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data)
});
return await res.json();
},
delete: async (id) => {
const res = await fetch(`${CONFIG.BASE_URL}/rumah_ibadah.php?id=${id}`, { method: 'DELETE' });
return await res.json();
},
getJangkauan: async (id, radius = 1) => {
const res = await fetch(`${CONFIG.BASE_URL}/rumah_ibadah.php?action=jangkauan&id=${id}&radius=${radius}`);
return await res.json();
}
};
@@ -0,0 +1,10 @@
export const CONFIG = {
BASE_URL: '/final/backend/api'
};
export const statistikService = {
getKepadatan: async () => {
const res = await fetch(`${CONFIG.BASE_URL}/statistik.php`);
return await res.json();
}
};
@@ -0,0 +1,18 @@
import { CONFIG } from '../config.js';
export const wargaMiskinService = {
getAll: async () => {
const res = await fetch(`${CONFIG.BASE_URL}/warga_miskin.php`);
return await res.json();
},
save: async (data) => {
const res = await fetch(`${CONFIG.BASE_URL}/warga_miskin.php`, {
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data)
});
return await res.json();
},
delete: async (id) => {
const res = await fetch(`${CONFIG.BASE_URL}/warga_miskin.php?id=${id}`, { method: 'DELETE' });
return await res.json();
}
};