import React from 'react' import { Helmet } from 'react-helmet' import { connect } from 'react-redux' import { Link } from 'react-router-dom' import ActivityMap from './ActivityMap' import CustomModal from './../Others/CustomModal' import { getData } from '../../actions' import { deleteActivity } from '../../actions/activities' import { formatActivityDate } from '../../utils' class ActivityDisplay extends React.Component { constructor(props, context) { super(props, context) this.state = { displayModal: false, } } componentDidMount() { this.props.loadActivity(this.props.match.params.activityId) } componentDidUpdate(prevProps) { if (prevProps.match.params.activityId !== this.props.match.params.activityId) { this.props.loadActivity(this.props.match.params.activityId) } } render() { const { activities, message, onDeleteActivity, sports } = this.props const { displayModal } = this.state const [activity] = activities const title = activity ? activity.title : 'Activity' const [sport] = activity ? sports.filter(s => s.id === activity.sport_id) : [] const activityDate = activity ? formatActivityDate(activity.activity_date) : null return (
{message}
) : (
Duration: {activity.duration} {activity.records.find(r => r.record_type === 'LD' ) && ( )} {' '} {activity.pauses !== '0:00:00' && activity.pauses !== null && ( `(pauses: ${activity.pauses})` )}
Distance: {activity.distance} km {activity.records.find(r => r.record_type === 'FD' ) && ( )}
Average speed: {activity.ave_speed} km/h
{activity.records.find(r => r.record_type === 'AS'
) && (
)}
Max speed : {activity.max_speed} km/h
{activity.records.find(r => r.record_type === 'MS'
) && (
)}
Min altitude: {activity.min_alt}m
Max altitude: {activity.max_alt}m
Ascent: {activity.ascent}m
Descent: {activity.descent}m