diff --git a/frontend/admin-panel/src/pages/Categories/CategoryManager.tsx b/frontend/admin-panel/src/pages/Categories/CategoryManager.tsx index 1fd1215..c1fcba2 100644 --- a/frontend/admin-panel/src/pages/Categories/CategoryManager.tsx +++ b/frontend/admin-panel/src/pages/Categories/CategoryManager.tsx @@ -108,6 +108,43 @@ export default function CategoryManager() { setSelectedCategoryOps(catOps); }; + const handleConfigureAttributes = async (category: Category) => { + setConfiguringCategory(category); + setIsAttrModalOpen(true); + loadAttributes(category.id); + }; + + const loadAttributes = async (categoryId: number) => { + const attrs = await attributeService.getByCategoryId(categoryId); + setAttributes(attrs); + }; + + const handleCreateAttribute = async (e: React.FormEvent) => { + e.preventDefault(); + if (!configuringCategory || !newAttrData.name) return; + + try { + await attributeService.create({ + ...newAttrData, + categoryId: configuringCategory.id + }); + setNewAttrData({ name: '', dataType: 'text', required: false }); + loadAttributes(configuringCategory.id); + } catch (error) { + console.error(error); + } + }; + + const handleDeleteAttribute = async (id: number) => { + if (!confirm('Eliminar atributo?')) return; + try { + await attributeService.delete(id); + if (configuringCategory) loadAttributes(configuringCategory.id); + } catch (error) { + console.error(error); + } + }; + const toggleOperation = async (opId: number, isChecked: boolean) => { if (!configuringCategory) return; @@ -154,6 +191,15 @@ export default function CategoryManager() { {node.name}
+ {/* Attributes Button */} + +