Skip to content

Commit

Permalink
Solve location comapre
Browse files Browse the repository at this point in the history
  • Loading branch information
kewal-wq committed Feb 8, 2022
1 parent 394e0c7 commit 833c9e1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/src/components/AllCustomers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ useEffect(() => {
<>
<h5>Name: {cust.name}</h5>
<h5>Email: {cust.email}</h5>
<h5>Mobile No. : {cust.mobileNumber}</h5>
<h5>Mobile No: {cust.mobileNumber}</h5>
<h5>lat : {cust.latitude}</h5>
<h5>long : {cust.longitude}</h5>
</>
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/CreateCustomer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ const CreateCustomer = () => {

const handleSubmit = (e) => {
e.preventDefault();
console.log(customer);

axios
.post("http://localhost:4000/customers/new", customer)
.then((res) => {});
.then((res) => {

});
};

return (
Expand Down
20 changes: 19 additions & 1 deletion client/src/components/CreateVendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const initialState = {
};

const CreateVendor = () => {

const [vendor, setVendor] = useState(initialState);
const [customer, setCustomer] = useState([]);

// const [lat, setLat] = useState(0);
// const [lng, setLng] = useState(0);

Expand All @@ -30,9 +33,24 @@ const CreateVendor = () => {
const handleSubmit = (e) => {
e.preventDefault();
console.log(vendor);
console.log(customer);
axios
.post("http://localhost:4000/vendors/new", vendor)
.then((res) => {});
.then((res) => {

navigator.geolocation.watchPosition((pos) => {
customer.map((cust) => {
if (pos.coords.latitude === cust.latitude && pos.coords.longitude === cust.longitude) {
console.log("Yaya we made it!!");
}
else{
console.log("It did not match");
}

})

})
});
};

return (
Expand Down

0 comments on commit 833c9e1

Please sign in to comment.