From 0be1e9819b2bc83c955693a34b48b13a435e47c0 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 25 May 2018 18:40:07 +0200 Subject: [PATCH] Client: Activity display refactor --- .../components/Activities/ActivityDisplay.jsx | 253 ------------------ .../ActivityDisplay/ActivityCardHeader.jsx | 83 ++++++ .../ActivityDisplay/ActivityDetails.jsx | 88 ++++++ .../{ => ActivityDisplay}/ActivityMap.jsx | 4 +- .../Activities/ActivityDisplay/index.jsx | 113 ++++++++ 5 files changed, 286 insertions(+), 255 deletions(-) delete mode 100644 mpwo_client/src/components/Activities/ActivityDisplay.jsx create mode 100644 mpwo_client/src/components/Activities/ActivityDisplay/ActivityCardHeader.jsx create mode 100644 mpwo_client/src/components/Activities/ActivityDisplay/ActivityDetails.jsx rename mpwo_client/src/components/Activities/{ => ActivityDisplay}/ActivityMap.jsx (93%) create mode 100644 mpwo_client/src/components/Activities/ActivityDisplay/index.jsx 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 ? ( - -