diff options
author | Eugene <eug-vs@keemail.me> | 2020-01-05 12:12:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-05 12:12:02 +0000 |
commit | e652fc1d4e171791c72de100ced0862a8b37d3d0 (patch) | |
tree | 4eb56d29f623e78f6b9d518825987de900d2f341 /src/components/Scoreboard/Scoreboard.js | |
parent | 048f277ef7831b8f1a02c5e6590fb8087862b7fc (diff) | |
parent | 5919ca26792796c99bfac316a9dfca0b9257fe76 (diff) | |
download | chrono-cube-ui-e652fc1d4e171791c72de100ced0862a8b37d3d0.tar.gz |
Merge pull request #23 from Eug-VS/solution-card
Isolate and improve SolutionCard
Diffstat (limited to 'src/components/Scoreboard/Scoreboard.js')
-rw-r--r-- | src/components/Scoreboard/Scoreboard.js | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js index 1235f9a..d55944d 100644 --- a/src/components/Scoreboard/Scoreboard.js +++ b/src/components/Scoreboard/Scoreboard.js @@ -1,12 +1,25 @@ import React, { useEffect, useState } from 'react'; -import { Container, Typography } from "@material-ui/core"; +import { + Container, + Typography, + Grid, +} from "@material-ui/core"; import { get } from "../../requests"; -import Solution from "./Solution"; +import SolutionCard from "../SolutionCard/SolutionCard"; +import { makeStyles } from "@material-ui/core/styles"; +const useStyles = makeStyles(theme => ({ + pageHeader: { + textAlign: 'center', + margin: theme.spacing(2), + } +})); + const Scoreboard = () => { + const classes = useStyles(); const [solutions, setSolutions] = useState([]); const updateSolutions = async () => { @@ -14,15 +27,26 @@ const Scoreboard = () => { await setSolutions(response.data); }; + const removeSolution = (id) => { + setSolutions(solutions.filter((solution => solution.id !== id))); + }; + useEffect(() => { updateSolutions(); }, []); - return ( - <Container maxWidth="sm"> - <Typography variant="h3" style={{textAlign: 'center'}}>Scoreboard</Typography> - {solutions.map(solution => (<Solution solution={solution}/>))} + <Container maxWidth="xs"> + <Typography variant="h3" className={classes.pageHeader}> + Scoreboard + </Typography> + <Grid container justify="center" direction="column" spacing={3}> + {solutions.map(solution => ( + <Grid item> + <SolutionCard data={solution} removeThisCard={removeSolution}/> + </Grid> + ))} + </Grid> </Container> ); }; |