Client: minor fix

This commit is contained in:
Sam 2018-06-11 19:15:38 +02:00
parent 859f690ba4
commit 489a123671
4 changed files with 6 additions and 6 deletions

View File

@ -43,7 +43,7 @@ export const addActivity = form => dispatch => FitTrackeeApi
} else { } else {
dispatch(setError(`activities: ${ret.message}`)) dispatch(setError(`activities: ${ret.message}`))
} }
dispatch(setLoading()) dispatch(setLoading(false))
}) })
.catch(error => dispatch(setError(`activities: ${error}`))) .catch(error => dispatch(setError(`activities: ${error}`)))
@ -117,7 +117,7 @@ export const editActivity = form => dispatch => FitTrackeeGenericApi
} else { } else {
dispatch(setError(`activities: ${ret.message}`)) dispatch(setError(`activities: ${ret.message}`))
} }
dispatch(setLoading()) dispatch(setLoading(false))
}) })
.catch(error => dispatch(setError(`activities: ${error}`))) .catch(error => dispatch(setError(`activities: ${error}`)))

View File

@ -13,8 +13,9 @@ export const setError = message => ({
message, message,
}) })
export const setLoading = () => ({ export const setLoading = loading => ({
type: 'SET_LOADING', type: 'SET_LOADING',
loading
}) })
export const getData = (target, data) => dispatch => { export const getData = (target, data) => dispatch => {

View File

@ -96,7 +96,7 @@ export default connect(
}), }),
dispatch => ({ dispatch => ({
onAddActivity: e => { onAddActivity: e => {
dispatch(setLoading()) dispatch(setLoading(true))
const form = new FormData() const form = new FormData()
form.append('file', e.target.form.gpxFile.files[0]) form.append('file', e.target.form.gpxFile.files[0])
form.append( form.append(
@ -105,7 +105,6 @@ export default connect(
dispatch(addActivity(form)) dispatch(addActivity(form))
}, },
onEditActivity: (e, activity) => { onEditActivity: (e, activity) => {
dispatch(setLoading())
dispatch(editActivity({ dispatch(editActivity({
id: activity.id, id: activity.id,
sport_id: +e.target.form.sport.value, sport_id: +e.target.form.sport.value,

View File

@ -109,7 +109,7 @@ const gpx = (state = initial.gpx, action) => {
const loading = (state = initial.loading, action) => { const loading = (state = initial.loading, action) => {
switch (action.type) { switch (action.type) {
case 'SET_LOADING': case 'SET_LOADING':
return !state return action.loading
default: default:
return state return state
} }