API & Client - max sizes and max number of files must be greater than 0 - #71

This commit is contained in:
Sam
2021-02-20 16:59:31 +01:00
parent c4e579dd25
commit fbc40385a0
18 changed files with 203 additions and 26 deletions

View File

@ -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}`)))
}

View File

@ -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') {