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

@@ -6,6 +6,8 @@ import { Empty } from 'antd';
import TaskAltIcon from '@mui/icons-material/TaskAlt';
import MyLocationIcon from '@mui/icons-material/MyLocation';
import HighlightOffIcon from '@mui/icons-material/HighlightOff';
import { enqueueSnackbar } from 'notistack';
import { CalendarMonth } from '@mui/icons-material';
// material-ui
import {
@@ -60,7 +62,8 @@ import MainCard from 'components/MainCard';
import Loader from 'components/Loader';
import { useTheme } from '@mui/material/styles';
import TitleCard from '../titleCard';
import { getreportlocationsummary } from '../api/api';
import { getreportlocationsummary, gettenantlocations } from '../api/api';
import CircularLoader from 'components/nearle_components/CircularLoader';
function formatNumberToRupees(value) {
return new Intl.NumberFormat('en-IN', {
@@ -70,6 +73,14 @@ function formatNumberToRupees(value) {
}).format(value);
}
const opentoast = (message, variant, time) => {
enqueueSnackbar(message, {
variant: variant,
anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: time ? time : 1500
});
};
// ==============================|| MUI TABLE - ENHANCED ||============================== //
export default function OrdersReport() {
@@ -95,7 +106,6 @@ export default function OrdersReport() {
const [searchword, setSearchword] = useState('');
const textFieldRef = useRef(null);
const [ridersdata, setRidersdata] = useState(null);
const [tenantLocations, setTenantlocations] = useState([]);
const [selectedLocation, setSelectedLocation] = useState(null);
const [locationId, setLocationId] = useState(0);
@@ -125,18 +135,16 @@ export default function OrdersReport() {
}, []);
// ============================================= || gettenantlocations (branches) || =============================================
const gettenantlocations = async () => {
try {
const res = await axios.get(`${process.env.REACT_APP_URL}/tenants/gettenantlocations?tenantid=${tenantid}`);
console.log('gettenantlocations', res.data.details);
setTenantlocations(res.data.details);
} catch (err) {
console.log('gettenantlocations', err);
}
};
useEffect(() => {
gettenantlocations();
}, []);
const {
data: tenantLocations,
isLoading: tenantLocationsIsLoading,
isError: tenantLocationsIsError,
error: tenantLocationsError
} = useQuery({
queryKey: ['tenantlocations'],
queryFn: gettenantlocations
});
// ==============================|| fetchOrdersSummary (orders summary)||============================== //
const {
@@ -196,139 +204,153 @@ export default function OrdersReport() {
calculate();
}, [rows]);
// if (isLoadingReports) return <Loader />;
if (isErrorReports) return 'An error has occurred:(isErrorReports) ' + reportsError.message;
let errormessage = '';
if (isErrorReports && reportsError?.message) {
errormessage = `An error has occurred: (isErrorReports) ${reportsError.message}`;
} else if (tenantLocationsIsError && tenantLocationsError?.message) {
errormessage = `An error has occurred: (tenantLocationsIsError) ${tenantLocationsError.message}`;
}
useEffect(() => {
if (errormessage) {
console.log('errormessage', errormessage);
opentoast(errormessage, 'warning', 2000);
}
}, [errormessage]);
return (
<>
{isLoadingReports && <Loader />}
<TitleCard title="Orders Summary" />{' '}
{(isLoadingReports || tenantLocationsIsLoading) && <Loader />}
{(isLoadingReports || tenantLocationsIsLoading) && <CircularLoader />}
<TitleCard
title="Orders Summary"
secondary={
<Stack>
{startdate && enddate && (
<Stack direction="row" spacing={2} flexWrap={'wrap'} gap={1}>
<Chip label={`Orders-${datestatus}`} color="primary" variant="light" size="small" />
<Chip
label={
<Typography noWrap color="secondary">
{dayjs(startdate).format('DD/MM/YYYY')} - {dayjs(enddate).format('DD/MM/YYYY')}
</Typography>
}
variant="combined"
color="warning"
size="small"
deleteIcon={<CalendarMonth style={{ fontSize: 18 }} />}
onDelete={() => {
setOpen(true);
}}
onClick={() => setOpen(true)}
sx={{ cursor: 'pointer' }}
/>
</Stack>
)}
{(!startdate || !enddate) && (
<>
<Stack direction="row" spacing={2}>
<Chip label="Orders-All" color="primary" variant="light" size="small" />
</Stack>
</>
)}
</Stack>
}
/>{' '}
<MainCard
content={false}
title={
<Stack display={'flex'} flexDirection={'row'} alignItems={'center'} justifyContent={'space-between'} flexWrap={'wrap'} gap={1}>
<Stack>
{startdate && enddate && (
<Stack direction="row" spacing={2} flexWrap={'wrap'} gap={1}>
<Chip label={`Orders-${datestatus}`} color="primary" variant="light" size="small" />
<Chip
label={
<Typography noWrap color="secondary">
{dayjs(startdate).format('DD/MM/YYYY')} - {dayjs(enddate).format('DD/MM/YYYY')}
</Typography>
}
variant="combined"
color="warning"
size="small"
/>
</Stack>
)}
{(!startdate || !enddate) && (
<>
<Stack direction="row" spacing={2}>
<Chip label="Orders-All" color="primary" variant="light" size="small" />
</Stack>
</>
)}
</Stack>
<Stack
sx={{
display: 'flex',
flexDirection: 'row',
gap: 2,
flexWrap: 'wrap',
flexGrow: 1,
justifyContent: 'right'
}}
>
<FormControl sx={{ width: 250 }}>
<OutlinedInput
inputRef={textFieldRef}
aria-describedby="header-search-text"
inputProps={{
'aria-label': 'weight'
}}
sx={{ background: 'white' }}
size="large"
id="header-search"
placeholder="Search (ctrl+k)"
value={searchword}
onChange={(e) => {
setSearchword(e.target.value);
}}
autoComplete="off"
startAdornment={
<InputAdornment position="start" sx={{ mr: -0.5 }}>
<SearchOutlined />
</InputAdornment>
}
endAdornment={
<IconButton
sx={{ visibility: searchword ? 'visible' : 'hidden' }}
onClick={() => {
setSearchword('');
}}
>
<ClearIcon style={{ fontSize: 'medium', color: '#65387A' }} />
<Stack
direction="row"
gap={2}
flexWrap="wrap"
sx={{
alignItems: 'center',
width: '100%',
justifyContent: 'flex-end'
}}
>
{/* Search Input */}
<FormControl sx={{ minWidth: 250, maxWidth: 400, flex: 1 }}>
<OutlinedInput
inputRef={textFieldRef}
id="header-search"
placeholder="Search (Ctrl + K)"
value={searchword}
onChange={(e) => setSearchword(e.target.value)}
autoComplete="off"
size="medium"
sx={{
bgcolor: 'white',
borderRadius: 2
}}
startAdornment={
<InputAdornment position="start">
<SearchOutlined />
</InputAdornment>
}
endAdornment={
<InputAdornment position="end">
<IconButton sx={{ visibility: searchword ? 'visible' : 'hidden' }} onClick={() => setSearchword('')}>
<ClearIcon sx={{ fontSize: 20, color: '#65387A' }} />
</IconButton>
}
/>
</FormControl>
<Stack>
{tenantLocations.length == 1 ? (
</InputAdornment>
}
/>
</FormControl>
{/* Location Input */}
{tenantLocations?.length === 1 ? (
<TextField
variant="outlined"
label="Business Location"
value={tenantLocations[0]?.locationname}
fullWidth
focused
sx={{
minWidth: 250,
maxWidth: 400,
flex: 1,
borderRadius: 2
}}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<MyLocationIcon color="primary" />
</InputAdornment>
),
sx: { bgcolor: 'white' }
}}
/>
) : (
<Autocomplete
fullWidth
options={tenantLocations || []}
value={selectedLocation}
getOptionLabel={(o) => `${o.locationname} (${o.suburb})`}
onChange={(event, value, reason) => {
setSelectedLocation(value);
setLocationId(value ? value.locationid : 0);
}}
sx={{
minWidth: 250,
maxWidth: 400,
flex: 1
}}
renderInput={(params) => (
<TextField
variant="outlined"
fullWidth
label={'Business Location'}
value={tenantLocations[0].locationname}
focused
sx={{ minWidth: 250 }}
InputProps={{
style: { color: theme.palette.primary.main },
startAdornment: (
<InputAdornment position="start">
<MyLocationIcon color="primary" />
</InputAdornment>
)
{...params}
label="Choose Location"
color="primary"
sx={{
bgcolor: 'white',
borderRadius: 2
}}
/>
) : (
<Autocomplete
fullWidth
id="combo-box-demo"
options={tenantLocations || []}
value={selectedLocation}
getOptionLabel={(option) => `${option.locationname} (${option.suburb})` || ''}
sx={{ minWidth: 250 }}
onChange={(event, value, reason) => {
setSelectedLocation(value);
if (value) {
console.log('Business Locations', value);
setLocationId(value.locationid);
}
if (reason == 'clear') {
setLocationId(0);
}
}}
renderInput={(params) => <TextField {...params} label="Choose Location" color="primary" />}
/>
)}
</Stack>
<Tooltip title="Order Filter">
<IconButton
color="secondary"
variant="light"
sx={{
color: 'text.primary',
bgcolor: 'grey.200'
}}
onClick={() => setOpen(true)}
>
<FilterList />
</IconButton>
</Tooltip>
</Stack>
/>
)}
</Stack>
}
>
@@ -336,8 +358,9 @@ export default function OrdersReport() {
sx={{
overflow: 'auto',
'&::-webkit-scrollbar': {
width: '3px',
height: '3px'
width: '12px', // Width of vertical scrollbar
height: '14px', // Height of horizontal scrollbar,
borderRadius: 10
},
'&::-webkit-scrollbar-thumb': {
backgroundColor: '#65387A' // Color of the scrollbar thumb
@@ -357,7 +380,7 @@ export default function OrdersReport() {
Deliveries{' '}
</TableCell>
<TableCell rowSpan={2}> Kilometer</TableCell>
<TableCell rowSpan={2}>Charges </TableCell>
{/* <TableCell rowSpan={2}>Charges </TableCell> */}
<TableCell rowSpan={2}>Amount </TableCell>
<TableCell rowSpan={2}> Action</TableCell>
</TableRow>
@@ -380,10 +403,6 @@ export default function OrdersReport() {
<TableRow
key={row.locationid}
sx={{
bgcolor: openRow === row.locationid ? '#e1bee7' : null,
'&:hover': {
bgcolor: openRow === row.locationid ? '#e1bee7!important' : null
},
cursor: openRow === row.locationid ? 'pointer' : null
}}
>
@@ -418,7 +437,7 @@ export default function OrdersReport() {
/>
</Tooltip>
<br />
{/* <br />
<Tooltip title="Actual kms" placement="bottom">
<Chip
size="small"
@@ -431,10 +450,10 @@ export default function OrdersReport() {
minWidth: 80
}}
/>
</Tooltip>
</Tooltip> */}
</TableCell>
<TableCell align="left">
<Tooltip title="Pay on Delivery" placement="top">
{/* <TableCell align="left"> */}
{/* <Tooltip title="Pay on Delivery" placement="top">
<Chip
size="small"
label={formatNumberToRupees(row.payondelivery)}
@@ -450,8 +469,8 @@ export default function OrdersReport() {
}}
/>
</Tooltip>
<br />
<Tooltip title="Pay Later" placement="bottom">
<br /> */}
{/* <Tooltip title="Pay Later" placement="bottom">
<Chip
size="small"
label={formatNumberToRupees(row.paylater)}
@@ -465,8 +484,8 @@ export default function OrdersReport() {
minWidth: 80
}}
/>
</Tooltip>
</TableCell>
</Tooltip> */}
{/* </TableCell> */}
<TableCell align="right">
<Tooltip title="Total Charges" placement="top">
<Chip
@@ -506,9 +525,9 @@ export default function OrdersReport() {
{openRow === row.locationid && (
<TableRow
sx={{
bgcolor: openRow === row.locationid ? '#f3e5f5' : null,
bgcolor: 'white',
'&:hover': {
bgcolor: openRow === row.locationid ? '#f3e5f5!important' : null
bgcolor: 'white!important'
},
cursor: openRow === row.locationid ? 'pointer' : null
}}
@@ -516,35 +535,56 @@ export default function OrdersReport() {
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={15}>
<Collapse in={openRow === row.locationid} timeout="auto" unmountOnExit>
<Box sx={{ margin: 1 }}>
<Typography variant="h5" gutterBottom component="div">
Riders Summary
</Typography>
<Table size="small" aria-label="purchases">
<TableHead
sx={{
bgcolor: '#f3e5f5',
bgcolor: 'white',
'&:onhover': {
bgcolor: '#f3e5f5!important'
bgcolor: 'white !important'
}
}}
>
<TableRow>
<TableCell>#</TableCell>
<TableRow
sx={{
bgcolor: openRow === row.locationid ? theme.palette.secondary.lighter : null
}}
>
<TableCell align="center">#</TableCell>
<TableCell>Rider</TableCell>
<TableCell align="left">Deliveries</TableCell>
<TableCell align="left">Assigned</TableCell>
<TableCell align="left">Accepted</TableCell>
<TableCell align="left">Picked</TableCell>
<TableCell align="left">Delivered</TableCell>
<TableCell align="center">kms/Actualkms</TableCell>
<TableCell align="center">POD/PLA</TableCell>
<TableCell align="center">Deliveries</TableCell>
<TableCell align="center">Pending</TableCell>
<TableCell align="center">Assigned</TableCell>
<TableCell align="center">Accepted</TableCell>
<TableCell align="center">Arrived</TableCell>
<TableCell align="center">Picked</TableCell>
<TableCell align="center">Skipped</TableCell>
<TableCell align="center">Delivered</TableCell>
<TableCell align="center">kms</TableCell>
{/* <TableCell align="center">POD/PLA</TableCell> */}
<TableCell align="center">Charges</TableCell>
</TableRow>
</TableHead>
<TableBody>
<TableBody
sx={{
bgcolor: 'white',
'&:onhover': {
bgcolor: 'white !important'
}
}}
>
{ridersdata?.map((rider, index) => (
<TableRow key={rider?.tenantname}>
<TableCell padding="none">{index + 1}</TableCell>
<TableRow
key={rider?.tenantname}
// sx={{
// bgcolor: openRow === row.locationid ? '#f3e5f5' : null,
// '&:hover': {
// bgcolor: openRow === row.locationid ? '#f3e5f5!important' : null
// }
// }}
>
<TableCell align="center" padding="none">
{index + 1}
</TableCell>
<TableCell align="left">
<Stack direction="row" sx={{ ml: -2 }}>
{rider?.firstname}
@@ -555,27 +595,30 @@ export default function OrdersReport() {
)}
</Stack>
</TableCell>
<TableCell align="left">{rider?.deliveries}</TableCell>
<TableCell align="left">{rider?.Assigened}</TableCell>
<TableCell align="left">{rider?.Accepted}</TableCell>
<TableCell align="left">{rider?.Picked}</TableCell>
<TableCell align="left">{rider?.delivered}</TableCell>
<TableCell align="center">{rider?.totalorders}</TableCell>
<TableCell align="center">{rider?.pending}</TableCell>
<TableCell align="center">{rider?.assigned}</TableCell>
<TableCell align="center">{rider?.accepted}</TableCell>
<TableCell align="center">{rider?.picked}</TableCell>
<TableCell align="center">{rider?.arrived}</TableCell>
<TableCell align="center">{rider?.skipped}</TableCell>
<TableCell align="center">{rider?.delivered}</TableCell>
<TableCell align="center">
<Tooltip title="kms" placement="top">
<Chip
size="small"
label={rider?.kms}
sx={{
color: '#1976d2',
bgcolor: '#e3f2fd',
mr: 1,
border: '1px solid #1976d2',
cursor: 'pointer',
minWidth: 80
}}
/>
</Tooltip>
<Tooltip title="Actual kms" placement="top">
{/* <Tooltip title="kms" placement="top"> */}
<Chip
size="small"
label={rider?.kms}
sx={{
color: '#1976d2',
bgcolor: '#e3f2fd',
mr: 1,
border: '1px solid #1976d2',
cursor: 'pointer',
minWidth: 80
}}
/>
{/* </Tooltip> */}
{/* <Tooltip title="Actual kms" placement="top">
<Chip
size="small"
label={rider?.actualkms}
@@ -587,11 +630,11 @@ export default function OrdersReport() {
minWidth: 80
}}
/>
</Tooltip>
</Tooltip> */}
</TableCell>
<TableCell align="center">
<Tooltip title="Pay on Delivery" placement="top">
{/* <TableCell align="center"> */}
{/* <Tooltip title="Pay on Delivery" placement="top">
<Chip
size="small"
label={formatNumberToRupees(rider?.payondelivery)}
@@ -604,26 +647,26 @@ export default function OrdersReport() {
minWidth: 80
}}
/>
</Tooltip>
<Tooltip title="Paylater" placement="top">
<Chip
size="small"
label={formatNumberToRupees(rider?.Paylater)}
sx={{
color: '#43a047',
bgcolor: '#c8e6c9',
border: '1px solid #43a047',
cursor: 'pointer',
minWidth: 80
}}
/>
</Tooltip>
</TableCell>
</Tooltip> */}
{/* <Tooltip title="Paylater" placement="top"> */}
{/* <Chip
size="small"
label={formatNumberToRupees(rider?.Paylater)}
sx={{
color: '#43a047',
bgcolor: '#c8e6c9',
border: '1px solid #43a047',
cursor: 'pointer',
minWidth: 80
}}
/> */}
{/* </Tooltip> */}
{/* </TableCell> */}
<TableCell align="center">
<Tooltip title="Amount" placement="top">
<Chip
size="small"
label={formatNumberToRupees(rider?.Deliveryamt)}
label={formatNumberToRupees(rider?.deliveryamt)}
sx={{
color: 'primary.main',
bgcolor: '#e1bee7',