Feat: Configuración y Administración de Tipos
This commit is contained in:
@@ -61,7 +61,20 @@ export default function AdEditorModal({ isOpen, onClose, onConfirm, clientId, pr
|
||||
api.get('/operations'),
|
||||
productService.getById(productId)
|
||||
]);
|
||||
setFlatCategories(processCategories(catRes.data));
|
||||
const allCategories = processCategories(catRes.data);
|
||||
let filteredCategories = allCategories;
|
||||
|
||||
if (prodData.categoryId) {
|
||||
const rootCategory = allCategories.find(c => c.id === prodData.categoryId);
|
||||
if (rootCategory) {
|
||||
// Filtrar para mostrar solo la categoría raíz y sus descendientes
|
||||
filteredCategories = allCategories.filter(c =>
|
||||
c.id === rootCategory.id || c.path.startsWith(rootCategory.path + ' > ')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
setFlatCategories(filteredCategories);
|
||||
setOperations(opRes.data);
|
||||
setProduct(prodData);
|
||||
|
||||
@@ -71,6 +84,12 @@ export default function AdEditorModal({ isOpen, onClose, onConfirm, clientId, pr
|
||||
} else {
|
||||
setDays(3);
|
||||
}
|
||||
|
||||
// Si hay una sola opción elegible, seleccionarla automáticamente
|
||||
const selectable = filteredCategories.filter(c => c.isSelectable);
|
||||
if (selectable.length === 1) {
|
||||
setCategoryId(selectable[0].id.toString());
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error cargando configuración", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user