diff --git a/mpwo_client/e2e/activities.test.js b/mpwo_client/e2e/activities.test.js index 09ec0a57..c30a6d09 100644 --- a/mpwo_client/e2e/activities.test.js +++ b/mpwo_client/e2e/activities.test.js @@ -24,7 +24,7 @@ test('standard user should be able to add a workout (w/o gpx)', async t => { await t .navigateTo(`${TEST_URL}/activities/add`) .expect(Selector('H1').withText('Dashboard').exists).notOk() - .expect(Selector('H2').withText('Add a sport').exists).ok() + .expect(Selector('H2').withText('Add an activity').exists).ok() .click(Selector('input[name="withoutGpx"]')) .click(Selector('select').filter('[name="sport_id"]')) .click(Selector('option').filter('[value="1"]')) diff --git a/mpwo_client/src/components/Activities/ActivityAdd.jsx b/mpwo_client/src/components/Activities/ActivityAdd.jsx index 9608631d..857a0893 100644 --- a/mpwo_client/src/components/Activities/ActivityAdd.jsx +++ b/mpwo_client/src/components/Activities/ActivityAdd.jsx @@ -1,91 +1,24 @@ import React from 'react' -import { Helmet } from 'react-helmet' import { connect } from 'react-redux' -import FormWithGpx from './ActivityForms/FormWithGpx' -import FormWithoutGpx from './ActivityForms/FormWithoutGpx' +import ActivityAddOrEdit from './ActivityAddOrEdit' import { getData } from '../../actions/index' -class AddActivity extends React.Component { - constructor(props, context) { - super(props, context) - this.state = { - withGpx: true, - } - } - +class ActivityAdd extends React.Component { componentDidMount() { this.props.loadSports() } - handleRadioChange (changeEvent) { - this.setState({ - withGpx: - changeEvent.target.name === 'withGpx' - ? changeEvent.target.value : !changeEvent.target.value - }) - } - render() { const { message, sports } = this.props - const { withGpx } = this.state return (
- - mpwo - Add an activity - -

- {message && ( - {message} - )} - -
-
-
-
-
-

- Add a sport -

-
-
-
-
- -
-
- -
-
-
- {withGpx ? ( - - ) : ( - - )} -
-
-
-
-
-
+
) } @@ -102,4 +35,4 @@ export default connect( dispatch(getData('sports')) }, }) -)(AddActivity) +)(ActivityAdd) diff --git a/mpwo_client/src/components/Activities/ActivityAddOrEdit.jsx b/mpwo_client/src/components/Activities/ActivityAddOrEdit.jsx index 5e1300f4..9782ec32 100644 --- a/mpwo_client/src/components/Activities/ActivityAddOrEdit.jsx +++ b/mpwo_client/src/components/Activities/ActivityAddOrEdit.jsx @@ -21,14 +21,20 @@ export default class ActivityAddEdit extends React.Component { } render() { - const { activity, sports } = this.props + const { activity, message, sports } = this.props const { withGpx } = this.state return (
- mpwo - Add an activity + mpwo - {activity + ? 'Edit an activity' + : 'Add an activity'} +

+ {message && ( + {message} + )}
diff --git a/mpwo_client/src/components/Activities/ActivityEdit.jsx b/mpwo_client/src/components/Activities/ActivityEdit.jsx index ec5e3503..684f4a56 100644 --- a/mpwo_client/src/components/Activities/ActivityEdit.jsx +++ b/mpwo_client/src/components/Activities/ActivityEdit.jsx @@ -1,5 +1,4 @@ import React from 'react' -import { Helmet } from 'react-helmet' import { connect } from 'react-redux' import ActivityAddOrEdit from './ActivityAddOrEdit' @@ -18,16 +17,10 @@ class ActivityEdit extends React.Component { const [activity] = activities return (
- - mpwo - Edit activity - -

- {message && ( - {message} - )} {sports.length > 0 && ( )} diff --git a/mpwo_client/src/components/App.css b/mpwo_client/src/components/App.css index 1480a1cb..e96ddac4 100644 --- a/mpwo_client/src/components/App.css +++ b/mpwo_client/src/components/App.css @@ -58,7 +58,7 @@ input, textarea { } .activity-card { - margin-bottom: 15px; + margin-bottom: 15px; } .add-activity { diff --git a/mpwo_client/src/components/Dashboard/ActivityCard.jsx b/mpwo_client/src/components/Dashboard/ActivityCard.jsx index f76d67a9..e0ee9c15 100644 --- a/mpwo_client/src/components/Dashboard/ActivityCard.jsx +++ b/mpwo_client/src/components/Dashboard/ActivityCard.jsx @@ -5,7 +5,7 @@ export default function ActivityCard (props) { const { activity, sports } = props return ( -
+
{sports.filter(sport => sport.id === activity.sport_id)