aboutsummaryrefslogtreecommitdiff
path: root/src/pages/Scoreboard
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-03-21 14:29:05 +0300
committereug-vs <eug-vs@keemail.me>2020-03-21 14:29:05 +0300
commitf4d8ee37400f25d4fec3638b1ba73e8661c30959 (patch)
tree06d86f70329ec7a5bdca66d360c9081a3458da37 /src/pages/Scoreboard
parent550f00b93c03a9ad98ef9bb1197c0fbfd5b1e572 (diff)
downloadchrono-cube-ui-f4d8ee37400f25d4fec3638b1ba73e8661c30959.tar.gz
feat: add types.d.ts, migrate Scoreboard
Diffstat (limited to 'src/pages/Scoreboard')
-rw-r--r--src/pages/Scoreboard/Scoreboard.tsx (renamed from src/pages/Scoreboard/Scoreboard.js)16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/pages/Scoreboard/Scoreboard.js b/src/pages/Scoreboard/Scoreboard.tsx
index 47c0899..c6826d2 100644
--- a/src/pages/Scoreboard/Scoreboard.js
+++ b/src/pages/Scoreboard/Scoreboard.tsx
@@ -3,6 +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 SolutionCard from '../../components/SolutionCard/SolutionCard';
import Loading from '../../components/Loading/Loading';
@@ -22,9 +23,16 @@ const useStyles = makeStyles(theme => ({
}
}));
-const Scoreboard = () => {
+
+interface RenderPropTypes {
+ index: number;
+ style: React.CSSProperties;
+}
+
+
+const Scoreboard: React.FC = () => {
const classes = useStyles();
- const [solutions, setSolutions] = useState([]);
+ const [solutions, setSolutions] = useState<Solution[]>([]);
const updateSolutions = () => {
get('scoreboard/').then(response => {
@@ -32,7 +40,7 @@ const Scoreboard = () => {
});
};
- const removeSolution = id => {
+ const removeSolution = (id: number) => {
updateSolutions();
};
@@ -40,7 +48,7 @@ const Scoreboard = () => {
setTimeout(updateSolutions, 300);
}, []);
- const renderItem = ({ index, style }) => {
+ const renderItem: React.FC<RenderPropTypes> = ({ index, style }) => {
return (
<div style={style} className={classes.cell}>
<SolutionCard data={solutions[index]} removeThisCard={removeSolution}/>