updates on the orders page about four kpis
This commit is contained in:
@@ -27,8 +27,11 @@ export const fetchAppLocations = async () => {
|
||||
|
||||
// ==============================|| fetchPercentageData (orders) ||============================== //
|
||||
|
||||
export const fetchPercentageData = async (appId) => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/orders/getordersummary/?applocationid=${appId}`);
|
||||
export const fetchPercentageData = async ({ queryKey }) => {
|
||||
const [, appId, startdate, enddate, tenantid, locationid] = queryKey;
|
||||
const response = await axios.get(
|
||||
`${process.env.REACT_APP_URL}/orders/getordersummary/?applocationid=${appId}&tenantid=${tenantid}&locationid=${locationid}&fromdate=${startdate}&todate=${enddate}`
|
||||
);
|
||||
const details = response.data.details;
|
||||
|
||||
return {
|
||||
@@ -42,6 +45,7 @@ export const fetchPercentageData = async (appId) => {
|
||||
percentage4: (Math.round((details.cancelled / details.total) * 100) || 0).toString()
|
||||
};
|
||||
};
|
||||
|
||||
// ===================================================== || getTenants || =====================================================
|
||||
|
||||
export const getTenants = async (appId) => {
|
||||
|
||||
@@ -369,11 +369,12 @@ const Orders = () => {
|
||||
error: fetchpercentageError,
|
||||
refetch: percentagedataRefetch
|
||||
} = useQuery({
|
||||
queryKey: ['percentageData', appId],
|
||||
queryFn: () => fetchPercentageData(appId), // Ensure appId is passed
|
||||
queryKey: ['percentageData', appId, startdate, enddate, tenantid, locationid],
|
||||
queryFn: fetchPercentageData,
|
||||
enabled: true
|
||||
});
|
||||
|
||||
|
||||
// ==============================|| getTenants ||============================== //
|
||||
|
||||
const {
|
||||
|
||||
Reference in New Issue
Block a user