aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorEugene <eug-vs@keemail.me>2020-01-12 15:08:34 +0000
committerGitHub <noreply@github.com>2020-01-12 15:08:34 +0000
commit23a5631531861ac76d532c0d9d2b19dd1862f739 (patch)
tree9c4c7e2c2255d8a7253f5bacebc149cde1dbc696 /src/components
parente78ecf560a0c6f4cf59a3c4341884996464c7923 (diff)
parentb5af9d633386e1e9139888cbe272ff4d34e6219b (diff)
downloadchrono-cube-ui-23a5631531861ac76d532c0d9d2b19dd1862f739.tar.gz
Merge pull request #31 from Eug-VS/scoreboard-requests
Improve requests logic on Scoreboard page
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Scoreboard/Scoreboard.js8
-rw-r--r--src/components/SolutionCard/SolutionCard.js5
2 files changed, 6 insertions, 7 deletions
diff --git a/src/components/Scoreboard/Scoreboard.js b/src/components/Scoreboard/Scoreboard.js
index 2d9bb80..5c83735 100644
--- a/src/components/Scoreboard/Scoreboard.js
+++ b/src/components/Scoreboard/Scoreboard.js
@@ -28,18 +28,16 @@ const Scoreboard = () => {
const updateSolutions = () => {
get('scoreboard/').then(response => {
- setTimeout(() => {
setSolutions(response.data);
- }, 300);
});
};
- const removeSolution = (id) => {
- setSolutions(solutions.filter((solution => solution.id !== id)));
+ const removeSolution = id => {
+ updateSolutions();
};
useEffect(() => {
- updateSolutions();
+ setTimeout(updateSolutions, 300);
}, []);
const renderItem = ({ index, style }) => {
diff --git a/src/components/SolutionCard/SolutionCard.js b/src/components/SolutionCard/SolutionCard.js
index 7cca74c..1fff873 100644
--- a/src/components/SolutionCard/SolutionCard.js
+++ b/src/components/SolutionCard/SolutionCard.js
@@ -54,9 +54,10 @@ const SolutionCard = ({ data, removeThisCard }) => {
};
const handleDelete = () => {
- del(`solutions/${data.id}/`);
+ del(`solutions/${data.id}/`).then(() => {
+ removeThisCard(data.id);
+ });
handleClose();
- removeThisCard(data.id);
};
return (