Skip to content
Snippets Groups Projects
Commit 3351fbf5 authored by Albin Henriksson's avatar Albin Henriksson
Browse files

Fix dashboard

parent b517f38a
No related branches found
No related tags found
1 merge request!68Fix dashboard
Pipeline #41222 passed with warnings
...@@ -11,11 +11,11 @@ export const getCities = () => async (dispatch: AppDispatch) => { ...@@ -11,11 +11,11 @@ export const getCities = () => async (dispatch: AppDispatch) => {
payload: res.data.items, payload: res.data.items,
}) })
dispatch({ dispatch({
type: Types.SET_COMPETITIONS_TOTAL, type: Types.SET_CITIES_COUNT,
payload: res.data.total_count, payload: res.data.total_count,
}) })
dispatch({ dispatch({
type: Types.SET_COMPETITIONS_COUNT, type: Types.SET_CITIES_TOTAL,
payload: res.data.count, payload: res.data.count,
}) })
}) })
......
import { Box, Typography } from '@material-ui/core' import { Box, Typography } from '@material-ui/core'
import React, { useEffect } from 'react' import React, { useEffect } from 'react'
import { getSearchUsers } from '../../../../actions/searchUser' import { getCompetitions } from '../../../../actions/competitions'
import { useAppDispatch, useAppSelector } from '../../../../hooks' import { useAppDispatch, useAppSelector } from '../../../../hooks'
const NumberOfCompetitions: React.FC = () => { const NumberOfCompetitions: React.FC = () => {
const cities = useAppSelector((state) => state.cities.cities) const competitions = useAppSelector((state) => state.competitions.competitions)
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const handleCount = () => { const handleCount = () => {
if (cities.length >= 1000000) { if (competitions.length >= 1000000) {
;<div>{cities.length / 1000000 + 'M'}</div> ;<div>{competitions.length / 1000000 + 'M'}</div>
} else if (cities.length >= 1000) { } else if (competitions.length >= 1000) {
;<div>{cities.length / 1000 + 'K'}</div> ;<div>{competitions.length / 1000 + 'K'}</div>
} }
return <div>{cities.length}</div> return <div>{competitions.length}</div>
} }
useEffect(() => { useEffect(() => {
dispatch(getSearchUsers()) dispatch(getCompetitions())
}, []) }, [])
return ( return (
<div> <div>
......
import { Box, Typography } from '@material-ui/core' import { Box, Typography } from '@material-ui/core'
import React, { useEffect } from 'react' import React, { useEffect } from 'react'
import { getSearchUsers } from '../../../../actions/searchUser' import { getCities } from '../../../../actions/cities'
import { useAppDispatch, useAppSelector } from '../../../../hooks' import { useAppDispatch, useAppSelector } from '../../../../hooks'
const NumberOfRegions: React.FC = () => { const NumberOfRegions: React.FC = () => {
const competitionTotal = useAppSelector((state) => state.competitions.total) const regions = useAppSelector((state) => state.cities.total)
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const handleCount = () => { const handleCount = () => {
if (competitionTotal >= 1000000) { if (regions >= 1000000) {
;<div>{competitionTotal / 1000000 + 'M'}</div> ;<div>{regions / 1000000 + 'M'}</div>
} else if (competitionTotal >= 1000) { } else if (regions >= 1000) {
;<div>{competitionTotal / 1000 + 'K'}</div> ;<div>{regions / 1000 + 'K'}</div>
} }
return <div>{competitionTotal}</div> return <div>{regions}</div>
} }
useEffect(() => { useEffect(() => {
dispatch(getSearchUsers()) dispatch(getCities())
}, []) }, [])
return ( return (
<div> <div>
......
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