updates
This commit is contained in:
176
src/pages/nearle/api/api.js
Normal file
176
src/pages/nearle/api/api.js
Normal file
@@ -0,0 +1,176 @@
|
||||
import axios from 'axios';
|
||||
const tenid = localStorage.getItem('tenantid');
|
||||
|
||||
// ==============================|| fetchOrderSummary (orders)||============================== //
|
||||
export const fetchOrderSummary = async () => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/orders/getordersummary`);
|
||||
console.log('fetchOrderSummary', response.data.details);
|
||||
return response.data.details;
|
||||
};
|
||||
|
||||
// ==============================|| fetchLocationSummary (orders)||============================== //
|
||||
export const fetchLocationSummary = async () => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/orders/getlocationsummary`);
|
||||
console.log('fetchLocationSummary', response.data.details);
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
|
||||
// ==============================|| fetchOrderInsight (orders)||============================== //
|
||||
export const fetchOrderInsight = async () => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/orders/getorderinsight`);
|
||||
console.log('fetchOrderInsight', response.data.details);
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| fetchDeliverySummary (delivery)||============================== //
|
||||
export const fetchDeliverySummary = async () => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/deliveries/deliverysummary`);
|
||||
console.log('fetchDeliverySummary', response.data.details);
|
||||
return response.data.details;
|
||||
};
|
||||
|
||||
// ==============================|| fetchDeliveryInsight (delivery)||============================== //
|
||||
export const fetchDeliveryInsight = async () => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/deliveries/getdeliveryinsight`);
|
||||
console.log('fetchDeliveryInsight', response.data.details);
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| fetchDeliveryLocationSummary (delivery)||============================== //
|
||||
export const fetchDeliveryLocationSummary = async () => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/deliveries/getlocationsummary`);
|
||||
console.log('fetchDeliveryLocationSummary', response.data.details);
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
|
||||
// ==============================|| fetchAllTenants (clients)||============================== //
|
||||
|
||||
export const fetchAllTenants = async ({ queryKey }) => {
|
||||
const [size, status, pageno, search, rough] = queryKey;
|
||||
|
||||
let url = '';
|
||||
if (search) {
|
||||
// url = `https://jupiter.nearle.app/live/api/v1/tenants/search/?keyword=${search}`;
|
||||
url = `${process.env.REACT_APP_URL}/tenants/search/?keyword=${search}`;
|
||||
} else {
|
||||
// url = `https://jupiter.nearle.app/live/api/v1/tenants/getalltenants?pageno=${pageno}&pagesize=${size}`;
|
||||
url = `${process.env.REACT_APP_URL}/tenants/getalltenants?pageno=${pageno}&pagesize=${size}`;
|
||||
}
|
||||
const response = await axios.get(url);
|
||||
|
||||
// tenants/search/?keyword=${search}
|
||||
console.log('fetchAllTenants', response.data.details);
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| fetchCustomersList (customers)||============================== //
|
||||
export const fetchCustomersList = async ({ queryKey }) => {
|
||||
const [pages] = queryKey;
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/customers/getallcustomers/?pageno=${pages}&pagesize=10`);
|
||||
console.log('fetchCustomersList', response.data.details);
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| fetchCustomersListBySearch (customers)||============================== //
|
||||
export const fetchCustomersListBySearch = async ({ queryKey }) => {
|
||||
const [search] = queryKey;
|
||||
const response = await axios.get(search.lenght > 3 && `${process.env.REACT_APP_URL}/customers/search/?keyword=${search}`);
|
||||
console.log('fetchCustomersListBySearch', response.data.details);
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| fetchOrdersSummary (orders summary)||============================== //
|
||||
export const fetchOrdersSummary = async ({ queryKey }) => {
|
||||
console.log('queryKey for fetchOrdersSummary', queryKey);
|
||||
const [id, startdate, enddate] = queryKey;
|
||||
const response = await axios.get(
|
||||
id == -1
|
||||
? `${process.env.REACT_APP_URL}/deliveries/getreportsummary/?&fromdate=${startdate}&todate=${enddate}`
|
||||
: `${process.env.REACT_APP_URL}/deliveries/getreportsummary/?partnerid=${id}&fromdate=${startdate}&todate=${enddate}`
|
||||
);
|
||||
console.log('fetchOrdersSummary', response.data.details);
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| fetchLocations (orders summary))||============================== //
|
||||
|
||||
export const fetchLocations = async ({ queryKey }) => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/partners/getpartners`);
|
||||
const updatedLocations = [
|
||||
...response.data.details,
|
||||
{ partnername: 'All', partnerid: -1 } // Add your new object here
|
||||
];
|
||||
console.log('fetchLocations', updatedLocations);
|
||||
|
||||
return updatedLocations;
|
||||
};
|
||||
// ==============================|| fetchAppLocations (report summary))||============================== //
|
||||
|
||||
export const fetchAppLocations = async ({ queryKey }) => {
|
||||
const response = await axios.get(`${process.env.REACT_APP_URL}/partners/getpartners`);
|
||||
const updatedLocations = [
|
||||
...response.data.details,
|
||||
{ partnername: 'All', applocationid: -1 } // Add your new object here
|
||||
];
|
||||
console.log('fetchAppLocations', updatedLocations);
|
||||
|
||||
return updatedLocations;
|
||||
};
|
||||
|
||||
// ==============================|| fetchRidersSummary (riders summary)||============================== //
|
||||
|
||||
export const fetchRidersSummary = async ({ queryKey }) => {
|
||||
console.log('queryKey for fetchRidersSummary', queryKey);
|
||||
const [id, 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}`
|
||||
);
|
||||
console.log('fetchRidersSummary', response.data.details);
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
|
||||
// ==============================|| fetchorderdetails (orders detail)||============================== //
|
||||
export const fetchorderdetails = async ({ queryKey }) => {
|
||||
console.log('queryKey of fetchorderdetails', queryKey);
|
||||
const [tabValue, appId, startdate, enddate] = queryKey;
|
||||
let status = tabValue === 0 ? 'delivered' : tabValue === 1 ? 'pending' : 'cancelled';
|
||||
const response = await axios.get(
|
||||
// appId == -1
|
||||
// ? `https://jupiter.nearle.app/live/api/v1/orders/getorders/?fromdate=${startdate}&todate=${enddate}`
|
||||
// : `https://jupiter.nearle.app/live/api/v1/orders/getorders/?fromdate=${startdate}&todate=${enddate}&applocationid=${appId}`
|
||||
`https://jupiter.nearle.app/live/api/v1/deliveries/getdeliveries/?tenantid=${tenid}&fromdate=${startdate}&todate=${enddate}`
|
||||
);
|
||||
console.log('fetchorderdetails', response.data.details);
|
||||
|
||||
return response.data.details;
|
||||
};
|
||||
// ==============================|| fetchCount (orders detail)||============================== //
|
||||
export const fetchCount = async ({ queryKey }) => {
|
||||
console.log('queryKey of fetchCount', queryKey);
|
||||
const [startdate, enddate] = queryKey;
|
||||
const response = await axios.get(`https://jupiter.nearle.app/live/api/v1/orders/getorders/?fromdate=${startdate}&todate=${enddate}`);
|
||||
const calculateOrderCounts = () => {
|
||||
let deliveredCount = 0;
|
||||
let pendingCount = 0;
|
||||
let cancelledCount = 0;
|
||||
|
||||
response.data.details.forEach((order) => {
|
||||
const status = order.orderstatus;
|
||||
if (status === 'delivered') {
|
||||
deliveredCount++;
|
||||
} else if (status === 'pending') {
|
||||
pendingCount++;
|
||||
} else if (status === 'cancelled') {
|
||||
cancelledCount++;
|
||||
}
|
||||
});
|
||||
|
||||
return { deliveredCount, pendingCount, cancelledCount };
|
||||
};
|
||||
console.log('fetchCount', calculateOrderCounts());
|
||||
|
||||
return calculateOrderCounts();
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
1007
src/pages/nearle/reports/ordersDetails.js
Normal file
1007
src/pages/nearle/reports/ordersDetails.js
Normal file
File diff suppressed because it is too large
Load Diff
48
src/pages/nearle/titleCard.js
Normal file
48
src/pages/nearle/titleCard.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import React from 'react';
|
||||
import { useTheme } from '@mui/material/styles';
|
||||
|
||||
import {
|
||||
Avatar,
|
||||
Chip,
|
||||
Grid,
|
||||
Link,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableContainer,
|
||||
TableHead,
|
||||
TableRow,
|
||||
Typography,
|
||||
CardContent,
|
||||
Skeleton,
|
||||
Stack,
|
||||
CardActions,
|
||||
Button,
|
||||
List
|
||||
} from '@mui/material';
|
||||
const TitleCard = ({ title }) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<Grid container spacing={2}>
|
||||
<CardActions
|
||||
sx={{
|
||||
position: 'sticky',
|
||||
top: '60px',
|
||||
// top:0,
|
||||
bgcolor: theme.palette.background.default,
|
||||
zIndex: 1,
|
||||
// borderBottom: `1px solid ${theme.palette.divider}`,
|
||||
width: '100%'
|
||||
}}
|
||||
>
|
||||
<Grid item xs={12}>
|
||||
<Stack direction={'row'} justifyContent={'space-between'} sx={{ p: 1 }}>
|
||||
<Typography variant="h3">{title}</Typography>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</CardActions>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
||||
export default TitleCard;
|
||||
Reference in New Issue
Block a user