Client - lint fix after prettier update
This commit is contained in:
parent
5b49928c84
commit
2fd2cd5c16
@ -45,41 +45,40 @@ export const updateUsersData = data => ({
|
|||||||
data,
|
data,
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getOrUpdateData = (
|
export const getOrUpdateData =
|
||||||
action,
|
(action, target, data, canDispatch = true) =>
|
||||||
target,
|
dispatch => {
|
||||||
data,
|
dispatch(setLoading(true))
|
||||||
canDispatch = true
|
if (data && data.id && target !== 'workouts' && isNaN(data.id)) {
|
||||||
) => dispatch => {
|
dispatch(setLoading(false))
|
||||||
dispatch(setLoading(true))
|
return dispatch(setError(`${target}|Incorrect id`))
|
||||||
if (data && data.id && target !== 'workouts' && isNaN(data.id)) {
|
}
|
||||||
dispatch(setLoading(false))
|
dispatch(emptyMessages())
|
||||||
return dispatch(setError(`${target}|Incorrect id`))
|
return FitTrackeeApi[action](target, data)
|
||||||
}
|
.then(ret => {
|
||||||
dispatch(emptyMessages())
|
if (ret.status === 'success') {
|
||||||
return FitTrackeeApi[action](target, data)
|
if (canDispatch) {
|
||||||
.then(ret => {
|
if (target === 'users' && action === 'getData') {
|
||||||
if (ret.status === 'success') {
|
return dispatch(
|
||||||
if (canDispatch) {
|
setPaginatedData(target, ret.data, ret.pagination)
|
||||||
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 {
|
||||||
} else if (action === 'updateData' && target === 'sports') {
|
dispatch(setError(`${target}|${ret.message || ret.status}`))
|
||||||
dispatch(updateSportsData(ret.data.sports[0]))
|
|
||||||
} else if (action === 'updateData' && target === 'users') {
|
|
||||||
dispatch(updateUsersData(ret.data.users[0]))
|
|
||||||
}
|
}
|
||||||
} else {
|
dispatch(setLoading(false))
|
||||||
dispatch(setError(`${target}|${ret.message || ret.status}`))
|
})
|
||||||
}
|
.catch(error => {
|
||||||
dispatch(setLoading(false))
|
dispatch(setLoading(false))
|
||||||
})
|
dispatch(setError(`${target}|${error}`))
|
||||||
.catch(error => {
|
})
|
||||||
dispatch(setLoading(false))
|
}
|
||||||
dispatch(setError(`${target}|${error}`))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const addData = (target, data) => dispatch =>
|
export const addData = (target, data) => dispatch =>
|
||||||
FitTrackeeApi.addData(target, data)
|
FitTrackeeApi.addData(target, data)
|
||||||
|
@ -154,19 +154,21 @@ export const deletePicture = () => dispatch =>
|
|||||||
throw error
|
throw error
|
||||||
})
|
})
|
||||||
|
|
||||||
export const deleteUser = (username, isAdmin = false) => dispatch =>
|
export const deleteUser =
|
||||||
FitTrackeeGenericApi.deleteData('users', username)
|
(username, isAdmin = false) =>
|
||||||
.then(ret => {
|
dispatch =>
|
||||||
if (ret.status === 204) {
|
FitTrackeeGenericApi.deleteData('users', username)
|
||||||
dispatch(getAppData('config'))
|
.then(ret => {
|
||||||
if (isAdmin) {
|
if (ret.status === 204) {
|
||||||
history.push('/admin/users')
|
dispatch(getAppData('config'))
|
||||||
|
if (isAdmin) {
|
||||||
|
history.push('/admin/users')
|
||||||
|
} else {
|
||||||
|
dispatch(logout())
|
||||||
|
history.push('/')
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dispatch(logout())
|
ret.json().then(r => dispatch(setError(`${r.message}`)))
|
||||||
history.push('/')
|
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
ret.json().then(r => dispatch(setError(`${r.message}`)))
|
.catch(error => dispatch(setError(`user|${error}`)))
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => dispatch(setError(`user|${error}`)))
|
|
||||||
|
@ -57,15 +57,8 @@ class AdminUsers extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { authUser, location, message, t, pagination, updateUser, users } =
|
||||||
authUser,
|
this.props
|
||||||
location,
|
|
||||||
message,
|
|
||||||
t,
|
|
||||||
pagination,
|
|
||||||
updateUser,
|
|
||||||
users,
|
|
||||||
} = this.props
|
|
||||||
const translatedFilters = translateValues(t, userFilters)
|
const translatedFilters = translateValues(t, userFilters)
|
||||||
const translatedSortOrders = translateValues(t, sortOrders)
|
const translatedSortOrders = translateValues(t, sortOrders)
|
||||||
return (
|
return (
|
||||||
|
@ -26,15 +26,8 @@ class DashBoard extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { loadMoreWorkouts, message, records, sports, t, user, workouts } =
|
||||||
loadMoreWorkouts,
|
this.props
|
||||||
message,
|
|
||||||
records,
|
|
||||||
sports,
|
|
||||||
t,
|
|
||||||
user,
|
|
||||||
workouts,
|
|
||||||
} = this.props
|
|
||||||
const paginationEnd =
|
const paginationEnd =
|
||||||
workouts.length > 0
|
workouts.length > 0
|
||||||
? workouts[workouts.length - 1].previous_workout === null
|
? workouts[workouts.length - 1].previous_workout === null
|
||||||
|
@ -61,13 +61,8 @@ class ProfileEdit extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { message, onDeleteUser, onHandleProfileFormSubmit, t, user } =
|
||||||
message,
|
this.props
|
||||||
onDeleteUser,
|
|
||||||
onHandleProfileFormSubmit,
|
|
||||||
t,
|
|
||||||
user,
|
|
||||||
} = this.props
|
|
||||||
const { displayModal, formData } = this.state
|
const { displayModal, formData } = this.state
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -5,16 +5,8 @@ import { getDateWithTZ } from '../../../utils'
|
|||||||
import { formatWorkoutDate } from '../../../utils/workouts'
|
import { formatWorkoutDate } from '../../../utils/workouts'
|
||||||
|
|
||||||
export default function WorkoutCardHeader(props) {
|
export default function WorkoutCardHeader(props) {
|
||||||
const {
|
const { dataType, displayModal, segmentId, sport, t, title, user, workout } =
|
||||||
dataType,
|
props
|
||||||
displayModal,
|
|
||||||
segmentId,
|
|
||||||
sport,
|
|
||||||
t,
|
|
||||||
title,
|
|
||||||
user,
|
|
||||||
workout,
|
|
||||||
} = props
|
|
||||||
const workoutDate = workout
|
const workoutDate = workout
|
||||||
? formatWorkoutDate(getDateWithTZ(workout.workout_date, user.timezone))
|
? formatWorkoutDate(getDateWithTZ(workout.workout_date, user.timezone))
|
||||||
: null
|
: null
|
||||||
|
Loading…
Reference in New Issue
Block a user