riseup-squad21/services/excecoesApi.ts
2025-10-20 21:49:35 -03:00

28 lines
765 B
TypeScript

// Caminho: services/excecoesApi.ts
import api from './api';
export interface Exception {
id: any;
doctor_id: string;
date: string;
kind: 'bloqueio' | 'liberacao';
[key: string]: any;
}
export const excecoesApi = {
list: async (): Promise<Exception[]> => {
const response = await api.get<Exception[]>('/rest/v1/doctor_exceptions?select=*');
return response.data;
},
create: async (data: Omit<Exception, 'id'>): Promise<Exception> => {
const response = await api.post<Exception[]>('/rest/v1/doctor_exceptions', data, {
headers: { 'Prefer': 'return=representation' }
});
return response.data[0];
},
delete: async (id: string): Promise<void> => {
await api.delete(`/rest/v1/doctor_exceptions?id=eq.${id}`);
},
};