diff options
Diffstat (limited to 'src/components/Scoreboard')
| -rw-r--r-- | src/components/Scoreboard/Scoreboard.js | 28 | ||||
| -rw-r--r-- | src/components/Scoreboard/Solution.js | 32 | 
2 files changed, 60 insertions, 0 deletions
| diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js new file mode 100644 index 0000000..1ebca90 --- /dev/null +++ b/src/components/Scoreboard/Scoreboard.js @@ -0,0 +1,28 @@ +import React, {useEffect, useState} from 'react'; + + +import { get } from "../../requests"; +import Solution from "./Solution"; + + +const Scoreboard = () => { +  const [solutions, setSolutions] = useState([]); + +  const updateSolutions = async () => { +    const response = await get('solutions/'); +    await setSolutions(response.data); +  }; + +  useEffect(() => { +    updateSolutions(); +  }, []); + + +  return ( +    <div> +      { solutions.map(solution => <Solution solution={solution}/>) } +    </div> +  ); +}; + +export default Scoreboard;
\ No newline at end of file diff --git a/src/components/Scoreboard/Solution.js b/src/components/Scoreboard/Solution.js new file mode 100644 index 0000000..3f46eb5 --- /dev/null +++ b/src/components/Scoreboard/Solution.js @@ -0,0 +1,32 @@ +import React from 'react'; + +import { +  Card, +  CardContent, +  Typography, +  Paper, +} from "@material-ui/core"; + +import styled from "styled-components"; + +const Solution = ({ solution }) => { + +  const author = solution.author? solution.author : 'anonymous'; +  return ( +    <PaperWrapper elevation={2} style={{backgroundColor: "#ddbea3"}}> +      <Typography variant="h4" style={{fontWeight: "bold"}}> +        { solution.result } +      </Typography> +      <Typography> +        by {author} +      </Typography> +    </PaperWrapper> +  ) +}; + +const PaperWrapper = styled(Card)` +  padding: 10px; +  margin: 25px; +`; + +export default Solution;
\ No newline at end of file | 
