diff --git a/webapp/src/pages/Dashboard.jsx b/webapp/src/pages/Dashboard.jsx index 126860b1..8fb7be0b 100644 --- a/webapp/src/pages/Dashboard.jsx +++ b/webapp/src/pages/Dashboard.jsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from "react"; -import { Heading, Button, Box, Stack, Tabs, TabList, Tab, TabPanels, TabPanel, Flex, Text } from "@chakra-ui/react"; +import { Heading, Button, Box, Stack, Tabs, TabList, Tab, TabPanels, TabPanel, Flex, Text, Spinner } from "@chakra-ui/react"; import { Center } from "@chakra-ui/layout"; import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; @@ -19,10 +19,10 @@ import { userInfo } from '../components/user/UserInfo'; export default function Dashboard() { const navigate = useNavigate(); - const [gamemode, setGamemode] = useState("KIWI_QUEST"); + const [gameMode, setGameMode] = useState("KIWI_QUEST"); const { t, i18n } = useTranslation(); - + const [isDashboardLoading, setIsDashboardLoading] = useState(true); const [isMenuOpen, setIsMenuOpen] = useState(false); const [selectedButton, setSelectedButton] = useState("Kiwi Quest"); const [modes, setModes] = useState([]); @@ -62,6 +62,7 @@ export default function Dashboard() { async function checkActiveStatus() { const i = await isActive(); setActive(i.data.is_active); + setIsDashboardLoading(false); } checkActiveStatus(); }, []); @@ -91,6 +92,34 @@ export default function Dashboard() { } }; + const menuButtons = (modes) => { + return + {modes.length > 0 && modes.map(mode => ( + + ))} + setIsSettingsOpen(true)} name={t("game.custom")}/> + setIsSettingsOpen(false)}/> + + } const initializeGameMode = async () => { try { let lang = i18n.language; @@ -100,7 +129,7 @@ export default function Dashboard() { lang = "es" else lang = "en"; - const newGameResponse = await newGame(lang, gamemode, null); + const newGameResponse = await newGame(lang, gameMode, null); if (newGameResponse) navigate("/dashboard/game"); } catch (error) { @@ -118,90 +147,77 @@ export default function Dashboard() { {t("common.welcome") + " " + user.username} - - - - {t("game.gamemodes")} - {t("game.userinfo")} - - - - {!active && ( - - {modes.length > 0 && modes.map(mode => ( - - ))} - setIsSettingsOpen(true)} name={t("game.custom")}/> - setIsSettingsOpen(false)}/> - - )} - - - - {t("session.username")} - {user.username} - {t("session.email")} - {user.email} - - - - - - - {!active ? ( - - ) : ( - - )} - - + {(isDashboardLoading) ? ( + + + + ) : <> + + + + {t("game.gamemodes")} + {t("game.userinfo")} + + + + { (!active) ? <>{ menuButtons(modes) } : <> } + + + + {t("session.username")} + {user.username} + {t("session.email")} + {user.email} + + + + + + + {!active ? ( + + ) : ( + + )} + + + + } )} diff --git a/webapp/src/pages/Statistics.jsx b/webapp/src/pages/Statistics.jsx index 74bacf1d..afdddc8c 100644 --- a/webapp/src/pages/Statistics.jsx +++ b/webapp/src/pages/Statistics.jsx @@ -14,6 +14,7 @@ import { AccordionPanel, Flex, ListItem, ListIcon, UnorderedList } from "@chakra-ui/react"; +import Avatar, { genConfig } from 'react-nice-avatar'; import React, {useEffect, useState} from "react"; import { useTranslation } from "react-i18next"; import GoBack from "components/GoBack"; @@ -24,6 +25,7 @@ import { FaChartBar } from 'react-icons/fa'; import MenuButton from '../components/menu/MenuButton'; import LateralMenu from '../components/menu/LateralMenu'; import {MdCheckCircle, MdClear, MdPercent} from "react-icons/md"; +import {Cell, Pie, PieChart} from "recharts"; export default function Statistics() { const { t, i18n } = useTranslation(); @@ -57,14 +59,13 @@ export default function Statistics() { setErrorMessage(errorType); } } - const formatTopTen = () => { return topTen.map((element, counter) => { return - + - {counter + 1} + {counter + 1} {element.user.username} {element.points} {element.user.username !== 'Dario G. Mori'? '🥝': '🍌' } @@ -72,20 +73,41 @@ export default function Statistics() { - - - - {t("statistics.texts.personalRight", {right: element.right})} - - - - {t("statistics.texts.personalWrong", {wrong: element.wrong})} - - - - {t("statistics.texts.personalRate", {rate: element.percentage})} - - + + + + + + + + + + + + + {t("statistics.texts.personalRight", {right: element.right})} + + + + {t("statistics.texts.personalWrong", {wrong: element.wrong})} + + + + {t("statistics.texts.personalRate", {rate: element.percentage})} + + + +