display records label on calendar
This commit is contained in:
parent
0c8921a6ff
commit
d37db4a714
@ -6,7 +6,7 @@ import { connect } from 'react-redux'
|
|||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
|
|
||||||
import { getMonthActivities } from '../../actions/activities'
|
import { getMonthActivities } from '../../actions/activities'
|
||||||
import { getDateWithTZ } from '../../utils'
|
import { getDateWithTZ, recordsLabels } from '../../utils'
|
||||||
|
|
||||||
const getStartAndEndMonth = date => {
|
const getStartAndEndMonth = date => {
|
||||||
const monthStart = dateFns.startOfMonth(date)
|
const monthStart = dateFns.startOfMonth(date)
|
||||||
@ -125,7 +125,11 @@ class Calendar extends React.Component {
|
|||||||
<i
|
<i
|
||||||
className="fa fa-trophy custom-fa-small"
|
className="fa fa-trophy custom-fa-small"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
title={act.records.map(r => ` ${r.record_type}`)}
|
title={act.records.map(rec => ` ${
|
||||||
|
recordsLabels.filter(
|
||||||
|
r => r.record_type === rec.record_type
|
||||||
|
)[0].label
|
||||||
|
}`)}
|
||||||
/>
|
/>
|
||||||
</sup>
|
</sup>
|
||||||
)}
|
)}
|
||||||
|
@ -91,29 +91,34 @@ export const formatActivityDate = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const recordsLabels = [
|
||||||
|
{ record_type: 'AS', label: 'Avg speed' },
|
||||||
|
{ record_type: 'FD', label: 'Farest distance' },
|
||||||
|
{ record_type: 'LD', label: 'Longest duration' },
|
||||||
|
{ record_type: 'MS', label: 'Max speed' },
|
||||||
|
]
|
||||||
|
|
||||||
export const formatRecord = (record, tz) => {
|
export const formatRecord = (record, tz) => {
|
||||||
let value, recordType = null
|
let value, recordType = null
|
||||||
switch (record.record_type) {
|
switch (record.record_type) {
|
||||||
case 'AS':
|
case 'AS':
|
||||||
case 'MS':
|
case 'MS':
|
||||||
value = `${record.value} km/h`
|
value = `${record.value} km/h`
|
||||||
recordType = record.record_type === 'AS' ? 'Avg speed' : 'Max speed'
|
|
||||||
break
|
break
|
||||||
case 'FD':
|
case 'FD':
|
||||||
value = `${record.value} km`
|
value = `${record.value} km`
|
||||||
recordType = 'Farest distance'
|
|
||||||
break
|
break
|
||||||
default: // 'LD'
|
default: // 'LD'
|
||||||
value = record.value // eslint-disable-line prefer-destructuring
|
value = record.value // eslint-disable-line prefer-destructuring
|
||||||
recordType = 'Longest duration'
|
|
||||||
}
|
}
|
||||||
|
[recordType] = recordsLabels.filter(r => r.record_type === record.record_type)
|
||||||
return {
|
return {
|
||||||
activity_date: formatActivityDate(
|
activity_date: formatActivityDate(
|
||||||
getDateWithTZ(record.activity_date, tz)
|
getDateWithTZ(record.activity_date, tz)
|
||||||
).activity_date,
|
).activity_date,
|
||||||
activity_id: record.activity_id,
|
activity_id: record.activity_id,
|
||||||
id: record.id,
|
id: record.id,
|
||||||
record_type: recordType,
|
record_type: recordType.label,
|
||||||
value: value,
|
value: value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user