Admin: sports creation

This commit is contained in:
Sam
2018-05-01 12:40:30 +02:00
parent fd8b51f416
commit be6e64e124
3 changed files with 87 additions and 4 deletions

View File

@ -33,14 +33,11 @@ export function getData(target, id = null) {
export function addData(target, data) {
return function(dispatch) {
if (isNaN(data.id)) {
return dispatch(setError(target, `${target}: Incorrect id`))
}
return mpwoApi
.addData(target, data)
.then(ret => {
if (ret.status === 'created') {
dispatch(setData(target, ret.data))
history.push(`/admin/${target}`)
} else {
dispatch(setError(`${target}: ${ret.status}`))
}