From f4d8ee37400f25d4fec3638b1ba73e8661c30959 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 21 Mar 2020 14:29:05 +0300 Subject: feat: add types.d.ts, migrate Scoreboard --- src/pages/Scoreboard/Scoreboard.tsx | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/pages/Scoreboard/Scoreboard.tsx (limited to 'src/pages/Scoreboard/Scoreboard.tsx') diff --git a/src/pages/Scoreboard/Scoreboard.tsx b/src/pages/Scoreboard/Scoreboard.tsx new file mode 100644 index 0000000..c6826d2 --- /dev/null +++ b/src/pages/Scoreboard/Scoreboard.tsx @@ -0,0 +1,76 @@ +import React, { useEffect, useState } from 'react'; + +import { makeStyles } from '@material-ui/core/styles'; + +import { Window, SmartList } from 'react-benzin'; +import { Solution } from '../../types'; + +import SolutionCard from '../../components/SolutionCard/SolutionCard'; +import Loading from '../../components/Loading/Loading'; + +import { get } from '../../requests'; + + +const useStyles = makeStyles(theme => ({ + cell: { + display: 'flex', + justifyContent: 'center', + padding: theme.spacing(4), + + '& .MuiCard-root': { + width: '30%', + } + } +})); + + +interface RenderPropTypes { + index: number; + style: React.CSSProperties; +} + + +const Scoreboard: React.FC = () => { + const classes = useStyles(); + const [solutions, setSolutions] = useState([]); + + const updateSolutions = () => { + get('scoreboard/').then(response => { + setSolutions(response.data); + }); + }; + + const removeSolution = (id: number) => { + updateSolutions(); + }; + + useEffect(() => { + setTimeout(updateSolutions, 300); + }, []); + + const renderItem: React.FC = ({ index, style }) => { + return ( +
+ +
+ ) + }; + + return ( + + { solutions.length === 0 && +
+ +
+ } + +
+ ) +}; + + +export default Scoreboard; -- cgit v1.2.3 From f3a684937565f3bd94034f3389aa95fea908f0c4 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 21 Mar 2020 15:06:30 +0300 Subject: chore: fix linting errors :rotating_light: --- src/pages/Scoreboard/Scoreboard.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pages/Scoreboard/Scoreboard.tsx') diff --git a/src/pages/Scoreboard/Scoreboard.tsx b/src/pages/Scoreboard/Scoreboard.tsx index c6826d2..9b9ee01 100644 --- a/src/pages/Scoreboard/Scoreboard.tsx +++ b/src/pages/Scoreboard/Scoreboard.tsx @@ -34,13 +34,13 @@ const Scoreboard: React.FC = () => { const classes = useStyles(); const [solutions, setSolutions] = useState([]); - const updateSolutions = () => { + const updateSolutions = (): void => { get('scoreboard/').then(response => { setSolutions(response.data); }); }; - const removeSolution = (id: number) => { + const removeSolution = (id: number): void => { updateSolutions(); }; -- cgit v1.2.3 From 146947a665dbc1d2960d2062a22a106de0c71062 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 21 Mar 2020 15:44:40 +0300 Subject: chore: migrate profile page to Typescript :label: --- src/pages/Scoreboard/Scoreboard.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/pages/Scoreboard/Scoreboard.tsx') diff --git a/src/pages/Scoreboard/Scoreboard.tsx b/src/pages/Scoreboard/Scoreboard.tsx index 9b9ee01..e4185bd 100644 --- a/src/pages/Scoreboard/Scoreboard.tsx +++ b/src/pages/Scoreboard/Scoreboard.tsx @@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { Window, SmartList } from 'react-benzin'; -import { Solution } from '../../types'; +import { Solution, RenderPropTypes } from '../../types'; import SolutionCard from '../../components/SolutionCard/SolutionCard'; import Loading from '../../components/Loading/Loading'; @@ -24,12 +24,6 @@ const useStyles = makeStyles(theme => ({ })); -interface RenderPropTypes { - index: number; - style: React.CSSProperties; -} - - const Scoreboard: React.FC = () => { const classes = useStyles(); const [solutions, setSolutions] = useState([]); -- cgit v1.2.3