import api from './api'; import { type Category } from '../types/Category'; export const categoryService = { getAll: async (): Promise => { const response = await api.get('/categories'); return response.data; }, getById: async (id: number): Promise => { const response = await api.get(`/categories/${id}`); return response.data; }, create: async (category: Partial): Promise => { const response = await api.post('/categories', category); return response.data; }, update: async (id: number, category: Partial): Promise => { await api.put(`/categories/${id}`, category); }, delete: async (id: number): Promise => { await api.delete(`/categories/${id}`); }, getOperations: async (id: number): Promise => { const response = await api.get(`/categories/${id}/operations`); return response.data; }, addOperation: async (categoryId: number, operationId: number): Promise => { await api.post(`/categories/${categoryId}/operations/${operationId}`); }, removeOperation: async (categoryId: number, operationId: number): Promise => { await api.delete(`/categories/${categoryId}/operations/${operationId}`); } };