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