From 8b773d506739b9d7b59bac9a0a339d7b79c6c2e6 Mon Sep 17 00:00:00 2001 From: Felix Hamme Date: Thu, 20 Jun 2019 15:40:47 +0200 Subject: [PATCH] Use loading page for tournament statistics page --- js/api.js | 6 ++++-- js/redux/tournamentStatistics.js | 1 + pages/tournament-statistics.js | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/api.js b/js/api.js index 6112c0d..0cee469 100644 --- a/js/api.js +++ b/js/api.js @@ -344,6 +344,7 @@ const reducerTournamentStatistics = (state = defaultStateTournamentStatistics, a storeOptionalToken(error.response); } action.parameters.errorCallback(); + return Object.assign({}, state, {loaded: true}); }); return state; case actionTypesTournamentStatistics.INT_REQUEST_TOURNAMENT_STATISTICS: @@ -361,11 +362,12 @@ const reducerTournamentStatistics = (state = defaultStateTournamentStatistics, a storeOptionalToken(error.response); } action.parameters.errorCallback(); + return Object.assign({}, state, {loaded: true}); }); - return Object.assign({}, state, action.parameters.tournamentInfo); + return Object.assign({}, state, action.parameters.tournamentInfo, {loaded: true}); case actionTypesTournamentStatistics.REQUEST_TOURNAMENT_STATISTICS_SUCCESS: action.parameters.successCallback(); - return Object.assign({}, state, action.parameters.tournamentStatistics); + return Object.assign({}, state, action.parameters.tournamentStatistics, {loaded: true}); default: return state; } }; diff --git a/js/redux/tournamentStatistics.js b/js/redux/tournamentStatistics.js index 4004982..0f4884c 100644 --- a/js/redux/tournamentStatistics.js +++ b/js/redux/tournamentStatistics.js @@ -16,6 +16,7 @@ export const defaultStateTournamentStatistics = { owner_username: '', isPublic: '', + loaded: false, statistics_available: false, most_dominant_team: {}, diff --git a/pages/tournament-statistics.js b/pages/tournament-statistics.js index 0beb23b..afbfbc2 100644 --- a/pages/tournament-statistics.js +++ b/pages/tournament-statistics.js @@ -11,6 +11,7 @@ import {requestTournamentStatistics} from '../js/api'; import {EditButton, TournamentStatusBar, TournamentStatusBarButton} from '../js/components/TournamentStatusBar'; import Navbar from 'react-bootstrap/Navbar'; import {TournamentBigImage} from '../js/components/TournamentBigImage'; +import {LoadingPage} from '../js/components/LoadingPage'; class StatisticsTournamentPage extends React.Component { static async getInitialProps({query}) { @@ -24,6 +25,10 @@ class StatisticsTournamentPage extends React.Component { render() { const {tournamentStatistics} = this.props; + if (!tournamentStatistics.loaded) { + return ; + } + return (