mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
improved admin UI
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
import { useLocation } from "@/hook/useLocation";
|
||||
import { useEffect, useState } from "react";
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import { Circle, MapContainer, Marker, TileLayer, useMap } from "react-leaflet";
|
||||
import { Circle, MapContainer, Marker, Popup, TileLayer, useMap } from "react-leaflet";
|
||||
import { useMapCircleDraw } from "@/hook/mapDrawing";
|
||||
import useAdmin from "@/hook/useAdmin";
|
||||
|
||||
function MapPan(props) {
|
||||
const map = useMap();
|
||||
@@ -91,4 +92,34 @@ export function ZonePicker({ minZone, setMinZone, maxZone, setMaxZone, editMode,
|
||||
<MapEventListener onClick={handleClick} onMouseMove={handleMouseMove} />
|
||||
</MapContainer>
|
||||
)
|
||||
}
|
||||
|
||||
export function LiveMap() {
|
||||
const location = useLocation(Infinity);
|
||||
const { zone, zoneExtremities, teams, getTeamName } = useAdmin();
|
||||
return (
|
||||
<MapContainer className='min-h-full w-full ' center={location} zoom={DEFAULT_ZOOM} scrollWheelZoom={true}>
|
||||
<TileLayer
|
||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
/>
|
||||
<MapPan center={location} zoom={DEFAULT_ZOOM} />
|
||||
{zone && <Circle center={zone.center} radius={zone.radius} color="blue" />}
|
||||
{zoneExtremities && <Circle center={zoneExtremities.begin.center} radius={zoneExtremities.begin.radius} color='black' fill={false} />}
|
||||
{zoneExtremities && <Circle center={zoneExtremities.end.center} radius={zoneExtremities.end.radius} color='red' fill={false} />}
|
||||
{teams.map((team) => team.currentLocation && !team.captured && <Marker key={team.id} position={team.currentLocation} icon={new L.Icon({
|
||||
iconUrl: '/icons/location.png',
|
||||
iconSize: [41, 41],
|
||||
iconAnchor: [12, 41],
|
||||
popupAnchor: [1, -34],
|
||||
shadowSize: [41, 41]
|
||||
})}>
|
||||
<Popup>
|
||||
<strong className="text-lg">{team.name}</strong>
|
||||
<p className="text-md">Chasing : {getTeamName(team.chasing)}</p>
|
||||
<p className="text-md">Chased by : {getTeamName(team.chased)}</p>
|
||||
</Popup>
|
||||
</Marker>)}
|
||||
</MapContainer>
|
||||
)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import useAdmin from "@/hook/useAdmin"
|
||||
|
||||
export function TeamReady() {
|
||||
const {teams} = useAdmin();
|
||||
return <div className='w-max h-full gap-1 bg-gray-200 p-10 flex flex-col text-center shadow-2xl overflow-y-scroll'>
|
||||
return <div className='w-max h-full gap-1 bg-white p-10 flex flex-col text-center shadow-2xl overflow-y-scroll'>
|
||||
<h2 className="text-2xl">Teams ready status</h2>
|
||||
{teams.map((team) => team.ready ? (
|
||||
<div key={team.id} className="p-2 text-white bg-green-500 shadow-md text-xl rounded flex flex-row">
|
||||
|
||||
@@ -37,7 +37,7 @@ export function ZoneSelector() {
|
||||
|
||||
}, [minZone, maxZone]);
|
||||
|
||||
return <div className='w-2/5 h-full gap-1 bg-gray-200 p-10 flex flex-col text-center shadow-2xl overflow-y-scroll'>
|
||||
return <div className='w-2/5 h-full gap-1 bg-white p-10 flex flex-col text-center shadow-2xl overflow-y-scroll'>
|
||||
<h2 className="text-2xl">Edit zones</h2>
|
||||
{editMode == EditMode.MIN && <RedButton onClick={() => setEditMode(EditMode.MAX)}>Edit end zone</RedButton>}
|
||||
{editMode == EditMode.MAX && <BlueButton onClick={() => setEditMode(EditMode.MIN)}>Edit start zone</BlueButton>}
|
||||
|
||||
Reference in New Issue
Block a user