diff --git a/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx b/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx index 7746306..ba443d8 100644 --- a/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx +++ b/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx @@ -955,10 +955,10 @@ const existingProduct = currentSubmission.products?.find(p => // Next quarter forecast (Q2) - December forecast_quantity: product.decQuantity || '0', forecast_cost: product.decCost || '0', - variation_reason_master_id: product.variationReason === null ? null : (product.variationReason || '0'), - other_variation_reason: product.otherVariationReason || '0', - zero_target_reason_master_id: product.zeroTargetReason === null ? null : (product.zeroTargetReason || '0'), - other_zero_target_reason: product.otherZeroTargetReason || '0', + variation_reason_master_id: product.variationReason === null ? null : (parseInt(product.variationReason) || 0), + other_variation_reason: product.otherVariationReason || '', + zero_target_reason_master_id: product.zeroTargetReason === null ? null : (parseInt(product.zeroTargetReason) || 0), + other_zero_target_reason: product.otherZeroTargetReason || '', remarks: product.remarks || remarks || '' // Use product.remarks if available, otherwise use the component's remarks state }; }); @@ -1000,10 +1000,10 @@ const existingProduct = currentSubmission.products?.find(p => current_cost: product.novCost || '0', forecast_quantity: product.decQuantity || '0', forecast_cost: product.decCost || '0', - variation_reason_master_id: product.variationReason === null ? null : (product.variationReason || '0'), - other_variation_reason: product.otherVariationReason || '0', - zero_target_reason_master_id: product.zeroTargetReason === null ? null : (product.zeroTargetReason || '0'), - other_zero_target_reason: product.otherZeroTargetReason || '0', + variation_reason_master_id: product.variationReason === null ? null : parseInt(product.variationReason), + other_variation_reason: product.otherVariationReason || '', + zero_target_reason_master_id: product.zeroTargetReason === null ? null : parseInt(product.zeroTargetReason), + other_zero_target_reason: product.otherZeroTargetReason || '', remarks: product.remarks || remarks || '', is_active: false // Mark as inactive }; @@ -1118,9 +1118,9 @@ useEffect(() => { junCost: product.forecast_cost_period_three || '0', // Variation reasons - variationReason: product.variation_reason_master_id !== null && product.variation_reason_master_id !== undefined ? product.variation_reason_master_id.toString() : null, + variationReason: product.variation_reason_master_id !== null && product.variation_reason_master_id !== undefined ? product.variation_reason_master_id.toString() : '', otherVariationReason: product.other_variation_reason || '', - zeroTargetReason: product.zero_target_reason_master_id !== null && product.zero_target_reason_master_id !== undefined ? product.zero_target_reason_master_id.toString() : null, + zeroTargetReason: product.zero_target_reason_master_id !== null && product.zero_target_reason_master_id !== undefined ? product.zero_target_reason_master_id.toString() : '', otherZeroTargetReason: product.other_zero_target_reason || '', remarks: product.remarks || '' }; diff --git a/ipi-survey-platform/src/components/survey/ReviewSubmit/ReviewSubmit.jsx b/ipi-survey-platform/src/components/survey/ReviewSubmit/ReviewSubmit.jsx index 77a2b61..6e615b4 100644 --- a/ipi-survey-platform/src/components/survey/ReviewSubmit/ReviewSubmit.jsx +++ b/ipi-survey-platform/src/components/survey/ReviewSubmit/ReviewSubmit.jsx @@ -538,8 +538,8 @@ if (!establishment) { return { // Use the existing product ID if found, otherwise use 0 for new products id: existingProduct?.id || 0, - product_id: product.product_id || null, - unit_id: product.unit?.toString() || '', + product_id: parseInt(product.product_id) || 0, + unit_id: parseInt(product.unit) || 0, annual_installed_capacity: product.capacity || '0', // ... rest of the product fields remain the same previous_quantity_period_one: product.octQuantity || '0', @@ -566,9 +566,9 @@ if (!establishment) { current_cost: product.novCost || '0', forecast_quantity: product.decQuantity || '0', forecast_cost: product.decCost || '0', - variation_reason_master_id: product.variationReason || '', + variation_reason_master_id: parseInt(product.variationReason) || 0, other_variation_reason: product.otherVariationReason || '', - zero_target_reason_master_id: product.zeroTargetReason || '', + zero_target_reason_master_id: parseInt(product.zeroTargetReason) || 0, other_zero_target_reason: product.otherZeroTargetReason || '', remarks: product.remarks || remarks || '' };