display stats depending on duration - #13

This commit is contained in:
Sam
2019-01-04 11:51:06 +01:00
parent cd39f46270
commit 3d4ad8da81
3 changed files with 58 additions and 3 deletions

View File

@ -9,12 +9,21 @@ import StatsChart from './StatsChart'
class Statistics extends React.PureComponent {
componentDidMount() {
this.props.loadMonthActivities(
this.props.loadActivities(
this.props.user.id,
this.props.statsParams,
)
}
componentDidUpdate(prevProps) {
if (this.props.statsParams !== prevProps.statsParams) {
this.props.loadActivities(
this.props.user.id,
this.props.statsParams,
)
}
}
render() {
const { sports, statistics, statsParams } = this.props
const stats = formatStats(statistics, sports, statsParams)
@ -37,7 +46,7 @@ export default connect(
user: state.user,
}),
dispatch => ({
loadMonthActivities: (userId, data) => {
loadActivities: (userId, data) => {
const dateFormat = 'YYYY-MM-DD'
const params = {
from: format(data.start, dateFormat),