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}`)))