Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ const FormaCrearSetsProducto = ({
if (!yaExiste) {
setProductos((prev) => [...prev, productoSeleccionado]);
} else {
// Remove product if it already exists (toggle behavior)
setProductos((prev) => prev.filter((producto) => producto.id !== productoSeleccionado.id));
}

// Clear products error when a product is selected
if (erroresCampos?.productos) {
setErroresCampos(prev => ({ ...prev, productos: false }));
}
Expand All @@ -61,15 +59,12 @@ const FormaCrearSetsProducto = ({
const handleFilaSeleccion = (itemSeleccion) => {
const ids = Array.isArray(itemSeleccion) ? itemSeleccion : Array.from(itemSeleccion?.ids || []);

// Get all products that correspond to the selected IDs
const productosSeleccionados = ids
.map((id) => rows.find((row) => row.id === id))
.filter((fila) => fila);

// Update the productos array to match exactly what's selected
setProductos(productosSeleccionados);

// Clear products error when products are selected
if (erroresCampos?.productos && productosSeleccionados.length > 0) {
setErroresCampos(prev => ({ ...prev, productos: false }));
}
Expand All @@ -83,7 +78,6 @@ const FormaCrearSetsProducto = ({
setNombreSetsProducto('');
}

// Clear error when user starts typing
if (erroresCampos?.nombre && value.trim()) {
setErroresCampos(prev => ({ ...prev, nombre: false }));
}
Expand All @@ -97,7 +91,6 @@ const FormaCrearSetsProducto = ({
setNombreVisible('');
}

// Clear error when user starts typing
if (erroresCampos?.nombreVisible && value.trim()) {
setErroresCampos(prev => ({ ...prev, nombreVisible: false }));
}
Expand All @@ -111,7 +104,6 @@ const FormaCrearSetsProducto = ({
setDescripcionSetsProducto('');
}

// Clear error when user starts typing
if (erroresCampos?.descripcion && value.trim()) {
setErroresCampos(prev => ({ ...prev, descripcion: false }));
}
Expand Down Expand Up @@ -202,4 +194,4 @@ const FormaCrearSetsProducto = ({
);
};

export default FormaCrearSetsProducto;
export default FormaCrearSetsProducto;
Loading