Fase 2: Gestor de Taxonomía (Árbol de Categorías) - Backend CORS y Frontend CRUD Recursivo

This commit is contained in:
2025-12-17 13:16:55 -03:00
parent f19cd781ad
commit 523a8394ae
7 changed files with 315 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import api from './api';
import { Category } from '../types/Category';
export const categoryService = {
getAll: async (): Promise<Category[]> => {
const response = await api.get<Category[]>('/categories');
return response.data;
},
getById: async (id: number): Promise<Category> => {
const response = await api.get<Category>(`/categories/${id}`);
return response.data;
},
create: async (category: Partial<Category>): Promise<Category> => {
const response = await api.post<Category>('/categories', category);
return response.data;
},
update: async (id: number, category: Partial<Category>): Promise<void> => {
await api.put(`/categories/${id}`, category);
},
delete: async (id: number): Promise<void> => {
await api.delete(`/categories/${id}`);
}
};