import React from 'react' import { connect } from 'react-redux' import { addActivityWithoutGpx } from '../../../actions/activities' import { history } from '../../../index' function FormWithoutGpx (props) { const { onAddSport, sports } = props return (
event.preventDefault()} >
onAddSport(event)} value="Submit" /> history.go(-1)} value="Cancel" />
) } export default connect( () => ({ }), dispatch => ({ onAddSport: e => { const data = [].slice .call(e.target.form.elements) .reduce(function(map, obj) { if (obj.name) { if (obj.name === 'duration' || obj.name === 'distance') { map[obj.name] = +obj.value } else { map[obj.name] = obj.value } } return map }, {}) dispatch(addActivityWithoutGpx(data)) }, }) )(FormWithoutGpx)