fixed
This commit is contained in:
parent
e18093869e
commit
84cbf5025a
@ -1136,6 +1136,11 @@ useEffect(() => {
|
||||
.filter(p => p.id !== currentProductId && p.product)
|
||||
.map(p => p.product);
|
||||
|
||||
// Get all currently selected product IDs from all products
|
||||
const allCurrentlySelectedProductIds = products
|
||||
.filter(p => p.product)
|
||||
.map(p => p.product);
|
||||
|
||||
// Get already submitted product IDs from current submission
|
||||
let submittedProductIds = [];
|
||||
try {
|
||||
@ -1153,14 +1158,15 @@ useEffect(() => {
|
||||
}
|
||||
|
||||
// Filter out selected products and already submitted products, but include the current product's selection
|
||||
// Also allow products that are in submitted list but not currently selected in any row
|
||||
return productOptions.filter(option => {
|
||||
// Keep the option if:
|
||||
// 1. It's the currently selected product for this row, OR
|
||||
// 2. It's not selected in any other row AND not in the submitted products list
|
||||
// 2. It's not selected in any other row AND (not in the submitted products list OR it's in submitted but not currently selected anywhere)
|
||||
return option.value === currentProductValue ||
|
||||
(!otherSelectedProductIds.includes(option.value) &&
|
||||
!submittedProductIds.includes(option.value) &&
|
||||
!submittedProductIds.includes(option.originalData?.product_id?.toString()));
|
||||
(!submittedProductIds.includes(option.value) || !allCurrentlySelectedProductIds.includes(option.value)) &&
|
||||
(!submittedProductIds.includes(option.originalData?.product_id?.toString()) || !allCurrentlySelectedProductIds.includes(option.originalData?.product_id?.toString())));
|
||||
});
|
||||
};
|
||||
|
||||
@ -1711,9 +1717,15 @@ useEffect(() => {
|
||||
);
|
||||
|
||||
// Count available products (total unique products - submitted - selected)
|
||||
// But allow products that are in submitted list but not currently selected
|
||||
let availableCount = 0;
|
||||
for (const [id, option] of allProductOptions.entries()) {
|
||||
if (!submittedProductIds.has(id) && !selectedProductIds.has(option.value)) {
|
||||
// Product is available if:
|
||||
// 1. It's not in submitted list, OR
|
||||
// 2. It's in submitted list but not currently selected anywhere
|
||||
// AND it's not currently selected in the form
|
||||
if ((!submittedProductIds.has(id) || !selectedProductIds.has(option.value)) &&
|
||||
!selectedProductIds.has(option.value)) {
|
||||
availableCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user