2018-06-07 17:06:41 +02:00
|
|
|
import { format } from 'date-fns'
|
|
|
|
import React from 'react'
|
|
|
|
import { Link } from 'react-router-dom'
|
|
|
|
|
2018-06-11 15:24:34 +02:00
|
|
|
import { getDateWithTZ } from '../../utils'
|
|
|
|
|
2019-01-09 12:07:57 +01:00
|
|
|
export default class ActivitiesList extends React.PureComponent {
|
|
|
|
render() {
|
|
|
|
const { activities, sports, user } = this.props
|
|
|
|
return (
|
|
|
|
<div className="card activity-card">
|
|
|
|
<div className="card-body">
|
|
|
|
<table className="table">
|
|
|
|
<thead>
|
2018-06-07 17:06:41 +02:00
|
|
|
<tr>
|
|
|
|
<th scope="col" />
|
|
|
|
<th scope="col">Workout</th>
|
|
|
|
<th scope="col">Date</th>
|
|
|
|
<th scope="col">Distance</th>
|
|
|
|
<th scope="col">Duration</th>
|
|
|
|
<th scope="col">Ave. speed</th>
|
2018-06-11 22:42:04 +02:00
|
|
|
<th scope="col">Max. speed</th>
|
2018-06-07 17:06:41 +02:00
|
|
|
</tr>
|
2019-01-09 12:07:57 +01:00
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{sports && activities.map((activity, idx) => (
|
2018-06-07 17:06:41 +02:00
|
|
|
// eslint-disable-next-line react/no-array-index-key
|
|
|
|
<tr key={idx}>
|
2019-01-09 12:07:57 +01:00
|
|
|
<td>
|
2018-06-07 17:06:41 +02:00
|
|
|
<img
|
|
|
|
className="activity-sport"
|
|
|
|
src={sports
|
|
|
|
.filter(s => s.id === activity.sport_id)
|
|
|
|
.map(s => s.img)}
|
|
|
|
alt="activity sport logo"
|
|
|
|
/>
|
|
|
|
</td>
|
2019-01-09 12:07:57 +01:00
|
|
|
<td>
|
2018-06-07 17:06:41 +02:00
|
|
|
<Link to={`/activities/${activity.id}`}>
|
|
|
|
{activity.title}
|
|
|
|
</Link>
|
2019-01-09 12:07:57 +01:00
|
|
|
</td>
|
2018-06-11 15:24:34 +02:00
|
|
|
<td>
|
|
|
|
{format(
|
|
|
|
getDateWithTZ(activity.activity_date, user.timezone),
|
2019-08-28 14:38:15 +02:00
|
|
|
'dd/MM/yyyy HH:mm'
|
2018-06-11 15:24:34 +02:00
|
|
|
)}
|
|
|
|
</td>
|
2018-06-07 17:50:22 +02:00
|
|
|
<td className="text-right">
|
|
|
|
{Number(activity.distance).toFixed(2)} km
|
|
|
|
</td>
|
2019-01-13 11:56:05 +01:00
|
|
|
<td className="text-right">{activity.moving}</td>
|
2018-06-07 17:50:22 +02:00
|
|
|
<td className="text-right">{activity.ave_speed} km/h</td>
|
2018-06-11 22:42:04 +02:00
|
|
|
<td className="text-right">{activity.max_speed} km/h</td>
|
2018-06-07 17:06:41 +02:00
|
|
|
</tr>
|
|
|
|
))}
|
2019-01-09 12:07:57 +01:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2018-06-07 17:06:41 +02:00
|
|
|
</div>
|
2019-01-09 12:07:57 +01:00
|
|
|
)
|
|
|
|
}
|
2018-06-07 17:06:41 +02:00
|
|
|
}
|