From b3e2b3f59424da7a61e1b09595d1f1e447c3a31a Mon Sep 17 00:00:00 2001 From: Eug-VS Date: Mon, 6 Jan 2020 21:10:48 +0300 Subject: Create initial TimerPage component Show last 5 results --- src/components/TimerPage/TimerPage.js | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/components/TimerPage/TimerPage.js (limited to 'src/components/TimerPage/TimerPage.js') diff --git a/src/components/TimerPage/TimerPage.js b/src/components/TimerPage/TimerPage.js new file mode 100644 index 0000000..968faab --- /dev/null +++ b/src/components/TimerPage/TimerPage.js @@ -0,0 +1,54 @@ +import React from 'react'; + +import { Grid, Box } from "@material-ui/core"; +import { makeStyles } from "@material-ui/core/styles"; + +import Timer from "../Timer/Timer"; +import SolutionCard from "../SolutionCard/SolutionCard"; + +import { post } from '../../requests'; + + +const useStyles = makeStyles(theme => ({ + root: { + display: 'flex', + justifyContent: 'space-between', + padding: theme.spacing(5, 4, 4, 4), + }, +})); + +const TimerPage = ({ recentSolutions, setRecentSolutions }) => { + const classes = useStyles(); + + const user = { + id: null, + username: 'anonymous', + }; + + const registerResult = result => { + const solution = { author_id: user.id, result }; + post('solutions/', solution).then(response => { + setRecentSolutions([response.data].concat(recentSolutions)); + }); + }; + + return ( + + + + + + + {recentSolutions.slice(0, 5).map(solution => ( + + + + ))} + + + + ); +}; + + +export default TimerPage; -- cgit v1.2.3