createOrder
This commit is contained in:
@@ -63,6 +63,8 @@ import CardContent from 'themes/overrides/CardContent';
|
|||||||
import { PhoneAndroid } from '@mui/icons-material';
|
import { PhoneAndroid } from '@mui/icons-material';
|
||||||
import { SearchOutlined, CloseOutlined } from '@ant-design/icons';
|
import { SearchOutlined, CloseOutlined } from '@ant-design/icons';
|
||||||
import PhoneInput from 'react-phone-number-input/input';
|
import PhoneInput from 'react-phone-number-input/input';
|
||||||
|
import MyLocationIcon from '@mui/icons-material/MyLocation';
|
||||||
|
import HighlightOffIcon from '@mui/icons-material/HighlightOff';
|
||||||
|
|
||||||
function loadScript(src, position, id) {
|
function loadScript(src, position, id) {
|
||||||
if (!position) {
|
if (!position) {
|
||||||
@@ -113,130 +115,130 @@ const Createorder1 = () => {
|
|||||||
const [tenanatLocoId, setTenanatLocoId] = useState(localStorage.getItem('locationid'));
|
const [tenanatLocoId, setTenanatLocoId] = useState(localStorage.getItem('locationid'));
|
||||||
const [isLocation, setIsLocation] = useState(false);
|
const [isLocation, setIsLocation] = useState(false);
|
||||||
|
|
||||||
// ====================================================== || address (pick)|| ======================================================
|
// // // ====================================================== || address (pick)|| ======================================================
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (address) {
|
// if (address) {
|
||||||
try {
|
// try {
|
||||||
Geocode.fromAddress(address).then(
|
// Geocode.fromAddress(address).then(
|
||||||
(response) => {
|
// (response) => {
|
||||||
if (response.status == 'OK') {
|
// if (response.status == 'OK') {
|
||||||
const { lat, lng } = response.results[0].geometry.location;
|
// const { lat, lng } = response.results[0].geometry.location;
|
||||||
console.log({ lat, lng });
|
// console.log({ lat, lng });
|
||||||
setLatlong({
|
// setLatlong({
|
||||||
lat,
|
// lat,
|
||||||
lng
|
// lng
|
||||||
});
|
// });
|
||||||
console.log(response);
|
// console.log(response);
|
||||||
if (response.results[0].address_components) {
|
// if (response.results[0].address_components) {
|
||||||
let place = response.results[0];
|
// let place = response.results[0];
|
||||||
let cityA, zipcodeA, stateA, suburbA;
|
// let cityA, zipcodeA, stateA, suburbA;
|
||||||
for (let i = 0; i < place.address_components.length; i++) {
|
// for (let i = 0; i < place.address_components.length; i++) {
|
||||||
for (let j = 0; j < place.address_components[i].types.length; j++) {
|
// for (let j = 0; j < place.address_components[i].types.length; j++) {
|
||||||
switch (place.address_components[i].types[j]) {
|
// switch (place.address_components[i].types[j]) {
|
||||||
case 'locality':
|
// case 'locality':
|
||||||
cityA = place.address_components[i].long_name;
|
// cityA = place.address_components[i].long_name;
|
||||||
break;
|
// break;
|
||||||
case 'administrative_area_level_1':
|
// case 'administrative_area_level_1':
|
||||||
stateA = place.address_components[i].long_name;
|
// stateA = place.address_components[i].long_name;
|
||||||
break;
|
// break;
|
||||||
case 'postal_code':
|
// case 'postal_code':
|
||||||
zipcodeA = place.address_components[i].long_name;
|
// zipcodeA = place.address_components[i].long_name;
|
||||||
break;
|
// break;
|
||||||
case 'sublocality':
|
// case 'sublocality':
|
||||||
suburbA = place.address_components[i].long_name;
|
// suburbA = place.address_components[i].long_name;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
setCity(cityA || '');
|
// setCity(cityA || '');
|
||||||
setState(stateA || '');
|
// setState(stateA || '');
|
||||||
setZipcode(zipcodeA || '');
|
// setZipcode(zipcodeA || '');
|
||||||
setSuburb(suburbA || '');
|
// setSuburb(suburbA || '');
|
||||||
console.log({ lat, lng, cityA, stateA, zipcodeA, suburbA });
|
// console.log({ lat, lng, cityA, stateA, zipcodeA, suburbA });
|
||||||
setPickCust({
|
// setPickCust({
|
||||||
...pickCust,
|
// ...pickCust
|
||||||
city: cityA,
|
// // city: cityA,
|
||||||
state: stateA,
|
// // state: stateA,
|
||||||
postcode: zipcodeA,
|
// // postcode: zipcodeA,
|
||||||
suburb: suburbA,
|
// // suburb: suburbA
|
||||||
latitude: lat,
|
// // latitude: lat,
|
||||||
longitude: lng
|
// // longitude: lng
|
||||||
});
|
// });
|
||||||
setStartPoint({ latitude: lat, longitude: lng });
|
// // setStartPoint({ latitude: lat, longitude: lng });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
(error) => {
|
// (error) => {
|
||||||
console.log(error);
|
// console.log(error);
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
console.log(err);
|
// console.log(err);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}, [address]);
|
// }, [address]);
|
||||||
// ====================================================== || address 1 (drop)|| ======================================================
|
// // // ====================================================== || address 1 (drop)|| ======================================================
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (address) {
|
// if (address) {
|
||||||
try {
|
// try {
|
||||||
Geocode.fromAddress(address1).then(
|
// Geocode.fromAddress(address1).then(
|
||||||
(response) => {
|
// (response) => {
|
||||||
if (response.status == 'OK') {
|
// if (response.status == 'OK') {
|
||||||
const { lat, lng } = response.results[0].geometry.location;
|
// const { lat, lng } = response.results[0].geometry.location;
|
||||||
|
|
||||||
setLatlong1({
|
// setLatlong1({
|
||||||
lat,
|
// lat,
|
||||||
lng
|
// lng
|
||||||
});
|
// });
|
||||||
console.log(response);
|
// console.log(response);
|
||||||
if (response.results[0].address_components) {
|
// if (response.results[0].address_components) {
|
||||||
let place = response.results[0];
|
// let place = response.results[0];
|
||||||
let cityB, zipcodeB, stateB, suburbB;
|
// let cityB, zipcodeB, stateB, suburbB;
|
||||||
for (let i = 0; i < place.address_components.length; i++) {
|
// for (let i = 0; i < place.address_components.length; i++) {
|
||||||
for (let j = 0; j < place.address_components[i].types.length; j++) {
|
// for (let j = 0; j < place.address_components[i].types.length; j++) {
|
||||||
switch (place.address_components[i].types[j]) {
|
// switch (place.address_components[i].types[j]) {
|
||||||
case 'locality':
|
// case 'locality':
|
||||||
cityB = place.address_components[i].long_name;
|
// cityB = place.address_components[i].long_name;
|
||||||
break;
|
// break;
|
||||||
case 'administrative_area_level_1':
|
// case 'administrative_area_level_1':
|
||||||
stateB = place.address_components[i].long_name;
|
// stateB = place.address_components[i].long_name;
|
||||||
break;
|
// break;
|
||||||
case 'postal_code':
|
// case 'postal_code':
|
||||||
zipcodeB = place.address_components[i].long_name;
|
// zipcodeB = place.address_components[i].long_name;
|
||||||
break;
|
// break;
|
||||||
case 'sublocality':
|
// case 'sublocality':
|
||||||
suburbB = place.address_components[i].long_name;
|
// suburbB = place.address_components[i].long_name;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
setCity(cityB || '');
|
// setCity(cityB || '');
|
||||||
setState(stateB || '');
|
// setState(stateB || '');
|
||||||
setZipcode(zipcodeB || '');
|
// setZipcode(zipcodeB || '');
|
||||||
setSuburb(suburbB || '');
|
// setSuburb(suburbB || '');
|
||||||
console.log({ lat, lng, cityB, stateB, zipcodeB, suburbB });
|
// console.log({ lat, lng, cityB, stateB, zipcodeB, suburbB });
|
||||||
setDropCust({
|
// setDropCust({
|
||||||
...dropCust,
|
// ...dropCust
|
||||||
city: cityB,
|
// // city: cityB,
|
||||||
state: stateB,
|
// // state: stateB,
|
||||||
postcode: zipcodeB,
|
// // postcode: zipcodeB,
|
||||||
suburb: suburbB,
|
// // suburb: suburbB
|
||||||
latitude: lat,
|
// // latitude: lat,
|
||||||
longitude: lng
|
// // longitude: lng
|
||||||
});
|
// });
|
||||||
setEndPoint({ latitude: lat, longitude: lng });
|
// // setEndPoint({ latitude: lat, longitude: lng });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
(error) => {
|
// (error) => {
|
||||||
console.log(error);
|
// console.log(error);
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
console.log(err);
|
// console.log(err);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}, [address1]);
|
// }, [address1]);
|
||||||
|
|
||||||
if (typeof window !== 'undefined' && !loaded.current) {
|
if (typeof window !== 'undefined' && !loaded.current) {
|
||||||
if (!document.querySelector('#google-maps')) {
|
if (!document.querySelector('#google-maps')) {
|
||||||
@@ -246,93 +248,92 @@ const Createorder1 = () => {
|
|||||||
'google-maps'
|
'google-maps'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
loaded.current = true;
|
loaded.current = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetch = React.useMemo(
|
// const fetch = React.useMemo(
|
||||||
() =>
|
// () =>
|
||||||
debounce((request, callback) => {
|
// debounce((request, callback) => {
|
||||||
autocompleteService.current.getPlacePredictions(request, callback);
|
// autocompleteService.current.getPlacePredictions(request, callback);
|
||||||
}, 400),
|
// }, 400),
|
||||||
[]
|
// []
|
||||||
);
|
// );
|
||||||
const fetch1 = React.useMemo(
|
// const fetch1 = React.useMemo(
|
||||||
() =>
|
// () =>
|
||||||
debounce((request, callback) => {
|
// debounce((request, callback) => {
|
||||||
autocompleteService.current.getPlacePredictions(request, callback);
|
// autocompleteService.current.getPlacePredictions(request, callback);
|
||||||
}, 400),
|
// }, 400),
|
||||||
[]
|
// []
|
||||||
);
|
// );
|
||||||
|
|
||||||
// ====================================================== || options (pick)|| ======================================================
|
// ====================================================== || options (pick)|| ======================================================
|
||||||
|
|
||||||
React.useEffect(() => {
|
// React.useEffect(() => {
|
||||||
let active = true;
|
// let active = true;
|
||||||
if (!autocompleteService.current && window.google) {
|
// if (!autocompleteService.current && window.google) {
|
||||||
autocompleteService.current = new window.google.maps.places.AutocompleteService();
|
// autocompleteService.current = new window.google.maps.places.AutocompleteService();
|
||||||
}
|
// }
|
||||||
if (!autocompleteService.current) {
|
// if (!autocompleteService.current) {
|
||||||
return undefined;
|
// return undefined;
|
||||||
}
|
// }
|
||||||
if (inputValue === '') {
|
// if (inputValue === '') {
|
||||||
setOptions(value ? [value] : []);
|
// setOptions(value ? [value] : []);
|
||||||
return undefined;
|
// return undefined;
|
||||||
}
|
// }
|
||||||
fetch({ input: inputValue }, (results) => {
|
// fetch({ input: inputValue }, (results) => {
|
||||||
if (active) {
|
// if (active) {
|
||||||
let newOptions = [];
|
// let newOptions = [];
|
||||||
|
|
||||||
if (value) {
|
// if (value) {
|
||||||
newOptions = [value];
|
// newOptions = [value];
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (results) {
|
// if (results) {
|
||||||
newOptions = [...newOptions, ...results];
|
// newOptions = [...newOptions, ...results];
|
||||||
}
|
// }
|
||||||
|
|
||||||
setOptions(newOptions);
|
// setOptions(newOptions);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
return () => {
|
// return () => {
|
||||||
active = false;
|
// active = false;
|
||||||
};
|
// };
|
||||||
}, [value, inputValue, fetch]);
|
// }, [value, inputValue, fetch]);
|
||||||
|
|
||||||
// ====================================================== || options1 (drop)|| ======================================================
|
// // ====================================================== || options1 (drop)|| ======================================================
|
||||||
React.useEffect(() => {
|
// React.useEffect(() => {
|
||||||
let active = true;
|
// let active = true;
|
||||||
if (!autocompleteService.current && window.google) {
|
// if (!autocompleteService.current && window.google) {
|
||||||
autocompleteService.current = new window.google.maps.places.AutocompleteService();
|
// autocompleteService.current = new window.google.maps.places.AutocompleteService();
|
||||||
}
|
// }
|
||||||
if (!autocompleteService.current) {
|
// if (!autocompleteService.current) {
|
||||||
return undefined;
|
// return undefined;
|
||||||
}
|
// }
|
||||||
if (inputValue1 === '') {
|
// if (inputValue1 === '') {
|
||||||
setOptions1(value1 ? [value1] : []);
|
// setOptions1(value1 ? [value1] : []);
|
||||||
return undefined;
|
// return undefined;
|
||||||
}
|
// }
|
||||||
fetch1({ input: inputValue1 }, (results) => {
|
// fetch1({ input: inputValue1 }, (results) => {
|
||||||
if (active) {
|
// if (active) {
|
||||||
let newOptions = [];
|
// let newOptions = [];
|
||||||
|
|
||||||
if (value1) {
|
// if (value1) {
|
||||||
newOptions = [value1];
|
// newOptions = [value1];
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (results) {
|
// if (results) {
|
||||||
newOptions = [...newOptions, ...results];
|
// newOptions = [...newOptions, ...results];
|
||||||
}
|
// }
|
||||||
|
|
||||||
setOptions1(newOptions);
|
// setOptions1(newOptions);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
return () => {
|
// return () => {
|
||||||
active = false;
|
// active = false;
|
||||||
};
|
// };
|
||||||
}, [value1, inputValue1, fetch1]);
|
// }, [value1, inputValue1, fetch1]);
|
||||||
|
|
||||||
const appId = localStorage.getItem('applocationid');
|
const appId = localStorage.getItem('applocationid');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -461,8 +462,8 @@ const Createorder1 = () => {
|
|||||||
}
|
}
|
||||||
setShowDistance(true);
|
setShowDistance(true);
|
||||||
if (roundedDistance > appLocaRadius) {
|
if (roundedDistance > appLocaRadius) {
|
||||||
opentoast('Service not available at this location', 'error', 2000);
|
|
||||||
setShowDistance(true);
|
setShowDistance(true);
|
||||||
|
setOpen4(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -772,106 +773,108 @@ const Createorder1 = () => {
|
|||||||
let arr = {};
|
let arr = {};
|
||||||
arr = {
|
arr = {
|
||||||
orders: {
|
orders: {
|
||||||
orderheaderid: 0,
|
|
||||||
tenantid: tenant.tenantid,
|
|
||||||
applocationid: tenant.applolcationid,
|
applocationid: tenant.applolcationid,
|
||||||
locationid: +tenanatLocoId, //main or branch
|
cancellled: '',
|
||||||
moduleid: +tenant.moduleid,
|
|
||||||
categoryid: +tenant.categoryid,
|
categoryid: +tenant.categoryid,
|
||||||
subcategoryid: +subCatId,
|
|
||||||
configid: +localStorage.getItem('configid'),
|
configid: +localStorage.getItem('configid'),
|
||||||
orderid: '', //
|
customerid: +pickCust.customerid || 0,
|
||||||
orderdate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
deliveryaddress: dropCust.address || '',
|
||||||
|
deliverycharge: +totalCharge.toFixed(2) || 0,
|
||||||
|
deliverycity: dropCust.city || '',
|
||||||
|
deliverycontactno: dropCust.contactno || '',
|
||||||
|
deliverycustomer: dropCust.firstname || '',
|
||||||
|
deliveryid: dropCust.customerid || 0,
|
||||||
|
deliverylandmark: dropCust.landmark || '',
|
||||||
|
deliverylat: dropCust.latitude.toString(),
|
||||||
|
deliverylocation: dropCust.suburb || '',
|
||||||
|
deliverylocationid: dropCust.deliverylocationid || 0,
|
||||||
|
deliverylong: dropCust.longitude.toString(),
|
||||||
deliverytime: `${dayjs(startdate).format('YYYY-MM-DD')} ${dayjs(selectedtime.$d).format('HH:mm:ss')}`,
|
deliverytime: `${dayjs(startdate).format('YYYY-MM-DD')} ${dayjs(selectedtime.$d).format('HH:mm:ss')}`,
|
||||||
deliverytype: pickCust.customerid !== 0 || dropCust.customerid !== 0 ? 'B' : 'C',
|
deliverytype: pickCust.customerid !== 0 || dropCust.customerid !== 0 ? 'B' : 'C',
|
||||||
|
delivered: '',
|
||||||
|
itemcount: 1,
|
||||||
|
kms: distance || 0,
|
||||||
|
locationid: +tenanatLocoId, //main or branch
|
||||||
|
moduleid: +tenant.moduleid,
|
||||||
|
orderamount: +totalCharge.toFixed(2) || 0,
|
||||||
|
ordercharges: 0.0,
|
||||||
|
orderdate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||||
|
orderheaderid: 0,
|
||||||
|
orderid: '', //
|
||||||
|
ordernotes: otherinstructions,
|
||||||
orderstatus: 'created',
|
orderstatus: 'created',
|
||||||
|
ordervalue: +totalCharge.toFixed(2) || 0,
|
||||||
|
partnerid: tenant.partnerid,
|
||||||
|
paymentstatus: 1,
|
||||||
|
paymenttype: 42,
|
||||||
pending: '',
|
pending: '',
|
||||||
|
pickupaddress: pickCust.address || '',
|
||||||
|
pickupcity: pickCust.city || '',
|
||||||
|
pickupcontactno: pickCust.contactno || '',
|
||||||
|
pickupcustomer: pickCust.firstname || '',
|
||||||
|
pickuplandmark: pickCust.landmark || '',
|
||||||
|
pickuplat: pickCust.latitude.toString(),
|
||||||
|
pickuplocation: pickCust.suburb || '',
|
||||||
|
pickuplocationid: pickCust.deliverylocationid || 0,
|
||||||
|
pickuplong: pickCust.longitude.toString(),
|
||||||
|
pickupaddress: pickCust.address || '',
|
||||||
processing: '',
|
processing: '',
|
||||||
ready: '',
|
ready: '',
|
||||||
delivered: '',
|
|
||||||
cancellled: '',
|
|
||||||
customerid: +pickCust.customerid || 0,
|
|
||||||
pickupcustomer: pickCust.firstname || '',
|
|
||||||
pickupcontactno: pickCust.contactno || '',
|
|
||||||
pickuplandmark: pickCust.landmark || '',
|
|
||||||
pickuplocation: pickCust.suburb || '',
|
|
||||||
pickupcity: pickCust.city || '',
|
|
||||||
pickuplocationid: pickCust.deliverylocationid || 0,
|
|
||||||
pickupaddress: pickCust.address || '',
|
|
||||||
pickuplat: pickCust.latitude.toString(),
|
|
||||||
pickuplong: pickCust.longitude.toString(),
|
|
||||||
deliveryid: dropCust.customerid || 0,
|
|
||||||
deliverycustomer: dropCust.firstname || '',
|
|
||||||
deliverycontactno: dropCust.contactno || '',
|
|
||||||
deliverylocationid: dropCust.deliverylocationid || 0,
|
|
||||||
deliverylat: dropCust.latitude.toString(),
|
|
||||||
deliverylong: dropCust.longitude.toString(),
|
|
||||||
deliveryaddress: dropCust.address || '',
|
|
||||||
deliverylandmark: dropCust.landmark || '',
|
|
||||||
deliverylocation: dropCust.suburb || '',
|
|
||||||
deliverycity: dropCust.city || '',
|
|
||||||
orderamount: +totalCharge.toFixed(2) || 0,
|
|
||||||
taxamount: 0.0,
|
|
||||||
ordercharges: 0.0,
|
|
||||||
ordervalue: +totalCharge.toFixed(2) || 0,
|
|
||||||
itemcount: 1,
|
|
||||||
paymenttype: 42,
|
|
||||||
paymentstatus: 1,
|
|
||||||
deliverycharge: +totalCharge.toFixed(2) || 0,
|
|
||||||
ordernotes: otherinstructions,
|
|
||||||
kms: distance || 0,
|
|
||||||
smsdelivery: 1,
|
|
||||||
remarks: '',
|
remarks: '',
|
||||||
tenantuserid: parseInt(localStorage.getItem('userid')),
|
smsdelivery: 1,
|
||||||
partnerid: tenant.partnerid
|
subcategoryid: +subCatId,
|
||||||
|
taxamount: 0.0,
|
||||||
|
tenantid: tenant.tenantid,
|
||||||
|
tenantuserid: parseInt(localStorage.getItem('userid'))
|
||||||
},
|
},
|
||||||
|
|
||||||
pickup: {
|
pickup: {
|
||||||
customerid: pickCust.customerid || 0,
|
address: pickCust.address || '',
|
||||||
configid: parseInt(localStorage.getItem('configid')),
|
|
||||||
firstname: pickCust.firstname || '',
|
|
||||||
applocationid: pickCust.applocationid,
|
applocationid: pickCust.applocationid,
|
||||||
profileimage: '',
|
city: pickCust.city || '',
|
||||||
dialcode: '+91',
|
configid: parseInt(localStorage.getItem('configid')),
|
||||||
contactno: pickCust.contactno || '',
|
contactno: pickCust.contactno || '',
|
||||||
|
customertoken: '',
|
||||||
|
customerid: pickCust.customerid || 0,
|
||||||
devicetype: '',
|
devicetype: '',
|
||||||
deviceid: '',
|
deviceid: '',
|
||||||
customertoken: '',
|
dialcode: '+91',
|
||||||
address: pickCust.address || '',
|
|
||||||
suburb: pickCust.suburb || '',
|
|
||||||
city: pickCust.city || '',
|
|
||||||
state: pickCust.state || '',
|
|
||||||
postcode: pickCust.postcode || '',
|
|
||||||
landmark: pickCust.landmark || '',
|
|
||||||
doorno: pickCust.doorno || '',
|
doorno: pickCust.doorno || '',
|
||||||
|
email: pickCust.email || '',
|
||||||
|
firstname: pickCust.firstname || '',
|
||||||
|
landmark: pickCust.landmark || '',
|
||||||
latitude: pickCust.latitude.toString() || '',
|
latitude: pickCust.latitude.toString() || '',
|
||||||
longitude: pickCust.longitude.toString() || '',
|
longitude: pickCust.longitude.toString() || '',
|
||||||
tenantid: tenant.tenantid,
|
postcode: pickCust.postcode || '',
|
||||||
email: pickCust.email || '',
|
primaryaddress: 1,
|
||||||
primaryaddress: 1
|
profileimage: '',
|
||||||
|
state: pickCust.state || '',
|
||||||
|
suburb: pickCust.suburb || '',
|
||||||
|
tenantid: tenant.tenantid
|
||||||
},
|
},
|
||||||
drop: {
|
drop: {
|
||||||
customerid: dropCust.customerid || 0,
|
address: dropCust.address || '',
|
||||||
configid: parseInt(localStorage.getItem('configid')),
|
|
||||||
firstname: dropCust.firstname || '',
|
|
||||||
applocationid: dropCust.applocationid,
|
applocationid: dropCust.applocationid,
|
||||||
profileimage: '',
|
city: dropCust.city || '',
|
||||||
dialcode: '+91',
|
configid: parseInt(localStorage.getItem('configid')),
|
||||||
contactno: dropCust.contactno || '',
|
contactno: dropCust.contactno || '',
|
||||||
|
customertoken: '',
|
||||||
|
customerid: dropCust.customerid || 0,
|
||||||
devicetype: '',
|
devicetype: '',
|
||||||
deviceid: '',
|
deviceid: '',
|
||||||
customertoken: '',
|
dialcode: '+91',
|
||||||
address: dropCust.address || '',
|
|
||||||
suburb: dropCust.suburb || '',
|
|
||||||
city: dropCust.city || '',
|
|
||||||
state: dropCust.state || '',
|
|
||||||
postcode: dropCust.postcode || '',
|
|
||||||
landmark: dropCust.landmark || '',
|
|
||||||
doorno: dropCust.doorno || '',
|
doorno: dropCust.doorno || '',
|
||||||
|
email: dropCust.email || '',
|
||||||
|
firstname: dropCust.firstname || '',
|
||||||
|
landmark: dropCust.landmark || '',
|
||||||
latitude: dropCust.latitude.toString(),
|
latitude: dropCust.latitude.toString(),
|
||||||
longitude: dropCust.longitude.toString(),
|
longitude: dropCust.longitude.toString(),
|
||||||
tenantid: tenant.tenantid,
|
postcode: dropCust.postcode || '',
|
||||||
email: dropCust.email || '',
|
primaryaddress: 1,
|
||||||
primaryaddress: 1
|
profileimage: '',
|
||||||
|
state: dropCust.state || '',
|
||||||
|
suburb: dropCust.suburb || '',
|
||||||
|
tenantid: tenant.tenantid
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
console.log('createsubmitobj2', arr);
|
console.log('createsubmitobj2', arr);
|
||||||
@@ -1058,6 +1061,7 @@ const Createorder1 = () => {
|
|||||||
// ============================================= || Google Maps Autocomplete(pick) || =============================================
|
// ============================================= || Google Maps Autocomplete(pick) || =============================================
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Initialize Google Maps Autocomplete
|
// Initialize Google Maps Autocomplete
|
||||||
|
if (inputValue2) {
|
||||||
const autocompleteInput = document.getElementById('addressAuto1');
|
const autocompleteInput = document.getElementById('addressAuto1');
|
||||||
const autocomplete = new window.google.maps.places.Autocomplete(autocompleteInput, {
|
const autocomplete = new window.google.maps.places.Autocomplete(autocompleteInput, {
|
||||||
// types: ['(cities)'], // You can adjust the types parameter based on your requirements
|
// types: ['(cities)'], // You can adjust the types parameter based on your requirements
|
||||||
@@ -1075,11 +1079,14 @@ const Createorder1 = () => {
|
|||||||
const place = autocomplete.getPlace();
|
const place = autocomplete.getPlace();
|
||||||
setInputValue2(`${place.name}, ${place.formatted_address}`);
|
setInputValue2(`${place.name}, ${place.formatted_address}`);
|
||||||
console.log('new place', place); // Do something with the selected place
|
console.log('new place', place); // Do something with the selected place
|
||||||
console.log('new place lat lng', { lat: place.geometry.location.lat(), lng: place.geometry.location.lng() }); // Do something with the selected place
|
console.log(' pick (new place) lat lng', { lat: place.geometry.location.lat(), lng: place.geometry.location.lng() }); // Do something with the selected place
|
||||||
|
// to trigger getDistance
|
||||||
|
setStartPoint({ latitude: place.geometry.location.lat(), longitude: place.geometry.location.lng() });
|
||||||
setValue(place);
|
setValue(place);
|
||||||
setAddress(`${place.name} ${place.formatted_address}`);
|
setAddress(`${place.name} ${place.formatted_address}`);
|
||||||
setPickCust({ ...pickCust, address: `${place.name} ${place.formatted_address}` });
|
setPickCust({ ...pickCust, address: `${place.name} ${place.formatted_address}` });
|
||||||
const address = {
|
const address = {
|
||||||
|
address: `${place.name} ${place.formatted_address}`,
|
||||||
street_number: '',
|
street_number: '',
|
||||||
route: '',
|
route: '',
|
||||||
locality: '',
|
locality: '',
|
||||||
@@ -1122,12 +1129,24 @@ const Createorder1 = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Use address object as per your requirements
|
// Use address object as per your requirements
|
||||||
console.log('Address:', address);
|
setPickCust({
|
||||||
|
...pickCust,
|
||||||
|
address: address.address,
|
||||||
|
doorno: `${address.street_number} ${address.route}`,
|
||||||
|
suburb: address.sublocality_level_1,
|
||||||
|
city: address.locality,
|
||||||
|
postcode: address.postal_code,
|
||||||
|
latitude: place.geometry.location.lat(),
|
||||||
|
longitude: place.geometry.location.lng()
|
||||||
});
|
});
|
||||||
}, [address, inputValue2, pickCust]);
|
console.log('Pick Address:', address);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [inputValue2]);
|
||||||
// ============================================= || Google Maps Autocomplete(Drop) || =============================================
|
// ============================================= || Google Maps Autocomplete(Drop) || =============================================
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (inputValue3) {
|
||||||
// Initialize Google Maps Autocomplete
|
// Initialize Google Maps Autocomplete
|
||||||
const autocompleteInput = document.getElementById('addressAuto2');
|
const autocompleteInput = document.getElementById('addressAuto2');
|
||||||
const autocomplete = new window.google.maps.places.Autocomplete(autocompleteInput, {
|
const autocomplete = new window.google.maps.places.Autocomplete(autocompleteInput, {
|
||||||
@@ -1146,11 +1165,13 @@ const Createorder1 = () => {
|
|||||||
const place = autocomplete.getPlace();
|
const place = autocomplete.getPlace();
|
||||||
setInputValue3(`${place.name}, ${place.formatted_address}`);
|
setInputValue3(`${place.name}, ${place.formatted_address}`);
|
||||||
console.log('new place', place); // Do something with the selected place
|
console.log('new place', place); // Do something with the selected place
|
||||||
console.log('new place lat lng', { lat: place.geometry.location.lat(), lng: place.geometry.location.lng() }); // Do something with the selected place
|
console.log('drop (new place) lat lng', { lat: place.geometry.location.lat(), lng: place.geometry.location.lng() }); // Do something with the selected place
|
||||||
|
setEndPoint({ latitude: place.geometry.location.lat(), longitude: place.geometry.location.lng() });
|
||||||
setValue1(place);
|
setValue1(place);
|
||||||
setAddress1(`${place.name} ${place.formatted_address}`);
|
setAddress1(`${place.name} ${place.formatted_address}`);
|
||||||
setDropCust({ ...pickCust, address: `${place.name} ${place.formatted_address}` });
|
setDropCust({ ...dropCust, address: `${place.name} ${place.formatted_address}` });
|
||||||
const address = {
|
const address = {
|
||||||
|
address: `${place.name} ${place.formatted_address}`,
|
||||||
street_number: '',
|
street_number: '',
|
||||||
route: '',
|
route: '',
|
||||||
locality: '',
|
locality: '',
|
||||||
@@ -1193,9 +1214,20 @@ const Createorder1 = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Use address object as per your requirements
|
// Use address object as per your requirements
|
||||||
console.log('Address:', address);
|
setDropCust({
|
||||||
|
...dropCust,
|
||||||
|
address: address.address,
|
||||||
|
doorno: `${address.street_number} ${address.route}`,
|
||||||
|
suburb: address.sublocality_level_1,
|
||||||
|
city: address.locality,
|
||||||
|
postcode: address.postal_code,
|
||||||
|
latitude: place.geometry.location.lat(),
|
||||||
|
longitude: place.geometry.location.lng()
|
||||||
});
|
});
|
||||||
}, [address, inputValue3, dropCust]);
|
console.log('Drop Address:', address);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [inputValue3]);
|
||||||
|
|
||||||
// ============================================= || gettenantlocations (branches) || =============================================
|
// ============================================= || gettenantlocations (branches) || =============================================
|
||||||
const gettenantlocations = async () => {
|
const gettenantlocations = async () => {
|
||||||
@@ -1240,7 +1272,21 @@ const Createorder1 = () => {
|
|||||||
>
|
>
|
||||||
<Typography variant="h3">Create Order</Typography>
|
<Typography variant="h3">Create Order</Typography>
|
||||||
{tenantLocations.length == 1 ? (
|
{tenantLocations.length == 1 ? (
|
||||||
<TextField variant="outlined" label={'Tenent Location'} value={tenantLocations[0].locationname} sx={{ width: 300 }} />
|
<TextField
|
||||||
|
variant="outlined"
|
||||||
|
label={'Business Location'}
|
||||||
|
value={tenantLocations[0].locationname}
|
||||||
|
focused
|
||||||
|
sx={{ width: 300 }}
|
||||||
|
InputProps={{
|
||||||
|
style: { color: theme.palette.primary.main },
|
||||||
|
startAdornment: (
|
||||||
|
<InputAdornment position="start">
|
||||||
|
<MyLocationIcon color="primary" />
|
||||||
|
</InputAdornment>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
disablePortal
|
disablePortal
|
||||||
@@ -1552,7 +1598,7 @@ const Createorder1 = () => {
|
|||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
label="Door No"
|
label="Door No / Street"
|
||||||
value={pickCust.doorno}
|
value={pickCust.doorno}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setPickCust({ ...pickCust, doorno: e.target.value });
|
setPickCust({ ...pickCust, doorno: e.target.value });
|
||||||
@@ -1922,7 +1968,7 @@ const Createorder1 = () => {
|
|||||||
<TextField
|
<TextField
|
||||||
fullWidth
|
fullWidth
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
label="Door No"
|
label="Door No / Street"
|
||||||
InputProps={{
|
InputProps={{
|
||||||
startAdornment: (
|
startAdornment: (
|
||||||
<IconButton>
|
<IconButton>
|
||||||
@@ -2123,7 +2169,7 @@ const Createorder1 = () => {
|
|||||||
label={dayjs(val).format('hh:mm A')}
|
label={dayjs(val).format('hh:mm A')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (distance > appLocaRadius) {
|
if (distance > appLocaRadius) {
|
||||||
opentoast('Service not available at this location', 'error', 2000);
|
setOpen4(true);
|
||||||
} else if (showDistance) {
|
} else if (showDistance) {
|
||||||
console.log('selectedtime', val);
|
console.log('selectedtime', val);
|
||||||
setSelectedtime(val);
|
setSelectedtime(val);
|
||||||
@@ -2233,9 +2279,19 @@ const Createorder1 = () => {
|
|||||||
<Button
|
<Button
|
||||||
disabled={!showDistance}
|
disabled={!showDistance}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
sx={{
|
||||||
|
'&:hover': {
|
||||||
|
bgcolor: 'white',
|
||||||
|
color: theme.palette.primary.main,
|
||||||
|
border: `1px solid ${theme.palette.primary.main}`
|
||||||
|
}
|
||||||
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
// createsubmitobj1();
|
setLoading(true);
|
||||||
createsubmitobj2();
|
createsubmitobj2();
|
||||||
|
setTimeout(() => {
|
||||||
|
setLoading(false);
|
||||||
|
}, 1000);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Create
|
Create
|
||||||
@@ -2366,7 +2422,7 @@ const Createorder1 = () => {
|
|||||||
setIsCustomerOpen(false);
|
setIsCustomerOpen(false);
|
||||||
if (pickordrop === 1) {
|
if (pickordrop === 1) {
|
||||||
console.log('PickupClient', address);
|
console.log('PickupClient', address);
|
||||||
// setPickCust({ ...pickCust, address: address });
|
|
||||||
setStartPoint({ latitude: address.latitude, longitude: address.longitude });
|
setStartPoint({ latitude: address.latitude, longitude: address.longitude });
|
||||||
setPickCust(address);
|
setPickCust(address);
|
||||||
} else {
|
} else {
|
||||||
@@ -2434,18 +2490,41 @@ const Createorder1 = () => {
|
|||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
{/* <Drawer
|
<Dialog
|
||||||
anchor={'right'}
|
// anchor={'right'}
|
||||||
open={open4}
|
open={open4}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setOpen4(false);
|
setOpen4(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<DialogTitle sx={{ textAlign: 'center' }}>
|
||||||
<Box sx={{ width: { sm: '600px', xs: '100%' } }}>
|
<HighlightOffIcon sx={{ fontSize: 60, color: theme.palette.error.main }} />
|
||||||
<GoogleMaps />
|
<Typography variant="h3" sx={{ color: theme.palette.error.main }}>
|
||||||
</Box>
|
Error
|
||||||
</Drawer> */}
|
</Typography>
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<Typography variant="h4" color={'secondary'}>
|
||||||
|
Service not available at this location
|
||||||
|
</Typography>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions
|
||||||
|
sx={{
|
||||||
|
bgcolor: theme.palette.error.main,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
fontSize: 20,
|
||||||
|
color: 'white',
|
||||||
|
cursor: 'pointer'
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
setOpen4(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
</Grid>
|
</Grid>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user