import React from "react";
import { useGame } from "../../hooks/useGame";
import GameQuestion from "./GameQuestion";
import { useNavigate } from "react-router-dom";
import { useUser } from "../../hooks/useUser";
import { postGameStatisticsData } from "../../services/WordpressFetchData";
export default function ExtraControls() {
	const { language, country } = useUser();
	const { contextGameDatas, score, currentGameModal, setCurrentGameModal } = useGame();

	const navigate = useNavigate();

	const correctAnswer = contextGameDatas?.gameObjects[0].attrs.behaviourType;
	const objectPictureUrl = contextGameDatas?.gameObjects[0].attrs.objectPictureUrl;

	function sendDatasTest() {
		postGameStatisticsData();
	}

	return (
		<div className='extra-controls'>
			<button onClick={sendDatasTest}>send datas</button>
			<button className='addModal' onClick={() => navigate("/")}>
				go home
			</button>
			<button
				className='addModal'
				onClick={() =>
					setCurrentGameModal(
						<GameQuestion
							questionId={0}
							correctAnswer={correctAnswer}
							objectPictureUrl={objectPictureUrl}
						/>
					)
				}>
				AddModal
			</button>
		</div>
	);
}
