@@ -134,14 +134,12 @@ register('PATCH', endpoints.updateUserRole, ({ params, data }) => {
|
||||
const nextRoleNames = Array.isArray(data.roles)
|
||||
? data.roles.filter(Boolean)
|
||||
: data.role
|
||||
? [data.role]
|
||||
: data.roleId
|
||||
? [roles.find((r) => r.id === Number(data.roleId))?.name].filter(Boolean)
|
||||
: []
|
||||
? [data.role]
|
||||
: data.roleId
|
||||
? [roles.find((r) => r.id === Number(data.roleId))?.name].filter(Boolean)
|
||||
: []
|
||||
const primary = nextRoleNames[0] ? byName(nextRoleNames[0]) : null
|
||||
const patch = nextRoleNames.length
|
||||
? { roles: nextRoleNames, roleId: primary?.id }
|
||||
: {}
|
||||
const patch = nextRoleNames.length > 0 ? { roles: nextRoleNames, roleId: primary?.id } : {}
|
||||
const updated = updateById(adminUsers, params.id, patch)
|
||||
return {
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user