mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
Corrections + admin full screen
This commit is contained in:
@@ -8,6 +8,8 @@ import { mapZooms } from "@/util/configurations";
|
||||
export default function LiveMap({ selectedTeamId, onSelected, isFocusing, setIsFocusing, mapStyle, showZones, showNames, showArrows }) {
|
||||
const { zoneType, zoneExtremities, teams, nextZoneDate, getTeam, gameState } = useAdmin();
|
||||
const [timeLeftNextZone, setTimeLeftNextZone] = useState(null);
|
||||
const [isFullScreen, setIsFullScreen] = useState(false);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (nextZoneDate) {
|
||||
@@ -50,8 +52,7 @@ export default function LiveMap({ selectedTeamId, onSelected, isFocusing, setIsF
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='h-full w-full flex flex-col'>
|
||||
{gameState == GameState.PLAYING && <p>{`Next zone in : ${formatTime(timeLeftNextZone)}`}</p>}
|
||||
<div className={`${isFullScreen ? "fixed inset-0 z-[9999]" : "relative h-full w-full"}`}>
|
||||
<CustomMapContainer mapStyle={mapStyle}>
|
||||
{isFocusing && <MapPan center={getTeam(selectedTeamId)?.currentLocation} zoom={mapZooms.high} animate />}
|
||||
<MapEventListener onDragStart={() => setIsFocusing(false)}/>
|
||||
@@ -60,12 +61,21 @@ export default function LiveMap({ selectedTeamId, onSelected, isFocusing, setIsF
|
||||
<CircleZone circle={team.startingArea} color="blue" display={gameState == GameState.PLACEMENT && showZones}>
|
||||
<Tag text={team.name} display={showNames} />
|
||||
</CircleZone>
|
||||
<Arrow pos1={team.currentLocation} pos2={getTeam(team.chased)?.currentLocation} display={showArrows}/>
|
||||
<Arrow pos1={team.currentLocation} pos2={getTeam(team.chasing)?.currentLocation} display={showArrows}/>
|
||||
<Position position={team.currentLocation} color={"blue"} onClick={() => onSelected(team.id)} display={!team.captured}>
|
||||
<Tag text={team.name} display={showNames} />
|
||||
</Position>
|
||||
</Fragment>)}
|
||||
</CustomMapContainer>
|
||||
{ gameState == GameState.PLAYING &&
|
||||
<div className="absolute top-4 left-1/2 -translate-x-1/2 z-[1000] pointer-events-none flex flex-col items-center bg-white p-2 rounded-lg shadow-lg drop-shadow">
|
||||
<p className="text-sm">Durée zone</p>
|
||||
<p className="text-2xl font-bold">{formatTime(timeLeftNextZone)}</p>
|
||||
</div>
|
||||
}
|
||||
<button className="absolute top-4 right-4 z-[1000] cursor-pointer bg-white p-3 rounded-full shadow-lg drop-shadow" onClick={() => setIsFullScreen(!isFullScreen)}>
|
||||
<img src={`/icons/fullscreen.png`} className="w-8 h-8" />
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ import { env } from 'next-runtime-env';
|
||||
import { useEffect, useState } from "react";
|
||||
import useAdmin from "@/hook/useAdmin";
|
||||
import { getStatus } from '@/util/functions';
|
||||
import { Colors } from '@/util/types';
|
||||
import { teamStatus } from '@/util/configurations';
|
||||
import { Colors, GameState } from '@/util/types';
|
||||
|
||||
function DotLine({ label, value }) {
|
||||
return (
|
||||
@@ -32,6 +31,7 @@ function IconValue({ color, icon, value }) {
|
||||
export default function TeamSidePanel({ selectedTeamId, onClose }) {
|
||||
const { getTeam, startDate, gameState } = useAdmin();
|
||||
const [imgSrc, setImgSrc] = useState("");
|
||||
const [_, setRefreshKey] = useState(0);
|
||||
const team = getTeam(selectedTeamId);
|
||||
const NO_VALUE = "XX";
|
||||
const NEXT_PUBLIC_SOCKET_HOST = env("NEXT_PUBLIC_SOCKET_HOST");
|
||||
@@ -43,6 +43,14 @@ export default function TeamSidePanel({ selectedTeamId, onClose }) {
|
||||
|
||||
if (!team) return null;
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setRefreshKey(prev => prev + 1);
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
function formatTime(startDate, endDate) {
|
||||
// startDate in milliseconds
|
||||
if (endDate == null || startDate == null || startDate < 0) return NO_VALUE + ":" + NO_VALUE;
|
||||
@@ -92,18 +100,22 @@ export default function TeamSidePanel({ selectedTeamId, onClose }) {
|
||||
<DotLine label="ID d'équipe" value={String(selectedTeamId).padStart(6, '0').replace(/(\d{3})(\d{3})/, "$1 $2")} />
|
||||
<DotLine label="ID de capture" value={team.captureCode ? String(team.captureCode).padStart(4, '0') : NO_VALUE} />
|
||||
</div>
|
||||
<div>
|
||||
<DotLine label="Chasse" value={getTeam(team.chasing)?.name ?? NO_VALUE} />
|
||||
<DotLine label="Chassé par" value={getTeam(team.chased)?.name ?? NO_VALUE} />
|
||||
</div>
|
||||
<div>
|
||||
<DotLine label="Distance" value={formatDistance(team.distance)} />
|
||||
<DotLine label="Temps de survie" value={formatTime(startDate, team.captured ? team.finishDate : Date.now())} />
|
||||
<DotLine label="Vitesse moyenne" value={formatSpeed(team.distance, startDate, team.captured ? team.finishDate : Date.now())} />
|
||||
<DotLine label="Captures" value={team.nCaptures ?? NO_VALUE} />
|
||||
<DotLine label="Observations" value={team.nSentLocation ?? NO_VALUE} />
|
||||
<DotLine label="Observé" value={team.nObserved ?? NO_VALUE} />
|
||||
</div>
|
||||
{ gameState != GameState.FINISHED &&
|
||||
<div>
|
||||
<DotLine label="Chasse" value={getTeam(team.chasing)?.name ?? NO_VALUE} />
|
||||
<DotLine label="Chassé par" value={getTeam(team.chased)?.name ?? NO_VALUE} />
|
||||
</div>
|
||||
}
|
||||
{ (gameState == GameState.PLAYING || gameState == GameState.FINISHED) &&
|
||||
<div>
|
||||
<DotLine label="Distance" value={formatDistance(team.distance)} />
|
||||
<DotLine label="Temps de survie" value={formatTime(startDate, team.finishDate || Date.now())} />
|
||||
<DotLine label="Vitesse moyenne" value={formatSpeed(team.distance, startDate, team.finishDate || Date.now())} />
|
||||
<DotLine label="Captures" value={team.nCaptures ?? NO_VALUE} />
|
||||
<DotLine label="Observations" value={team.nSentLocation ?? NO_VALUE} />
|
||||
<DotLine label="Observé" value={team.nObserved ?? NO_VALUE} />
|
||||
</div>
|
||||
}
|
||||
<div>
|
||||
<DotLine label="Modèle" value={team.phoneModel ?? NO_VALUE} />
|
||||
<DotLine label="Nom" value={team.phoneName ?? NO_VALUE} />
|
||||
|
||||
Reference in New Issue
Block a user