fix: improve role assignment logic and permission handling in dashboard components
This commit is contained in:
@@ -105,8 +105,11 @@
|
||||
// Se for alterar role, pegar a role atual do usuário
|
||||
if (acao === "alterar_role" && usuariosQuery.data) {
|
||||
const usuario = usuariosQuery.data.find((u: any) => u._id === usuarioId);
|
||||
if (usuario) {
|
||||
novaRoleId = usuario.role._id;
|
||||
if (usuario && usuario.role && usuario.role._id) {
|
||||
novaRoleId = usuario.role._id as Id<"roles">;
|
||||
} else if (rolesQuery.data && rolesQuery.data.length > 0) {
|
||||
// Se não conseguir pegar a role atual, usar a primeira role disponível
|
||||
novaRoleId = rolesQuery.data[0]._id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user