FitTrackee/mpwo_client/src/actions/activities.js

20 lines
464 B
JavaScript
Raw Normal View History

2018-05-01 19:29:21 +02:00
import mpwoApi from '../mwpoApi/activities'
import { history } from '../index'
import { setError } from './index'
export function addActivity(form) {
return function(dispatch) {
return mpwoApi
.addActivity(form)
.then(ret => {
if (ret.status === 'created') {
history.push('/')
} else {
dispatch(setError(`activities: ${ret.message}`))
}
})
.catch(error => dispatch(setError(`activities: ${error}`)))
}
}