import React from 'react' import { connect } from 'react-redux' import { addActivity } from '../../../actions/activities' import { history } from '../../../index' function FormWithGpx (props) { const { onAddSport, sports } = props return (
event.preventDefault()} >
onAddSport(event)} value="Submit" /> history.go(-1)} value="Cancel" />
) } export default connect( () => ({ }), dispatch => ({ onAddSport: event => { const form = new FormData() form.append('file', event.target.form.gpxFile.files[0]) form.append( 'data', `{"sport_id": ${event.target.form.sport.value}}` ) dispatch(addActivity(form)) }, }) )(FormWithGpx)