Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding menu button to the results page and goBack buttons follow conventions #290

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions webapp/src/components/GoBack.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { useNavigate } from "react-router";
export default function GoBack() {
const {t} = useTranslation();
const navigate = useNavigate();
return <Flex direction="row" justifyContent="center" alignItems="center">
<Button data-testid={"GoBack"} type="submit" colorScheme="pigment_green" margin={"10px"} className={"custom-button effect1"} onClick={() => navigate("/dashboard")} w="100%">
return <Flex justify={"center"}>
<Button size={"lg"} fontSize={"2xl"} flex={1} data-testid={"GoBack"} type="submit" colorScheme="pigment_green" margin={"0.5rem"} className={"custom-button effect1"} onClick={() => navigate("/dashboard")}>
{t("common.goBack")}
</Button>
</Flex>
Expand Down
14 changes: 12 additions & 2 deletions webapp/src/pages/Results.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import React from "react";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { Button, Flex, Box, Heading, Center } from "@chakra-ui/react";
import { useNavigate, useLocation } from "react-router-dom";
import UserStatistics from "../components/statistics/UserStatistics";
import LateralMenu from '../components/menu/LateralMenu';
import MenuButton from '../components/menu/MenuButton';

export default function Results() {
const { t } = useTranslation();
const { t, i18n } = useTranslation();
const location = useLocation();
const navigate = useNavigate();
const correctAnswers = location.state?.correctAnswers || 0;
const [isMenuOpen, setIsMenuOpen] = useState(false);

const changeLanguage = async (selectedLanguage) => {
await i18n.changeLanguage(selectedLanguage);
};

return (
<Center display="flex" flexDirection="column" w="100wh" h="100vh" justifyContent="center" alignItems="center" bgImage={'/background.svg'}>
<MenuButton onClick={() => setIsMenuOpen(true)} />
<LateralMenu isOpen={isMenuOpen} onClose={() => setIsMenuOpen(false)} changeLanguage={changeLanguage} isDashboard={false}/>

<Heading as="h2">{t("common.results")}</Heading>
<Box bg="white" p={4} borderRadius="md" boxShadow="md" mt={4} mb={4} w="fit-content" shadow="2xl" rounded="1rem">
<Heading textAlign={"center"} as="h3" color="green.400" fontSize="xl">{`Correct answers: ${correctAnswers}`}</Heading>
Expand Down
8 changes: 3 additions & 5 deletions webapp/src/pages/Statistics.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Center, Heading, Stack, StackDivider, Table, Tbody, Text,
import { Box, Center, Heading, Stack, Table, Tbody, Text,
Td, Th, Thead, Tr, CircularProgress} from "@chakra-ui/react";
import React, {useEffect, useState} from "react";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -80,9 +80,7 @@ export default function Statistics() {
t={t} errorWhere={"error.statistics.top"}/>
<FaChartBar style={{ fontSize: '2.5rem', color: 'green' }} />
<Heading as="h1">{t("common.statistics.title")}</Heading>
<Stack spacing={4} divider={<StackDivider />} minH="50vh"
p="1rem" backgroundColor="whiteAlpha.900" shadow="1.25em"
boxShadow="md" rounded="1rem" alignItems={"center"} data-testid={"leaderboard-component"}>
<Stack spacing={4} p="1rem" backgroundColor="whiteAlpha.900" boxShadow="md" rounded="1rem" data-testid={"leaderboard-component"}>
{retrievedData ?
<Box display={"flex"} flexDirection={"column"} justifyContent={"center"} alignItems={"center"}>
<Heading as="h2" fontSize={"1.75em"}>
Expand Down Expand Up @@ -111,8 +109,8 @@ export default function Statistics() {
: <CircularProgress data-testid="leaderboard-spinner" isIndeterminate color={"green"} />
}
<UserStatistics />
<GoBack />
</Stack>
<GoBack />
</Stack>
</Center>
);
Expand Down