diff options
Diffstat (limited to 'src/components/Scoreboard')
-rw-r--r-- | src/components/Scoreboard/Scoreboard.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js index 47e306e..c7bc6d8 100644 --- a/src/components/Scoreboard/Scoreboard.js +++ b/src/components/Scoreboard/Scoreboard.js @@ -6,25 +6,30 @@ import { Grid, } from "@material-ui/core"; +import { makeStyles } from "@material-ui/core/styles"; + import { get } from "../../requests"; import SolutionCard from "../SolutionCard/SolutionCard"; -import { makeStyles } from "@material-ui/core/styles"; +import Loading from "../Loading/Loading"; const useStyles = makeStyles(theme => ({ pageHeader: { textAlign: 'center', margin: theme.spacing(2), - } + }, })); const Scoreboard = () => { const classes = useStyles(); const [solutions, setSolutions] = useState([]); - const updateSolutions = async () => { - const response = await get('solutions/'); - await setSolutions(response.data); + const updateSolutions = () => { + get('scoreboard/').then(response => { + setTimeout(() => { + setSolutions(response.data); + }, 300); + }); }; const removeSolution = (id) => { @@ -40,8 +45,9 @@ const Scoreboard = () => { <Typography variant="h3" className={classes.pageHeader}> Scoreboard </Typography> + {(solutions.length === 0) && <Loading />} <Grid container justify="center" direction="column" spacing={3}> - {solutions.map(solution => ( + {solutions.slice(0, 30).map(solution => ( <Grid item key={solution.id}> <SolutionCard data={solution} removeThisCard={removeSolution}/> </Grid> |