"use client"; import { useCallback, useEffect, useState } from "react"; import type { CallForFireDifficulty, CallForFireStats, } from "@/app/(frontend)/minigames/call-for-fire/actions"; import { useRealtimePresence } from "@/hooks/useRealtimePresence"; import { useSidebar } from "@/components/ui/sidebar"; import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard"; import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard"; import { CallForFireDevControls } from "@/components/frontend/minigames/dev/CallForFireDevControls"; import { MinigameDevDock } from "@/components/frontend/minigames/dev/MinigameDevDock"; import { CallForFireLeaderboard } from "./CallForFireLeaderboard"; import { FireMissionBoard, type CallForFireDevSnapshot } from "./FireMissionBoard"; export function CallForFireArena({ initialStats, currentUserId, isSuperuser = false, }: { initialStats: CallForFireStats; currentUserId: number | string; isSuperuser?: boolean; }) { const [refreshKey, setRefreshKey] = useState(0); const [playing, setPlaying] = useState(false); const [selectedDifficulty, setSelectedDifficulty] = useState("patrol"); const [missionSnapshot, setMissionSnapshot] = useState(null); const { isMobile, setOpenMobile } = useSidebar(); const activeTeams = useRealtimePresence("callForFire", playing, true); const onPhaseChange = useCallback((phase: "ready" | "playing" | "over") => { setPlaying(phase === "playing"); }, []); useEffect(() => { if (playing && isMobile) setOpenMobile(false); }, [isMobile, playing, setOpenMobile]); return (
setRefreshKey((key) => key + 1)} onPhaseChange={onPhaseChange} onDifficultyChange={setSelectedDifficulty} isSuperuser={isSuperuser} onDevSnapshotChange={setMissionSnapshot} />
); }