Files
cod-fe/src/api/dashboard-home.jsx
2025-09-17 12:19:00 +07:00

48 lines
1.4 KiB
JavaScript

import { SendRequest } from '../components/Global/ApiRequest';
const getTotal = async (query = '') => {
const prefix = `${query ? `?${query}` : ''}`;
const fullUrl = `${import.meta.env.VITE_API_SERVER}/dashboard/${prefix}`;
try {
const response = await SendRequest({
method: 'get',
prefix: `dashboard/${prefix}`,
});
return response;
} catch (error) {
console.error(`[API Call] Failed: GET ${fullUrl}`, error);
throw error;
}
};
const getTotalPermit = async (query = '') => {
const prefix = `dashboard/permit-total${query ? `?${query}` : ''}`;
const fullUrl = `${import.meta.env.VITE_API_SERVER}/${prefix}`;
try {
const response = await SendRequest({
method: 'get',
prefix,
});
return response;
} catch (error) {
console.error(`[API Call] Failed: GET ${fullUrl}`, error);
throw error;
}
};
const getTotalPermitPerYear = async (query = '') => {
const prefix = `dashboard/permit-breakdown${query ? `?${query}` : ''}`;
const fullUrl = `${import.meta.env.VITE_API_SERVER}/${prefix}`;
try {
const response = await SendRequest({
method: 'get',
prefix,
});
return response;
} catch (error) {
console.error(`[API Call] Failed: GET ${fullUrl}`, error);
throw error;
}
};
export { getTotal, getTotalPermit, getTotalPermitPerYear };