2018-06-07 12:58:23 +02:00
|
|
|
import { format } from 'date-fns'
|
2018-05-09 10:25:08 +02:00
|
|
|
import React from 'react'
|
|
|
|
import { Link } from 'react-router-dom'
|
|
|
|
|
2018-06-11 15:24:34 +02:00
|
|
|
import { apiUrl, getDateWithTZ } from '../../utils'
|
2018-05-30 13:35:27 +02:00
|
|
|
|
2018-05-09 10:25:08 +02:00
|
|
|
export default function ActivityCard (props) {
|
2018-06-11 15:24:34 +02:00
|
|
|
const { activity, sports, user } = props
|
2018-05-09 10:25:08 +02:00
|
|
|
|
|
|
|
return (
|
2018-05-10 17:21:19 +02:00
|
|
|
<div className="card activity-card text-center">
|
2018-05-09 10:25:08 +02:00
|
|
|
<div className="card-header">
|
|
|
|
<Link to={`/activities/${activity.id}`}>
|
|
|
|
{sports.filter(sport => sport.id === activity.sport_id)
|
|
|
|
.map(sport => sport.label)} -{' '}
|
2018-06-11 15:24:34 +02:00
|
|
|
{format(
|
|
|
|
getDateWithTZ(activity.activity_date, user.timezone),
|
|
|
|
'DD/MM/YYYY HH:mm'
|
|
|
|
)}
|
2018-05-09 10:25:08 +02:00
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
<div className="card-body">
|
2018-05-30 13:35:27 +02:00
|
|
|
<div className="row">
|
|
|
|
{activity.map && (
|
|
|
|
<div className="col">
|
|
|
|
<img
|
|
|
|
alt="Map"
|
|
|
|
src={`${apiUrl}activities/map/${activity.map}` +
|
|
|
|
`?${Date.now()}`}
|
|
|
|
className="img-fluid"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div className="col">
|
|
|
|
<p>
|
|
|
|
<i className="fa fa-clock-o" aria-hidden="true" />{' '}
|
|
|
|
Duration: {activity.duration}
|
|
|
|
{activity.map ? (
|
|
|
|
<span><br /><br /></span>
|
|
|
|
) : (
|
|
|
|
' - '
|
|
|
|
)}
|
|
|
|
<i className="fa fa-road" aria-hidden="true" />{' '}
|
|
|
|
Distance: {activity.distance} km
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-05-09 10:25:08 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|