updates on the orders and assign page
This commit is contained in:
@@ -24,6 +24,34 @@ export const fetchOrders = async ({ pageParam = 1, queryKey }) => {
|
||||
};
|
||||
};
|
||||
|
||||
// ==============================|| fetchPercentageData (orders) ||============================== //
|
||||
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 {
|
||||
created: details.created.toString(),
|
||||
uncoveredOrders: details.pending.toString(),
|
||||
coveredOrders: details.delivered.toString(),
|
||||
cancelled: details.cancelled.toString(),
|
||||
percentage1: (Math.round((details.created / details.total) * 100) || 0).toString(),
|
||||
percentage2: (Math.round((details.pending / details.total) * 100) || 0).toString(),
|
||||
percentage3: (Math.round((details.delivered / details.total) * 100) || 0).toString(),
|
||||
percentage4: (Math.round((details.cancelled / details.total) * 100) || 0).toString()
|
||||
};
|
||||
};
|
||||
|
||||
// ==============================|| fetchorderscount (orders) ||============================== //
|
||||
export const fetchorderscount = async ({ queryKey }) => {
|
||||
const [, appId, startdate, enddate, currentStatus, tenantid, locationid] = queryKey;
|
||||
const url = `${process.env.REACT_APP_URL}/orders/getordersummary/?applocationid=${appId}&tenantid=${tenantid}&locationid=${locationid}&fromdate=${startdate}&todate=${enddate}&status=${currentStatus}`;
|
||||
const response = await axios.get(url);
|
||||
return response.data.details;
|
||||
};
|
||||
|
||||
// ==============================|| fetchOrderSummary (orders)||============================== //
|
||||
export const fetchOrderSummary = async () => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/orders/getordersummary`);
|
||||
@@ -385,12 +413,12 @@ export const createAutomationDeliveries = async (variables) => {
|
||||
const absentRiders = Array.isArray(variables.absent_riders) ? variables.absent_riders : [];
|
||||
|
||||
const url =
|
||||
variables.selectedMode.value == 1
|
||||
variables.selectedMode?.value == 1
|
||||
? `https://routes.workolik.com/api/v1/optimization/riderassign?hypertuning_params=${variables.hypertuning_params}`
|
||||
: `https://routemate.workolik.com/api/v1/optimization/riderassign?strategy=multi_trip`;
|
||||
|
||||
const body =
|
||||
variables.selectedMode.value == 1
|
||||
variables.selectedMode?.value == 1
|
||||
? { deliveries: variables.deliveries, absent_riders: absentRiders }
|
||||
: { ...(variables.data || {}), absent_riders: absentRiders };
|
||||
|
||||
@@ -431,3 +459,37 @@ export const fetchDeliveries = async ({ pageParam = 1, queryKey }) => {
|
||||
nextPage: response.data.details.length === Number(rowsPerPage) ? pageParam + 1 : undefined
|
||||
};
|
||||
};
|
||||
|
||||
// Fetch payment types.
|
||||
export const fetchPaymentType = async () => {
|
||||
const { data } = await axios.get(`${process.env.REACT_APP_URL}/utils/getapptypes/?tag=paymentmode`);
|
||||
return data.details.map((val) => ({
|
||||
...val,
|
||||
label: val.typename
|
||||
}));
|
||||
};
|
||||
|
||||
// Fetch all riders.
|
||||
export const getallriders = async () => {
|
||||
try {
|
||||
const res = await axios.get(`${process.env.REACT_APP_URL}/partners/getallriders?partnerid=64`);
|
||||
return res.data.details;
|
||||
} catch (err) {
|
||||
console.log('getallriders', err.message);
|
||||
}
|
||||
};
|
||||
|
||||
// Cancel multiple orders.
|
||||
export const cancelMultipleOrder = async (orderlist) => {
|
||||
const data = orderlist?.map((e) => ({
|
||||
orderheaderid: e.orderheaderid,
|
||||
orderstatus: 'cancelled',
|
||||
cancelled: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
}));
|
||||
|
||||
const response = await axios.put(`${process.env.REACT_APP_URL}/orders/updatemultipleorders`, data);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user