modo-claro

modified:   src/hooks/useAgenda.js
modified:   src/index.css
modified:   src/main.jsx
modified:   src/mappers/reportMapper.js
modified:   src/pages/AgendaPage.jsx
modified:   src/pages/AuthPages.jsx
modified:   src/pages/MedicalRecordsPage.jsx
modified:   src/pages/PatientsPage.jsx
modified:   src/pages/ReportsPage.jsx
modified:   src/pages/SettingsPage.jsx
modified:   src/repositories/analyticsRepository.js
modified:   src/repositories/authRepository.js
modified:   src/repositories/patientRepository.js
modified:   src/repositories/reportRepository.js
modified:   src/repositories/repositoryUtils.js
new file:   src/utils/theme.js
new file:   vercel.json
This commit is contained in:
2026-05-07 05:51:07 -03:00
parent 64d9527318
commit db7a2fe8f5
17 changed files with 669 additions and 121 deletions

View File

@@ -1,10 +1,11 @@
import { apiConfig, getAuthenticatedHeaders } from '../config/api.js'
import { getResponseError } from './repositoryUtils.js'
export const patientRepository = {
// 1. Listar pacientes
async getAll() {
const response = await fetch(`${apiConfig.restUrl}/patients?select=*`, { headers: getAuthenticatedHeaders() })
if (!response.ok) throw new Error('Erro ao buscar pacientes')
if (!response.ok) throw new Error(await getResponseError(response, 'Erro ao buscar pacientes.'))
return response.json()
},
@@ -19,7 +20,7 @@ export const patientRepository = {
async getDirectoryRows({ doctorId } = {}) {
const [patients, appointments] = await Promise.all([
this.getAll().catch(() => []),
this.getAll(),
getAppointments({ doctorId }).catch(() => []),
])
@@ -48,9 +49,11 @@ export const patientRepository = {
})
if (!response.ok) {
const error = await response.json().catch(() => ({}))
console.error('Erro da API ao criar paciente:', error)
throw new Error(error.message || error.hint || JSON.stringify(error))
if ([401, 403].includes(response.status)) {
return this.createWithValidation(data)
}
throw new Error(await getResponseError(response, 'Erro ao criar paciente.'))
}
return response.json()
@@ -74,8 +77,7 @@ export const patientRepository = {
})
if (!response.ok) {
const error = await response.json().catch(() => ({}))
throw new Error(error.message || 'Erro ao criar paciente com validação')
throw new Error(await getResponseError(response, 'Erro ao criar paciente com validação.'))
}
return response.json()
@@ -97,7 +99,7 @@ export const patientRepository = {
body: JSON.stringify(body),
})
if (!response.ok) throw new Error('Erro ao atualizar paciente')
if (!response.ok) throw new Error(await getResponseError(response, 'Erro ao atualizar paciente.'))
return response.json()
},
@@ -108,7 +110,7 @@ export const patientRepository = {
headers: getAuthenticatedHeaders(),
})
if (!response.ok) throw new Error('Erro ao deletar paciente')
if (!response.ok) throw new Error(await getResponseError(response, 'Erro ao deletar paciente.'))
return true
},
}