diff --git a/mpwo_api/mpwo_api/activities/activities.py b/mpwo_api/mpwo_api/activities/activities.py index 95eb3d7e..295d9b4d 100644 --- a/mpwo_api/mpwo_api/activities/activities.py +++ b/mpwo_api/mpwo_api/activities/activities.py @@ -95,6 +95,7 @@ def post_activity(auth_user_id): new_activity.ascent = gpx_data['uphill'] new_activity.max_speed = gpx_data['max_speed'] new_activity.ave_speed = gpx_data['average_speed'] + db.session.add(new_activity) db.session.commit() response_object = { diff --git a/mpwo_client/src/actions/activities.js b/mpwo_client/src/actions/activities.js new file mode 100644 index 00000000..e735a0c6 --- /dev/null +++ b/mpwo_client/src/actions/activities.js @@ -0,0 +1,19 @@ +import mpwoApi from '../mwpoApi/activities' +import { history } from '../index' +import { setError } from './index' + + +export function addActivity(form) { + return function(dispatch) { + return mpwoApi + .addActivity(form) + .then(ret => { + if (ret.status === 'created') { + history.push('/') + } else { + dispatch(setError(`activities: ${ret.message}`)) + } + }) + .catch(error => dispatch(setError(`activities: ${error}`))) + } +} diff --git a/mpwo_client/src/components/Activities/AddActivity.jsx b/mpwo_client/src/components/Activities/AddActivity.jsx new file mode 100644 index 00000000..91f65f41 --- /dev/null +++ b/mpwo_client/src/components/Activities/AddActivity.jsx @@ -0,0 +1,114 @@ +import React from 'react' +import { Helmet } from 'react-helmet' +import { connect } from 'react-redux' + +import { addActivity } from '../../actions/activities' +import { getData } from '../../actions/index' +import { history } from '../../index' + + +class AddActivity extends React.Component { + componentDidMount() { + this.props.loadSports() + } + + render() { + const { message, onAddSport, sports } = this.props + + return ( +
{message}
+ )}
+
+