// Caminho: services/agendamentosApi.ts import api from './api'; export interface Appointment { id: any; patient_id: string; doctor_id: string; scheduled_at: string; [key: string]: any; } interface AvailableSlotsData { doctor_id: string; start_date: string; end_date: string; appointment_type?: 'presencial' | 'telemedicina'; } export const agendamentosApi = { list: async (): Promise => { const response = await api.get('/rest/v1/appointments?select=*'); return response.data; }, getById: async (id: string): Promise => { const response = await api.get(`/rest/v1/appointments?id=eq.${id}&select=*`, { headers: { Accept: 'application/vnd.pgrst.object+json' }, }); return response.data; }, create: async (data: Omit): Promise => { const response = await api.post('/rest/v1/appointments', data, { headers: { 'Prefer': 'return=representation' } }); return response.data[0]; }, update: async (id: string, data: Partial): Promise => { const response = await api.patch(`/rest/v1/appointments?id=eq.${id}`, data, { headers: { 'Prefer': 'return=representation' } }); return response.data[0]; }, delete: async (id: string): Promise => { await api.delete(`/rest/v1/appointments?id=eq.${id}`); }, searchAvailableSlots: async (data: AvailableSlotsData): Promise => { const response = await api.post('/functions/v1/get-available-slots', data); return response.data; }, };