Skip to content

Commit

Permalink
chore: fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Toto-hitori committed Apr 8, 2024
1 parent 6d5ce7c commit 44becd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 56 deletions.
42 changes: 1 addition & 41 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,12 @@ on:
push:
branches:
- master
- develop
release:
types: [published]
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/checkout@v4
- run: npm --prefix webapp ci
- run: npm --prefix webapp test -- --coverage
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- run: mvn clean verify
working-directory: api
env:
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
e2e-tests:
needs: [ unit-tests ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
# - run: npm --prefix webapp run test:e2e
docker-push-api:
runs-on: ubuntu-latest
needs: [ e2e-tests ]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -71,7 +33,6 @@ jobs:
permissions:
contents: read
packages: write
needs: [ e2e-tests ]
steps:

- uses: actions/checkout@v4
Expand All @@ -94,7 +55,6 @@ jobs:
REACT_APP_API_ENDPOINT
docker-push-question-generator:
runs-on: ubuntu-latest
needs: [ e2e-tests ]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand Down
32 changes: 17 additions & 15 deletions webapp/src/pages/Game.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useCallback } from "react";
import React, { useState, useEffect } from "react";
import { Grid, Flex, Heading, Button, Box, Text, Spinner, CircularProgress } from "@chakra-ui/react";
import { Center } from "@chakra-ui/layout";
import { useNavigate } from "react-router-dom";
Expand Down Expand Up @@ -43,7 +43,7 @@ export default function Game() {
/*
Generate new question when the round changes
*/
const assignQuestion = useCallback(async (gameId) => {
const assignQuestion = async (gameId) => {
try {
const result = await getCurrentQuestion(gameId);
if (result.status === HttpStatusCode.Ok) {
Expand All @@ -57,7 +57,7 @@ export default function Game() {
console.error("Error fetching question:", error);
navigate("/dashboard");
}
}, [navigate]);
}

const answerButtonClick = async (optionIndex, answer) => {
const selectedOptionIndex = selectedOption === optionIndex ? null : optionIndex;
Expand All @@ -67,7 +67,7 @@ export default function Game() {
setNextDisabled(!anyOptionSelected);
};

const startNewRound = useCallback(async (gameId) => {
const startNewRound = async (gameId) => {
try{
console.log("pepe");
const result = await startRound(gameId);
Expand All @@ -88,7 +88,7 @@ export default function Game() {

}

}, [roundNumber, correctAnswers, assignQuestion, navigate]);
}

/*
Initialize game when loading the page
Expand Down Expand Up @@ -122,9 +122,7 @@ export default function Game() {
}
};

initializeGame();

const nextRound = useCallback(async () => {
const nextRound = async () => {
if (roundNumber + 1 > maxRoundNumber)
navigate("/dashboard/game/results", { state: { correctAnswers: correctAnswers } });
else {
Expand All @@ -134,10 +132,9 @@ export default function Game() {
await startNewRound(gameId);
}

}, [gameId, maxRoundNumber, roundNumber, startNewRound,
correctAnswers, navigate]);
}

const nextButtonClick = useCallback(async () => {
const nextButtonClick = async () => {
try {
const result = await answerQuestion(gameId, answer.id);
let isCorrect = result.data.was_correct;
Expand All @@ -152,11 +149,15 @@ export default function Game() {
if(error.response.status === 400){
setTimeout(nextButtonClick, 2000)
}else{
console.log('xd'+error.status)
console.log('xd'+error.response.status)
}
}
}, [gameId, answer.id, nextRound, correctAnswers]);

};
useEffect(() => {
// Empty dependency array [] ensures this effect runs only once after initial render
initializeGame();
// eslint-disable-next-line
}, []);
useEffect(() => {
let timeout;
if (showConfetti)
Expand All @@ -177,7 +178,8 @@ export default function Game() {
}, 1000);
}
return () => clearTimeout(timeout);
}, [timeElapsed, nextRound, timeStartRound, roundDuration]);
// eslint-disable-next-line
}, [timeElapsed, timeStartRound, roundDuration]);


return (
Expand Down

0 comments on commit 44becd4

Please sign in to comment.