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) => {
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,
})
})
......
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>
......
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>
......
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