modified: index.html

modified:   src/App.jsx
modified:   src/components/AppShell.jsx
modified:   src/components/featureStateStyles.js
modified:   src/config/permissions.js
modified:   src/hooks/useAgenda.js
modified:   src/mappers/reportMapper.js
modified:   src/pages/AgendaPage.jsx
modified:   src/pages/AnalyticsPage.jsx
modified:   src/pages/AuthPages.jsx
modified:   src/pages/HomePage.jsx
modified:   src/pages/MedicalRecordsPage.jsx
modified:   src/pages/MessagesPage.jsx
modified:   src/pages/PatientsPage.jsx
modified:   src/pages/ReportsPage.jsx
modified:   src/pages/SettingsPage.jsx
deleted:    src/pages/TeamPage.jsx
modified:   src/pages/UsersPage.jsx
modified:   src/repositories/availabilityRepository.js
modified:   src/repositories/patientRepository.js
modified:   src/repositories/professionalRepository.js
modified:   src/repositories/reportRepository.js
modified:   src/repositories/settingsRepository.js
This commit is contained in:
2026-05-07 01:11:10 -03:00
parent 9335e974eb
commit efb942d5aa
23 changed files with 1461 additions and 591 deletions

View File

@@ -38,11 +38,17 @@ export function UsersPage({ role: currentRole }) {
const [saving, setSaving] = useState(false)
const [deletingId, setDeletingId] = useState(null)
const [form, setForm] = useState(initialUserForm)
const [roleFilter, setRoleFilter] = useState('Todos')
const normalizedRole = normalizeRole(currentRole)
const canManageUsers = hasCapability(normalizedRole, 'manageUsers')
const creatableRoles = normalizedRole === 'admin' ? ADMIN_CREATABLE_ROLES : GESTOR_CREATABLE_ROLES
const isPasswordCreation = form.auth_method === 'password'
const filterableRoles = normalizedRole === 'admin' ? ADMIN_CREATABLE_ROLES : GESTOR_CREATABLE_ROLES
const filteredUsers = users.filter((user) => {
if (roleFilter === 'Todos') return true
return normalizeRole(getUserRole(user)) === roleFilter
})
useEffect(() => {
loadUsers()
@@ -167,6 +173,29 @@ export function UsersPage({ role: currentRole }) {
<p className="py-10 text-center text-sm text-red-400">Erro ao carregar usuários: {error}</p>
) : (
<div className="rounded-2xl border border-[#404040] bg-[#262626] shadow-sm">
<div className="flex flex-col gap-3 border-b border-[#404040] px-6 py-4 sm:flex-row sm:items-center sm:justify-between">
<div>
<p className="text-sm font-semibold text-[#e5e5e5]">Filtros</p>
<p className="mt-1 text-xs text-[#a3a3a3]">
{filteredUsers.length} de {users.length} usuários exibidos
</p>
</div>
<label className="grid gap-1.5 text-xs font-semibold text-[#a3a3a3] sm:min-w-56">
<span>Perfil</span>
<select
className={darkInput}
onChange={(event) => setRoleFilter(event.target.value)}
value={roleFilter}
>
<option value="Todos">Todos os perfis</option>
{filterableRoles.map((role) => (
<option key={`filter-role-${role}`} value={role}>
{ROLE_LABELS[role]}
</option>
))}
</select>
</label>
</div>
<div className="overflow-x-auto">
<table className="w-full whitespace-nowrap text-left text-sm">
<thead className="bg-[#171717] text-xs font-semibold uppercase text-[#a3a3a3]">
@@ -179,9 +208,9 @@ export function UsersPage({ role: currentRole }) {
</tr>
</thead>
<tbody className="divide-y divide-[#404040]">
{users.length ? (
users.map((user) => {
const userRole = Array.isArray(user.roles) ? user.roles[0] : (user.role ?? '—')
{filteredUsers.length ? (
filteredUsers.map((user) => {
const userRole = getUserRole(user)
return (
<tr className="transition hover:bg-[#303030]" key={user.id}>
<td className="px-6 py-4">
@@ -221,7 +250,7 @@ export function UsersPage({ role: currentRole }) {
) : (
<tr>
<td className="px-6 py-10 text-center text-[#a3a3a3]" colSpan={5}>
Nenhum usuário encontrado.
{users.length ? 'Nenhum usuário encontrado para o perfil selecionado.' : 'Nenhum usuário encontrado.'}
</td>
</tr>
)}
@@ -439,3 +468,7 @@ function RoleBadge({ role }) {
</span>
)
}
function getUserRole(user) {
return Array.isArray(user.roles) ? user.roles[0] : (user.role ?? '—')
}