match,
- createAllArtistSelector(),
- (match, allArtists) => {
+ (state) => state.artist,
+ (match, artist) => {
const foreignArtistId = match.params.foreignArtistId;
- const artistIndex = _.findIndex(allArtists, { foreignArtistId });
+ const {
+ isFetching,
+ isPopulated,
+ error,
+ items
+ } = artist;
+
+ const artistIndex = _.findIndex(items, { foreignArtistId });
if (artistIndex > -1) {
return {
+ isFetching,
+ isPopulated,
foreignArtistId
};
}
- return {};
+ return {
+ isFetching,
+ isPopulated,
+ error
+ };
}
);
}
@@ -48,9 +65,30 @@ class ArtistDetailsPageConnector extends Component {
render() {
const {
- foreignArtistId
+ foreignArtistId,
+ isFetching,
+ isPopulated,
+ error
} = this.props;
+ if (isFetching && !isPopulated) {
+ return (
+
+
+
+
+
+ );
+ }
+
+ if (!isFetching && !!error) {
+ return (
+
+ {getErrorMessage(error, 'Failed to load artist from API')}
+
+ );
+ }
+
if (!foreignArtistId) {
return (