API & Client - max sizes and max number of files must be greater than 0 - #71
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import FitTrackeeGenericApi from '../fitTrackeeApi'
|
||||
import { history } from '../index'
|
||||
import { setError } from './index'
|
||||
import { generateIds } from '../utils'
|
||||
import { emptyMessages, setError } from './index'
|
||||
|
||||
export const setAppConfig = data => ({
|
||||
type: 'SET_APP_CONFIG',
|
||||
@ -12,6 +13,8 @@ export const setAppStats = data => ({
|
||||
data,
|
||||
})
|
||||
|
||||
const SetAppErrors = messages => ({ type: 'APP_ERRORS', messages })
|
||||
|
||||
export const getAppData = target => dispatch =>
|
||||
FitTrackeeGenericApi.getData(target)
|
||||
.then(ret => {
|
||||
@ -27,14 +30,18 @@ export const getAppData = target => dispatch =>
|
||||
})
|
||||
.catch(error => dispatch(setError(`application|${error}`)))
|
||||
|
||||
export const updateAppConfig = formData => dispatch =>
|
||||
export const updateAppConfig = formData => dispatch => {
|
||||
dispatch(emptyMessages())
|
||||
FitTrackeeGenericApi.updateData('config', formData)
|
||||
.then(ret => {
|
||||
if (ret.status === 'success') {
|
||||
dispatch(setAppConfig(ret.data))
|
||||
history.push('/admin/application')
|
||||
} else if (Array.isArray(ret.message)) {
|
||||
dispatch(SetAppErrors(generateIds(ret.message)))
|
||||
} else {
|
||||
dispatch(setError(`application|${ret.message}`))
|
||||
dispatch(setError(ret.message))
|
||||
}
|
||||
})
|
||||
.catch(error => dispatch(setError(`application|${error}`)))
|
||||
}
|
||||
|
@ -3,11 +3,16 @@ import i18next from 'i18next'
|
||||
import FitTrackeeApi from '../fitTrackeeApi/index'
|
||||
import { history } from '../index'
|
||||
|
||||
export const emptyMessages = () => ({
|
||||
type: 'CLEAN_ALL_MESSAGES',
|
||||
})
|
||||
|
||||
export const setData = (target, data) => ({
|
||||
type: 'SET_DATA',
|
||||
data,
|
||||
target,
|
||||
})
|
||||
|
||||
export const setPaginatedData = (target, data, pagination) => ({
|
||||
type: 'SET_PAGINATED_DATA',
|
||||
data,
|
||||
@ -51,7 +56,7 @@ export const getOrUpdateData = (
|
||||
dispatch(setLoading(false))
|
||||
return dispatch(setError(`${target}|Incorrect id`))
|
||||
}
|
||||
dispatch(setError(''))
|
||||
dispatch(emptyMessages())
|
||||
return FitTrackeeApi[action](target, data)
|
||||
.then(ret => {
|
||||
if (ret.status === 'success') {
|
||||
|
Reference in New Issue
Block a user