Client - add application configuration in Application Admin - #15

This commit is contained in:
Sam
2019-11-13 20:15:50 +01:00
parent 97534b698b
commit 1398c7ff4a
28 changed files with 563 additions and 97 deletions

View File

@ -43,6 +43,10 @@ export const addActivity = form => dispatch =>
dispatch(loadProfile())
history.push('/')
}
} else if (ret.status === 413) {
dispatch(
setError('activities|File size is greater than the allowed size')
)
} else {
dispatch(setError(`activities|${ret.message}`))
}

View File

@ -0,0 +1,38 @@
import FitTrackeeGenericApi from '../fitTrackeeApi'
import { setError } from './index'
export const setAppConfig = data => ({
type: 'SET_APP_CONFIG',
data,
})
export const setAppStats = data => ({
type: 'SET_APP_STATS',
data,
})
export const getAppData = target => dispatch =>
FitTrackeeGenericApi.getData(target)
.then(ret => {
if (ret.status === 'success') {
if (target === 'config') {
dispatch(setAppConfig(ret.data))
} else if (target === 'stats/all') {
dispatch(setAppStats(ret.data))
}
} else {
dispatch(setError(`application|${ret.message}`))
}
})
.catch(error => dispatch(setError(`application|${error}`)))
export const updateAppConfig = formData => dispatch =>
FitTrackeeGenericApi.updateData('config', formData)
.then(ret => {
if (ret.status === 'success') {
dispatch(setAppConfig(ret.data))
} else {
dispatch(setError(`application|${ret.message}`))
}
})
.catch(error => dispatch(setError(`application|${error}`)))

View File

@ -1,22 +1,6 @@
import FitTrackeeGenericApi from '../fitTrackeeApi'
import { setData, setError } from './index'
export const setAppStats = data => ({
type: 'SET_APP_STATS',
data,
})
export const getAppStats = () => dispatch =>
FitTrackeeGenericApi.getData('stats/all')
.then(ret => {
if (ret.status === 'success') {
dispatch(setAppStats(ret.data))
} else {
dispatch(setError(`application|${ret.message}`))
}
})
.catch(error => dispatch(setError(`application|${error}`)))
export const getStats = (userId, type, data) => dispatch =>
FitTrackeeGenericApi.getData(`stats/${userId}/${type}`, data)
.then(ret => {