more
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import Col from "react-bootstrap/Col";
|
import Col from "react-bootstrap/Col";
|
||||||
import Form from "react-bootstrap/Form";
|
import Form from "react-bootstrap/Form";
|
||||||
import Row from "react-bootstrap/Row";
|
import Row from "react-bootstrap/Row";
|
||||||
@@ -68,6 +68,37 @@ const SignupPage = () => {
|
|||||||
const [valY, setValY] = useState(4);
|
const [valY, setValY] = useState(4);
|
||||||
const userAgent = window.navigator.userAgent;
|
const userAgent = window.navigator.userAgent;
|
||||||
|
|
||||||
|
async function saveData(data) {
|
||||||
|
const id = uuidv4();
|
||||||
|
const visitRef = collection(db, "signupvisitors");
|
||||||
|
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 userAgentIn = window?.navigator.userAgent;
|
||||||
|
getPosition().then((data) => {
|
||||||
|
const dateTime = new Date();
|
||||||
|
const currentLat = data.coords.latitude;
|
||||||
|
const currentLong = data.coords.longitude;
|
||||||
|
const values = {};
|
||||||
|
values["userAgent"] = userAgentIn;
|
||||||
|
values["latitude"] = currentLat;
|
||||||
|
values["longitude"] = currentLong;
|
||||||
|
values["dateTime"] = String(dateTime);
|
||||||
|
saveData(values);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleChangeInput = (e, name) => {
|
const handleChangeInput = (e, name) => {
|
||||||
const newData = handleFormDataChange(e, name, data, signupFields);
|
const newData = handleFormDataChange(e, name, data, signupFields);
|
||||||
if (newData !== null) {
|
if (newData !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user