Skip to content
Snippets Groups Projects
Commit 99ce739f authored by Björn Modée's avatar Björn Modée
Browse files

add comments

parent d34e1a73
No related branches found
No related tags found
No related merge requests found
Pipeline #44349 passed with warnings
...@@ -6,6 +6,11 @@ import NumberOfCompetitions from './components/NumberOfCompetitions' ...@@ -6,6 +6,11 @@ import NumberOfCompetitions from './components/NumberOfCompetitions'
import NumberOfRegions from './components/NumberOfRegions' import NumberOfRegions from './components/NumberOfRegions'
import NumberOfUsers from './components/NumberOfUsers' 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) => const useStyles = makeStyles((theme: Theme) =>
createStyles({ createStyles({
root: { root: {
......
/** 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 { AppBar, Tab, Tabs } from '@material-ui/core'
import React from 'react' import React from 'react'
import AdminLogin from './components/AdminLogin' import AdminLogin from './components/AdminLogin'
......
/** Component that handles the log in when a user is an admin */
import { Button, TextField, Typography } from '@material-ui/core' import { Button, TextField, Typography } from '@material-ui/core'
import { Alert, AlertTitle } from '@material-ui/lab' import { Alert, AlertTitle } from '@material-ui/lab'
import { Formik, FormikHelpers } from 'formik' import { Formik, FormikHelpers } from 'formik'
......
/** 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 { Button, TextField, Typography } from '@material-ui/core'
import { Alert, AlertTitle } from '@material-ui/lab' import { Alert, AlertTitle } from '@material-ui/lab'
import { Formik } from 'formik' import { Formik } from 'formik'
...@@ -38,7 +40,7 @@ const CompetitionLogin: React.FC = () => { ...@@ -38,7 +40,7 @@ const CompetitionLogin: React.FC = () => {
const handleCompetitionSubmit = async (values: CompetitionLoginFormModel) => { const handleCompetitionSubmit = async (values: CompetitionLoginFormModel) => {
dispatch(loginCompetition(values.model.code, history, true)) dispatch(loginCompetition(values.model.code, history, true))
} }
return ( return (
<Formik <Formik
initialValues={competitionInitialValues} initialValues={competitionInitialValues}
......
...@@ -113,14 +113,13 @@ const OperatorViewPage: React.FC = () => { ...@@ -113,14 +113,13 @@ const OperatorViewPage: React.FC = () => {
useEffect(() => { useEffect(() => {
socketConnect() socketConnect()
socketSetSlide // Behövs denna? socketSetSlide
handleOpenCodes() handleOpenCodes()
setTimeout(startCompetition, 1000) // Ghetto, wait for everything to load setTimeout(startCompetition, 1000) // Wait for socket to connect
// console.log(id)
}, []) }, [])
/** Handles the browsers back button and if pressed cancels the ongoing competition */
window.onpopstate = () => { window.onpopstate = () => {
//Handle browser back arrow
alert('Tävlingen avslutas för alla') alert('Tävlingen avslutas för alla')
endCompetition() endCompetition()
} }
...@@ -136,11 +135,12 @@ const OperatorViewPage: React.FC = () => { ...@@ -136,11 +135,12 @@ const OperatorViewPage: React.FC = () => {
} }
const startCompetition = () => { const startCompetition = () => {
socketStartPresentation() socketStartPresentation() // Calls the socket to start competition
console.log('started competition for') console.log('started competition for')
console.log(competitionId) console.log(competitionId)
} }
/** Making sure the user wants to exit the competition by displaying a dialog box */
const handleVerifyExit = () => { const handleVerifyExit = () => {
setOpen(true) setOpen(true)
} }
...@@ -155,7 +155,7 @@ const OperatorViewPage: React.FC = () => { ...@@ -155,7 +155,7 @@ const OperatorViewPage: React.FC = () => {
setOpen(false) setOpen(false)
socketEndPresentation() socketEndPresentation()
history.push('/admin/tävlingshanterare') 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 () => { const getCodes = async () => {
...@@ -205,9 +205,8 @@ const OperatorViewPage: React.FC = () => { ...@@ -205,9 +205,8 @@ const OperatorViewPage: React.FC = () => {
return typeName return typeName
} }
/** Sums the scores for the teams. */
const addScore = (team: RichTeam) => { const addScore = (team: RichTeam) => {
// Sums the scores for the teams.
let totalScore = 0 let totalScore = 0
for (let j = 0; j < team.question_answers.length; j++) { for (let j = 0; j < team.question_answers.length; j++) {
totalScore = totalScore + team.question_answers[j].score totalScore = totalScore + team.question_answers[j].score
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment