FitTrackee/fittrackee_client/src/components/Dashboard/ActivityCard.jsx

52 lines
1.5 KiB
React
Raw Normal View History

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'
import { apiUrl, getDateWithTZ } from '../../utils'
2018-05-09 10:25:08 +02:00
export default function ActivityCard (props) {
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)} -{' '}
{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">
<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>
)
}