From d34e1a7331b3b2b20e3908d1819e6c6f388f5e53 Mon Sep 17 00:00:00 2001
From: bmodee <bjomo323@student.liu.se>
Date: Thu, 6 May 2021 14:52:12 +0200
Subject: [PATCH] add comments

---
 .../src/pages/admin/competitions/CompetitionManager.tsx   | 8 +++++++-
 .../src/pages/admin/dashboard/components/CurrentUser.tsx  | 2 ++
 .../admin/dashboard/components/NumberOfCompetitions.tsx   | 2 ++
 .../pages/admin/dashboard/components/NumberOfRegions.tsx  | 2 ++
 .../pages/admin/dashboard/components/NumberOfUsers.tsx    | 2 ++
 client/src/pages/admin/regions/AddRegion.tsx              | 1 +
 client/src/pages/admin/regions/Regions.tsx                | 3 +++
 client/src/pages/admin/users/AddUser.tsx                  | 3 +++
 8 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/client/src/pages/admin/competitions/CompetitionManager.tsx b/client/src/pages/admin/competitions/CompetitionManager.tsx
index affd5c26..7de930dc 100644
--- a/client/src/pages/admin/competitions/CompetitionManager.tsx
+++ b/client/src/pages/admin/competitions/CompetitionManager.tsx
@@ -131,6 +131,7 @@ const CompetitionManager: React.FC = (props: any) => {
     }
   }
 
+  /** Start the competition by redirecting with URL with Code */
   const handleStartCompetition = () => {
     const operatorCode = codes.find((code) => code.view_type_id === 4)?.code
     if (operatorCode) {
@@ -138,6 +139,7 @@ const CompetitionManager: React.FC = (props: any) => {
     }
   }
 
+  /** Fetch all the connection codes from the server */
   const getCodes = async (id: number) => {
     await axios
       .get(`/api/competitions/${id}/codes`)
@@ -147,6 +149,7 @@ const CompetitionManager: React.FC = (props: any) => {
       .catch(console.log)
   }
 
+  /** Fetch all the teams from the server that is connected to a specific competition*/
   const getTeams = async (id: number) => {
     await axios
       .get(`/api/competitions/${id}/teams`)
@@ -159,6 +162,7 @@ const CompetitionManager: React.FC = (props: any) => {
       })
   }
 
+  /** Fetch the copetition name from the server */
   const getCompetitionName = async () => {
     await axios
       .get(`/api/competitions/${activeId}`)
@@ -198,16 +202,18 @@ const CompetitionManager: React.FC = (props: any) => {
     return typeName
   }
 
+  /** Handles the opening of the code dialog box */
   const handleOpenDialog = async () => {
     await getCompetitionName()
     setDialogIsOpen(true)
   }
-
+  /** Handles the closing of the code dialog box */
   const handleCloseDialog = () => {
     setDialogIsOpen(false)
     setAnchorEl(null)
   }
 
+  /** Function that copies an existing competition */
   const handleDuplicateCompetition = async () => {
     if (activeId) {
       await axios
diff --git a/client/src/pages/admin/dashboard/components/CurrentUser.tsx b/client/src/pages/admin/dashboard/components/CurrentUser.tsx
index 0dfdf557..1d6afe73 100644
--- a/client/src/pages/admin/dashboard/components/CurrentUser.tsx
+++ b/client/src/pages/admin/dashboard/components/CurrentUser.tsx
@@ -2,6 +2,8 @@ import { Box, Typography } from '@material-ui/core'
 import React from 'react'
 import { useAppSelector } from '../../../../hooks'
 
+/** This component show information about the currently logged in user */
+
 const CurrentUser: React.FC = () => {
   const currentUser = useAppSelector((state: { user: { userInfo: any } }) => state.user.userInfo)
   return (
diff --git a/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx b/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx
index eb667ebd..1ebe9dfb 100644
--- a/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx
+++ b/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx
@@ -2,6 +2,8 @@ import { Box, Typography } from '@material-ui/core'
 import React from 'react'
 import { useAppSelector } from '../../../../hooks'
 
+/** Shows how many competitions is on the system */
+
 const NumberOfCompetitions: React.FC = () => {
   const competitions = useAppSelector((state) => state.statistics.competitions)
 
diff --git a/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx b/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx
index f3195f4c..5f9ecef5 100644
--- a/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx
+++ b/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx
@@ -3,6 +3,8 @@ import React, { useEffect } from 'react'
 import { getCities } from '../../../../actions/cities'
 import { useAppDispatch, useAppSelector } from '../../../../hooks'
 
+/** Shows how many regions is on the system */
+
 const NumberOfRegions: React.FC = () => {
   const regions = useAppSelector((state) => state.statistics.regions)
   const dispatch = useAppDispatch()
diff --git a/client/src/pages/admin/dashboard/components/NumberOfUsers.tsx b/client/src/pages/admin/dashboard/components/NumberOfUsers.tsx
index 0e75cf1b..91291e68 100644
--- a/client/src/pages/admin/dashboard/components/NumberOfUsers.tsx
+++ b/client/src/pages/admin/dashboard/components/NumberOfUsers.tsx
@@ -3,6 +3,8 @@ import React, { useEffect } from 'react'
 import { getSearchUsers } from '../../../../actions/searchUser'
 import { useAppDispatch, useAppSelector } from '../../../../hooks'
 
+/** Shows how many users are on the system */
+
 const NumberOfUsers: React.FC = () => {
   const usersTotal = useAppSelector((state) => state.statistics.users)
   const dispatch = useAppDispatch()
diff --git a/client/src/pages/admin/regions/AddRegion.tsx b/client/src/pages/admin/regions/AddRegion.tsx
index b0096138..8bd5e562 100644
--- a/client/src/pages/admin/regions/AddRegion.tsx
+++ b/client/src/pages/admin/regions/AddRegion.tsx
@@ -30,6 +30,7 @@ const useStyles = makeStyles((theme: Theme) =>
 
 type formType = FormModel<AddCityModel>
 
+/** add a region form with some constraints. */
 const schema: Yup.SchemaOf<formType> = Yup.object({
   model: Yup.object()
     .shape({
diff --git a/client/src/pages/admin/regions/Regions.tsx b/client/src/pages/admin/regions/Regions.tsx
index 436da6f6..28a25cad 100644
--- a/client/src/pages/admin/regions/Regions.tsx
+++ b/client/src/pages/admin/regions/Regions.tsx
@@ -14,6 +14,9 @@ import { getCities } from '../../../actions/cities'
 import { useAppDispatch, useAppSelector } from '../../../hooks'
 import { RemoveMenuItem, TopBar } from '../styledComp'
 import AddRegion from './AddRegion'
+
+/** shows all the regions in a list */
+
 const useStyles = makeStyles((theme: Theme) =>
   createStyles({
     table: {
diff --git a/client/src/pages/admin/users/AddUser.tsx b/client/src/pages/admin/users/AddUser.tsx
index 9f1511ea..d24bf130 100644
--- a/client/src/pages/admin/users/AddUser.tsx
+++ b/client/src/pages/admin/users/AddUser.tsx
@@ -1,3 +1,5 @@
+/** Add a user component */
+
 import { Button, FormControl, InputLabel, MenuItem, Popover, TextField } from '@material-ui/core'
 import PersonAddIcon from '@material-ui/icons/PersonAdd'
 import { Alert, AlertTitle } from '@material-ui/lab'
@@ -16,6 +18,7 @@ type formType = FormModel<AddUserModel>
 const noRoleSelected = 'Välj roll'
 const noCitySelected = 'Välj stad'
 
+/** Form when adding a user with some constraints */
 const userSchema: Yup.SchemaOf<formType> = Yup.object({
   model: Yup.object()
     .shape({
-- 
GitLab