2018-06-12 12:51:23 +02:00
|
|
|
import FitTrackeeGenericApi from '../fitTrackeeApi'
|
2018-06-06 20:17:37 +02:00
|
|
|
import { setData, setError } from './index'
|
|
|
|
|
2019-08-28 15:35:22 +02:00
|
|
|
export const getStats = (userId, type, data) => dispatch =>
|
|
|
|
FitTrackeeGenericApi.getData(`stats/${userId}/${type}`, data)
|
2018-06-06 20:17:37 +02:00
|
|
|
.then(ret => {
|
|
|
|
if (ret.status === 'success') {
|
2019-08-28 15:35:22 +02:00
|
|
|
dispatch(setData('statistics', ret.data))
|
2018-06-06 20:17:37 +02:00
|
|
|
} else {
|
|
|
|
dispatch(setError(`statistics: ${ret.message}`))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(error => dispatch(setError(`statistics: ${error}`)))
|