Fase 2: Implementación de la Matriz de Operaciones (Backend & Frontend)
This commit is contained in:
@@ -23,5 +23,18 @@ export const categoryService = {
|
||||
|
||||
delete: async (id: number): Promise<void> => {
|
||||
await api.delete(`/categories/${id}`);
|
||||
},
|
||||
|
||||
getOperations: async (id: number): Promise<import('../types/Operation').Operation[]> => {
|
||||
const response = await api.get(`/categories/${id}/operations`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
addOperation: async (categoryId: number, operationId: number): Promise<void> => {
|
||||
await api.post(`/categories/${categoryId}/operations/${operationId}`);
|
||||
},
|
||||
|
||||
removeOperation: async (categoryId: number, operationId: number): Promise<void> => {
|
||||
await api.delete(`/categories/${categoryId}/operations/${operationId}`);
|
||||
}
|
||||
};
|
||||
|
||||
18
frontend/admin-panel/src/services/operationService.ts
Normal file
18
frontend/admin-panel/src/services/operationService.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import api from './api';
|
||||
import { Operation } from '../types/Operation'; // ID: type-import-fix
|
||||
|
||||
export const operationService = {
|
||||
getAll: async (): Promise<Operation[]> => {
|
||||
const response = await api.get<Operation[]>('/operations');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
create: async (name: string): Promise<Operation> => {
|
||||
const response = await api.post<Operation>('/operations', { name });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
delete: async (id: number): Promise<void> => {
|
||||
await api.delete(`/operations/${id}`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user