import React, { useState, useEffect } from 'react';
import { gameInfo, getGuesses, sendGuess } from "../../../domain/GGSHService";
import Loading from '../../util/Loading';
import GuessPane from "./GuessPane";
import PositionedStreetView from "./PositionedStreetView";
const GamePanelContainer = ({ gameId, playerName, onRoundEnd, onGameEnd }) => {
const [{ currentRound, targetPoint, roundSeconds }, setRoundInfo] = useState({currentRound: null, targetPoint: null, roundSeconds: null});
const [submitDisabled, setSubmitDisabled] = useState(false);
const [selectedPoint, setSelectedPoint] = useState(null);
useEffect(() => {
const setup = async () => {
const { currentRound } = await getGuesses(gameId, playerName);
if (currentRound) {
const { coords, timer } = await gameInfo(gameId);
const targetPoint = coords[currentRound];
setRoundInfo({ currentRound, targetPoint, roundSeconds: timer });
} else {
onGameEnd();
}
}
setup();
}, [gameId, playerName, onGameEnd]);
if (!currentRound || !targetPoint || !roundSeconds) {
return