overall updates
This commit is contained in:
@@ -1,6 +1,28 @@
|
||||
import axios from 'axios';
|
||||
const tenid = localStorage.getItem('tenantid');
|
||||
|
||||
export const fetchOrders = async ({ pageParam = 1, queryKey }) => {
|
||||
const [, { tenantId, locationId, status, startdate, enddate, searchword, rowsPerPage }] = queryKey;
|
||||
|
||||
const url =
|
||||
`${process.env.REACT_APP_URL}/orders/tenant/getorders/` +
|
||||
`?tenantid=${tenantId}` +
|
||||
`&locationid=${locationId}` +
|
||||
`&status=${status}` +
|
||||
`&fromdate=${startdate}` +
|
||||
`&todate=${enddate}` +
|
||||
`&pageno=${pageParam}` + // 👈 pageParam comes from TanStack
|
||||
`&pagesize=${rowsPerPage}` +
|
||||
`&keyword=${searchword}`;
|
||||
|
||||
const res = await axios.get(url);
|
||||
return {
|
||||
details: res.data.details,
|
||||
nextPage: res.data.details.length === rowsPerPage ? pageParam + 1 : undefined
|
||||
// 👈 API must return this flag
|
||||
};
|
||||
};
|
||||
|
||||
// ==============================|| fetchOrderSummary (orders)||============================== //
|
||||
export const fetchOrderSummary = async () => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/orders/getordersummary`);
|
||||
@@ -38,6 +60,21 @@ export const fetchDeliveryLocationSummary = async () => {
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| getorders (Locations)||============================== //
|
||||
// fetchOrders.js
|
||||
|
||||
export const fetchOrders1 = async ({ pageParam = 1, queryKey }) => {
|
||||
const [_key, tenantid, locationid, status, startdate, enddate, searchword, rowsPerPage] = queryKey;
|
||||
|
||||
const res = await axios.get(
|
||||
`${process.env.REACT_APP_URL}/orders/tenant/getorders/?tenantid=${tenantid}&locationid=${locationid}&status=${status}&fromdate=${startdate}&todate=${enddate}&pageno=${pageParam}&pagesize=${rowsPerPage}&keyword=${searchword}`
|
||||
);
|
||||
|
||||
return {
|
||||
details: res.data.details,
|
||||
nextPage: res.data.details.length === rowsPerPage ? pageParam + 1 : undefined
|
||||
};
|
||||
};
|
||||
|
||||
// ==============================|| fetchAllTenants (clients)||============================== //
|
||||
|
||||
@@ -73,7 +110,7 @@ export const fetchCustomersListBySearch = async ({ queryKey }) => {
|
||||
console.log('fetchCustomersListBySearch', response.data.details);
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| fetchOrdersSummary (orders summary)||============================== //
|
||||
// ==============================|| fetchOrdersSummary (rider summary)||============================== //
|
||||
export const fetchOrdersSummary = async ({ queryKey }) => {
|
||||
console.log('queryKey for fetchOrdersSummary', queryKey);
|
||||
const [startdate, enddate] = queryKey;
|
||||
@@ -95,6 +132,17 @@ export const getreportlocationsummary = async ({ queryKey }) => {
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| getriderlocationreportsummary (orders summary)||============================== //
|
||||
export const getriderlocationreportsummary = async ({ queryKey }) => {
|
||||
console.log('queryKey for getriderlocationreportsummary', queryKey);
|
||||
const [startdate, enddate, locationId] = queryKey;
|
||||
const response = await axios.get(
|
||||
`${process.env.REACT_APP_URL}/deliveries/getriderlocationreportsummary/?tenantid=${tenid}&locationid=${locationId}&fromdate=${startdate}&todate=${enddate}`
|
||||
);
|
||||
console.log('getriderlocationreportsummary', response.data.details);
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| fetchLocations (orders summary))||============================== //
|
||||
|
||||
export const fetchLocations = async () => {
|
||||
@@ -107,6 +155,19 @@ export const fetchLocations = async () => {
|
||||
|
||||
return updatedLocations;
|
||||
};
|
||||
// ==============================|| gettenantlocations (orders summary))||============================== //
|
||||
|
||||
export const gettenantlocations = async ({ queryKey }) => {
|
||||
const [, searchLocation] = queryKey;
|
||||
try {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/tenants/gettenantlocations?tenantid=${tenid}&keyword=${searchLocation}`);
|
||||
return response.data?.details || []; // safe fallback
|
||||
} catch (error) {
|
||||
console.error('Error fetching tenant locations:', error);
|
||||
return error.message;
|
||||
}
|
||||
};
|
||||
|
||||
// ==============================|| fetchDeliverySummary (orders summary)||============================== //
|
||||
export const fetchDeliverySummary = async ({ queryKey }) => {
|
||||
const [, startdate, enddate, currentStatus, locationId] = queryKey;
|
||||
@@ -133,11 +194,9 @@ export const fetchAppLocations = async () => {
|
||||
|
||||
export const fetchRidersSummary = async ({ queryKey }) => {
|
||||
console.log('queryKey for fetchRidersSummary', queryKey);
|
||||
const [id, startdate, enddate] = queryKey;
|
||||
const [tenantid, startdate, enddate] = queryKey;
|
||||
const response = await axios.get(
|
||||
id == -1
|
||||
? `${process.env.REACT_APP_URL}/deliveries/getridersummary/?&fromdate=${startdate}&todate=${enddate}`
|
||||
: `${process.env.REACT_APP_URL}/deliveries/getridersummary/?applocationid=${id}&fromdate=${startdate}&todate=${enddate}`
|
||||
`${process.env.REACT_APP_URL}/deliveries/getridersummary/?tenantid=${tenantid}&fromdate=${startdate}&todate=${enddate}`
|
||||
);
|
||||
console.log('fetchRidersSummary', response.data.details);
|
||||
|
||||
@@ -146,7 +205,7 @@ export const fetchRidersSummary = async ({ queryKey }) => {
|
||||
|
||||
// ==============================|| fetchorderdetails (orders detail)||============================== //
|
||||
export const fetchorderdetails = async ({ pageParam = 0, queryKey }) => {
|
||||
const [startdate, enddate, currentStatus, locationId] = queryKey;
|
||||
const [startdate, enddate, currentStatus, locationId, searchword] = queryKey;
|
||||
|
||||
const limit = 10;
|
||||
const pageno = pageParam + 1; // ✅ increment page by 1 each time
|
||||
@@ -156,7 +215,7 @@ export const fetchorderdetails = async ({ pageParam = 0, queryKey }) => {
|
||||
process.env.REACT_APP_URL
|
||||
}/deliveries/getdeliveries/?tenantid=${tenid}&locationid=${locationId}&fromdate=${startdate}&todate=${enddate}&status=${
|
||||
currentStatus === 'All' ? '' : currentStatus
|
||||
}&pageno=${pageno}&pagesize=${limit}`
|
||||
}&pageno=${pageno}&pagesize=${limit}&keyword=${searchword}`
|
||||
);
|
||||
|
||||
const details = response.data.details || [];
|
||||
@@ -206,3 +265,14 @@ export const fetchCount = async ({ queryKey }) => {
|
||||
|
||||
return calculateOrderCounts();
|
||||
};
|
||||
|
||||
// ==============================|| fetchRidersLogs (RiderLogs)||============================== //
|
||||
|
||||
export const fetchRidersLogs = async ({ queryKey }) => {
|
||||
const [tenantid, startdate] = queryKey;
|
||||
const riderLogsResponse = await axios.get(
|
||||
`${process.env.REACT_APP_URL}/partners/getriderlogs/?tenantid=${tenantid}&fromdate=${startdate || ''}`
|
||||
);
|
||||
console.log('fetchRidersLogs', riderLogsResponse.data.details);
|
||||
return riderLogsResponse.data.details;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user