From 360ab724d985944d9e72b9bc39855cd2c06a1bad Mon Sep 17 00:00:00 2001 From: Albin Henriksson <albhe428@student.liu.se> Date: Wed, 14 Apr 2021 10:04:27 +0200 Subject: [PATCH] Fix tests --- .../src/pages/admin/dashboard/Dashboard.tsx | 18 +++++------- .../dashboard/components/CurrentUser.tsx | 29 +++++++++++++++++++ .../NumberOfCompetitions.tsx | 6 ++-- .../NumberOfRegions.tsx | 6 ++-- .../{widgets => components}/NumberOfUsers.tsx | 6 ++-- .../admin/dashboard/widgets/CurrentUser.tsx | 27 ----------------- 6 files changed, 46 insertions(+), 46 deletions(-) create mode 100644 client/src/pages/admin/dashboard/components/CurrentUser.tsx rename client/src/pages/admin/dashboard/{widgets => components}/NumberOfCompetitions.tsx (81%) rename client/src/pages/admin/dashboard/{widgets => components}/NumberOfRegions.tsx (81%) rename client/src/pages/admin/dashboard/{widgets => components}/NumberOfUsers.tsx (80%) delete mode 100644 client/src/pages/admin/dashboard/widgets/CurrentUser.tsx diff --git a/client/src/pages/admin/dashboard/Dashboard.tsx b/client/src/pages/admin/dashboard/Dashboard.tsx index e73b6533..a0f569b0 100644 --- a/client/src/pages/admin/dashboard/Dashboard.tsx +++ b/client/src/pages/admin/dashboard/Dashboard.tsx @@ -1,11 +1,10 @@ +import { createStyles, makeStyles, Paper, Theme, Typography } from '@material-ui/core' import Grid from '@material-ui/core/Grid' -import Paper from '@material-ui/core/Paper' -import { createStyles, makeStyles, Theme } from '@material-ui/core/styles' import React from 'react' -import CurrentUser from './widgets/CurrentUser' -import NumberOfCompetitions from './widgets/NumberOfCompetitions' -import NumberOfRegions from './widgets/NumberOfRegions' -import NumberOfUsers from './widgets/NumberOfUsers' +import CurrentUser from './components/CurrentUser' +import NumberOfCompetitions from './components/NumberOfCompetitions' +import NumberOfRegions from './components/NumberOfRegions' +import NumberOfUsers from './components/NumberOfUsers' const useStyles = makeStyles((theme: Theme) => createStyles({ @@ -22,7 +21,6 @@ const useStyles = makeStyles((theme: Theme) => const Dashboard: React.FC = () => { const classes = useStyles() - return ( <div className={classes.root}> <div> @@ -35,19 +33,19 @@ const Dashboard: React.FC = () => { <Grid item xs> <Paper className={classes.paper}> - <h1>Antal Användare:</h1> + <Typography variant="h4">Antal Användare:</Typography> <NumberOfUsers /> </Paper> </Grid> <Grid item xs> <Paper className={classes.paper}> - <h1>Antal Regioner:</h1> + <Typography variant="h4">Antal Regioner:</Typography> <NumberOfRegions /> </Paper> </Grid> <Grid item xs> <Paper className={classes.paper}> - <h1>Antal Tävlingar:</h1> + <Typography variant="h4">Antal Tävlingar:</Typography> <NumberOfCompetitions /> </Paper> </Grid> diff --git a/client/src/pages/admin/dashboard/components/CurrentUser.tsx b/client/src/pages/admin/dashboard/components/CurrentUser.tsx new file mode 100644 index 00000000..0dfdf557 --- /dev/null +++ b/client/src/pages/admin/dashboard/components/CurrentUser.tsx @@ -0,0 +1,29 @@ +import { Box, Typography } from '@material-ui/core' +import React from 'react' +import { useAppSelector } from '../../../../hooks' + +const CurrentUser: React.FC = () => { + const currentUser = useAppSelector((state: { user: { userInfo: any } }) => state.user.userInfo) + return ( + <div> + <Box display="flex" flexDirection="column" alignContent="flex-start"> + <div> + <Typography variant="h2"> + Välkommen{currentUser && currentUser.name ? `, ${currentUser.name}` : ''}! + </Typography> + </div> + <div> + <Typography variant="h6">Email: {currentUser && currentUser.email}</Typography> + </div> + <div> + <Typography variant="h6">Region: {currentUser && currentUser.city && currentUser.city.name}</Typography> + </div> + <div> + <Typography variant="h6">Roll: {currentUser && currentUser.role && currentUser.role.name}</Typography> + </div> + </Box> + </div> + ) +} + +export default CurrentUser diff --git a/client/src/pages/admin/dashboard/widgets/NumberOfCompetitions.tsx b/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx similarity index 81% rename from client/src/pages/admin/dashboard/widgets/NumberOfCompetitions.tsx rename to client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx index a6a73455..da5d015f 100644 --- a/client/src/pages/admin/dashboard/widgets/NumberOfCompetitions.tsx +++ b/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx @@ -1,4 +1,4 @@ -import { Box } from '@material-ui/core' +import { Box, Typography } from '@material-ui/core' import React, { useEffect } from 'react' import { getSearchUsers } from '../../../../actions/searchUser' import { useAppDispatch, useAppSelector } from '../../../../hooks' @@ -21,9 +21,9 @@ const NumberOfCompetitions: React.FC = () => { }, []) return ( <div> - <Box color="text.primary" bgcolor="" fontFamily="h3.fontFamily" width="100%" height="100%"> + <Box width="100%" height="100%"> <div> - <h1>{handleCount()}</h1> + <Typography variant="h4">{handleCount()}</Typography> </div> </Box> </div> diff --git a/client/src/pages/admin/dashboard/widgets/NumberOfRegions.tsx b/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx similarity index 81% rename from client/src/pages/admin/dashboard/widgets/NumberOfRegions.tsx rename to client/src/pages/admin/dashboard/components/NumberOfRegions.tsx index d2bf7251..a48b41a6 100644 --- a/client/src/pages/admin/dashboard/widgets/NumberOfRegions.tsx +++ b/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx @@ -1,4 +1,4 @@ -import { Box } from '@material-ui/core' +import { Box, Typography } from '@material-ui/core' import React, { useEffect } from 'react' import { getSearchUsers } from '../../../../actions/searchUser' import { useAppDispatch, useAppSelector } from '../../../../hooks' @@ -21,9 +21,9 @@ const NumberOfRegions: React.FC = () => { }, []) return ( <div> - <Box color="text.primary" bgcolor="" fontFamily="h3.fontFamily" width="100%" height="100%"> + <Box width="100%" height="100%"> <div> - <h1>{handleCount()}</h1> + <Typography variant="h4">{handleCount()}</Typography> </div> </Box> </div> diff --git a/client/src/pages/admin/dashboard/widgets/NumberOfUsers.tsx b/client/src/pages/admin/dashboard/components/NumberOfUsers.tsx similarity index 80% rename from client/src/pages/admin/dashboard/widgets/NumberOfUsers.tsx rename to client/src/pages/admin/dashboard/components/NumberOfUsers.tsx index 1de1b5b9..af0f9767 100644 --- a/client/src/pages/admin/dashboard/widgets/NumberOfUsers.tsx +++ b/client/src/pages/admin/dashboard/components/NumberOfUsers.tsx @@ -1,4 +1,4 @@ -import { Box } from '@material-ui/core' +import { Box, Typography } from '@material-ui/core' import React, { useEffect } from 'react' import { getSearchUsers } from '../../../../actions/searchUser' import { useAppDispatch, useAppSelector } from '../../../../hooks' @@ -21,9 +21,9 @@ const NumberOfUsers: React.FC = () => { }, []) return ( <div> - <Box color="text.primary" bgcolor="" fontFamily="h3.fontFamily" width="100%" height="100%"> + <Box width="100%" height="100%"> <div> - <h1>{handleCount()}</h1> + <Typography variant="h4">{handleCount()}</Typography> </div> </Box> </div> diff --git a/client/src/pages/admin/dashboard/widgets/CurrentUser.tsx b/client/src/pages/admin/dashboard/widgets/CurrentUser.tsx deleted file mode 100644 index 66384c97..00000000 --- a/client/src/pages/admin/dashboard/widgets/CurrentUser.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Box } from '@material-ui/core' -import React from 'react' -import { useAppSelector } from '../../../../hooks' - -const CurrentUser: React.FC = () => { - const currentUser = useAppSelector((state: { user: { userInfo: any } }) => state.user.userInfo) - return ( - <div> - <Box display="flex" flexDirection="column" alignContent="flex-start"> - <div> - <h1>Välkommen, {currentUser.name}!</h1> - </div> - <div> - <h2>Email: {currentUser.email}</h2> - </div> - <div> - <h2>Region: {currentUser.city.name}</h2> - </div> - <div> - <h2>Roll: {currentUser.role.name}</h2> - </div> - </Box> - </div> - ) -} - -export default CurrentUser -- GitLab