Add api
This commit is contained in:
48
src/api/dashboard-home.jsx
Normal file
48
src/api/dashboard-home.jsx
Normal file
@@ -0,0 +1,48 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user