Client - admin can delete user account - #15

This commit is contained in:
Sam
2020-05-01 17:02:50 +02:00
parent f249b09146
commit 8f48c34bed
6 changed files with 67 additions and 5 deletions

View File

@ -134,12 +134,16 @@ export const deletePicture = () => dispatch =>
throw error
})
export const deleteUser = username => dispatch =>
export const deleteUser = (username, isAdmin = false) => dispatch =>
FitTrackeeGenericApi.deleteData('users', username)
.then(ret => {
if (ret.status === 204) {
dispatch(logout())
history.push('/')
if (isAdmin) {
history.push('/admin/users')
} else {
dispatch(logout())
history.push('/')
}
} else {
ret.json().then(r => dispatch(setError(`${r.message}`)))
}