Client - add application configuration in Application Admin - #15
This commit is contained in:
@ -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}`))
|
||||
}
|
||||
|
38
fittrackee_client/src/actions/application.js
Normal file
38
fittrackee_client/src/actions/application.js
Normal 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}`)))
|
@ -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 => {
|
||||
|
Reference in New Issue
Block a user