Commit ff1f1041 authored by Gijs Hendriksen's avatar Gijs Hendriksen
Browse files

Replace success and hasLoaded props by new status prop

parent bd4a50e4
......@@ -125,9 +125,9 @@ class Calendar extends Component {
};
render() {
if (!this.props.hasLoaded) {
if (this.props.status === 'initial') {
return <LoadingScreen />;
} else if (!this.props.success) {
} else if (this.props.status === 'failure') {
return (
<ScrollView
contentContainerStyle={styles.content}
......@@ -190,16 +190,14 @@ Calendar.propTypes = {
url: PropTypes.string,
})).isRequired,
loading: PropTypes.bool.isRequired,
status: PropTypes.string.isRequired,
refresh: PropTypes.func.isRequired,
success: PropTypes.bool.isRequired,
hasLoaded: PropTypes.bool.isRequired,
};
const mapStateToProps = state => ({
eventList: state.calendar.eventList,
loading: state.calendar.loading,
success: state.calendar.success,
hasLoaded: state.calendar.hasLoaded,
status: state.calendar.status,
});
const mapDispatchToProps = dispatch => ({
......
......@@ -70,9 +70,9 @@ class Welcome extends Component {
};
render() {
if (!this.props.hasLoaded) {
if (this.props.status === 'initial') {
return <LoadingScreen />;
} else if (!this.props.success) {
} else if (this.props.status === 'failure') {
return (
<ScrollView
contentContainerStyle={styles.content}
......@@ -135,15 +135,13 @@ Welcome.propTypes = {
})).isRequired,
refresh: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
success: PropTypes.bool.isRequired,
hasLoaded: PropTypes.bool.isRequired,
status: PropTypes.string.isRequired,
};
const mapStateToProps = state => ({
eventList: state.welcome.eventList,
loading: state.welcome.loading,
success: state.welcome.success,
hasLoaded: state.welcome.hasLoaded,
status: state.welcome.status,
});
const mapDispatchToProps = dispatch => ({
......
......@@ -3,8 +3,7 @@ import * as calendarActions from '../actions/calendar';
const initialState = {
eventList: [],
loading: true,
success: true,
hasLoaded: false,
status: 'initial',
};
export default function calendar(state = initialState, action = {}) {
......@@ -13,15 +12,13 @@ export default function calendar(state = initialState, action = {}) {
return {
eventList: action.payload.eventList,
loading: false,
success: true,
hasLoaded: true,
status: 'success',
};
case calendarActions.FAILURE:
return {
...state,
loading: false,
success: false,
hasLoaded: true,
status: 'failure',
};
case calendarActions.REFRESH:
return { ...state, loading: true };
......
......@@ -3,8 +3,7 @@ import * as welcomeActions from '../actions/welcome';
const initialState = {
eventList: [],
loading: true,
success: true,
hasLoaded: false,
status: 'initial',
};
export default function welcome(state = initialState, action = {}) {
......@@ -13,15 +12,13 @@ export default function welcome(state = initialState, action = {}) {
return {
eventList: action.payload.eventList,
loading: false,
success: true,
hasLoaded: true,
status: 'success',
};
case welcomeActions.FAILURE:
return {
...state,
loading: false,
success: false,
hasLoaded: true,
status: 'failure',
};
case welcomeActions.REFRESH:
return { ...state, loading: true };
......
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