diff --git a/mpwo_client/src/components/Activities/ActivityDisplay.jsx b/mpwo_client/src/components/Activities/ActivityDisplay.jsx
deleted file mode 100644
index 50e34e1a..00000000
--- a/mpwo_client/src/components/Activities/ActivityDisplay.jsx
+++ /dev/null
@@ -1,253 +0,0 @@
-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 ? (
-
-
-
- ) : (
-
- )}
-
-
-
-
-
- {title}{' '}
-
-
-
- this.setState({ displayModal: true })
- }
- />
- {activityDate && (
-
- {`${activityDate.activity_date} - ${
- activityDate.activity_time}`}
-
- )}
-
-
- {activity.next_activity ? (
-
-
-
- ) : (
-
- )}
-
-
-
-
-
- {activity.with_gpx && (
-
- )}
-
-
-
- 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'
- ) && (
-
-
-
- )}
-
- {activity.min_alt && activity.max_alt && (
-
-
- Min altitude: {activity.min_alt}m
-
- Max altitude: {activity.max_alt}m
-
- )}
- {activity.ascent && activity.descent && (
-
-
- Ascent: {activity.ascent}m
-
- Descent: {activity.descent}m
-
- )}
-
-
-
-
-
-
- )}
-
- )}
-
- )
- }
-}
-
-export default connect(
- state => ({
- activities: state.activities.data,
- message: state.message,
- sports: state.sports.data,
- user: state.user,
- }),
- dispatch => ({
- loadActivity: activityId => {
- dispatch(getData('activities', activityId))
- },
- onDeleteActivity: activityId => {
- dispatch(deleteActivity(activityId))
- },
- })
-)(ActivityDisplay)
diff --git a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCardHeader.jsx b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCardHeader.jsx
new file mode 100644
index 00000000..eebf1775
--- /dev/null
+++ b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCardHeader.jsx
@@ -0,0 +1,83 @@
+import React from 'react'
+import { Link } from 'react-router-dom'
+
+import { formatActivityDate } from '../../../utils'
+
+
+export default function ActivityCardHeader(props) {
+ const { activity, displayModal, sport, title } = props
+ const activityDate = activity
+ ? formatActivityDate(activity.activity_date)
+ : null
+ return (
+
+
+
+ {activity.previous_activity ? (
+
+
+
+ ) : (
+
+ )}
+
+
+
+
+
+ {title}{' '}
+
+
+
+ displayModal(true)}
+ />
+ {activityDate && (
+
+ {`${activityDate.activity_date} - ${activityDate.activity_time}`}
+
+ )}
+
+
+ {activity.next_activity ? (
+
+
+
+ ) : (
+
+ )}
+
+
+
+ )
+}
diff --git a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityDetails.jsx b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityDetails.jsx
new file mode 100644
index 00000000..91984efd
--- /dev/null
+++ b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityDetails.jsx
@@ -0,0 +1,88 @@
+import React from 'react'
+
+export default function ActivityDetails(props) {
+ const { activity } = props
+ return (
+
+
+
+ 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'
+ ) && (
+
+
+
+ )}
+
+ {activity.min_alt && activity.max_alt && (
+
+
+ Min altitude: {activity.min_alt}m
+
+ Max altitude: {activity.max_alt}m
+
+ )}
+ {activity.ascent && activity.descent && (
+
+
+ Ascent: {activity.ascent}m
+
+ Descent: {activity.descent}m
+
+ )}
+
+ )
+}
diff --git a/mpwo_client/src/components/Activities/ActivityMap.jsx b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityMap.jsx
similarity index 93%
rename from mpwo_client/src/components/Activities/ActivityMap.jsx
rename to mpwo_client/src/components/Activities/ActivityDisplay/ActivityMap.jsx
index cc46029c..6a423541 100644
--- a/mpwo_client/src/components/Activities/ActivityMap.jsx
+++ b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityMap.jsx
@@ -3,8 +3,8 @@ import React from 'react'
import { GeoJSON, Map, TileLayer } from 'react-leaflet'
import { connect } from 'react-redux'
-import { getActivityGpx } from '../../actions/activities'
-import { getGeoJson, thunderforestApiKey } from '../../utils'
+import { getActivityGpx } from '../../../actions/activities'
+import { getGeoJson, thunderforestApiKey } from '../../../utils'
class ActivityMap extends React.Component {
diff --git a/mpwo_client/src/components/Activities/ActivityDisplay/index.jsx b/mpwo_client/src/components/Activities/ActivityDisplay/index.jsx
new file mode 100644
index 00000000..ad89d637
--- /dev/null
+++ b/mpwo_client/src/components/Activities/ActivityDisplay/index.jsx
@@ -0,0 +1,113 @@
+import React from 'react'
+import { Helmet } from 'react-helmet'
+import { connect } from 'react-redux'
+
+import ActivityCardHeader from './ActivityCardHeader'
+import ActivityDetails from './ActivityDetails'
+import ActivityMap from './ActivityMap'
+import CustomModal from './../../Others/CustomModal'
+import { getData } from '../../../actions'
+import { deleteActivity } from '../../../actions/activities'
+
+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)
+ }
+ }
+
+ displayModal(value) {
+ this.setState({ displayModal: value })
+ }
+
+ 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)
+ : []
+
+ return (
+
+
+ mpwo - {title}
+
+ {message ? (
+
{message}
+ ) : (
+
+ {displayModal &&
+
{
+ onDeleteActivity(activity.id)
+ this.displayModal(false)
+ }}
+ close={() => this.displayModal(false)}
+ />}
+ {activity && sport && activities.length === 1 && (
+
+
+
+
+
this.displayModal(true)}
+ />
+
+
+
+ {activity.with_gpx && (
+
+ )}
+
+
+
+
+
+
+ )}
+
+ )}
+
+ )
+ }
+}
+
+export default connect(
+ state => ({
+ activities: state.activities.data,
+ message: state.message,
+ sports: state.sports.data,
+ user: state.user,
+ }),
+ dispatch => ({
+ loadActivity: activityId => {
+ dispatch(getData('activities', activityId))
+ },
+ onDeleteActivity: activityId => {
+ dispatch(deleteActivity(activityId))
+ },
+ })
+)(ActivityDisplay)