admin interface basic functionalities

This commit is contained in:
Quentin Roussel
2024-03-26 01:21:26 +01:00
parent 2478ee32ec
commit b23d2a63e6
24 changed files with 1504 additions and 40 deletions

View File

@@ -1,7 +1,8 @@
"use client";
import Button from '@/components/util/button';
import dynamic from 'next/dynamic';
import React, { useEffect, useState } from 'react'
import React, { useEffect } from 'react'
import useGame from '../../hook/useGame';
//Load the map without SSR
const LiveMap = dynamic(() => import('@/components/team/map'), {
@@ -9,27 +10,13 @@ const LiveMap = dynamic(() => import('@/components/team/map'), {
});
export default function Track() {
const [currentPosition, setCurrentPosition] = useState([0,0]);
const [enemyPosition, setEnemyPosition] = useState([0,0]);
useEffect(() => {
const t = setTimeout(() => {
setEnemyPosition([currentPosition[0] + Math.random() / 100, currentPosition[1] + Math.random() / 100]);
}, 1000);
return () => clearInterval(t);
}, [currentPosition]);
useEffect(() => {
navigator.geolocation.watchPosition((position) => {
setCurrentPosition([position.coords.latitude, position.coords.longitude]);
});
}, []);
const { currentPosition, enemyPosition, updateCurrentPosition, sendCurrentPosition } = useGame();
return (
<div className='h-full flex flex-col justify-between'>
<LiveMap currentPosition={currentPosition} enemyPosition={enemyPosition} className="h-4/5" />
<Button>Update position</Button>
<Button onClick={sendCurrentPosition}>Update position</Button>
<div className='shadow-lg m-5 p-2 flex flex-col text-center mx-auto w-4/5 rounded'>
<p className='text-xl text-black'>30min</p>
<p className='text-gray-700'> before penalty</p>