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