import type { Prestataire, PrestataireWrite } from './dto/prestataire' import type { HydraCollection } from '~/utils/api' import { extractHydraMembers } from '~/utils/api' export function usePrestataireService() { const api = useApi() async function getAll(): Promise { const data = await api.get>('/prestataires') return extractHydraMembers(data) } async function getById(id: number): Promise { return api.get(`/prestataires/${id}`) } async function create(payload: PrestataireWrite): Promise { return api.post('/prestataires', payload as Record, { toastSuccessKey: 'prestataires.created', }) } async function update(id: number, payload: Partial): Promise { return api.patch(`/prestataires/${id}`, payload as Record, { toastSuccessKey: 'prestataires.updated', }) } async function remove(id: number): Promise { await api.delete(`/prestataires/${id}`, {}, { toastSuccessKey: 'prestataires.deleted', }) } return { getAll, getById, create, update, remove } }