From 2a52b9081d7096abf3cc2e49ba9e68d4f8f16476 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 28 Aug 2019 15:35:22 +0200 Subject: [PATCH] Client - reformat js files w/ prettier --- fittrackee_client/src/actions/activities.js | 221 +++++++------ fittrackee_client/src/actions/index.js | 58 ++-- fittrackee_client/src/actions/stats.js | 6 +- fittrackee_client/src/actions/user.js | 90 +++--- .../components/Activities/ActivitiesList.jsx | 81 ++--- .../src/components/Activities/index.jsx | 21 +- .../src/components/Activity/ActivityAdd.jsx | 21 +- .../components/Activity/ActivityAddOrEdit.jsx | 63 ++-- .../ActivityDisplay/ActivityCardHeader.jsx | 78 ++--- .../ActivityDisplay/ActivityCharts.jsx | 61 ++-- .../ActivityDisplay/ActivityDetails.jsx | 75 ++--- .../Activity/ActivityDisplay/ActivityMap.jsx | 22 +- .../ActivityDisplay/ActivityNoMap.jsx | 6 +- .../ActivityDisplay/ActivityNotes.jsx | 4 +- .../ActivityDisplay/ActivitySegments.jsx | 4 +- .../ActivityDisplay/ActivityWeather.jsx | 24 +- .../Activity/ActivityDisplay/index.jsx | 65 ++-- .../src/components/Activity/ActivityEdit.jsx | 5 +- .../Activity/ActivityForms/FormWithGpx.jsx | 37 ++- .../Activity/ActivityForms/FormWithoutGpx.jsx | 34 +- .../src/components/Activity/index.jsx | 20 +- .../src/components/Admin/Sports/AdminMenu.jsx | 2 +- .../components/Admin/Sports/AdminSport.jsx | 5 +- .../components/Admin/Sports/AdminSports.jsx | 7 +- .../Admin/Sports/AdminSportsAdd.jsx | 18 +- .../components/Admin/generic/AdminDetail.jsx | 171 +++++----- .../components/Admin/generic/AdminPage.jsx | 68 ++-- .../src/components/Admin/index.jsx | 24 +- fittrackee_client/src/components/App.jsx | 78 ++--- .../components/Common/Stats/CustomLabel.jsx | 2 +- .../components/Common/Stats/CustomTooltip.jsx | 20 +- .../components/Common/Stats/StatsChart.jsx | 39 ++- .../src/components/Common/Stats/index.jsx | 19 +- .../src/components/Dashboard/ActivityCard.jsx | 38 ++- .../src/components/Dashboard/Calendar.jsx | 64 ++-- .../src/components/Dashboard/Records.jsx | 90 +++--- .../src/components/Dashboard/Statistics.jsx | 5 +- .../components/Dashboard/UserStatistics.jsx | 3 +- .../src/components/Dashboard/index.jsx | 38 ++- .../src/components/Footer/index.jsx | 6 +- .../src/components/NavBar/index.jsx | 37 +-- .../src/components/Others/AccessDenied.jsx | 4 +- .../src/components/Others/NotFound.jsx | 4 +- .../src/components/Statistics/index.jsx | 72 ++--- .../src/components/User/Form.jsx | 66 ++-- .../src/components/User/Logout.jsx | 6 +- .../src/components/User/Profile.jsx | 61 ++-- .../src/components/User/ProfileEdit.jsx | 306 +++++++++--------- .../src/components/User/UserForm.jsx | 23 +- fittrackee_client/src/fitTrackeeApi/index.js | 5 +- fittrackee_client/src/fitTrackeeApi/user.js | 1 - fittrackee_client/src/index.js | 2 +- fittrackee_client/src/reducers/index.js | 29 +- .../src/registerServiceWorker.js | 6 +- fittrackee_client/src/utils/activities.js | 10 +- fittrackee_client/src/utils/index.js | 20 +- fittrackee_client/src/utils/stats.js | 55 ++-- 57 files changed, 1148 insertions(+), 1252 deletions(-) diff --git a/fittrackee_client/src/actions/activities.js b/fittrackee_client/src/actions/activities.js index 80785f8e..8228c26f 100644 --- a/fittrackee_client/src/actions/activities.js +++ b/fittrackee_client/src/actions/activities.js @@ -29,155 +29,154 @@ export const setChartData = chartData => ({ chartData, }) -export const addActivity = form => dispatch => FitTrackeeGenericApi - .addDataWithFile('activities', form) - .then(ret => { - if (ret.status === 'created') { - if (ret.data.activities.length === 0) { +export const addActivity = form => dispatch => + FitTrackeeGenericApi.addDataWithFile('activities', form) + .then(ret => { + if (ret.status === 'created') { + if (ret.data.activities.length === 0) { dispatch(setError('activities: no correct file')) - } else if (ret.data.activities.length === 1) { + } else if (ret.data.activities.length === 1) { dispatch(loadProfile()) history.push(`/activities/${ret.data.activities[0].id}`) - } else { // ret.data.activities.length > 1 + } else { + // ret.data.activities.length > 1 dispatch(loadProfile()) history.push('/') + } + } else { + dispatch(setError(`activities: ${ret.message}`)) } - } else { - dispatch(setError(`activities: ${ret.message}`)) - } - dispatch(setLoading(false)) - }) - .catch(error => dispatch(setError(`activities: ${error}`))) + dispatch(setLoading(false)) + }) + .catch(error => dispatch(setError(`activities: ${error}`))) - -export const addActivityWithoutGpx = form => dispatch => FitTrackeeGenericApi - .addData('activities/no_gpx', form) - .then(ret => { - if (ret.status === 'created') { - dispatch(loadProfile()) - history.push(`/activities/${ret.data.activities[0].id}`) - } else { - dispatch(setError(`activities: ${ret.message}`)) - } - }) - .catch(error => dispatch(setError(`activities: ${error}`))) - - -export const getActivityGpx = activityId => dispatch => { - if (activityId) { - return FitTrackeeGenericApi - .getData(`activities/${activityId}/gpx`) +export const addActivityWithoutGpx = form => dispatch => + FitTrackeeGenericApi.addData('activities/no_gpx', form) .then(ret => { - if (ret.status === 'success') { - dispatch(setGpx(ret.data.gpx)) + if (ret.status === 'created') { + dispatch(loadProfile()) + history.push(`/activities/${ret.data.activities[0].id}`) } else { dispatch(setError(`activities: ${ret.message}`)) } }) .catch(error => dispatch(setError(`activities: ${error}`))) + +export const getActivityGpx = activityId => dispatch => { + if (activityId) { + return FitTrackeeGenericApi.getData(`activities/${activityId}/gpx`) + .then(ret => { + if (ret.status === 'success') { + dispatch(setGpx(ret.data.gpx)) + } else { + dispatch(setError(`activities: ${ret.message}`)) + } + }) + .catch(error => dispatch(setError(`activities: ${error}`))) } dispatch(setGpx(null)) } export const getSegmentGpx = (activityId, segmentId) => dispatch => { if (activityId) { - return FitTrackeeGenericApi - .getData(`activities/${activityId}/gpx/segment/${segmentId}`) - .then(ret => { - if (ret.status === 'success') { - dispatch(setGpx(ret.data.gpx)) - } else { - dispatch(setError(`activities: ${ret.message}`)) - } - }) - .catch(error => dispatch(setError(`activities: ${error}`))) + return FitTrackeeGenericApi.getData( + `activities/${activityId}/gpx/segment/${segmentId}` + ) + .then(ret => { + if (ret.status === 'success') { + dispatch(setGpx(ret.data.gpx)) + } else { + dispatch(setError(`activities: ${ret.message}`)) + } + }) + .catch(error => dispatch(setError(`activities: ${error}`))) } dispatch(setGpx(null)) } - export const getActivityChartData = activityId => dispatch => { if (activityId) { - return FitTrackeeGenericApi - .getData(`activities/${activityId}/chart_data`) - .then(ret => { - if (ret.status === 'success') { - dispatch(setChartData(formatChartData(ret.data.chart_data))) - } else { - dispatch(setError(`activities: ${ret.message}`)) - } - }) - .catch(error => dispatch(setError(`activities: ${error}`))) + return FitTrackeeGenericApi.getData(`activities/${activityId}/chart_data`) + .then(ret => { + if (ret.status === 'success') { + dispatch(setChartData(formatChartData(ret.data.chart_data))) + } else { + dispatch(setError(`activities: ${ret.message}`)) + } + }) + .catch(error => dispatch(setError(`activities: ${error}`))) } dispatch(setChartData(null)) } export const getSegmentChartData = (activityId, segmentId) => dispatch => { if (activityId) { - return FitTrackeeGenericApi - .getData(`activities/${activityId}/chart_data/segment/${segmentId}`) + return FitTrackeeGenericApi.getData( + `activities/${activityId}/chart_data/segment/${segmentId}` + ) + .then(ret => { + if (ret.status === 'success') { + dispatch(setChartData(formatChartData(ret.data.chart_data))) + } else { + dispatch(setError(`activities: ${ret.message}`)) + } + }) + .catch(error => dispatch(setError(`activities: ${error}`))) + } + dispatch(setChartData(null)) +} + +export const deleteActivity = id => dispatch => + FitTrackeeGenericApi.deleteData('activities', id) + .then(ret => { + if (ret.status === 204) { + Promise.resolve(dispatch(removeActivity(id))) + .then(() => dispatch(loadProfile())) + .then(() => history.push('/')) + } else { + dispatch(setError(`activities: ${ret.status}`)) + } + }) + .catch(error => dispatch(setError(`activities: ${error}`))) + +export const editActivity = form => dispatch => + FitTrackeeGenericApi.updateData('activities', form) .then(ret => { if (ret.status === 'success') { - dispatch(setChartData(formatChartData(ret.data.chart_data))) + dispatch(loadProfile()) + history.push(`/activities/${ret.data.activities[0].id}`) + } else { + dispatch(setError(`activities: ${ret.message}`)) + } + dispatch(setLoading(false)) + }) + .catch(error => dispatch(setError(`activities: ${error}`))) + +export const getMoreActivities = params => dispatch => + FitTrackeeGenericApi.getData('activities', params) + .then(ret => { + if (ret.status === 'success') { + if (ret.data.activities.length > 0) { + dispatch(pushActivities(ret.data.activities)) + } } else { dispatch(setError(`activities: ${ret.message}`)) } }) .catch(error => dispatch(setError(`activities: ${error}`))) - } - dispatch(setChartData(null)) -} - - -export const deleteActivity = id => dispatch => FitTrackeeGenericApi - .deleteData('activities', id) - .then(ret => { - if (ret.status === 204) { - Promise.resolve(dispatch(removeActivity(id))).then(() => - dispatch(loadProfile()) - ).then(() => history.push('/')) - } else { - dispatch(setError(`activities: ${ret.status}`)) - } - }) - .catch(error => dispatch(setError(`activities: ${error}`))) - - -export const editActivity = form => dispatch => FitTrackeeGenericApi - .updateData('activities', form) - .then(ret => { - if (ret.status === 'success') { - dispatch(loadProfile()) - history.push(`/activities/${ret.data.activities[0].id}`) - } else { - dispatch(setError(`activities: ${ret.message}`)) - } - dispatch(setLoading(false)) - }) - .catch(error => dispatch(setError(`activities: ${error}`))) - - -export const getMoreActivities = params => dispatch => FitTrackeeGenericApi - .getData('activities', params) - .then(ret => { - if (ret.status === 'success') { - if (ret.data.activities.length > 0) { - dispatch(pushActivities(ret.data.activities)) - } - } else { - dispatch(setError(`activities: ${ret.message}`)) - } - }) - .catch(error => dispatch(setError(`activities: ${error}`))) export const getMonthActivities = (from, to) => dispatch => - FitTrackeeGenericApi - .getData('activities', { from, to, order: 'asc', per_page: 100 }) - .then(ret => { - if (ret.status === 'success') { - dispatch(updateCalendar(ret.data.activities)) - } else { - dispatch(setError(`activities: ${ret.message}`)) - } + FitTrackeeGenericApi.getData('activities', { + from, + to, + order: 'asc', + per_page: 100, }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .then(ret => { + if (ret.status === 'success') { + dispatch(updateCalendar(ret.data.activities)) + } else { + dispatch(setError(`activities: ${ret.message}`)) + } + }) + .catch(error => dispatch(setError(`activities: ${error}`))) diff --git a/fittrackee_client/src/actions/index.js b/fittrackee_client/src/actions/index.js index 132536ec..89473d32 100644 --- a/fittrackee_client/src/actions/index.js +++ b/fittrackee_client/src/actions/index.js @@ -1,7 +1,6 @@ import FitTrackeeApi from '../fitTrackeeApi/index' import { history } from '../index' - export const setData = (target, data) => ({ type: 'SET_DATA', data, @@ -15,7 +14,7 @@ export const setError = message => ({ export const setLoading = loading => ({ type: 'SET_LOADING', - loading + loading, }) export const getOrUpdateData = (action, target, data) => dispatch => { @@ -23,39 +22,38 @@ export const getOrUpdateData = (action, target, data) => dispatch => { return dispatch(setError(target, `${target}: Incorrect id`)) } return FitTrackeeApi[action](target, data) - .then(ret => { - if (ret.status === 'success') { - dispatch(setData(target, ret.data)) - } else { - dispatch(setError(`${target}: ${ret.message || ret.status}`)) - } - }) - .catch(error => dispatch(setError(`${target}: ${error}`))) + .then(ret => { + if (ret.status === 'success') { + dispatch(setData(target, ret.data)) + } else { + dispatch(setError(`${target}: ${ret.message || ret.status}`)) + } + }) + .catch(error => dispatch(setError(`${target}: ${error}`))) } -export const addData = (target, data) => dispatch => FitTrackeeApi - .addData(target, data) - .then(ret => { - if (ret.status === 'created') { - history.push(`/admin/${target}`) - } else { - dispatch(setError(`${target}: ${ret.status}`)) - } - }) - .catch(error => dispatch(setError(`${target}: ${error}`))) +export const addData = (target, data) => dispatch => + FitTrackeeApi.addData(target, data) + .then(ret => { + if (ret.status === 'created') { + history.push(`/admin/${target}`) + } else { + dispatch(setError(`${target}: ${ret.status}`)) + } + }) + .catch(error => dispatch(setError(`${target}: ${error}`))) export const deleteData = (target, id) => dispatch => { if (isNaN(id)) { return dispatch(setError(target, `${target}: Incorrect id`)) } - return FitTrackeeApi - .deleteData(target, id) - .then(ret => { - if (ret.status === 204) { - history.push(`/admin/${target}`) - } else { - dispatch(setError(`${target}: ${ret.message || ret.status}`)) - } - }) - .catch(error => dispatch(setError(`${target}: ${error}`))) + return FitTrackeeApi.deleteData(target, id) + .then(ret => { + if (ret.status === 204) { + history.push(`/admin/${target}`) + } else { + dispatch(setError(`${target}: ${ret.message || ret.status}`)) + } + }) + .catch(error => dispatch(setError(`${target}: ${error}`))) } diff --git a/fittrackee_client/src/actions/stats.js b/fittrackee_client/src/actions/stats.js index ef2c7c6b..de23f754 100644 --- a/fittrackee_client/src/actions/stats.js +++ b/fittrackee_client/src/actions/stats.js @@ -1,11 +1,11 @@ import FitTrackeeGenericApi from '../fitTrackeeApi' import { setData, setError } from './index' -export const getStats = (userId, type, data) => dispatch => FitTrackeeGenericApi - .getData(`stats/${userId}/${type}`, data) +export const getStats = (userId, type, data) => dispatch => + FitTrackeeGenericApi.getData(`stats/${userId}/${type}`, data) .then(ret => { if (ret.status === 'success') { - dispatch(setData('statistics', ret.data)) + dispatch(setData('statistics', ret.data)) } else { dispatch(setError(`statistics: ${ret.message}`)) } diff --git a/fittrackee_client/src/actions/user.js b/fittrackee_client/src/actions/user.js index d6170aeb..87f3026f 100644 --- a/fittrackee_client/src/actions/user.js +++ b/fittrackee_client/src/actions/user.js @@ -4,7 +4,6 @@ import { history } from '../index' import { generateIds } from '../utils' import { getOrUpdateData } from './index' - const AuthError = message => ({ type: 'AUTH_ERROR', message }) const AuthErrors = messages => ({ type: 'AUTH_ERRORS', messages }) @@ -16,7 +15,8 @@ const ProfileSuccess = profil => ({ type: 'PROFILE_SUCCESS', profil }) const ProfileError = message => ({ type: 'PROFILE_ERROR', message }) const ProfileUpdateError = message => ({ - type: 'PROFILE_UPDATE_ERROR', message + type: 'PROFILE_UPDATE_ERROR', + message, }) export const logout = () => ({ type: 'LOGOUT' }) @@ -28,32 +28,32 @@ export const loadProfile = () => dispatch => { return { type: 'LOGOUT' } } -export const getProfile = () => dispatch => FitTrackeeGenericApi - .getData('auth/profile') - .then(ret => { - if (ret.status === 'success') { - dispatch(getOrUpdateData('getData', 'sports')) - ret.data.isAuthenticated = true - return dispatch(ProfileSuccess(ret.data)) - } - return dispatch(ProfileError(ret.message)) - }) - .catch(error => { - throw error - }) +export const getProfile = () => dispatch => + FitTrackeeGenericApi.getData('auth/profile') + .then(ret => { + if (ret.status === 'success') { + dispatch(getOrUpdateData('getData', 'sports')) + ret.data.isAuthenticated = true + return dispatch(ProfileSuccess(ret.data)) + } + return dispatch(ProfileError(ret.message)) + }) + .catch(error => { + throw error + }) -export const loginOrRegister = (target, formData) => dispatch => FitTrackeeApi - .loginOrRegister(target, formData) - .then(ret => { - if (ret.status === 'success') { - window.localStorage.setItem('authToken', ret.auth_token) - return dispatch(getProfile()) - } - return dispatch(AuthError(ret.message)) - }) - .catch(error => { - throw error - }) +export const loginOrRegister = (target, formData) => dispatch => + FitTrackeeApi.loginOrRegister(target, formData) + .then(ret => { + if (ret.status === 'success') { + window.localStorage.setItem('authToken', ret.auth_token) + return dispatch(getProfile()) + } + return dispatch(AuthError(ret.message)) + }) + .catch(error => { + throw error + }) const RegisterFormControl = formData => { const errMsg = [] @@ -61,7 +61,7 @@ const RegisterFormControl = formData => { errMsg.push('Username: 3 to 12 characters required.') } if (formData.password !== formData.password_conf) { - errMsg.push('Password and password confirmation don\'t match.') + errMsg.push("Password and password confirmation don't match.") } if (formData.password.length < 8) { errMsg.push('Password: 8 characters required.') @@ -81,13 +81,12 @@ export const handleUserFormSubmit = (formData, formType) => dispatch => { export const handleProfileFormSubmit = formData => dispatch => { if (!formData.password === formData.password_conf) { - return dispatch(ProfileUpdateError( - 'Password and password confirmation don\'t match.' - )) + return dispatch( + ProfileUpdateError("Password and password confirmation don't match.") + ) } delete formData.id - return FitTrackeeGenericApi - .postData('auth/profile/edit', formData) + return FitTrackeeGenericApi.postData('auth/profile/edit', formData) .then(ret => { if (ret.status === 'success') { dispatch(getProfile()) @@ -105,8 +104,7 @@ export const uploadPicture = event => dispatch => { const form = new FormData() form.append('file', event.target.picture.files[0]) event.target.reset() - return FitTrackeeGenericApi - .addDataWithFile('auth/picture', form) + return FitTrackeeGenericApi.addDataWithFile('auth/picture', form) .then(ret => { if (ret.status === 'success') { return dispatch(getProfile()) @@ -118,14 +116,14 @@ export const uploadPicture = event => dispatch => { }) } -export const deletePicture = () => dispatch => FitTrackeeApi - .deletePicture() - .then(ret => { - if (ret.status === 204) { - return dispatch(getProfile()) - } - return dispatch(PictureError(ret.message)) - }) - .catch(error => { - throw error - }) +export const deletePicture = () => dispatch => + FitTrackeeApi.deletePicture() + .then(ret => { + if (ret.status === 204) { + return dispatch(getProfile()) + } + return dispatch(PictureError(ret.message)) + }) + .catch(error => { + throw error + }) diff --git a/fittrackee_client/src/components/Activities/ActivitiesList.jsx b/fittrackee_client/src/components/Activities/ActivitiesList.jsx index 69e9e8c4..7cb607c8 100644 --- a/fittrackee_client/src/components/Activities/ActivitiesList.jsx +++ b/fittrackee_client/src/components/Activities/ActivitiesList.jsx @@ -12,48 +12,49 @@ export default class ActivitiesList extends React.PureComponent {
- - - - - - - - + + + + + + + + - {sports && activities.map((activity, idx) => ( - // eslint-disable-next-line react/no-array-index-key - - - - - - - - - - ))} + {sports && + activities.map((activity, idx) => ( + // eslint-disable-next-line react/no-array-index-key + + + + + + + + + + ))}
- WorkoutDateDistanceDurationAve. speedMax. speed
+ WorkoutDateDistanceDurationAve. speedMax. speed
- s.id === activity.sport_id) - .map(s => s.img)} - alt="activity sport logo" - /> - - - {activity.title} - - - {format( - getDateWithTZ(activity.activity_date, user.timezone), - 'dd/MM/yyyy HH:mm' - )} - - {Number(activity.distance).toFixed(2)} km - {activity.moving}{activity.ave_speed} km/h{activity.max_speed} km/h
+ s.id === activity.sport_id) + .map(s => s.img)} + alt="activity sport logo" + /> + + + {activity.title} + + + {format( + getDateWithTZ(activity.activity_date, user.timezone), + 'dd/MM/yyyy HH:mm' + )} + + {Number(activity.distance).toFixed(2)} km + {activity.moving}{activity.ave_speed} km/h{activity.max_speed} km/h
diff --git a/fittrackee_client/src/components/Activities/index.jsx b/fittrackee_client/src/components/Activities/index.jsx index 69b9c11e..608da64b 100644 --- a/fittrackee_client/src/components/Activities/index.jsx +++ b/fittrackee_client/src/components/Activities/index.jsx @@ -8,7 +8,6 @@ import ActivitiesList from './ActivitiesList' import { getOrUpdateData } from '../../actions' import { getMoreActivities } from '../../actions/activities' - class Activities extends React.Component { constructor(props, context) { super(props, context) @@ -36,12 +35,18 @@ class Activities extends React.Component { } render() { const { - activities, loadActivities, loadMoreActivities, message, sports, user + activities, + loadActivities, + loadMoreActivities, + message, + sports, + user, } = this.props const { params } = this.state - const paginationEnd = activities.length > 0 - ? activities[activities.length - 1].previous_activity === null - : true + const paginationEnd = + activities.length > 0 + ? activities[activities.length - 1].previous_activity === null + : true return (
@@ -65,7 +70,7 @@ class Activities extends React.Component { sports={sports} user={user} /> - {!paginationEnd && + {!paginationEnd && ( - } + )} {activities.length === 0 && (
- No workouts. {' '} + No workouts.{' '} Upload one ! diff --git a/fittrackee_client/src/components/Activity/ActivityAdd.jsx b/fittrackee_client/src/components/Activity/ActivityAdd.jsx index 77526ec9..777d09c8 100644 --- a/fittrackee_client/src/components/Activity/ActivityAdd.jsx +++ b/fittrackee_client/src/components/Activity/ActivityAdd.jsx @@ -3,24 +3,17 @@ import { connect } from 'react-redux' import ActivityAddOrEdit from './ActivityAddOrEdit' - -function ActivityAdd (props) { +function ActivityAdd(props) { const { message, sports } = props return (
- +
) } -export default connect( - state => ({ - message: state.message, - sports: state.sports.data, - user: state.user, - }), -)(ActivityAdd) +export default connect(state => ({ + message: state.message, + sports: state.sports.data, + user: state.user, +}))(ActivityAdd) diff --git a/fittrackee_client/src/components/Activity/ActivityAddOrEdit.jsx b/fittrackee_client/src/components/Activity/ActivityAddOrEdit.jsx index fdde8d19..83f7ec7b 100644 --- a/fittrackee_client/src/components/Activity/ActivityAddOrEdit.jsx +++ b/fittrackee_client/src/components/Activity/ActivityAddOrEdit.jsx @@ -13,11 +13,12 @@ class ActivityAddEdit extends React.Component { } } - handleRadioChange (changeEvent) { + handleRadioChange(changeEvent) { this.setState({ withGpx: changeEvent.target.name === 'withGpx' - ? changeEvent.target.value : !changeEvent.target.value + ? changeEvent.target.value + : !changeEvent.target.value, }) } @@ -27,15 +28,13 @@ class ActivityAddEdit extends React.Component { return (
- FitTrackee - {activity - ? 'Edit a workout' - : 'Add a workout'} - + + FitTrackee - {activity ? 'Edit a workout' : 'Add a workout'} + -

- {message && ( - {message} - )} +
+
+ {message && {message}}
@@ -57,27 +56,31 @@ class ActivityAddEdit extends React.Component {
@@ -101,8 +104,6 @@ class ActivityAddEdit extends React.Component { } } -export default connect( - state => ({ - loading: state.loading - }), -)(ActivityAddEdit) +export default connect(state => ({ + loading: state.loading, +}))(ActivityAddEdit) diff --git a/fittrackee_client/src/components/Activity/ActivityDisplay/ActivityCardHeader.jsx b/fittrackee_client/src/components/Activity/ActivityDisplay/ActivityCardHeader.jsx index e19049b5..81b66ac7 100644 --- a/fittrackee_client/src/components/Activity/ActivityDisplay/ActivityCardHeader.jsx +++ b/fittrackee_client/src/components/Activity/ActivityDisplay/ActivityCardHeader.jsx @@ -4,26 +4,30 @@ import { Link } from 'react-router-dom' import { getDateWithTZ } from '../../../utils' import { formatActivityDate } from '../../../utils/activities' - export default function ActivityCardHeader(props) { const { - activity, dataType, displayModal, segmentId, sport, title, user + activity, + dataType, + displayModal, + segmentId, + sport, + title, + user, } = props const activityDate = activity - ? formatActivityDate( - getDateWithTZ(activity.activity_date, user.timezone) - ) + ? formatActivityDate(getDateWithTZ(activity.activity_date, user.timezone)) : null - const previousUrl = dataType === 'segment' && segmentId !== 1 - ? `/activities/${activity.id}/segment/${segmentId - 1}` - : dataType === 'activity' && activity.previous_activity + const previousUrl = + dataType === 'segment' && segmentId !== 1 + ? `/activities/${activity.id}/segment/${segmentId - 1}` + : dataType === 'activity' && activity.previous_activity ? `/activities/${activity.previous_activity}` : null - const nextUrl = - dataType === 'segment' && segmentId < activity.segments.length - ? `/activities/${activity.id}/segment/${segmentId + 1}` - : dataType === 'activity' && activity.next_activity + const nextUrl = + dataType === 'segment' && segmentId < activity.segments.length + ? `/activities/${activity.id}/segment/${segmentId + 1}` + : dataType === 'activity' && activity.next_activity ? `/activities/${activity.next_activity}` : null @@ -32,10 +36,7 @@ export default function ActivityCardHeader(props) {
{previousUrl ? ( - +