Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Botón respuesta correcta y tope de 10 preguntas #65

Merged
merged 4 commits into from
Feb 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions webapp/src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Game=() =>{
const [respuestaCorrecta, setRespuestaCorrecta] = useState('');
const [questionType, setQuestionType] = useState('');;//para el tipo de pregunta a buscar
const [answerType, setAnswerType] = useState('');;//para el tipo de respuesta a buscar

const [numberClics, setNumberClics] = useState(1);

const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000';

Expand Down Expand Up @@ -89,6 +89,9 @@ const Game=() =>{
};

const handleButtonClick = () => {

setNumberClics(numberClics + 1);//aumento el numero de clics en 1

obtenerPreguntaAleatoria();
//pais, libro,actor, edificio
if (questionType=='pais'){
Expand All @@ -105,22 +108,30 @@ const Game=() =>{

return (




<div>
<h1>Pregunta: </h1>
{numberClics > 10 ? (
<p>Fin</p>
) : (<>
<h1>Pregunta Número {numberClics} :</h1>
<div>
<Typography component="h1" variant="h5" sx={{ textAlign: 'center' }}>
{questionBody} {informacionWikidata}
</Typography>

<Button variant="contained" color="primary" onClick={handleButtonClick}>
Generar pregunta
{respuestaCorrecta}
</Button>

</div>
<Button variant="contained" color="primary" size="large">
{respuestaCorrecta}
</Button>
</>
)}
</div>
);
);


}

export default Game;