From 3351fbf563257a530827236cc3188e3c9606b7ec Mon Sep 17 00:00:00 2001
From: Albin Henriksson <albhe428@student.liu.se>
Date: Mon, 19 Apr 2021 13:39:32 +0000
Subject: [PATCH] Fix dashboard

---
 client/src/actions/cities.ts                     |  4 ++--
 .../components/NumberOfCompetitions.tsx          | 16 ++++++++--------
 .../dashboard/components/NumberOfRegions.tsx     | 16 ++++++++--------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/client/src/actions/cities.ts b/client/src/actions/cities.ts
index a54475c7..9226aee5 100644
--- a/client/src/actions/cities.ts
+++ b/client/src/actions/cities.ts
@@ -11,11 +11,11 @@ export const getCities = () => async (dispatch: AppDispatch) => {
         payload: res.data.items,
       })
       dispatch({
-        type: Types.SET_COMPETITIONS_TOTAL,
+        type: Types.SET_CITIES_COUNT,
         payload: res.data.total_count,
       })
       dispatch({
-        type: Types.SET_COMPETITIONS_COUNT,
+        type: Types.SET_CITIES_TOTAL,
         payload: res.data.count,
       })
     })
diff --git a/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx b/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx
index da5d015f..87d8272a 100644
--- a/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx
+++ b/client/src/pages/admin/dashboard/components/NumberOfCompetitions.tsx
@@ -1,23 +1,23 @@
 import { Box, Typography } from '@material-ui/core'
 import React, { useEffect } from 'react'
-import { getSearchUsers } from '../../../../actions/searchUser'
+import { getCompetitions } from '../../../../actions/competitions'
 import { useAppDispatch, useAppSelector } from '../../../../hooks'
 
 const NumberOfCompetitions: React.FC = () => {
-  const cities = useAppSelector((state) => state.cities.cities)
+  const competitions = useAppSelector((state) => state.competitions.competitions)
   const dispatch = useAppDispatch()
 
   const handleCount = () => {
-    if (cities.length >= 1000000) {
-      ;<div>{cities.length / 1000000 + 'M'}</div>
-    } else if (cities.length >= 1000) {
-      ;<div>{cities.length / 1000 + 'K'}</div>
+    if (competitions.length >= 1000000) {
+      ;<div>{competitions.length / 1000000 + 'M'}</div>
+    } else if (competitions.length >= 1000) {
+      ;<div>{competitions.length / 1000 + 'K'}</div>
     }
-    return <div>{cities.length}</div>
+    return <div>{competitions.length}</div>
   }
 
   useEffect(() => {
-    dispatch(getSearchUsers())
+    dispatch(getCompetitions())
   }, [])
   return (
     <div>
diff --git a/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx b/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx
index a48b41a6..360b3663 100644
--- a/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx
+++ b/client/src/pages/admin/dashboard/components/NumberOfRegions.tsx
@@ -1,23 +1,23 @@
 import { Box, Typography } from '@material-ui/core'
 import React, { useEffect } from 'react'
-import { getSearchUsers } from '../../../../actions/searchUser'
+import { getCities } from '../../../../actions/cities'
 import { useAppDispatch, useAppSelector } from '../../../../hooks'
 
 const NumberOfRegions: React.FC = () => {
-  const competitionTotal = useAppSelector((state) => state.competitions.total)
+  const regions = useAppSelector((state) => state.cities.total)
   const dispatch = useAppDispatch()
 
   const handleCount = () => {
-    if (competitionTotal >= 1000000) {
-      ;<div>{competitionTotal / 1000000 + 'M'}</div>
-    } else if (competitionTotal >= 1000) {
-      ;<div>{competitionTotal / 1000 + 'K'}</div>
+    if (regions >= 1000000) {
+      ;<div>{regions / 1000000 + 'M'}</div>
+    } else if (regions >= 1000) {
+      ;<div>{regions / 1000 + 'K'}</div>
     }
-    return <div>{competitionTotal}</div>
+    return <div>{regions}</div>
   }
 
   useEffect(() => {
-    dispatch(getSearchUsers())
+    dispatch(getCities())
   }, [])
   return (
     <div>
-- 
GitLab