roles-checkbox-fix2
Some checks failed
Deploy on push / deploy (push) Failing after 5s

This commit is contained in:
2025-07-25 11:25:39 +03:00
parent 857588cd33
commit 1b5c77b322

View File

@@ -105,17 +105,21 @@ const UserEditModal: Component<UserEditModalProps> = (props) => {
const handleRoleToggle = (roleId: string) => { const handleRoleToggle = (roleId: string) => {
if (roleId === 'admin') { if (roleId === 'admin') {
return return // Системная роль не может быть изменена
} }
setFormData((prev) => { setFormData((prev) => {
const currentRoles = prev.roles || [] const currentRoles = prev.roles || []
const newRoles = currentRoles.includes(roleId) const isCurrentlySelected = currentRoles.includes(roleId)
? currentRoles.filter((r: string) => r !== roleId)
: [...currentRoles, roleId] const newRoles = isCurrentlySelected
? currentRoles.filter((r: string) => r !== roleId) // Убираем роль
: [...currentRoles, roleId] // Добавляем роль
return { ...prev, roles: newRoles } return { ...prev, roles: newRoles }
}) })
// Очищаем ошибки, связанные с ролями
if (errors().roles) { if (errors().roles) {
setErrors((prev) => { setErrors((prev) => {
const newErrors = { ...prev } const newErrors = { ...prev }
@@ -288,7 +292,11 @@ const UserEditModal: Component<UserEditModalProps> = (props) => {
background: isAdminRole && isSelected ? 'rgba(245, 158, 11, 0.1)' : undefined, background: isAdminRole && isSelected ? 'rgba(245, 158, 11, 0.1)' : undefined,
border: isAdminRole && isSelected ? '1px solid rgba(245, 158, 11, 0.3)' : undefined border: isAdminRole && isSelected ? '1px solid rgba(245, 158, 11, 0.3)' : undefined
}} }}
onClick={() => !isDisabled && handleRoleToggle(role.id)} onClick={() => {
if (!isDisabled && role.id !== 'admin') {
handleRoleToggle(role.id)
}
}}
> >
<div class={formStyles.roleHeader}> <div class={formStyles.roleHeader}>
<span class={formStyles.roleName}> <span class={formStyles.roleName}>
@@ -334,7 +342,7 @@ const UserEditModal: Component<UserEditModalProps> = (props) => {
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
> >
<polyline points="20 6 9 17 4 12"></polyline> <polyline points="20 6 9 17 4 12" />
</svg> </svg>
</Show> </Show>
</div> </div>