Skip to content

Commit

Permalink
Merge pull request #81 from Arquisoft/deploy-fixes
Browse files Browse the repository at this point in the history
Arreglado el cambio de modo en Stats
  • Loading branch information
iyanfdezz authored Apr 2, 2024
2 parents acb5c9d + af28852 commit ed3075f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions webapp/src/pages/Stats/Stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const Stats = () => {
const [error, setError] = useState(null);
const [fetched, setFetched] = useState(false);

const fetchStats = () => {
const fetchStats = (mode) => {
setIsLoading(true);
fetch(gatewayUrl + `/stats?user=${username}&gamemode=${gamemode}`)
fetch(gatewayUrl + `/stats?user=${username}&gamemode=${mode}`)
.then((response) => response.json())
.then((data) => {
setStats(data);
Expand All @@ -42,7 +42,7 @@ const Stats = () => {

useEffect(() => {
if (!fetched) {
fetchStats();
fetchStats(gamemode);
setFetched(true);
}
// eslint-disable-next-line
Expand All @@ -52,14 +52,16 @@ const Stats = () => {
setUsername(event.target.value);
};

const handleGamemodeChange = (mode) => {
const handleGamemodeChange = async (mode) => {
if (mode === gamemode) return;

setGamemode(mode);
// Llama a fetchStats() para actualizar las estadísticas cuando se cambia el modo de juego
fetchStats();
fetchStats(mode);
};


const handleSearch = () => {
fetchStats();
fetchStats(gamemode);
};

const getModeName = () => {
Expand Down

0 comments on commit ed3075f

Please sign in to comment.