Ajuste em Massa - Paciente, Terapeuta, Clinica e Admin - Inicio agenda

This commit is contained in:
Leonardo
2026-02-22 17:56:01 -03:00
parent 6eff67bf22
commit 89b4ecaba1
77 changed files with 9433 additions and 1995 deletions
@@ -0,0 +1,24 @@
// src/features/agenda/composables/useAgendaClinicStaff.js
import { ref } from 'vue'
import { listTenantStaff } from '../services/agendaRepository'
export function useAgendaClinicStaff () {
const loading = ref(false)
const error = ref('')
const staff = ref([])
async function load (tenantId) {
loading.value = true
error.value = ''
try {
staff.value = await listTenantStaff(tenantId)
} catch (e) {
error.value = e?.message || 'Falha ao carregar profissionais.'
staff.value = []
} finally {
loading.value = false
}
}
return { loading, error, staff, load }
}
@@ -0,0 +1,106 @@
// src/features/agenda/composables/useAgendaEvents.js
import { ref } from 'vue'
import {
listMyAgendaEvents,
listClinicEvents,
createAgendaEvento,
updateAgendaEvento,
deleteAgendaEvento
} from '../services/agendaRepository.js'
export function useAgendaEvents () {
const loading = ref(false)
const error = ref('')
const rows = ref([])
async function loadMyRange (startISO, endISO) {
loading.value = true
error.value = ''
try {
rows.value = await listMyAgendaEvents({ startISO, endISO })
return rows.value
} catch (e) {
error.value = e?.message || 'Falha ao carregar eventos.'
rows.value = []
return []
} finally {
loading.value = false
}
}
async function loadClinicRange (ownerIds, startISO, endISO) {
loading.value = true
error.value = ''
try {
// ✅ evita erro "invalid input syntax for type uuid: null"
const safeIds = (ownerIds || []).filter(id => typeof id === 'string' && id && id !== 'null' && id !== 'undefined')
if (!safeIds.length) {
rows.value = []
return []
}
rows.value = await listClinicEvents({ ownerIds: safeIds, startISO, endISO })
return rows.value
} catch (e) {
error.value = e?.message || 'Falha ao carregar eventos da clínica.'
rows.value = []
return []
} finally {
loading.value = false
}
}
async function create (payload) {
loading.value = true
error.value = ''
try {
const created = await createAgendaEvento(payload)
return created
} catch (e) {
error.value = e?.message || 'Falha ao criar evento.'
throw e
} finally {
loading.value = false
}
}
async function update (id, patch) {
loading.value = true
error.value = ''
try {
const updated = await updateAgendaEvento(id, patch)
return updated
} catch (e) {
error.value = e?.message || 'Falha ao atualizar evento.'
throw e
} finally {
loading.value = false
}
}
async function remove (id) {
loading.value = true
error.value = ''
try {
await deleteAgendaEvento(id)
return true
} catch (e) {
error.value = e?.message || 'Falha ao excluir evento.'
throw e
} finally {
loading.value = false
}
}
return {
loading,
error,
rows,
loadMyRange,
loadClinicRange,
create,
update,
remove
}
}
@@ -0,0 +1,24 @@
// src/features/agenda/composables/useAgendaSettings.js
import { ref } from 'vue'
import { getMyAgendaSettings } from '../services/agendaRepository'
export function useAgendaSettings () {
const loading = ref(false)
const error = ref('')
const settings = ref(null)
async function load () {
loading.value = true
error.value = ''
try {
settings.value = await getMyAgendaSettings()
} catch (e) {
error.value = e?.message || 'Falha ao carregar configurações da agenda.'
settings.value = null
} finally {
loading.value = false
}
}
return { loading, error, settings, load }
}