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

@@ -15,11 +15,16 @@ import { PatientDetailPage, PatientsPage } from './pages/PatientsPage.jsx'
import { ProfilePage } from './pages/ProfilePage.jsx'
import { ReportsPage } from './pages/ReportsPage.jsx'
import { SettingsPage } from './pages/SettingsPage.jsx'
import { TeamPage } from './pages/TeamPage.jsx'
import { UsersPage } from './pages/UsersPage.jsx'
import { VisitsPage } from './pages/VisitsPage.jsx'
import { patientRepository } from './repositories/patientRepository.js'
const PANEL_PATHS = ['/inicio', '/home', '/dashboard']
const ROLE_HOME_PATHS = {
medico: '/agenda',
secretaria: '/agenda',
}
function App() {
const [location, setLocation] = useState(() => readLocation())
const { isAuthenticated, role, loading: authLoading } = useAuth()
@@ -77,6 +82,12 @@ function App() {
// Usuário autenticado mas sem permissão para a rota
if (!role || !canAccess(role, location.pathname)) {
const roleHomePath = ROLE_HOME_PATHS[role]
if (roleHomePath && PANEL_PATHS.includes(location.pathname)) {
navigate(roleHomePath, { replace: true })
return null
}
return (
<AppShell currentPath={location.pathname} navigate={navigate} role={role} routeTitle="Sem acesso">
<UnauthorizedPage navigate={navigate} />
@@ -151,7 +162,7 @@ function resolveRoute(pathname, navigate, role) {
if (pathname.startsWith('/pacientes/')) {
const patientId = pathname.split('/')[2]
return {
element: <PatientDetailRoute navigate={navigate} patientId={patientId} />,
element: <PatientDetailRoute navigate={navigate} patientId={patientId} role={role} />,
title: 'Paciente',
withShell: true,
}
@@ -167,8 +178,8 @@ function resolveRoute(pathname, navigate, role) {
if (pathname === '/laudos') {
return {
element: <ReportsPage navigate={navigate} />,
title: 'Relatórios médicos',
element: <ReportsPage navigate={navigate} role={role} />,
title: 'Relatórios',
withShell: true,
}
}
@@ -176,7 +187,7 @@ function resolveRoute(pathname, navigate, role) {
if (pathname === '/relatorios') {
return {
element: <AnalyticsPage />,
title: 'Relatórios',
title: 'Analytics',
withShell: true,
}
}
@@ -198,14 +209,6 @@ function resolveRoute(pathname, navigate, role) {
}
}
if (pathname === '/profissionais') {
return {
element: <TeamPage navigate={navigate} />,
title: 'Profissionais',
withShell: true,
}
}
if (pathname === '/usuarios') {
return {
element: <UsersPage role={role} />,
@@ -237,7 +240,7 @@ function resolveRoute(pathname, navigate, role) {
}
}
function PatientDetailRoute({ navigate, patientId }) {
function PatientDetailRoute({ navigate, patientId, role }) {
const [patient, setPatient] = useState(null)
const [loading, setLoading] = useState(true)
@@ -263,7 +266,7 @@ function PatientDetailRoute({ navigate, patientId }) {
}
return patient ? (
<PatientDetailPage navigate={navigate} patient={patient} />
<PatientDetailPage navigate={navigate} patient={patient} role={role} />
) : (
<NotFoundPage navigate={navigate} />
)