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 (
mpwo - {title} {message ? ( {message} ) : (
{displayModal && { onDeleteActivity(activity.id) this.setState({ displayModal: false }) }} close={() => this.setState({ displayModal: false })} />} {activity && sport && activities.length === 1 && (
{activity.previous_activity ? (