import { useState, useEffect } from 'react'; import { getCurrentRound } from "../../../domain/GGSHService"; export default (gameId, playerName) => { const [finished, setFinished] = useState(false); const [roundInfo, setRoundInfo] = useState({currentRound: null, targetPoint: null, roundSeconds: null}); useEffect(() => { const setup = async () => { const { currentRound, coord, timer } = await getCurrentRound(gameId, playerName); if (currentRound) { setRoundInfo({ currentRound, targetPoint: coord, roundSeconds: timer }); } else { setFinished(true); } } setup(); }, [gameId, playerName]); return [finished, roundInfo]; }