From a7adeadb08c34981e6900bb46c8878f4776d7750 Mon Sep 17 00:00:00 2001 From: Dan Strano Date: Tue, 30 May 2023 14:37:34 -0400 Subject: [PATCH] #839: Don't show 0 counts for top submitters --- src/views/Home.js | 198 +++++++++++++++++++++++++--------------------- 1 file changed, 107 insertions(+), 91 deletions(-) diff --git a/src/views/Home.js b/src/views/Home.js index e9a1c813..d918794f 100644 --- a/src/views/Home.js +++ b/src/views/Home.js @@ -23,17 +23,30 @@ const Home = (props) => { axios.get(config.api.getUriPrefix() + '/user/topSubmitters') .then(res => { const tSubmitters = res.data.data - tSubmitters.allTime[0].rank = '🥇' - tSubmitters.allTime[1].rank = '🥈' - tSubmitters.allTime[2].rank = '🥉' - tSubmitters.monthly[0].rank = '🥇' - tSubmitters.monthly[1].rank = '🥈' - tSubmitters.monthly[2].rank = '🥉' tSubmitters.weekly[0].rank = '🥇' tSubmitters.weekly[1].rank = '🥈' tSubmitters.weekly[2].rank = '🥉' + tSubmitters.monthly[0].rank = '🥇' + tSubmitters.monthly[1].rank = '🥈' + tSubmitters.monthly[2].rank = '🥉' + tSubmitters.allTime[0].rank = '🥇' + tSubmitters.allTime[1].rank = '🥈' + tSubmitters.allTime[2].rank = '🥉' + + const ts = { weekly: [], monthly: [], allTime: [] } + for (let i = 0; i < 3; ++i) { + if (tSubmitters.weekly[i].submissionsCount > 0) { + ts.weekly.push(tSubmitters.weekly[i]) + } + if (tSubmitters.monthly[i].submissionsCount > 0) { + ts.monthly.push(tSubmitters.monthly[i]) + } + if (tSubmitters.allTime[i].submissionsCount > 0) { + ts.allTime.push(tSubmitters.allTime[i]) + } + } - setTopSubmitters(tSubmitters) + setTopSubmitters(ts) }) if (!props.tabKey) { @@ -85,90 +98,93 @@ const Home = (props) => {
Top Submitters
Loading...}> - -
- this.props.history.push('/User/' + record.id + '/Submissions')} - tableLayout='auto' - rowClassName='link' - /> -
-
- -
- this.props.history.push('/User/' + record.id + '/Submissions')} - tableLayout='auto' - rowClassName='link' - /> -
-
- -
- this.props.history.push('/User/' + record.id + '/Submissions')} - tableLayout='auto' - rowClassName='link' - /> -
-
+ {(topSubmitters.weekly.length > 0) && + +
+ this.props.history.push('/User/' + record.id + '/Submissions')} + tableLayout='auto' + rowClassName='link' + /> +
+
} + {(topSubmitters.monthly.length > 0) && + +
+ this.props.history.push('/User/' + record.id + '/Submissions')} + tableLayout='auto' + rowClassName='link' + /> +
+
} + {(topSubmitters.allTime.length > 0) && + +
+ this.props.history.push('/User/' + record.id + '/Submissions')} + tableLayout='auto' + rowClassName='link' + /> +
+
}