
export  function postTeamsize(data) {
    const requestOptions = {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'},
        body: JSON.stringify({ teamsize: data})
    }
    return fetch("http://192.168.0.94:5555/teamsize", requestOptions)

}

export function getConnection() {
    return 0
}
export function getQuestion(setAns1, setAns2, setAns3, setQuestion, setCorrectField, setCorrectAnsw) {
    return fetch("http://192.168.0.94:5555/question")
        .then(response => response.json())
        .then(data => {
            setQuestion(data.QuestionNr)
            setAns1(data.Answeroption_1)
            setAns2(data.Answeroption_2)
            setAns3(data.Answeroption_3)
            setCorrectField(data.Correct_field)
            setCorrectAnsw(data.Correct_answeroption)
            console.log(data)
        })
        .catch(error => console.error(error));
}

export function getScoreboard(setScoreBlue, setScoreGreen, setScoreRed) {
    return fetch("http://192.168.0.94:5555/scoreboard")
        .then(response => response.json())
        .then(data => {
            setScoreBlue(data.score_blue)
            setScoreRed(data.score_red)
            setScoreGreen(data.score_green)
        })
        .catch(error => console.error(error))
}

export function getCheck() {

}

export function getReset(setAns1, setAns2, setAns3, setQuestion) {
    setAns1('?');
    setAns2('?');
    setAns3('?');
    setQuestion('?');
    return fetch("http://192.168.0.94:5555/reset")
}