aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugene <eug-vs@keemail.me>2020-01-06 00:22:12 +0000
committerGitHub <noreply@github.com>2020-01-06 00:22:12 +0000
commit4d3d3ea44eb1ef440c4ba81562f3738ab5e09fd2 (patch)
treeaf02da5b596a9ac84fdd2871524e5474fe0a8aa4 /src
parent4e82e018e1fd88e24886362db864ae7d0d73cc7b (diff)
parent644bb29f796372860c57bf6c7fc8f3f5be51d1e8 (diff)
downloadchrono-cube-ui-4d3d3ea44eb1ef440c4ba81562f3738ab5e09fd2.tar.gz
Merge pull request #26 from Eug-VS/scoreboard-render
Refine Scoreboard
Diffstat (limited to 'src')
-rw-r--r--src/components/Loading/Loading.js32
-rw-r--r--src/components/Scoreboard/Scoreboard.js18
2 files changed, 44 insertions, 6 deletions
diff --git a/src/components/Loading/Loading.js b/src/components/Loading/Loading.js
new file mode 100644
index 0000000..632142b
--- /dev/null
+++ b/src/components/Loading/Loading.js
@@ -0,0 +1,32 @@
+import React from 'react';
+
+import {
+ Card,
+ CardHeader,
+} from "@material-ui/core";
+
+import { makeStyles } from "@material-ui/core/styles";
+import CircularProgress from '@material-ui/core/CircularProgress';
+
+
+const useStyles = makeStyles(theme => ({
+ root: {
+ padding: theme.spacing(1),
+ },
+}));
+
+const Loading = () => {
+ const classes = useStyles();
+
+ return (
+ <Card elevation={5} className={classes.root}>
+ <CardHeader
+ avatar={(<CircularProgress color="secondary" />)}
+ title="Loading"
+ subheader="Please, wait."
+ />
+ </Card>
+ )
+};
+
+export default Loading;
diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js
index 47e306e..c7bc6d8 100644
--- a/src/components/Scoreboard/Scoreboard.js
+++ b/src/components/Scoreboard/Scoreboard.js
@@ -6,25 +6,30 @@ import {
Grid,
} from "@material-ui/core";
+import { makeStyles } from "@material-ui/core/styles";
+
import { get } from "../../requests";
import SolutionCard from "../SolutionCard/SolutionCard";
-import { makeStyles } from "@material-ui/core/styles";
+import Loading from "../Loading/Loading";
const useStyles = makeStyles(theme => ({
pageHeader: {
textAlign: 'center',
margin: theme.spacing(2),
- }
+ },
}));
const Scoreboard = () => {
const classes = useStyles();
const [solutions, setSolutions] = useState([]);
- const updateSolutions = async () => {
- const response = await get('solutions/');
- await setSolutions(response.data);
+ const updateSolutions = () => {
+ get('scoreboard/').then(response => {
+ setTimeout(() => {
+ setSolutions(response.data);
+ }, 300);
+ });
};
const removeSolution = (id) => {
@@ -40,8 +45,9 @@ const Scoreboard = () => {
<Typography variant="h3" className={classes.pageHeader}>
Scoreboard
</Typography>
+ {(solutions.length === 0) && <Loading />}
<Grid container justify="center" direction="column" spacing={3}>
- {solutions.map(solution => (
+ {solutions.slice(0, 30).map(solution => (
<Grid item key={solution.id}>
<SolutionCard data={solution} removeThisCard={removeSolution}/>
</Grid>