fix(api): simplifica consultas de agendamentos e medicos
This commit is contained in:
@@ -1,23 +1,15 @@
|
||||
import { apiConfig, apiEndpoint, getAuthenticatedHeaders } from '../config/api.js'
|
||||
import { fetchJsonWithFallback, normalizeCollection } from './repositoryUtils.js'
|
||||
import { apiConfig, getAuthenticatedHeaders } from '../config/api.js'
|
||||
|
||||
export const professionalRepository = {
|
||||
async getAll() {
|
||||
const data = await fetchJsonWithFallback(
|
||||
[
|
||||
{
|
||||
url: apiEndpoint('/listar-medicos'),
|
||||
options: { headers: getAuthenticatedHeaders() },
|
||||
},
|
||||
{
|
||||
url: `${apiConfig.restUrl}/doctors`,
|
||||
options: { headers: getAuthenticatedHeaders() },
|
||||
},
|
||||
],
|
||||
'Erro ao buscar medicos.',
|
||||
)
|
||||
|
||||
return normalizeCollection(data, ['medicos', 'doctors', 'professionals', 'data']).map(mapProfessional)
|
||||
const response = await fetch(`${apiConfig.restUrl}/doctors`, {
|
||||
headers: getAuthenticatedHeaders()
|
||||
})
|
||||
|
||||
if (!response.ok) throw new Error('Erro ao buscar medicos.')
|
||||
|
||||
const data = await response.json()
|
||||
return (Array.isArray(data) ? data : []).map(mapProfessional)
|
||||
},
|
||||
|
||||
getCoverageMap() {
|
||||
|
||||
Reference in New Issue
Block a user