This commit is contained in:
Malai Raja
2023-12-13 10:33:57 +05:30
parent be9d119961
commit e076b8942f
9 changed files with 280 additions and 92 deletions

View File

@@ -1,6 +1,9 @@
// import React from 'react';
// import Createstaff from 'pages/createstaff'
import { enqueueSnackbar } from 'notistack';
import { DeleteFilled, NotificationOutlined } from '@ant-design/icons';
import {
useState,
useEffect,
@@ -64,7 +67,8 @@ import {
import {
SearchOutlined, EnvironmentOutlined, UserOutlined,
// MoreOutlined
// MoreOutlined ,
CloseOutlined
} from '@ant-design/icons';
import { PopupTransition } from 'components/@extended/Transitions';
@@ -224,11 +228,11 @@ import {
disablePadding: false,
label: 'STATUS',
},
// {
// id: 'action',
// disablePadding: false,
// label: 'ACTION',
// }
{
id: 'action',
disablePadding: false,
label: 'ACTION',
}
];
@@ -294,6 +298,53 @@ import {
const [dialogopen, setDialogopen] = useState(false);
const [stafflist, setStafflist] = useState([])
const [loading1, setLoading1] = useState(false)
const [open,setOpen]=useState(false);
const [orderheaderid,setOrderheaderid]=useState('')
const cancelorder = async () => {
await axios.put(`${process.env.REACT_APP_URL}/orders/updateorder`, {
"orderheaderid": orderheaderid,
"orderstatus": "cancelled",
"cancelled": dayjs().format('YYYY-MM-DD HH:mm:ss')
})
.then((res) => {
console.log(res)
if (res.data.status) {
// if (orderheaderid && tenantid) {
// fetchorderdetails();
// fetchorderaddons();
// fetchorderattires();
// }
enqueueSnackbar('Order Cancelled Successfully', {
variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
})
handleClose(true);
if (localStorage.getItem('tenantid')) {
setTenantid(localStorage.getItem('tenantid'))
let val = localStorage.getItem('tenantid')
fetchtable(val);
fetchpercentage(val);
fetchtableuncovered(val);
fetchtablecovered(val);
fetchtablecancelled(val);
fetchtableassigned(val);
fetchtablepicked(val);
fetchtablecreated(val);
}
}
}).catch((err) => {
console.log(err)
})
}
const fetchstafflist = async (odid) => {
@@ -370,11 +421,74 @@ import {
),
[order, orderBy, page, rowsPerPage],
);
const handleClose = () => {
setOpen(false);
setOrderheaderid('')
};
function AlertCustomerDelete({
// title,
open, handleClose }) {
// const [deletepassword, setDeletepassword] = useState('');
return (
<Dialog
open={open}
onClose={()=>handleClose(false)}
// keepMounted
// TransitionComponent={PopupTransition}
maxWidth="xs"
// aria-labelledby="column-delete-title"
// aria-describedby="column-delete-description"
>
<DialogContent sx={{ mt: 2, my: 1 }}>
<Stack alignItems="center" spacing={3.5}>
<Avatar color="error" sx={{ width: 72, height: 72, fontSize: '1.75rem' }}>
<DeleteFilled />
</Avatar>
{/* <Grid >
<Chip label={orderid.slice(4)} variant="combined" color='warning' size='small' />
</Grid> */}
<Stack spacing={2}>
<Typography variant="h4" align="center">
Are you sure you want to cancel this order?
</Typography>
{/* <Typography variant="h4" align="center">
Please type in the order number to confirm.
</Typography> */}
</Stack>
<Stack direction="row" spacing={2} sx={{ width: 1 }}>
<Button fullWidth color="error" variant="contained" onClick={() => {
// if (deletepassword === orderid.slice(4)) {
cancelorder();
// }
}} autoFocus>
Yes, Cancel
</Button>
<Button fullWidth onClick={() =>{
handleClose(false)
} } color="secondary" variant="outlined">
No
</Button>
</Stack>
</Stack>
</DialogContent>
</Dialog>
);
}
return (
<Box sx={{ width: '100%' }}>
<AlertCustomerDelete open={open} handleClose={handleClose} />
<TableContainer sx={{ width: '100%', borderBottom: 1, borderColor: 'divider' }}>
@@ -517,9 +631,14 @@ import {
<Typography variant='body2' noWrap>{row.orderid}</Typography>
<Typography noWrap
sx={{ fontSize: '11px' }}>
{dayjs(row.deliverydate).utc().format('MM/DD/YYYY hh:mm A')}
{dayjs(row.deliverydate).utc().format('MM/DD/YYYY')}
</Typography>
<Typography noWrap
sx={{ fontSize: '11px' }}
variant='h5'
>
{dayjs(row.deliverydate).utc().format('hh:mm A')}
</Typography>
</TableCell>
<TableCell align="left">
<Stack direction='column'>
@@ -648,25 +767,39 @@ import {
{/* <Tooltip title='View'>
<TableCell>
{(row.orderstatus == 'created')&&
<>
<Tooltip title='Cancel'>
<IconButton
disabled
// disabled
onClick={(e) => {
e.stopPropagation();
navigate(`/details`, {
state: {
orderheaderid: row.orderheaderid,
tenantid: row.tenantid
}
})
setOrderheaderid(row.orderheaderid)
setOpen(true)
// navigate(`/details`, {
// state: {
// orderheaderid: row.orderheaderid,
// tenantid: row.tenantid
// }
// })
}}>
<EyeTwoTone twoToneColor={theme.palette.secondary.main} />
{/* <EyeTwoTone twoToneColor={theme.palette.secondary.main} /> */}
<CloseOutlined
style={{
color:theme.palette.error.main
}}
// twoToneColor={theme.palette.primary.main}
/>
</IconButton>
</Tooltip>
</TableCell> */}
</>
}
</TableCell>
</TableRow>
<TableRow >
<TableCell style={{ paddingBottom: 0, paddingTop: 0, paddingLeft: 0, paddingRight: 0 }} colSpan={8} sx={{ width: '100%' }}>
@@ -1085,10 +1218,10 @@ import {
const [completed, setCompleted] = useState('');
const [closed, setClosed] = useState('');
const [picked,setPicked] = useState('')
const [created,setCreated]=useState('')
const [tabstatus, setTabstatus] = useState('All Orders');
const [tabstatus, setTabstatus] = useState('Created');
const [loading, setLoading] = useState(true)
const theme = useTheme();
let [rows, setRows] = useState([])
@@ -1109,8 +1242,8 @@ import {
setTabvalue(i);
if (i === 0) setTabstatus('All orders')
// if (i === 1) setTabstatus('Created')
// if (i === 0) setTabstatus('All orders')
if (i === 0) setTabstatus('Created')
// if (i === 2) setTabstatus('Modified')
if (i === 1) setTabstatus('Pending')
@@ -1195,11 +1328,11 @@ import {
// if (tabstatus === 'Cancelled') setRows(orderarrcancelled)
// if (tabstatus === 'Assigned') setRows(orderarrassigned)
// if (tabstatus === 'Confirmed') setRows(orderarrconfirmed)
// if (tabstatus === 'Modified') setRows(orderarrmodified)
if (tabstatus === 'Created') setRows(orderarrcreated)
if (tabstatus === 'All orders') setRows(orderarr)
if (tabstatus === 'Delivered') setRows(orderarrcovered)
if (tabstatus === 'Pending') setRows(orderarrcreated)
if (tabstatus === 'Pending') setRows(orderarruncovered)
// if (tabstatus === 'Active') setRows(orderarractive)
// if (tabstatus === 'Pending') setRows(orderarruncovered)
@@ -1256,9 +1389,10 @@ import {
return (val.orderid.toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
// || val.tenantname.toLowerCase().includes(searchword.toLowerCase())
|| val.customername.toLowerCase().includes(searchword.toLowerCase())
|| val.pickupaddress.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.ordernotes.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
@@ -1277,6 +1411,8 @@ import {
|| val.pickupaddress.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.ordernotes.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
|| val.customername.toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
@@ -1292,9 +1428,10 @@ import {
return (val.orderid.toLowerCase().includes(searchword.toLowerCase())
|| val.eventname.toLowerCase().includes(searchword.toLowerCase())
|| val.tenantname.toLowerCase().includes(searchword.toLowerCase())
|| val.customername.toLowerCase().includes(searchword.toLowerCase())
|| val.ordervalue.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
@@ -1306,19 +1443,21 @@ import {
} else if (tabstatus === 'Pending') {
if (searchword) {
let arr = orderarruncovered.filter((val) => {
let arr = orderarrcreated.filter((val) => {
return (val.orderid.toLowerCase().includes(searchword.toLowerCase())
|| val.pickupaddress.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.ordernotes.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
|| val.customername.toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
console.log(arr)
setRows([...arr])
} else {
setRows([...orderarruncovered])
setRows([...orderarrcreated])
}
} else if (tabstatus === 'Cancelled') {
@@ -1327,9 +1466,10 @@ import {
return (val.orderid.toLowerCase().includes(searchword.toLowerCase())
|| val.eventname.toLowerCase().includes(searchword.toLowerCase())
|| val.tenantname.toLowerCase().includes(searchword.toLowerCase())
|| val.customername.toLowerCase().includes(searchword.toLowerCase())
|| val.ordervalue.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
@@ -1347,6 +1487,8 @@ import {
|| val.pickupaddress.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.ordernotes.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
|| val.customername.toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
@@ -1364,6 +1506,8 @@ import {
|| val.pickupaddress.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.ordernotes.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
|| val.customername.toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
@@ -1383,6 +1527,7 @@ import {
|| val.tenantname.toLowerCase().includes(searchword.toLowerCase())
|| val.ordervalue.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
@@ -1402,6 +1547,7 @@ import {
|| val.tenantname.toLowerCase().includes(searchword.toLowerCase())
|| val.ordervalue.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
@@ -1416,6 +1562,8 @@ import {
|| val.pickupaddress.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.ordernotes.toString().toLowerCase().includes(searchword.toLowerCase())
|| val.deliveryaddress.toLowerCase().includes(searchword.toLowerCase())
|| val.customername.toLowerCase().includes(searchword.toLowerCase())
|| val.contactno.toString().toLowerCase().includes(searchword.toLowerCase())
)
})
@@ -1501,6 +1649,9 @@ import {
arr = [...arr, { ...val, sno: i + 1 }];
})
setArrcreated(arr)
if(tabstatus == 'Created'){
setRows(arr)
}
// }
}).catch((err) => {
console.log(err)
@@ -1729,7 +1880,7 @@ import {
setUncoveredorders(res.data.details.pending.toString())
// setActiveorders(res.data.details.assigned.toString());
setAssigned(res.data.details.accepted.toString());
setCreated(res.data.details.created.toString())
setClosed(res.data.details.delivered.toString());
setPicked(res.data.details.picked.toString())
setPercentage1((Math.round((res.data.details.pending/ res.data.details.total) * 100) || 0).toString())
@@ -1935,14 +2086,14 @@ import {
}}>
<Tabs value={tabvalue} onChange={handleChangetab} variant="scrollable" scrollButtons="auto" >
<Tab label="All orders"
{/* <Tab label="All orders"
iconPosition="end"
icon={<Chip label={allorders} color="primary" variant="light" size="small" />}
/>
{/* <Tab label="Created"
icon={<Chip label={modified} color="primary" variant="light" size="small" />}
iconPosition="end"
/> */}
<Tab label="Created"
icon={<Chip label={created} color="primary" variant="light" size="small" />}
iconPosition="end"
/>
<Tab label="Pending"
icon={<Chip label={uncoveredorders} color="primary" variant="light" size="small" />}
iconPosition="end"
@@ -2026,7 +2177,7 @@ import {
</Grid>
<Dialog open={open} >
{/* <Dialog open={open} >
<DialogTitle align='left'>
<Typography variant='h4'>Select Filter Options</Typography>
</DialogTitle>
@@ -2116,7 +2267,7 @@ import {
</Stack>
</Dialog>
*/}