Client - lint fix after prettier update

This commit is contained in:
Sam 2021-05-22 17:25:14 +02:00
parent 5b49928c84
commit 2fd2cd5c16
6 changed files with 56 additions and 82 deletions

View File

@ -45,41 +45,40 @@ export const updateUsersData = data => ({
data,
})
export const getOrUpdateData = (
action,
target,
data,
canDispatch = true
) => dispatch => {
dispatch(setLoading(true))
if (data && data.id && target !== 'workouts' && isNaN(data.id)) {
dispatch(setLoading(false))
return dispatch(setError(`${target}|Incorrect id`))
}
dispatch(emptyMessages())
return FitTrackeeApi[action](target, data)
.then(ret => {
if (ret.status === 'success') {
if (canDispatch) {
if (target === 'users' && action === 'getData') {
return dispatch(setPaginatedData(target, ret.data, ret.pagination))
export const getOrUpdateData =
(action, target, data, canDispatch = true) =>
dispatch => {
dispatch(setLoading(true))
if (data && data.id && target !== 'workouts' && isNaN(data.id)) {
dispatch(setLoading(false))
return dispatch(setError(`${target}|Incorrect id`))
}
dispatch(emptyMessages())
return FitTrackeeApi[action](target, data)
.then(ret => {
if (ret.status === 'success') {
if (canDispatch) {
if (target === 'users' && action === 'getData') {
return dispatch(
setPaginatedData(target, ret.data, ret.pagination)
)
}
dispatch(setData(target, ret.data))
} else if (action === 'updateData' && target === 'sports') {
dispatch(updateSportsData(ret.data.sports[0]))
} else if (action === 'updateData' && target === 'users') {
dispatch(updateUsersData(ret.data.users[0]))
}
dispatch(setData(target, ret.data))
} else if (action === 'updateData' && target === 'sports') {
dispatch(updateSportsData(ret.data.sports[0]))
} else if (action === 'updateData' && target === 'users') {
dispatch(updateUsersData(ret.data.users[0]))
} else {
dispatch(setError(`${target}|${ret.message || ret.status}`))
}
} else {
dispatch(setError(`${target}|${ret.message || ret.status}`))
}
dispatch(setLoading(false))
})
.catch(error => {
dispatch(setLoading(false))
dispatch(setError(`${target}|${error}`))
})
}
dispatch(setLoading(false))
})
.catch(error => {
dispatch(setLoading(false))
dispatch(setError(`${target}|${error}`))
})
}
export const addData = (target, data) => dispatch =>
FitTrackeeApi.addData(target, data)

View File

@ -154,19 +154,21 @@ export const deletePicture = () => dispatch =>
throw error
})
export const deleteUser = (username, isAdmin = false) => dispatch =>
FitTrackeeGenericApi.deleteData('users', username)
.then(ret => {
if (ret.status === 204) {
dispatch(getAppData('config'))
if (isAdmin) {
history.push('/admin/users')
export const deleteUser =
(username, isAdmin = false) =>
dispatch =>
FitTrackeeGenericApi.deleteData('users', username)
.then(ret => {
if (ret.status === 204) {
dispatch(getAppData('config'))
if (isAdmin) {
history.push('/admin/users')
} else {
dispatch(logout())
history.push('/')
}
} else {
dispatch(logout())
history.push('/')
ret.json().then(r => dispatch(setError(`${r.message}`)))
}
} else {
ret.json().then(r => dispatch(setError(`${r.message}`)))
}
})
.catch(error => dispatch(setError(`user|${error}`)))
})
.catch(error => dispatch(setError(`user|${error}`)))

View File

@ -57,15 +57,8 @@ class AdminUsers extends React.Component {
}
render() {
const {
authUser,
location,
message,
t,
pagination,
updateUser,
users,
} = this.props
const { authUser, location, message, t, pagination, updateUser, users } =
this.props
const translatedFilters = translateValues(t, userFilters)
const translatedSortOrders = translateValues(t, sortOrders)
return (

View File

@ -26,15 +26,8 @@ class DashBoard extends React.Component {
}
render() {
const {
loadMoreWorkouts,
message,
records,
sports,
t,
user,
workouts,
} = this.props
const { loadMoreWorkouts, message, records, sports, t, user, workouts } =
this.props
const paginationEnd =
workouts.length > 0
? workouts[workouts.length - 1].previous_workout === null

View File

@ -61,13 +61,8 @@ class ProfileEdit extends React.Component {
}
render() {
const {
message,
onDeleteUser,
onHandleProfileFormSubmit,
t,
user,
} = this.props
const { message, onDeleteUser, onHandleProfileFormSubmit, t, user } =
this.props
const { displayModal, formData } = this.state
return (
<div>

View File

@ -5,16 +5,8 @@ import { getDateWithTZ } from '../../../utils'
import { formatWorkoutDate } from '../../../utils/workouts'
export default function WorkoutCardHeader(props) {
const {
dataType,
displayModal,
segmentId,
sport,
t,
title,
user,
workout,
} = props
const { dataType, displayModal, segmentId, sport, t, title, user, workout } =
props
const workoutDate = workout
? formatWorkoutDate(getDateWithTZ(workout.workout_date, user.timezone))
: null