This commit is contained in:
insvrgent
2025-02-06 10:32:18 +07:00
parent e2b0ef1046
commit 3e5d795153
3 changed files with 57 additions and 7 deletions

View File

@@ -402,14 +402,22 @@ export const getReports = async (cafeId, filter) => {
);
return response.json();
};
export const getAnalytics = async (filter) => {
const response = await fetch(
API_BASE_URL + "/transaction/get-analytics" + "?type=" + filter,
getHeaders('POST')
);
export const getAnalytics = async (filter, selectedCafeId) => {
// Start the URL with the filter type query
let url = API_BASE_URL + "/transaction/get-analytics" + "?type=" + filter;
// Only add selectedCafeId to the query string if it's not null
if (selectedCafeId !== null) {
url += "&cafeId=" + selectedCafeId;
}
// Fetch with the updated URL
const response = await fetch(url, getHeaders('POST'));
return response.json();
};
export const getIncome = async (cafeId) => {
const response = await fetch(
`${API_BASE_URL}/transaction/get-income/${cafeId}`,