This commit is contained in:
Kenneth Jannette
2024-03-20 03:32:01 -05:00
parent 4778e42e1a
commit 2994d998e0
2 changed files with 0 additions and 62 deletions

View File

@@ -10,37 +10,6 @@ import "../../styles/homepage.scss";
const HomePage = () => {
const navigate = useNavigate();
async function saveData(data) {
const id = uuidv4();
const visitRef = collection(db, "homevisitors");
await setDoc(doc(visitRef, `${id}`), data);
}
function getPosition() {
return new Promise((res, rej) => {
navigator.geolocation.getCurrentPosition(res, rej);
});
}
useEffect(() => {
if (window.location.href === "http://localhost:3000/") {
return;
}
const userAgent = window?.navigator.userAgent;
getPosition().then((data) => {
const dateTime = new Date();
const currentLat = data.coords.latitude;
const currentLong = data.coords.longitude;
const values = {};
values["userAgent"] = userAgent;
values["latitude"] = currentLat;
values["longitude"] = currentLong;
values["dateTime"] = String(dateTime);
saveData(values);
});
}, []);
const handleNavigate = () => {
navigate("/signup");
};