createorder
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -5,29 +5,12 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
Stack,
|
Stack,
|
||||||
Box,
|
Box,
|
||||||
// Autocomplete,
|
|
||||||
Button,
|
Button,
|
||||||
// Stepper,
|
|
||||||
// Step,
|
|
||||||
// StepLabel,
|
|
||||||
TextField,
|
TextField,
|
||||||
Autocomplete,
|
Autocomplete,
|
||||||
CardActions,
|
CardActions,
|
||||||
// CardActions,
|
|
||||||
Chip,
|
Chip,
|
||||||
// AvatarGroup,
|
|
||||||
// RadioGroup,
|
|
||||||
// Radio
|
|
||||||
Avatar,
|
Avatar,
|
||||||
// List,
|
|
||||||
// ListItem,
|
|
||||||
// IconButton,
|
|
||||||
// ListItemAvatar,
|
|
||||||
// ListItemText,
|
|
||||||
// Menu,
|
|
||||||
// MenuItem,
|
|
||||||
// ListItemIcon,
|
|
||||||
// Link,
|
|
||||||
Divider,
|
Divider,
|
||||||
Table,
|
Table,
|
||||||
TableContainer,
|
TableContainer,
|
||||||
@@ -35,7 +18,6 @@ import {
|
|||||||
TableCell,
|
TableCell,
|
||||||
TableHead,
|
TableHead,
|
||||||
TableBody,
|
TableBody,
|
||||||
// FormLabel,
|
|
||||||
Tooltip,
|
Tooltip,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -50,8 +32,8 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
Switch
|
Switch
|
||||||
// LinkOutlined
|
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
|
|
||||||
import { useNavigate } from 'react-router';
|
import { useNavigate } from 'react-router';
|
||||||
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
|
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
|
||||||
import AccessTimeOutlinedIcon from '@mui/icons-material/AccessTimeOutlined';
|
import AccessTimeOutlinedIcon from '@mui/icons-material/AccessTimeOutlined';
|
||||||
@@ -138,6 +120,8 @@ function loadScript(src, position, id) {
|
|||||||
const autocompleteService = { current: null };
|
const autocompleteService = { current: null };
|
||||||
|
|
||||||
const Createorder1 = () => {
|
const Createorder1 = () => {
|
||||||
|
const appId = localStorage.getItem('applocationid');
|
||||||
|
|
||||||
Geocode.setApiKey(process.env.REACT_APP_GOOGLE_MAPS_API_KEY);
|
Geocode.setApiKey(process.env.REACT_APP_GOOGLE_MAPS_API_KEY);
|
||||||
|
|
||||||
function GoogleMaps() {
|
function GoogleMaps() {
|
||||||
@@ -680,8 +664,10 @@ const Createorder1 = () => {
|
|||||||
|
|
||||||
const [startdate, setStartdate] = useState(dayjs().format('MM-DD-YYYY'));
|
const [startdate, setStartdate] = useState(dayjs().format('MM-DD-YYYY'));
|
||||||
const [enddate, setEnddate] = useState(dayjs().add(1, 'day').format('MM-DD-YYYY'));
|
const [enddate, setEnddate] = useState(dayjs().add(1, 'day').format('MM-DD-YYYY'));
|
||||||
const [starttime, setStatrttime] = useState(`${dayjs().format('MM-DD-YYYY')} 08:00:00`);
|
// const [starttime, setStatrttime] = useState(`${dayjs().format('MM-DD-YYYY')} 08:00:00`);
|
||||||
const [endtime, setEndtime] = useState(`${dayjs().format('MM-DD-YYYY')} 20:00:00`);
|
const [starttime, setStatrttime] = useState();
|
||||||
|
// const [endtime, setEndtime] = useState(`${dayjs().format('MM-DD-YYYY')} 20:00:00`);
|
||||||
|
const [endtime, setEndtime] = useState();
|
||||||
|
|
||||||
const [timeslotarr, setTimeslotarr] = useState([]);
|
const [timeslotarr, setTimeslotarr] = useState([]);
|
||||||
const [currentsno, setCurrentsno] = useState('');
|
const [currentsno, setCurrentsno] = useState('');
|
||||||
@@ -712,7 +698,8 @@ const Createorder1 = () => {
|
|||||||
const [clientdetailarr, setClientdetailarr] = useState([]);
|
const [clientdetailarr, setClientdetailarr] = useState([]);
|
||||||
const [clientdetailbusinessarr, setClientdetailbusinessarr] = useState([]);
|
const [clientdetailbusinessarr, setClientdetailbusinessarr] = useState([]);
|
||||||
|
|
||||||
const [admintoken, setAdmintoken] = useState('');
|
// const [admintoken, setAdmintoken] = useState('');
|
||||||
|
const [admintoken, setAdmintoken] = useState();
|
||||||
const [tenantlocationlist, setTenantlocationlist] = useState([]);
|
const [tenantlocationlist, setTenantlocationlist] = useState([]);
|
||||||
const [tenant, setTenant] = useState({});
|
const [tenant, setTenant] = useState({});
|
||||||
const [clientinfo, setClientinfo] = useState({});
|
const [clientinfo, setClientinfo] = useState({});
|
||||||
@@ -750,6 +737,20 @@ const Createorder1 = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchTenantPricing();
|
fetchTenantPricing();
|
||||||
}, []);
|
}, []);
|
||||||
|
// const fetchAppPricing = async () => {
|
||||||
|
// try {
|
||||||
|
// const pricingResponse = await axios.get(`${process.env.REACT_APP_URL}/utils/getapppricing/?applocationid=${appId}`);
|
||||||
|
// console.log('pricingResponse', pricingResponse.data.details);
|
||||||
|
// setBasePrice(pricingResponse.data.details.baseprice);
|
||||||
|
// setPricePerKm(pricingResponse.data.details.priceperkm);
|
||||||
|
// setMinKm(pricingResponse.data.details.minkm);
|
||||||
|
// } catch (error) {
|
||||||
|
// console.log('fetchAppPricing error', error);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// useEffect(() => {
|
||||||
|
// fetchAppPricing();
|
||||||
|
// }, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('startPoint', startPoint);
|
console.log('startPoint', startPoint);
|
||||||
@@ -872,6 +873,8 @@ const Createorder1 = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ==================================================== || fetchtenantinfo || ====================================================
|
||||||
|
|
||||||
const fetchtenantinfo = async () => {
|
const fetchtenantinfo = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
console.log('tid', tid);
|
console.log('tid', tid);
|
||||||
@@ -881,8 +884,8 @@ const Createorder1 = () => {
|
|||||||
console.log('fetchtenantinfo', res);
|
console.log('fetchtenantinfo', res);
|
||||||
if (res.data.status) {
|
if (res.data.status) {
|
||||||
setTenant(res.data.details);
|
setTenant(res.data.details);
|
||||||
|
// fetchadmintoken(res.data.details.tenantid, res.data.details.partnerid);
|
||||||
fetchadmintoken(res.data.details.tenantid, res.data.details.partnerid);
|
fetchAppAdminTokens();
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
})
|
})
|
||||||
@@ -896,6 +899,42 @@ const Createorder1 = () => {
|
|||||||
fetchtenantlocation();
|
fetchtenantlocation();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// ==================================================== || fetchTiming || ====================================================
|
||||||
|
const fetchTiming = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
console.log('tid', tid);
|
||||||
|
await axios
|
||||||
|
.get(`${process.env.REACT_APP_URL}/utils/getapplocations/?applocationid=${appId}`)
|
||||||
|
.then((res) => {
|
||||||
|
console.log('fetchTiming', res);
|
||||||
|
const { opentime, closetime } = res.data.details[0];
|
||||||
|
if (res.data.status) {
|
||||||
|
setStatrttime(`${dayjs().format('MM-DD-YYYY')} ${opentime}`);
|
||||||
|
setEndtime(`${dayjs().format('MM-DD-YYYY')} ${closetime}`);
|
||||||
|
console.log('starttime', `${dayjs().format('MM-DD-YYYY')} ${opentime}`);
|
||||||
|
console.log('endtime', `${dayjs().format('MM-DD-YYYY')} ${closetime} `);
|
||||||
|
let arr = [];
|
||||||
|
for (
|
||||||
|
let i = `${dayjs().format('MM-DD-YYYY')} ${opentime}`, j = 0;
|
||||||
|
dayjs(`${dayjs().format('MM-DD-YYYY')} ${closetime} `).diff(i, 'm') >= 0;
|
||||||
|
j++, i = dayjs(i).add(30, 'm')
|
||||||
|
) {
|
||||||
|
arr.push(i);
|
||||||
|
}
|
||||||
|
console.log('setTimeslotarr', arr);
|
||||||
|
setTimeslotarr(arr);
|
||||||
|
}
|
||||||
|
setLoading(false);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
fetchTiming();
|
||||||
|
}, [starttime, endtime]);
|
||||||
|
|
||||||
// const fetchtenantinfolist = async () => {
|
// const fetchtenantinfolist = async () => {
|
||||||
// setLoading(true);
|
// setLoading(true);
|
||||||
// console.log('tid', tid);
|
// console.log('tid', tid);
|
||||||
@@ -948,21 +987,47 @@ const Createorder1 = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchadmintoken = async (tid, pid) => {
|
// // =============================================== || fetchadmintoken (via tid , pid) || ===============================================
|
||||||
|
// const fetchadmintoken = async (tid, pid) => {
|
||||||
|
// setLoading(true);
|
||||||
|
// await axios
|
||||||
|
// .get(`${process.env.REACT_APP_URL}/partners/getadmintoken/?tenantid=${tid}&partnerid=${pid}`)
|
||||||
|
// .then((res) => {
|
||||||
|
// console.log(res);
|
||||||
|
// if (res.data.status) {
|
||||||
|
// setAdmintoken(res.data.details.userfcmtokem);
|
||||||
|
|
||||||
|
// let arr = [];
|
||||||
|
// for (let i = starttime, j = 0; dayjs(endtime).diff(i, 'm') >= 0; j++, i = dayjs(i).add(30, 'm')) {
|
||||||
|
// arr.push(i);
|
||||||
|
// }
|
||||||
|
// console.log(arr);
|
||||||
|
// setTimeslotarr(arr);
|
||||||
|
// }
|
||||||
|
// setLoading(false);
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// console.log(err);
|
||||||
|
// setLoading(false);
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
// =============================================== || fetchAppAdminTokens (via appId) || ===============================================
|
||||||
|
const fetchAppAdminTokens = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
await axios
|
await axios
|
||||||
.get(`${process.env.REACT_APP_URL}/partners/getadmintoken/?tenantid=${tid}&partnerid=${pid}`)
|
.get(`${process.env.REACT_APP_URL}/utils/getapplocationconfig/?applocationid=${appId}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
const userfcmtokemArray = res.data.details.applocationadmins.map((admin) => admin.userfcmtokem);
|
||||||
|
console.log('fetchAppAdminTokens', res);
|
||||||
|
console.log('userfcmtokemArray', userfcmtokemArray);
|
||||||
if (res.data.status) {
|
if (res.data.status) {
|
||||||
setAdmintoken(res.data.details.userfcmtokem);
|
setAdmintoken(userfcmtokemArray);
|
||||||
|
// let arr = [];
|
||||||
let arr = [];
|
// for (let i = starttime, j = 0; dayjs(endtime).diff(i, 'm') >= 0; j++, i = dayjs(i).add(30, 'm')) {
|
||||||
for (let i = starttime, j = 0; dayjs(endtime).diff(i, 'm') >= 0; j++, i = dayjs(i).add(30, 'm')) {
|
// arr.push(i);
|
||||||
arr.push(i);
|
// }
|
||||||
}
|
// console.log('setTimeslotarr', arr);
|
||||||
console.log(arr);
|
// setTimeslotarr(arr);
|
||||||
setTimeslotarr(arr);
|
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
})
|
})
|
||||||
@@ -972,6 +1037,14 @@ const Createorder1 = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (starttime && endtime) {
|
||||||
|
fetchAppAdminTokens();
|
||||||
|
}
|
||||||
|
}, [starttime, endtime]);
|
||||||
|
|
||||||
|
// =============================================== || opentoast || ===============================================
|
||||||
|
|
||||||
const opentoast = (message) => {
|
const opentoast = (message) => {
|
||||||
enqueueSnackbar(message, {
|
enqueueSnackbar(message, {
|
||||||
variant: 'error',
|
variant: 'error',
|
||||||
@@ -989,6 +1062,7 @@ const Createorder1 = () => {
|
|||||||
setCurrentsno('');
|
setCurrentsno('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =============================================== || createsubmitobj1 (create orders) || ===============================================
|
||||||
const createsubmitobj1 = async () => {
|
const createsubmitobj1 = async () => {
|
||||||
let arr = [];
|
let arr = [];
|
||||||
let timecheck = false;
|
let timecheck = false;
|
||||||
@@ -1058,7 +1132,8 @@ const Createorder1 = () => {
|
|||||||
autoHideDuration: 1000
|
autoHideDuration: 1000
|
||||||
});
|
});
|
||||||
if (admintoken) {
|
if (admintoken) {
|
||||||
notifyadmin(admintoken);
|
// notifyadmin(admintoken);
|
||||||
|
sendnotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate('/orders');
|
navigate('/orders');
|
||||||
@@ -1078,13 +1153,6 @@ const Createorder1 = () => {
|
|||||||
console.log(arr);
|
console.log(arr);
|
||||||
};
|
};
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (localStorage.getItem('tenantid')) {
|
|
||||||
|
|
||||||
// fetchtenantinfo(localStorage.getItem('tenantid'))
|
|
||||||
// }
|
|
||||||
// }, [clientdetail.tenantname])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('shiftarr');
|
console.log('shiftarr');
|
||||||
console.log(shiftarr);
|
console.log(shiftarr);
|
||||||
@@ -1170,21 +1238,59 @@ const Createorder1 = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const notifyadmin = async (id1) => {
|
// ================================================== || notifyadmin || ==================================================
|
||||||
|
// const notifyadmin = async (id1) => {
|
||||||
|
// setLoading(true);
|
||||||
|
// await axios
|
||||||
|
// .post(`${process.env.REACT_APP_URL}/utils/notifyuser`, {
|
||||||
|
// sender: localStorage.getItem('firstname'),
|
||||||
|
// accessid: process.env.REACT_APP_RIDER_ACCESS_ID,
|
||||||
|
// notification: {
|
||||||
|
// priority: 'high',
|
||||||
|
// to: id1,
|
||||||
|
// notification: {
|
||||||
|
// title: 'Nearle Admin',
|
||||||
|
// body: 'Orders has been placed for delivery.Kindly accept and process deliveries',
|
||||||
|
// sound: 'ring'
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// console.log(res);
|
||||||
|
// if (res.data.message == 'Success') {
|
||||||
|
// enqueueSnackbar('Notification sent Successfully', {
|
||||||
|
// variant: 'success',
|
||||||
|
// anchorOrigin: { vertical: 'top', horizontal: 'right' },
|
||||||
|
// autoHideDuration: 1000
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// setLoading(false);
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// console.log(err);
|
||||||
|
// enqueueSnackbar(err.message, {
|
||||||
|
// variant: 'error',
|
||||||
|
// anchorOrigin: { vertical: 'top', horizontal: 'right' },
|
||||||
|
// autoHideDuration: 1000
|
||||||
|
// });
|
||||||
|
// setLoading(false);
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
// ================================================== || sendnotifications || ==================================================
|
||||||
|
const sendnotifications = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
await axios
|
await axios
|
||||||
.post(`${process.env.REACT_APP_URL}/utils/notifyuser`, {
|
.post(`${process.env.REACT_APP_URL}/utils/sendnotifications`, {
|
||||||
sender: localStorage.getItem('firstname'),
|
|
||||||
accessid: process.env.REACT_APP_RIDER_ACCESS_ID,
|
|
||||||
notification: {
|
|
||||||
priority: 'high',
|
priority: 'high',
|
||||||
to: id1,
|
registration_ids: admintoken,
|
||||||
|
data: {
|
||||||
|
accessid: process.env.REACT_APP_RIDER_ACCESS_ID
|
||||||
|
},
|
||||||
notification: {
|
notification: {
|
||||||
title: 'Nearle Admin',
|
title: 'Nearle Merchant',
|
||||||
body: 'Orders has been placed for delivery.Kindly accept and process deliveries',
|
body: 'An Order has been placed successfully,kindly process the same',
|
||||||
sound: 'ring'
|
sound: 'ring'
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
@@ -1423,8 +1529,8 @@ const Createorder1 = () => {
|
|||||||
{showDistance && (
|
{showDistance && (
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Stack sx={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
|
<Stack sx={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
|
||||||
<Chip label={`Distance: ${distance} km`} size="small" variant="light" color="warning" />
|
<Chip label={`Distance: ${distance} km`} size="small" variant="light" color="primary" />
|
||||||
<Chip label={`Charge: ₹${totalCharge.toFixed(2)}`} size="small" variant="light" color="warning" />
|
<Chip label={`Charge: ₹${totalCharge.toFixed(2)}`} size="small" variant="light" color="primary" />
|
||||||
{/* <Button variant="contained">{`Distance: ${distance} km`}</Button> */}
|
{/* <Button variant="contained">{`Distance: ${distance} km`}</Button> */}
|
||||||
{/* <Button variant="contained">{`Charge: ₹${totalCharge.toFixed(2)}`}</Button> */}
|
{/* <Button variant="contained">{`Charge: ₹${totalCharge.toFixed(2)}`}</Button> */}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -1648,7 +1648,7 @@ const Orders = () => {
|
|||||||
try {
|
try {
|
||||||
// await axios.get(`${process.env.REACT_APP_URL}/orders/getordersummary/?tenantid=${tid}&fromdate=${startdate}&todate=${enddate}`)
|
// await axios.get(`${process.env.REACT_APP_URL}/orders/getordersummary/?tenantid=${tid}&fromdate=${startdate}&todate=${enddate}`)
|
||||||
await axios
|
await axios
|
||||||
.get(`${process.env.REACT_APP_URL}/orders/getordersummary/?tenantid=${tid}`)
|
.get(`${process.env.REACT_APP_URL}/orders/getordersummary/?applocationid=${tid}`)
|
||||||
|
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const Details = Loadable(lazy(() => import('pages/nearle/orders/details')));
|
|||||||
|
|
||||||
const Accountsettings = Loadable(lazy(() => import('pages/nearle/accountsettings')));
|
const Accountsettings = Loadable(lazy(() => import('pages/nearle/accountsettings')));
|
||||||
|
|
||||||
const Createorder = Loadable(lazy(() => import('pages/nearle/orders/createorder')));
|
// const Createorder = Loadable(lazy(() => import('pages/nearle/orders/createorder')));
|
||||||
const Createclient = Loadable(lazy(() => import('pages/nearle/clients/createclient')));
|
const Createclient = Loadable(lazy(() => import('pages/nearle/clients/createclient')));
|
||||||
|
|
||||||
const Createorder1 = Loadable(lazy(() => import('pages/nearle/orders/createorder1')));
|
const Createorder1 = Loadable(lazy(() => import('pages/nearle/orders/createorder1')));
|
||||||
@@ -71,10 +71,10 @@ const MainRoutes = {
|
|||||||
path: 'accountsettings',
|
path: 'accountsettings',
|
||||||
element: <Accountsettings />
|
element: <Accountsettings />
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
path: 'orders/create1',
|
// path: 'orders/create1',
|
||||||
element: <Createorder />
|
// element: <Createorder />
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
path: 'orders/create',
|
path: 'orders/create',
|
||||||
element: <Createorder1 />
|
element: <Createorder1 />
|
||||||
|
|||||||
Reference in New Issue
Block a user