diff --git a/client/src/pages/admin/dashboard/Dashboard.tsx b/client/src/pages/admin/dashboard/Dashboard.tsx index a0f569b066a8073a14f9342dcb7d988be63b93b9..51aa4f4084ebf016fefbb740dcb081ac20f0e7fe 100644 --- a/client/src/pages/admin/dashboard/Dashboard.tsx +++ b/client/src/pages/admin/dashboard/Dashboard.tsx @@ -6,6 +6,11 @@ import NumberOfCompetitions from './components/NumberOfCompetitions' import NumberOfRegions from './components/NumberOfRegions' import NumberOfUsers from './components/NumberOfUsers' +/** + * This is the first page that is shown after a user logs in. It shows som statistics about the site. + * + */ + const useStyles = makeStyles((theme: Theme) => createStyles({ root: { diff --git a/client/src/pages/login/LoginPage.tsx b/client/src/pages/login/LoginPage.tsx index 8f8e967c435af9c2611bc9ac3c1365b114a7666a..34c9c5ae6c5344666dc383d7f2df7586ecc13e10 100644 --- a/client/src/pages/login/LoginPage.tsx +++ b/client/src/pages/login/LoginPage.tsx @@ -1,3 +1,7 @@ +/** This is the login page, it contains two child components, one is + * to log in as an admin, the other is to connect to a competition using a code + */ + import { AppBar, Tab, Tabs } from '@material-ui/core' import React from 'react' import AdminLogin from './components/AdminLogin' diff --git a/client/src/pages/login/components/AdminLogin.tsx b/client/src/pages/login/components/AdminLogin.tsx index 964fb8abd148a9a0735206e9dbe3288cbe72ea3a..4fe475245cb0539bd61c0987d8aa39fa4cc6e40d 100644 --- a/client/src/pages/login/components/AdminLogin.tsx +++ b/client/src/pages/login/components/AdminLogin.tsx @@ -1,3 +1,5 @@ +/** Component that handles the log in when a user is an admin */ + import { Button, TextField, Typography } from '@material-ui/core' import { Alert, AlertTitle } from '@material-ui/lab' import { Formik, FormikHelpers } from 'formik' diff --git a/client/src/pages/login/components/CompetitionLogin.tsx b/client/src/pages/login/components/CompetitionLogin.tsx index 8dbbee33b6962c5bcd21f346ee594b224719a9a7..444634740fa361ad6deb1493c6673427f5fb8717 100644 --- a/client/src/pages/login/components/CompetitionLogin.tsx +++ b/client/src/pages/login/components/CompetitionLogin.tsx @@ -1,3 +1,5 @@ +/** Component that handles the log in when a user connects to a competition through a code */ + import { Button, TextField, Typography } from '@material-ui/core' import { Alert, AlertTitle } from '@material-ui/lab' import { Formik } from 'formik' @@ -38,7 +40,7 @@ const CompetitionLogin: React.FC = () => { const handleCompetitionSubmit = async (values: CompetitionLoginFormModel) => { dispatch(loginCompetition(values.model.code, history, true)) } - + return ( <Formik initialValues={competitionInitialValues} diff --git a/client/src/pages/views/OperatorViewPage.tsx b/client/src/pages/views/OperatorViewPage.tsx index 22d91ac3122a971786c840c6090bc58b44b6f5d0..a2979945d16a2f80dd5ca30da9569a31aef87c3c 100644 --- a/client/src/pages/views/OperatorViewPage.tsx +++ b/client/src/pages/views/OperatorViewPage.tsx @@ -113,14 +113,13 @@ const OperatorViewPage: React.FC = () => { useEffect(() => { socketConnect() - socketSetSlide // Behövs denna? + socketSetSlide handleOpenCodes() - setTimeout(startCompetition, 1000) // Ghetto, wait for everything to load - // console.log(id) + setTimeout(startCompetition, 1000) // Wait for socket to connect }, []) + /** Handles the browsers back button and if pressed cancels the ongoing competition */ window.onpopstate = () => { - //Handle browser back arrow alert('Tävlingen avslutas för alla') endCompetition() } @@ -136,11 +135,12 @@ const OperatorViewPage: React.FC = () => { } const startCompetition = () => { - socketStartPresentation() + socketStartPresentation() // Calls the socket to start competition console.log('started competition for') console.log(competitionId) } + /** Making sure the user wants to exit the competition by displaying a dialog box */ const handleVerifyExit = () => { setOpen(true) } @@ -155,7 +155,7 @@ const OperatorViewPage: React.FC = () => { setOpen(false) socketEndPresentation() history.push('/admin/tävlingshanterare') - window.location.reload(false) // TODO: fix this ugly hack, we "need" to refresh site to be able to run the competition correctly again + window.location.reload(false) // TODO: fix this, we "need" to refresh site to be able to run the competition correctly again } const getCodes = async () => { @@ -205,9 +205,8 @@ const OperatorViewPage: React.FC = () => { return typeName } + /** Sums the scores for the teams. */ const addScore = (team: RichTeam) => { - // Sums the scores for the teams. - let totalScore = 0 for (let j = 0; j < team.question_answers.length; j++) { totalScore = totalScore + team.question_answers[j].score