Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Arquisoft/wiq_es04c into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
yagonavajas committed Mar 2, 2024
2 parents fc47299 + 5c350cc commit f50ce9d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions webapp/src/components/game/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Game = () => {

const [question, setQuestion] = useState('');
const [answers, setAnswers] = useState([]);
const [loadingMessage, setLoadingMessage] = useState('');
const [snackbarOpen, setSnackbarOpen] = useState(false);
const [snackbarMessage, setSnackbarMessage] = useState('');
const [snackbarSeverity, setSnackbarSeverity] = useState('success');
Expand All @@ -26,6 +27,9 @@ const Game = () => {
if (correct) {
setSnackbarMessage('Respuesta correcta');
setSnackbarSeverity('success');
setQuestion('');
setAnswers([]);
setLoadingMessage('Generando próxima pregunta');
fetchQuestionAndAnswers();
} else {
setSnackbarMessage('Respuesta incorrecta');
Expand All @@ -41,6 +45,7 @@ const Game = () => {
// Almacena la pregunta y las respuestas en los estado.
setQuestion(response.data.question);
setAnswers(response.data.answers);
setLoadingMessage('');
// setQuestion(exampleData.question);
// setAnswers(exampleData.answers);
} catch (error) {
Expand All @@ -60,6 +65,7 @@ const Game = () => {
Generate Question
</Button>
</Box>
{loadingMessage && (<Typography variant="h2">{loadingMessage}</Typography>)}
{/* Muestra la pregunta y las respuesta si existen */}
{question && (
<Paper elevation={3} sx={{ p: 2, mb: 2 }}>
Expand Down

0 comments on commit f50ce9d

Please sign in to comment.