import { Fragment, useEffect, useState } from "react"; import { Arrow, CircleZone, PolygonZone, Position, Tag } from "@/components/layer"; import { CustomMapContainer, MapEventListener, MapPan } from "@/components/map"; import useAdmin from "@/hook/useAdmin"; import { GameState, ZoneTypes } from "@/util/types"; 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); useEffect(() => { if (nextZoneDate) { const updateTime = () => { setTimeLeftNextZone(Math.max(0, Math.floor((nextZoneDate - Date.now()) / 1000))); }; updateTime(); const interval = setInterval(updateTime, 1000); return () => clearInterval(interval); } }, [nextZoneDate]); function formatTime(time) { // time is in seconds if (!time || time < 0) return "00:00"; const minutes = Math.floor(time / 60); const seconds = Math.floor(time % 60); return String(minutes).padStart(2,"0") + ":" + String(seconds).padStart(2,"0"); } function Zones() { if (!(showZones && gameState == GameState.PLAYING)) return null; switch (zoneType) { case ZoneTypes.CIRCLE: return (<> ); case ZoneTypes.POLYGON: return (<> ); default: return null; } } return (
{gameState == GameState.PLAYING &&

{`Next zone in : ${formatTime(timeLeftNextZone)}`}

} {isFocusing && } setIsFocusing(false)}/> {teams.map((team) => team && onSelected(team.id)} display={!team.captured}> )}
) }