Bug Description
When creating or editing an attendant in the CRM, the "Função" (Role) dropdown appears to work (expands and shows options) but does not retain the selected value — the field remains empty after clicking an option.
Root Cause
The RoleSerializer in the auth service does not include the key field in its JSON output.
The frontend (React) uses Radix UI's <Select> component and maps roles like this (from the compiled bundle):
o.map(x => <SelectItem value={x.key}>{x.name}</SelectItem>)
Since x.key is undefined (not returned by the API), all <SelectItem> elements have value={undefined}, and the Radix Select component cannot match or store the selection.
Affected File
app/serializers/role_serializer.rb — both full and basic methods return role data without the key field:
# Current (broken)
def full(role)
{
id: role.id,
name: role.name,
description: role.description,
permissions: role.permissions_by_resource,
# ...
}
end
def basic(role)
{ id: role.id, name: role.name, description: role.description }
end
Fix
Add key: role.key to both serializer methods:
def full(role)
{
id: role.id,
key: role.key, # <-- ADD THIS
name: role.name,
description: role.description,
permissions: role.permissions_by_resource,
created_at: role.created_at,
updated_at: role.updated_at
}
end
def basic(role)
{ id: role.id, key: role.key, name: role.name, description: role.description }
# ^^^^^^^^^^
end
Steps to Reproduce
- Log in as admin in Evo CRM
- Go to Atendentes → Novo Atendente
- Click the "Função" (Role) dropdown
- Select any option (e.g., "Atendente")
- The dropdown closes but shows empty — role is not selected
Impact
- Admins cannot assign roles when creating attendants
- If role is required, form submission fails with a validation error
Environment
- Deployment: Docker Swarm / Portainer
- Frontend: React + Radix UI + Vite
- Backend: Rails 7.1
evo-crm-community:latest
Bug Description
When creating or editing an attendant in the CRM, the "Função" (Role) dropdown appears to work (expands and shows options) but does not retain the selected value — the field remains empty after clicking an option.
Root Cause
The
RoleSerializerin the auth service does not include thekeyfield in its JSON output.The frontend (React) uses Radix UI's
<Select>component and maps roles like this (from the compiled bundle):Since
x.keyisundefined(not returned by the API), all<SelectItem>elements havevalue={undefined}, and the Radix Select component cannot match or store the selection.Affected File
app/serializers/role_serializer.rb— bothfullandbasicmethods return role data without thekeyfield:Fix
Add
key: role.keyto both serializer methods:Steps to Reproduce
Impact
Environment
evo-crm-community:latest