overall updates

This commit is contained in:
joshikannan
2025-11-26 18:24:03 +05:30
parent 12df2e9dc4
commit e71e44319c
35 changed files with 3145 additions and 2404 deletions

View File

@@ -23,8 +23,6 @@ import {
IconButton,
Tooltip,
Chip,
Autocomplete,
TextField,
Collapse
} from '@mui/material';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
@@ -45,12 +43,12 @@ import {
startOfWeek
// startOfYear,
} from 'date-fns';
import { FilterList } from '@mui/icons-material';
// project imports
import MainCard from 'components/MainCard';
import Loader from 'components/Loader';
import TitleCard from '../titleCard';
import { fetchRidersSummary } from '../api/api';
import { useTheme } from '@mui/material/styles';
// table filter
function descendingComparator(a, b, orderBy) {
@@ -88,6 +86,8 @@ function formatNumberToRupees(value) {
export default function RidersSummary() {
// const [rows, setRows] = useState([]);
const theme = useTheme();
const tenantid = localStorage.getItem('tenantid');
const [order, setOrder] = useState('asc');
const [orderBy, setOrderBy] = useState('calories');
const [selected, setSelected] = useState([]);
@@ -141,9 +141,12 @@ export default function RidersSummary() {
data: rows,
error: reportsError
} = useQuery({
queryKey: [appId, startdate, enddate],
queryKey: [tenantid, startdate, enddate],
queryFn: fetchRidersSummary
});
useEffect(() => {
rows && console.log('rows', rows);
}, [rows]);
// ==============================|| calculate||============================== //
const calculate = async () => {
let calculatedTotal = 0;
@@ -157,7 +160,7 @@ export default function RidersSummary() {
console.log('calculatedTotal', calculatedTotal);
};
useEffect(() => {
calculate();
rows && calculate();
}, [rows]);
if (isLoadingReports) return <Loader />;
@@ -167,7 +170,8 @@ export default function RidersSummary() {
const fetchTenantSummary = async (riderUserid) => {
try {
const tenantRes = await axios.get(
`${process.env.REACT_APP_URL}/deliveries/getreportsummary/?&fromdate=${startdate}&todate=${enddate}&userid=${riderUserid}`
// `${process.env.REACT_APP_URL}/deliveries/getreportlocationsummary/?&fromdate=${startdate}&todate=${enddate}&userid=${riderUserid}&tenantid=${tenantid}`
`${process.env.REACT_APP_URL}/deliveries/getriderlocationreportsummary/?&fromdate=${startdate}&todate=${enddate}&userid=${riderUserid}&tenantid=${tenantid}`
);
console.log('tenantRes', tenantRes.data.details);
setTenantData(tenantRes.data.details);
@@ -176,42 +180,9 @@ export default function RidersSummary() {
}
};
const handleClick = (event, name) => {
const selectedIndex = selected.indexOf(name);
let newSelected = [];
if (selectedIndex === -1) {
newSelected = newSelected.concat(selected, name);
} else if (selectedIndex === 0) {
newSelected = newSelected.concat(selected.slice(1));
} else if (selectedIndex === selected.length - 1) {
newSelected = newSelected.concat(selected.slice(0, -1));
} else if (selectedIndex > 0) {
newSelected = newSelected.concat(selected.slice(0, selectedIndex), selected.slice(selectedIndex + 1));
}
const selectedRowData = rows.filter((row) => newSelected.includes(row.name));
setSelectedValue(selectedRowData);
setSelected(newSelected);
};
const handleChangePage = (event, newPage) => {
setPage(newPage);
};
const handleChangeRowsPerPage = (event) => {
setRowsPerPage(parseInt(event?.target.value, 10));
setPage(0);
};
const isSelected = (name) => selected.indexOf(name) !== -1;
// Avoid a layout jump when reaching the last page with empty rows.
const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0;
return (
<>
<TitleCard title="Riders Summary" />
<MainCard
content={false}
title={
@@ -249,15 +220,19 @@ export default function RidersSummary() {
<Table>
<TableHead>
<TableRow>
<TableCell>S.No </TableCell>
<TableCell># </TableCell>
<TableCell> Rider</TableCell>
<TableCell> Deliveries</TableCell>
<TableCell>Total </TableCell>
{/* <TableCell> Pending</TableCell>
<TableCell> Assigned</TableCell>
<TableCell> Accepted</TableCell>
<TableCell>Arrived </TableCell>
<TableCell>Picked </TableCell>
<TableCell>Active </TableCell>
<TableCell>Skipped </TableCell> */}
<TableCell>Delivered </TableCell>
<TableCell>KMS/Actualkms </TableCell>
<TableCell> POD/PLA</TableCell>
<TableCell>kms </TableCell>
<TableCell> COD/PLA</TableCell>
<TableCell> Charges</TableCell>
<TableCell>Action </TableCell>
</TableRow>
@@ -265,7 +240,7 @@ export default function RidersSummary() {
{/* ============================================ || TableBody || ============================================ */}
<TableBody>
{rows.length === 0 && (
{/* {rows?.length === 0 && (
<TableRow>
<TableCell colSpan={11}>
<Stack width={'100%'} direction={'row'} justifyContent={'center'}>
@@ -273,57 +248,59 @@ export default function RidersSummary() {
</Stack>
</TableCell>
</TableRow>
)}
)} */}
{stableSort(rows, getComparator(order, orderBy))
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
.map((row, index) => {
if (typeof row === 'number') return null;
const isItemSelected = isSelected(row.name);
const labelId = `enhanced-table-checkbox-${index}`;
{rows?.map((row, index) => (
<>
{/* // ============================================ || tablerow 1 || ============================================ */}
return (
rows.length !== 0 && (
<>
{/* // ============================================ || tablerow 1 || ============================================ */}
<TableRow
sx={{
cursor: openRow === row.userid ? 'pointer' : null
}}
>
<TableCell component="th" scope="row" padding="none">
{index + 1}
</TableCell>
<TableCell align="left">
<Stack direction="row" sx={{ ml: -2 }}>
{row.firstname}
{row.status == 'Active' ? (
<TaskAltIcon fontSize="small" color="success" sx={{ ml: 1 }} />
) : (
<HighlightOffIcon fontSize="small" color="error" sx={{ ml: 1 }} />
)}
</Stack>
</TableCell>
<TableRow
hover
onClick={(event) => handleClick(event, row.name)}
role="checkbox"
aria-checked={isItemSelected}
tabIndex={-1}
key={row.tenantname}
selected={isItemSelected}
sx={{
bgcolor: openRow === row.userid ? '#e1bee7' : null,
'&:hover': {
bgcolor: openRow === row.userid ? '#e1bee7!important' : null
},
cursor: openRow === row.userid ? 'pointer' : null
}}
>
<TableCell component="th" id={labelId} scope="row" padding="none">
{index + 1}
<TableCell align="left">{row.totalorders}</TableCell>
{/* <TableCell align="left">
{row.pending ? <Chip color="primary" variant="light" label={row.pending} /> : row.pending}
</TableCell>
<TableCell align="left">
<Stack direction="row" sx={{ ml: -2 }}>
{row.firstname}
{row.status == 'Active' ? (
<TaskAltIcon fontSize="small" color="success" sx={{ ml: 1 }} />
) : (
<HighlightOffIcon fontSize="small" color="error" sx={{ ml: 1 }} />
)}
</Stack>
{row.assigned ? <Chip color="primary" variant="light" label={row.assigned} /> : row.assigned}
</TableCell>
<TableCell align="left">{row.deliveries}</TableCell>
<TableCell align="left">{row.Assigened}</TableCell>
<TableCell align="left">{row.Accepted}</TableCell>
<TableCell align="left">{row.Picked}</TableCell>
<TableCell align="left">{row.delivered}</TableCell>
<TableCell align="left">
<Stack direction={'row'}>
<Tooltip title="kms" placement="top">
{row.accepted ? <Chip color="primary" variant="light" label={row.accepted} /> : row.accepted}
</TableCell>
<TableCell align="left">
{row.arrived ? <Chip color="primary" variant="light" label={row.arrived} /> : row.arrived}
</TableCell>
<TableCell align="left">
{row.picked ? <Chip color="primary" variant="light" label={row.picked} /> : row.picked}
</TableCell>
<TableCell align="left">
{row.active ? <Chip color="primary" variant="light" label={row.active} /> : row.active}
</TableCell>
<TableCell align="left">
{row.skipped ? <Chip color="primary" variant="light" label={row.skipped} /> : row.skipped}
</TableCell> */}
<TableCell align="left">{row.delivered}</TableCell>
<TableCell align="left">
<Stack direction={'row'}>
{/* <Tooltip title="kms" placement="top">
<Chip
size="small"
label={row.kms}
@@ -336,165 +313,149 @@ export default function RidersSummary() {
minWidth: 80
}}
/>
</Tooltip>
<Tooltip title="Actual kms" placement="bottom">
<Chip
size="small"
label={row.actualkms}
sx={{
color: '#ff8f00',
bgcolor: '#ffecb3',
border: '1px solid #ff8f00',
cursor: 'pointer',
minWidth: 80
}}
/>
</Tooltip>
</Stack>
</TableCell>
<TableCell align="right">
<Stack direction={'row'}>
<Tooltip title="Pay on Delivery" placement="top">
<Chip
size="small"
label={formatNumberToRupees(row.payondelivery)}
sx={{
color: '#f44336',
bgcolor: '#ffcdd2',
border: '1px solid #f44336',
cursor: 'pointer',
minWidth: 80,
mr: 1
}}
/>
</Tooltip>
<Tooltip title="Pay Later" placement="bottom">
<Chip
size="small"
label={formatNumberToRupees(row.Paylater)}
sx={{
color: '#43a047',
bgcolor: '#c8e6c9',
border: '1px solid #43a047',
cursor: 'pointer',
minWidth: 80
}}
/>
</Tooltip>
</Stack>
</TableCell>
<TableCell align="right">
<Tooltip title="Total Charges" placement="top">
<Chip
size="small"
label={formatNumberToRupees(row.Deliveryamt)}
sx={{
color: 'primary.main',
bgcolor: '#e1bee7',
border: '1px solid #662582 ',
cursor: 'pointer',
minWidth: 100
}}
/>
</Tooltip>
</TableCell>
<TableCell align="center">
<IconButton
aria-label="expand row"
size="small"
onClick={() => {
fetchTenantSummary(row.userid);
setOpenRow(openRow === row.userid ? null : row.userid);
}}
sx={{
bgcolor: openRow === row.userid ? 'primary.main' : null,
color: openRow === row.userid ? 'white' : null,
'&:hover': {
bgcolor: openRow === row.userid ? 'primary.main' : '#e1bee7'
}
}}
>
{openRow === row.userid ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}
</IconButton>
</TableCell>
</TableRow>
{/* // ============================================ || collapsive row || ============================================ */}
{openRow === row.userid && (
<TableRow
</Tooltip> */}
<Tooltip title="Actual kms" placement="bottom">
<Chip
size="small"
label={row.actualkms}
sx={{
bgcolor: openRow === row.userid ? '#f3e5f5' : null,
'&:hover': {
bgcolor: openRow === row.userid ? '#f3e5f5!important' : null
},
cursor: openRow === row.userid ? 'pointer' : null
color: '#ff8f00',
bgcolor: '#ffecb3',
border: '1px solid #ff8f00',
cursor: 'pointer',
minWidth: 80
}}
>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={15}>
<Collapse
// in={openRow[row.tenantname]}
in={true}
timeout="auto"
unmountOnExit
>
<Box sx={{ margin: 1 }}>
<Typography variant="h5" gutterBottom component="div">
Tenant Summary
</Typography>
<Table size="small" aria-label="purchases">
<TableHead
sx={{
bgcolor: '#f3e5f5',
'&:onhover': {
bgcolor: '#f3e5f5!important'
}
}}
>
<TableRow>
<TableCell>#</TableCell>
<TableCell>Client</TableCell>
<TableCell align="left">All</TableCell>
<TableCell align="left">Pending</TableCell>
<TableCell align="left">Completed</TableCell>
<TableCell align="left">Cancelled</TableCell>
<TableCell align="center">Kms/Actual Kms</TableCell>
<TableCell align="center">POD / PLA</TableCell>
<TableCell align="center">Amount</TableCell>
</TableRow>
</TableHead>
<TableBody>
{tenantData.map((row, index) => (
<TableRow
hover
onClick={(event) => handleClick(event, row.name)}
role="checkbox"
aria-checked={isItemSelected}
tabIndex={-1}
key={row.tenantname}
selected={isItemSelected}
>
{/* <TableCell sx={{ pl: 3 }} padding="checkbox">
<Checkbox
color="primary"
checked={isItemSelected}
inputProps={{
"aria-labelledby": labelId,
}}
/>
</TableCell> */}
<TableCell component="th" id={labelId} scope="row" padding="none">
{index + 1}
</TableCell>
<TableCell align="left">
<Stack direction="row" sx={{ ml: -2 }}>
{row.tenantname}
</Stack>
</TableCell>
<TableCell align="left">{row.totalorders}</TableCell>
<TableCell align="left">{row.deliveriespending}</TableCell>
<TableCell align="left">{row.deliveriescompleted}</TableCell>
<TableCell align="left">{row.deliveriescancelled}</TableCell>
<TableCell align="center">
<Chip
/>
</Tooltip>
</Stack>
</TableCell>
<TableCell align="right">
<Stack direction={'row'}>
<Tooltip title="Pay on Delivery" placement="top">
<Chip
size="small"
label={formatNumberToRupees(row.payondelivery)}
sx={{
color: '#f44336',
bgcolor: '#ffcdd2',
border: '1px solid #f44336',
cursor: 'pointer',
minWidth: 80,
mr: 1
}}
/>
</Tooltip>
<Tooltip title="Pay Later" placement="bottom">
<Chip
size="small"
label={formatNumberToRupees(row.Paylater)}
sx={{
color: '#43a047',
bgcolor: '#c8e6c9',
border: '1px solid #43a047',
cursor: 'pointer',
minWidth: 80
}}
/>
</Tooltip>
</Stack>
</TableCell>
<TableCell align="left">
<Tooltip title="Total Charges" placement="top">
<Chip
size="small"
label={formatNumberToRupees(row.deliveryamt)}
sx={{
color: '#1976d2',
bgcolor: '#e3f2fd',
border: '1px solid #1976d2',
cursor: 'pointer',
minWidth: 100
}}
/>
</Tooltip>
</TableCell>
<TableCell align="center">
<IconButton
aria-label="expand row"
size="small"
onClick={() => {
fetchTenantSummary(row.userid);
setOpenRow(openRow === row.userid ? null : row.userid);
}}
sx={{
bgcolor: openRow === row.userid ? 'primary.main' : null,
color: openRow === row.userid ? 'white' : null,
'&:hover': {
bgcolor: openRow === row.userid ? 'primary.main' : '#e1bee7'
}
}}
>
{openRow === row.userid ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}
</IconButton>
</TableCell>
</TableRow>
{/* // ============================================ || collapsive row || ============================================ */}
{openRow === row.userid && (
<TableRow
sx={{
bgcolor: openRow === row.userid ? 'white' : null,
'&:hover': {
bgcolor: openRow === row.userid ? 'white!important' : null
},
cursor: openRow === row.userid ? 'pointer' : null
}}
>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={15}>
<Collapse in={true} timeout="auto" unmountOnExit>
<Box sx={{ margin: 1 }}>
<Table size="small" aria-label="purchases">
<TableHead>
<TableRow
sx={{
bgcolor: theme.palette.secondary.lighter,
'&:hover': {
bgcolor: `${theme.palette.secondary.lighter} !important`
}
}}
>
<TableCell>#</TableCell>
<TableCell>Location</TableCell>
<TableCell align="left">All</TableCell>
{/* <TableCell align="left">Pending</TableCell> */}
<TableCell align="left">Completed</TableCell>
{/* <TableCell align="left">Cancelled</TableCell> */}
<TableCell align="left">Actual Kms</TableCell>
<TableCell align="left">COD / PLA</TableCell>
<TableCell align="left">Amount</TableCell>
</TableRow>
</TableHead>
<TableBody>
{tenantData?.map((row, index) => (
<TableRow
sx={{
bgcolor: 'white!important',
'&:onhover': {
bgcolor: 'white!important'
}
}}
key={row.tenantname}
>
<TableCell component="th" scope="row" padding="none">
{index + 1}
</TableCell>
<TableCell align="left">
<Stack direction="row" sx={{ ml: -2 }}>
{row.locationname}
</Stack>
</TableCell>
<TableCell align="left">{row.totalorders}</TableCell>
{/* <TableCell align="left">{row.deliveriespending}</TableCell> */}
<TableCell align="left">{row.deliveriescompleted}</TableCell>
{/* <TableCell align="left">{row.deliveriescancelled}</TableCell> */}
<TableCell align="left">
{/* <Chip
size="small"
label={row.kms}
sx={{
@@ -504,93 +465,77 @@ export default function RidersSummary() {
border: '1px solid #1976d2',
minWidth: 80
}}
/>
<Chip
size="small"
label={row.actualkms}
sx={{
color: '#ff8f00',
bgcolor: '#ffecb3',
border: '1px solid #ff8f00',
minWidth: 80
}}
/>
</TableCell>
/> */}
<Chip
size="small"
label={row.actualkms}
sx={{
color: '#ff8f00',
bgcolor: '#ffecb3',
border: '1px solid #ff8f00',
minWidth: 80
}}
/>
</TableCell>
<TableCell align="center">
<Chip
size="small"
label={formatNumberToRupees(row.payondelivery)}
sx={{
color: '#f44336',
bgcolor: '#ffcdd2',
border: '1px solid #f44336',
minWidth: 80
}}
/>{' '}
<Chip
size="small"
label={formatNumberToRupees(row.paylater)}
sx={{
color: '#43a047',
bgcolor: '#c8e6c9',
border: '1px solid #43a047',
minWidth: 80
}}
/>
</TableCell>
<TableCell align="left">
<Chip
size="small"
label={formatNumberToRupees(row.payondelivery)}
sx={{
color: '#f44336',
bgcolor: '#ffcdd2',
border: '1px solid #f44336',
minWidth: 80
}}
/>{' '}
<Chip
size="small"
label={formatNumberToRupees(row.paylater)}
sx={{
color: '#43a047',
bgcolor: '#c8e6c9',
border: '1px solid #43a047',
minWidth: 80
}}
/>
</TableCell>
<TableCell align="center">
<Chip
size="small"
label={formatNumberToRupees(row.charges)}
sx={{
color: 'primary.main',
bgcolor: '#e1bee7',
border: '1px solid #662582 ',
minWidth: 100
}}
/>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Box>
</Collapse>
</TableCell>
</TableRow>
)}
</>
)
);
})}
{emptyRows > 0 && (
<TableRow sx={{ height: (dense ? 33 : 53) * emptyRows }}>
<TableCell colSpan={6} />
</TableRow>
)}
<TableCell align="left">
<Chip
size="small"
label={formatNumberToRupees(row.charges)}
sx={{
color: 'primary.main',
bgcolor: '#e1bee7',
border: '1px solid #662582 ',
minWidth: 100
}}
/>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Box>
</Collapse>
</TableCell>
</TableRow>
)}
</>
))}
</TableBody>
</Table>
</TableContainer>
<Divider />
<Stack direction={'row'} sx={{ display: 'flex', justifyContent: 'end', px: 1, py: 2 }}>
{/* <Stack direction={'row'} sx={{ display: 'flex', justifyContent: 'end', px: 1, py: 2 }}>
<Typography variant="h5">Total :</Typography>
<Typography variant="h5" sx={{ ml: 5, mr: 1.5 }}>
{formatNumberToRupees(total)}
</Typography>
</Stack>
{/* table pagination */}
{/* <TablePagination
rowsPerPageOptions={[10, 25, 50]}
component="div"
count={rows.length}
rowsPerPage={rowsPerPage}
page={page}
onPageChange={handleChangePage}
onRowsPerPageChange={handleChangeRowsPerPage}
/> */}
</Stack> */}
</MainCard>
{/* ================================================ || Date Filter || ================================================ */}
<Dialog open={open}>
<DialogTitle align="left">
<Typography variant="h4">Select Filter Options</Typography>
@@ -605,7 +550,6 @@ export default function RidersSummary() {
setDateselect('all');
setStartdate('');
setEnddate('');
setOpen(false);
} else {
setDateselect('select');