Implemented player login

This commit is contained in:
Quentin Roussel
2024-03-26 03:35:19 +01:00
parent b23d2a63e6
commit 7d75e91c80
16 changed files with 182 additions and 130 deletions

View File

@@ -0,0 +1,21 @@
"use client";
import { useEffect, useState } from "react";
/**
* A hook that returns the location of the user and updates it periodically
* @returns {Object} The location of the user
*/
export function useLocation(interval) {
const [location, setLocation] = useState();
useEffect(() => {
function update() {
navigator.geolocation.getCurrentPosition((position) => {
setLocation([position.coords.latitude, position.coords.longitude]);
setTimeout(update, interval);
}, () => { }, { enableHighAccuracy: true, timeout: Infinity, maximumAge: 0 });
}
update();
}, []);
return location;
}