diff --git a/fittrackee_client/src/actions/activities.js b/fittrackee_client/src/actions/activities.js index b910e2b0..0cc90cb9 100644 --- a/fittrackee_client/src/actions/activities.js +++ b/fittrackee_client/src/actions/activities.js @@ -43,7 +43,7 @@ export const addActivity = form => dispatch => FitTrackeeApi } else { dispatch(setError(`activities: ${ret.message}`)) } - dispatch(setLoading()) + dispatch(setLoading(false)) }) .catch(error => dispatch(setError(`activities: ${error}`))) @@ -117,7 +117,7 @@ export const editActivity = form => dispatch => FitTrackeeGenericApi } else { dispatch(setError(`activities: ${ret.message}`)) } - dispatch(setLoading()) + dispatch(setLoading(false)) }) .catch(error => dispatch(setError(`activities: ${error}`))) diff --git a/fittrackee_client/src/actions/index.js b/fittrackee_client/src/actions/index.js index 9c1f2d0b..00e1ec9e 100644 --- a/fittrackee_client/src/actions/index.js +++ b/fittrackee_client/src/actions/index.js @@ -13,8 +13,9 @@ export const setError = message => ({ message, }) -export const setLoading = () => ({ +export const setLoading = loading => ({ type: 'SET_LOADING', + loading }) export const getData = (target, data) => dispatch => { diff --git a/fittrackee_client/src/components/Activity/ActivityForms/FormWithGpx.jsx b/fittrackee_client/src/components/Activity/ActivityForms/FormWithGpx.jsx index aae64f2d..a30b3327 100644 --- a/fittrackee_client/src/components/Activity/ActivityForms/FormWithGpx.jsx +++ b/fittrackee_client/src/components/Activity/ActivityForms/FormWithGpx.jsx @@ -96,7 +96,7 @@ export default connect( }), dispatch => ({ onAddActivity: e => { - dispatch(setLoading()) + dispatch(setLoading(true)) const form = new FormData() form.append('file', e.target.form.gpxFile.files[0]) form.append( @@ -105,7 +105,6 @@ export default connect( dispatch(addActivity(form)) }, onEditActivity: (e, activity) => { - dispatch(setLoading()) dispatch(editActivity({ id: activity.id, sport_id: +e.target.form.sport.value, diff --git a/fittrackee_client/src/reducers/index.js b/fittrackee_client/src/reducers/index.js index 7ddba67b..d54e934f 100644 --- a/fittrackee_client/src/reducers/index.js +++ b/fittrackee_client/src/reducers/index.js @@ -109,7 +109,7 @@ const gpx = (state = initial.gpx, action) => { const loading = (state = initial.loading, action) => { switch (action.type) { case 'SET_LOADING': - return !state + return action.loading default: return state }