Client - reformat js files w/ prettier

This commit is contained in:
Sam
2019-08-28 15:35:22 +02:00
parent c8ea44eecc
commit 2a52b9081d
57 changed files with 1148 additions and 1252 deletions

View File

@ -6,11 +6,8 @@ import { addActivity, editActivity } from '../../../actions/activities'
import { history } from '../../../index'
import { gpxLimit } from '../../../utils'
function FormWithGpx (props) {
const {
activity, loading, onAddActivity, onEditActivity, sports
} = props
function FormWithGpx(props) {
const { activity, loading, onAddActivity, onEditActivity, sports } = props
const sportId = activity ? activity.sport_id : ''
return (
<form
@ -52,9 +49,10 @@ function FormWithGpx (props) {
) : (
<div className="form-group">
<label>
<strong>gpx</strong> file or <strong>zip</strong>{' '}
file containing <strong>gpx</strong> (no folder inside, {
gpxLimit} files max):
{/* prettier-ignore */}
<strong>gpx</strong> file or <strong>zip</strong> file containing
{/* prettier-ignore */}
<strong> gpx</strong> (no folder inside, {gpxLimit} files max):
<input
accept=".gpx, .zip"
className="form-control form-control-file gpx-file"
@ -85,10 +83,8 @@ function FormWithGpx (props) {
<input
type="submit"
className="btn btn-primary btn-lg btn-block"
onClick={
event => activity
? onEditActivity(event, activity)
: onAddActivity(event)
onClick={event =>
activity ? onEditActivity(event, activity) : onAddActivity(event)
}
value="Submit"
/>
@ -106,13 +102,14 @@ function FormWithGpx (props) {
export default connect(
state => ({
loading: state.loading
loading: state.loading,
}),
dispatch => ({
onAddActivity: e => {
dispatch(setLoading(true))
const form = new FormData()
form.append('file', e.target.form.gpxFile.files[0])
/* prettier-ignore */
form.append(
'data',
`{"sport_id": ${e.target.form.sport.value
@ -121,12 +118,14 @@ export default connect(
dispatch(addActivity(form))
},
onEditActivity: (e, activity) => {
dispatch(editActivity({
id: activity.id,
notes: e.target.form.notes.value,
sport_id: +e.target.form.sport.value,
title: e.target.form.title.value,
}))
dispatch(
editActivity({
id: activity.id,
notes: e.target.form.notes.value,
sport_id: +e.target.form.sport.value,
title: e.target.form.title.value,
})
)
},
})
)(FormWithGpx)

View File

@ -2,14 +2,17 @@ import React from 'react'
import { connect } from 'react-redux'
import {
addActivityWithoutGpx, editActivity
addActivityWithoutGpx,
editActivity,
} from '../../../actions/activities'
import { history } from '../../../index'
import { formatActivityDate } from '../../../utils/activities'
function FormWithoutGpx (props) {
function FormWithoutGpx(props) {
const { activity, onAddOrEdit, sports } = props
let activityDate, activityTime, sportId = ''
let activityDate,
activityTime,
sportId = ''
if (activity) {
const activityDateTime = formatActivityDate(
activity.activity_date,
@ -21,9 +24,7 @@ function FormWithoutGpx (props) {
}
return (
<form
onSubmit={event => event.preventDefault()}
>
<form onSubmit={event => event.preventDefault()}>
<div className="form-group">
<label>
Title:
@ -78,15 +79,15 @@ function FormWithoutGpx (props) {
<div className="form-group">
<label>
Duration:
<input
name="duration"
defaultValue={activity ? activity.duration : ''}
className="form-control col-xs-4"
pattern="^([0-9]*[0-9]):([0-5][0-9]):([0-5][0-9])$"
placeholder="hh:mm:ss"
required
type="text"
/>
<input
name="duration"
defaultValue={activity ? activity.duration : ''}
className="form-control col-xs-4"
pattern="^([0-9]*[0-9]):([0-5][0-9]):([0-5][0-9])$"
placeholder="hh:mm:ss"
required
type="text"
/>
</label>
</div>
<div className="form-group">
@ -131,12 +132,13 @@ function FormWithoutGpx (props) {
}
export default connect(
() => ({ }),
() => ({}),
dispatch => ({
onAddOrEdit: (e, activity) => {
const d = e.target.form.duration.value.split(':')
const duration = +d[0] * 60 * 60 + +d[1] * 60 + +d[2]
/* prettier-ignore */
const activityDate = `${e.target.form.activity_date.value
} ${ e.target.form.activity_time.value}`