Skip to content
Snippets Groups Projects
Commit 976f420f authored by Chris Lawton's avatar Chris Lawton
Browse files

add error state to detail view

parent 38237e85
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ class DetailView extends Component { ...@@ -19,6 +19,7 @@ class DetailView extends Component {
windowSize: PropTypes.objectOf(PropTypes.number), windowSize: PropTypes.objectOf(PropTypes.number),
clearSubmission: PropTypes.func.isRequired, clearSubmission: PropTypes.func.isRequired,
isLoading: PropTypes.bool, isLoading: PropTypes.bool,
error: PropTypes.string,
}; };
isMobile = (width) => (width ? width : this.props.windowSize.windowWidth) < 1024 isMobile = (width) => (width ? width : this.props.windowSize.windowWidth) < 1024
...@@ -28,8 +29,9 @@ class DetailView extends Component { ...@@ -28,8 +29,9 @@ class DetailView extends Component {
} }
render() { render() {
const { listing, submissionID, isLoading } = this.props; const { listing, submissionID, isLoading, error } = this.props;
const activeSubmision = !!submissionID; const activeSubmision = !!submissionID;
const isError = Boolean(error);
if (this.isMobile()) { if (this.isMobile()) {
var activeDisplay; var activeDisplay;
...@@ -57,6 +59,13 @@ class DetailView extends Component { ...@@ -57,6 +59,13 @@ class DetailView extends Component {
return ( return (
<LoadingPanel /> <LoadingPanel />
) )
} else if (isError) {
return (
<div className="loading-panel">
<h5>Something went wrong!</h5>
<p>{error}</p>
</div>
)
} }
return ( return (
<div className="detail-view"> <div className="detail-view">
......
...@@ -6,28 +6,35 @@ import DetailView from '@components/DetailView'; ...@@ -6,28 +6,35 @@ import DetailView from '@components/DetailView';
import ByRoundListing from '@containers/ByRoundListing'; import ByRoundListing from '@containers/ByRoundListing';
import { import {
getRoundsFetching, getRoundsFetching,
getRoundsErrored,
} from '@selectors/rounds'; } from '@selectors/rounds';
import { import {
getByGivenStatusesLoading, getByGivenStatusesLoading,
getByGivenStatusesError,
} from '@selectors/submissions'; } from '@selectors/submissions';
class GroupByRoundDetailView extends React.Component { class GroupByRoundDetailView extends React.Component {
static propTypes = { static propTypes = {
submissionStatuses: PropTypes.arrayOf(PropTypes.string), submissionStatuses: PropTypes.arrayOf(PropTypes.string),
isLoading: PropTypes.bool, isLoading: PropTypes.bool,
isErrored: PropTypes.bool,
}; };
render() { render() {
const listing = <ByRoundListing submissionStatuses={this.props.submissionStatuses} />; const listing = <ByRoundListing submissionStatuses={this.props.submissionStatuses} />;
const { isLoading } = this.props; const { isLoading, isErrored } = this.props;
return ( return (
<DetailView listing={listing} isLoading={isLoading} /> <DetailView listing={listing} isLoading={isLoading} error={isErrored ? 'Fetching failed.' : undefined} />
); );
} }
} }
const mapStateToProps = (state, ownProps) => ({ const mapStateToProps = (state, ownProps) => ({
isErrored: (
getByGivenStatusesError(ownProps.submissionStatuses)(state) ||
getRoundsErrored(state)
),
isLoading: ( isLoading: (
getByGivenStatusesLoading(ownProps.submissionStatuses)(state) || getByGivenStatusesLoading(ownProps.submissionStatuses)(state) ||
getRoundsFetching(state) getRoundsFetching(state)
......
...@@ -7,6 +7,7 @@ import ByStatusListing from '@containers/ByStatusListing'; ...@@ -7,6 +7,7 @@ import ByStatusListing from '@containers/ByStatusListing';
import { import {
getCurrentRound, getCurrentRound,
getSubmissionsByRoundError,
} from '@selectors/submissions'; } from '@selectors/submissions';
...@@ -14,20 +15,22 @@ class GroupByStatusDetailView extends React.Component { ...@@ -14,20 +15,22 @@ class GroupByStatusDetailView extends React.Component {
static propTypes = { static propTypes = {
submissions: PropTypes.arrayOf(PropTypes.object), submissions: PropTypes.arrayOf(PropTypes.object),
round: PropTypes.object, round: PropTypes.object,
error: PropTypes.string,
}; };
render() { render() {
const listing = <ByStatusListing />; const listing = <ByStatusListing />;
const { round } = this.props; const { round, error } = this.props;
const isLoading = !round || (round && (round.isFetching || round.submissions.isFetching)) const isLoading = !round || (round && (round.isFetching || round.submissions.isFetching))
return ( return (
<DetailView listing={listing} isLoading={isLoading} /> <DetailView listing={listing} isLoading={isLoading} error={error} />
); );
} }
} }
const mapStateToProps = state => ({ const mapStateToProps = state => ({
round: getCurrentRound(state), round: getCurrentRound(state),
error: getSubmissionsByRoundError(state),
}) })
export default connect( export default connect(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment