Commit 1b2b5953 authored by Karishma Chadha's avatar Karishma Chadha

Get rid of extra piece of state being tracked in redux and update selector to...

Get rid of extra piece of state being tracked in redux and update selector to tell if studio load failed. Use that to display 404 page instead.
parent 04035031
...@@ -26,9 +26,7 @@ const getInitialState = () => ({ ...@@ -26,9 +26,7 @@ const getInitialState = () => ({
manager: false, manager: false,
curator: false, curator: false,
following: false, following: false,
invited: false, invited: false
studioNotAvailable: false
}); });
const studioReducer = (state, action) => { const studioReducer = (state, action) => {
...@@ -53,13 +51,6 @@ const studioReducer = (state, action) => { ...@@ -53,13 +51,6 @@ const studioReducer = (state, action) => {
if (action.error) { if (action.error) {
log.error(action.error); log.error(action.error);
} }
if (action.fetchType === 'infoStatus' && action.fetchStatus === Status.ERROR) {
return {
...state,
[action.fetchType]: action.fetchStatus,
studioNotAvailable: true
};
}
return { return {
...state, ...state,
[action.fetchType]: action.fetchStatus [action.fetchType]: action.fetchStatus
...@@ -100,10 +91,10 @@ const selectStudioDescription = state => state.studio.description; ...@@ -100,10 +91,10 @@ const selectStudioDescription = state => state.studio.description;
const selectStudioImage = state => state.studio.image; const selectStudioImage = state => state.studio.image;
const selectStudioOpenToAll = state => state.studio.openToAll; const selectStudioOpenToAll = state => state.studio.openToAll;
const selectStudioCommentsAllowed = state => state.studio.commentsAllowed; const selectStudioCommentsAllowed = state => state.studio.commentsAllowed;
const selectStudioLoadFailed = state => state.studio.infoStatus === Status.ERROR;
const selectIsFetchingInfo = state => state.studio.infoStatus === Status.FETCHING; const selectIsFetchingInfo = state => state.studio.infoStatus === Status.FETCHING;
const selectIsFollowing = state => state.studio.following; const selectIsFollowing = state => state.studio.following;
const selectIsFetchingRoles = state => state.studio.rolesStatus === Status.FETCHING; const selectIsFetchingRoles = state => state.studio.rolesStatus === Status.FETCHING;
const selectIsStudioAvailable = state => !state.studio.studioNotAvailable;
// Thunks // Thunks
const getInfo = () => ((dispatch, getState) => { const getInfo = () => ((dispatch, getState) => {
...@@ -167,8 +158,8 @@ module.exports = { ...@@ -167,8 +158,8 @@ module.exports = {
selectStudioImage, selectStudioImage,
selectStudioOpenToAll, selectStudioOpenToAll,
selectStudioCommentsAllowed, selectStudioCommentsAllowed,
selectStudioLoadFailed,
selectIsFetchingInfo, selectIsFetchingInfo,
selectIsFetchingRoles, selectIsFetchingRoles,
selectIsFollowing, selectIsFollowing
selectIsStudioAvailable
}; };
...@@ -30,18 +30,19 @@ import { ...@@ -30,18 +30,19 @@ import {
activity activity
} from './lib/redux-modules'; } from './lib/redux-modules';
const {getInitialState, studioReducer, selectIsStudioAvailable} = require('../../redux/studio'); const {getInitialState, studioReducer, selectStudioLoadFailed} = require('../../redux/studio');
const {studioReportReducer} = require('../../redux/studio-report'); const {studioReportReducer} = require('../../redux/studio-report');
const {commentsReducer} = require('../../redux/comments'); const {commentsReducer} = require('../../redux/comments');
const {studioMutationsReducer} = require('../../redux/studio-mutations'); const {studioMutationsReducer} = require('../../redux/studio-mutations');
import './studio.scss'; import './studio.scss';
const StudioShell = ({isStudioAvailable}) => { const StudioShell = ({studioLoadFailed}) => {
const match = useRouteMatch(); const match = useRouteMatch();
return ( return (
isStudioAvailable ? studioLoadFailed ?
<NotAvailable /> :
<div className="studio-shell"> <div className="studio-shell">
<div className="studio-info"> <div className="studio-info">
<StudioInfo /> <StudioInfo />
...@@ -70,18 +71,17 @@ const StudioShell = ({isStudioAvailable}) => { ...@@ -70,18 +71,17 @@ const StudioShell = ({isStudioAvailable}) => {
</Switch> </Switch>
</div> </div>
</div> </div>
</div> : </div>
<NotAvailable />
); );
}; };
StudioShell.propTypes = { StudioShell.propTypes = {
isStudioAvailable: PropTypes.bool studioLoadFailed: PropTypes.bool
}; };
const ConnectedStudioShell = connect( const ConnectedStudioShell = connect(
state => ({ state => ({
isStudioAvailable: selectIsStudioAvailable(state) studioLoadFailed: selectStudioLoadFailed(state)
}), }),
)(StudioShell); )(StudioShell);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment