11122023
This commit is contained in:
@@ -59,6 +59,7 @@ import Geocode from "react-geocode";
|
||||
// import {setApi} from "react-geocode";
|
||||
import Autocomplete1 from "react-google-autocomplete";
|
||||
// import logo from 'assets/images/location.png'
|
||||
import Loader from 'components/Loader'
|
||||
|
||||
import {
|
||||
// EditOutlined,
|
||||
@@ -141,7 +142,7 @@ const Createorder = () => {
|
||||
|
||||
const [stafflist, setStafflist] = useState([]);
|
||||
const [loading2, setLoading2] = useState(false);
|
||||
|
||||
const [loading,setLoading]=useState(false)
|
||||
|
||||
|
||||
const [shiftarr, setShiftarr] = useState([]);
|
||||
@@ -163,12 +164,12 @@ const Createorder = () => {
|
||||
sno: 1,
|
||||
address: '',
|
||||
"customerid": '',
|
||||
"deliverytime": "",
|
||||
"deliverytime": dayjs(),
|
||||
"deliverylocationid": '',
|
||||
"clientname": '',
|
||||
"contactno": ''
|
||||
}])
|
||||
console.log(orderarr)
|
||||
// console.log(dayjs())
|
||||
}
|
||||
}, [])
|
||||
|
||||
@@ -195,14 +196,17 @@ const Createorder = () => {
|
||||
}, [searchword])
|
||||
|
||||
const fetchtenantinfo = async (tid) => {
|
||||
setLoading(true)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/tenants/gettenantinfo/?tenantid=${tid}`)
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
if (res.data.status) {
|
||||
setTenantinfo(res.data.details);
|
||||
}
|
||||
setLoading(false)
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
setLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -223,7 +227,7 @@ const Createorder = () => {
|
||||
|
||||
|
||||
|
||||
const createsubmitobj1 = () => {
|
||||
const createsubmitobj1 = async() => {
|
||||
let arr = []
|
||||
let timecheck = false;
|
||||
let addresscheck = false;
|
||||
@@ -243,7 +247,7 @@ const Createorder = () => {
|
||||
"moduleid": tenantinfo.moduleid,
|
||||
"configid": 7,
|
||||
"orderid": "",
|
||||
"customerid": val.customerid, //
|
||||
"customerid": val.customerid,
|
||||
"orderdate": dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
"orderstatus": "created",
|
||||
"pending": "",
|
||||
@@ -266,13 +270,16 @@ const Createorder = () => {
|
||||
"deliverycharge": 0,
|
||||
"deliverytime": `${dayjs(startdate).format('YYYY-MM-DD')} ${dayjs(val.deliverytime.$d).format('HH:mm:ss')}`,
|
||||
"deliverylocationid": val.deliverylocationid, //
|
||||
"delivceryaddress": val.address,
|
||||
"deliveryaddress": val.address,
|
||||
"pickupaddress": tenantinfo.address,
|
||||
"pickuplat": tenantinfo.latitude,
|
||||
"pickuplong": tenantinfo.longitude,
|
||||
"ordernotes": otherinstructions,
|
||||
"remarks": "",
|
||||
"tenantuserid": parseInt(localStorage.getItem('tenantid'))
|
||||
"tenantuserid": parseInt(localStorage.getItem('tenantid')),
|
||||
"categoryid":tenantinfo.categoryid,
|
||||
"subcategoryid":tenantinfo.subcategoryid,
|
||||
"partnerid":tenantinfo.partnerid
|
||||
})
|
||||
|
||||
})
|
||||
@@ -283,7 +290,28 @@ const Createorder = () => {
|
||||
opentoast('Choose Client')
|
||||
|
||||
} else {
|
||||
opentoast('success')
|
||||
setLoading(true)
|
||||
await axios.post(`${process.env.REACT_APP_URL}/orders/createorders`,arr)
|
||||
.then((res) => {
|
||||
if (res.data.status) {
|
||||
enqueueSnackbar('Order Created Successfully', {
|
||||
variant: 'success', anchorOrigin: { vertical: 'top', horizontal: 'right' },
|
||||
autoHideDuration: 2000
|
||||
})
|
||||
navigate('/orders')
|
||||
}else{
|
||||
opentoast(res.data.message)
|
||||
}
|
||||
setLoading(false)
|
||||
console.log(res)
|
||||
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
opentoast(err.data.message)
|
||||
setLoading(false)
|
||||
|
||||
})
|
||||
// opentoast('success')
|
||||
}
|
||||
|
||||
console.log(arr)
|
||||
@@ -433,6 +461,11 @@ const Createorder = () => {
|
||||
|
||||
|
||||
return <>
|
||||
{(loading) &&
|
||||
|
||||
<Loader />
|
||||
|
||||
}
|
||||
<Grid container rowSpacing={4.5} columnSpacing={2.75}>
|
||||
|
||||
<CardActions
|
||||
@@ -463,7 +496,7 @@ const Createorder = () => {
|
||||
sno: 1,
|
||||
address: '',
|
||||
"customerid": '',
|
||||
"deliverytime": "",
|
||||
"deliverytime":dayjs(),
|
||||
"deliverylocationid": '',
|
||||
"clientname": '',
|
||||
"contactno": ''
|
||||
@@ -475,7 +508,7 @@ const Createorder = () => {
|
||||
sno: 1,
|
||||
address: '',
|
||||
"customerid": '',
|
||||
"deliverytime": "",
|
||||
"deliverytime": dayjs(),
|
||||
"deliverylocationid": '',
|
||||
"clientname": '',
|
||||
"contactno": ''
|
||||
@@ -785,17 +818,18 @@ const Createorder = () => {
|
||||
setOrderarr([{
|
||||
sno: 1,
|
||||
address: address.address,
|
||||
"customerid": '',
|
||||
"deliverytime": "",
|
||||
"deliverylocationid": '',
|
||||
"customerid": address.customerid,
|
||||
"deliverytime": dayjs(),
|
||||
"deliverylocationid": address.deliverylocationid,
|
||||
"clientname": address.firstname,
|
||||
"contactno": address.contactno
|
||||
}])
|
||||
} else {
|
||||
if (orderarr.find((val2) => val2.address == address.address)) {
|
||||
if (orderarr.find((val2) => val2.customerid == address.customerid)) {
|
||||
if (orderarr.length > 1) {
|
||||
let arr = orderarr;
|
||||
arr.splice(address.sno - 1, 1);
|
||||
let res = orderarr.find((val2) => val2.customerid == address.customerid)
|
||||
arr.splice(res.sno - 1, 1);
|
||||
let arr1 = []
|
||||
arr.map((val2, k) => {
|
||||
arr1.push({
|
||||
@@ -814,7 +848,7 @@ const Createorder = () => {
|
||||
sno: 1,
|
||||
address: '',
|
||||
"customerid": '',
|
||||
"deliverytime": "",
|
||||
"deliverytime": dayjs(),
|
||||
"deliverylocationid": '',
|
||||
"clientname": '',
|
||||
"contactno": ''
|
||||
@@ -827,7 +861,7 @@ const Createorder = () => {
|
||||
sno: arr.length + 1,
|
||||
'address': address.address,
|
||||
"customerid": address.customerid,
|
||||
"deliverytime": "",
|
||||
"deliverytime": dayjs(),
|
||||
"deliverylocationid": address.deliverylocationid,
|
||||
"clientname":address.firstname,
|
||||
"contactno": address.contactno
|
||||
@@ -844,7 +878,7 @@ const Createorder = () => {
|
||||
sno: 1,
|
||||
address: address.address,
|
||||
"customerid": address.customerid,
|
||||
"deliverytime": "",
|
||||
"deliverytime": dayjs(),
|
||||
"deliverylocationid": address.deliverylocationid,
|
||||
"clientname":address.firstname,
|
||||
"contactno": address.contactno
|
||||
@@ -869,10 +903,11 @@ const Createorder = () => {
|
||||
cursor: 'pointer',
|
||||
p: 1.25,
|
||||
'&:hover': {
|
||||
bgcolor: theme.palette.primary.lighter,
|
||||
borderColor: theme.palette.primary.lighter
|
||||
// bgcolor: theme.palette.primary.lighter,
|
||||
// borderColor: theme.palette.primary.lighter
|
||||
bgcolor:(orderarr.find((val2) => val2.customerid == address.customerid)) ? '#e1bee7' : ''
|
||||
},
|
||||
bgcolor: (orderarr.find((val2) => val2.address == address.address)) ? '#e1bee7' : ''
|
||||
bgcolor: (orderarr.find((val2) => val2.customerid == address.customerid)) ? '#e1bee7' : ''
|
||||
}}
|
||||
>
|
||||
<Stack direction={'row'} justifyContent={'space-between'}>
|
||||
@@ -880,7 +915,7 @@ const Createorder = () => {
|
||||
{address.firstname}
|
||||
</Typography>
|
||||
{(orderarr.find((val2) => val2.address == address.address)) &&
|
||||
<CheckCircleIcon color='#662582' />
|
||||
<CheckCircleIcon color='primary' />
|
||||
}
|
||||
|
||||
</Stack>
|
||||
|
||||
@@ -517,9 +517,9 @@ import {
|
||||
<Typography variant='body2' noWrap>{row.orderid}</Typography>
|
||||
<Typography noWrap
|
||||
sx={{ fontSize: '11px' }}>
|
||||
{dayjs(row.orderdate).utc().format('MM/DD/YYYY')}
|
||||
{dayjs(row.deliverydate).utc().format('MM/DD/YYYY hh:mm A')}
|
||||
</Typography>
|
||||
|
||||
|
||||
</TableCell>
|
||||
<TableCell align="left">
|
||||
<Stack direction='column'>
|
||||
@@ -536,7 +536,7 @@ import {
|
||||
<TableCell align="left">
|
||||
<Stack direction='column'>
|
||||
{/* <Typography variant="caption" > {row.eventname}</Typography> */}
|
||||
<Tooltip title={row.delivceryaddress}>
|
||||
<Tooltip title={row.deliveryaddress}>
|
||||
<Typography variant="caption" color="textSecondary"
|
||||
>
|
||||
{row.deliveryaddress.slice(0,20)}
|
||||
@@ -1065,6 +1065,8 @@ import {
|
||||
let [orderarrmodified, setArrmodified] = useState([]);
|
||||
let [orderarrclosed, setArrclosed] = useState([]);
|
||||
let [orderarrpicked, setArrpicked] = useState([]);
|
||||
let [orderarrcreated, setArrcreated] = useState([]);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1108,8 +1110,9 @@ import {
|
||||
setTabvalue(i);
|
||||
|
||||
if (i === 0) setTabstatus('All orders')
|
||||
if (i === 1) setTabstatus('Pending')
|
||||
// if (i === 1) setTabstatus('Created')
|
||||
// if (i === 2) setTabstatus('Modified')
|
||||
if (i === 1) setTabstatus('Pending')
|
||||
|
||||
if (i === 2) setTabstatus('Assigned')
|
||||
if (i === 3) setTabstatus('Picked')
|
||||
@@ -1147,6 +1150,7 @@ import {
|
||||
fetchtablecancelled(val);
|
||||
fetchtableassigned(val);
|
||||
fetchtablepicked(val);
|
||||
fetchtablecreated(val);
|
||||
// fetchtableconfirmed(val);
|
||||
// fetchtablemodified(val);
|
||||
// fetchtableclosed(val)
|
||||
@@ -1175,6 +1179,7 @@ import {
|
||||
// fetchtablemodified(val);
|
||||
// fetchtableclosed(val)
|
||||
fetchtable(val)
|
||||
fetchtablecreated(val)
|
||||
|
||||
console.log(activeorders);
|
||||
}
|
||||
@@ -1186,7 +1191,7 @@ import {
|
||||
// if (tabstatus === 'All orders') setRows(orderarr)
|
||||
// if (tabstatus === 'Completed') setRows(orderarrcovered)
|
||||
// if (tabstatus === 'Active') setRows(orderarractive)
|
||||
if (tabstatus === 'Pending') setRows(orderarruncovered)
|
||||
// if (tabstatus === 'Pending') setRows(orderarruncovered)
|
||||
// if (tabstatus === 'Cancelled') setRows(orderarrcancelled)
|
||||
// if (tabstatus === 'Assigned') setRows(orderarrassigned)
|
||||
// if (tabstatus === 'Confirmed') setRows(orderarrconfirmed)
|
||||
@@ -1194,6 +1199,8 @@ import {
|
||||
|
||||
if (tabstatus === 'All orders') setRows(orderarr)
|
||||
if (tabstatus === 'Delivered') setRows(orderarrcovered)
|
||||
if (tabstatus === 'Pending') setRows(orderarrcreated)
|
||||
|
||||
// if (tabstatus === 'Active') setRows(orderarractive)
|
||||
// if (tabstatus === 'Pending') setRows(orderarruncovered)
|
||||
if (tabstatus === 'Cancelled') setRows(orderarrcancelled)
|
||||
@@ -1434,8 +1441,8 @@ import {
|
||||
const fetchtable = async (tid) => {
|
||||
|
||||
try {
|
||||
// await axios.get(`${process.env.REACT_APP_URL}/orders/getorders/?tenantid=${tid}`)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenantorders/?tenantid=${tid}`)
|
||||
// await axios.get(`${process.env.REACT_APP_URL}/orders/tenantorders/?tenantid=${tid}`)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenant/getorders/?tenantid=${tid}`)
|
||||
.then((res) => {
|
||||
if (res.data.status) {
|
||||
let arr = []
|
||||
@@ -1463,7 +1470,7 @@ import {
|
||||
|
||||
try {
|
||||
// await axios.get(`${process.env.REACT_APP_URL}/orders/getorders/?tenantid=${tid}&status=completed`)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenantorders/?tenantid=${tid}&status=delivered`)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenant/getorders/?tenantid=${tid}&status=delivered`)
|
||||
.then((res) => {
|
||||
// if (res.data.message === "Success") {
|
||||
let arr = []
|
||||
@@ -1481,6 +1488,29 @@ import {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const fetchtablecreated = async (tid) => {
|
||||
|
||||
try {
|
||||
// await axios.get(`${process.env.REACT_APP_URL}/orders/getorders/?tenantid=${tid}&status=completed`)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenant/getorders/?tenantid=${tid}&status=created`)
|
||||
.then((res) => {
|
||||
// if (res.data.message === "Success") {
|
||||
let arr = []
|
||||
res.data.details.map((val, i) => {
|
||||
arr = [...arr, { ...val, sno: i + 1 }];
|
||||
})
|
||||
setArrcreated(arr)
|
||||
// }
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const fetchtableactive = async () => {
|
||||
@@ -1509,7 +1539,7 @@ import {
|
||||
const fetchtableuncovered = async (tid) => {
|
||||
|
||||
try {
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenantorders/?tenantid=${tid}&status=pending`)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenant/getorders/?tenantid=${tid}&status=pending`)
|
||||
.then((res) => {
|
||||
if (res.data.message === "Success") {
|
||||
let arr = []
|
||||
@@ -1532,7 +1562,7 @@ import {
|
||||
const fetchtablecancelled = async (tid) => {
|
||||
|
||||
try {
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenantorders/?tenantid=${tid}&status=cancelled`)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenant/getorders/?tenantid=${tid}&status=cancelled`)
|
||||
// await axios.get(`${process.env.REACT_APP_URL2}/client/orders/getordersbystatus?tenantid=${tid}&status=cancelled`)
|
||||
|
||||
.then((res) => {
|
||||
@@ -1558,7 +1588,7 @@ import {
|
||||
const fetchtableassigned = async (tid) => {
|
||||
|
||||
try {
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenantorders/?tenantid=${tid}&status=accepted`)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenant/getorders/?tenantid=${tid}&status=accepted`)
|
||||
.then((res) => {
|
||||
// if (res.data.message === "Success") {
|
||||
let arr = [];
|
||||
@@ -1582,7 +1612,7 @@ import {
|
||||
const fetchtablepicked = async (tid) => {
|
||||
|
||||
try {
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenantorders/?tenantid=${tid}&status=picked`)
|
||||
await axios.get(`${process.env.REACT_APP_URL}/orders/tenant/getorders/?tenantid=${tid}&status=picked`)
|
||||
.then((res) => {
|
||||
// if (res.data.message === "Success") {
|
||||
let arr = [];
|
||||
@@ -1909,7 +1939,10 @@ import {
|
||||
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="Pending"
|
||||
icon={<Chip label={uncoveredorders} color="primary" variant="light" size="small" />}
|
||||
iconPosition="end"
|
||||
|
||||
Reference in New Issue
Block a user