Skip to content

Commit

Permalink
Arreglado el cambio de modo en Stats
Browse files Browse the repository at this point in the history
  • Loading branch information
iyanfdezz committed Apr 2, 2024
1 parent 7664713 commit af28852
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 af28852

Please sign in to comment.