From da34c59a90c6c025919eb2346170402d0e406816 Mon Sep 17 00:00:00 2001 From: Malini Date: Wed, 11 Feb 2026 12:30:57 +0530 Subject: [PATCH] client given cr fixed --- .../EstablishmentInfo/EstablishmentInfo.jsx | 17 ++---- .../survey/ProductData/ProductData.jsx | 56 +++++++++++++++++++ .../Admin/configuration/CompanyProfile.jsx | 6 +- .../configuration/EditCompanyProfile.jsx | 24 ++++---- 4 files changed, 79 insertions(+), 24 deletions(-) diff --git a/ipi-survey-platform/src/components/survey/EstablishmentInfo/EstablishmentInfo.jsx b/ipi-survey-platform/src/components/survey/EstablishmentInfo/EstablishmentInfo.jsx index 879b008..8609531 100644 --- a/ipi-survey-platform/src/components/survey/EstablishmentInfo/EstablishmentInfo.jsx +++ b/ipi-survey-platform/src/components/survey/EstablishmentInfo/EstablishmentInfo.jsx @@ -602,32 +602,28 @@ React.useEffect(() => { value={info.establishmentName} onChange={handleFieldChange('establishmentName')} disabled={true} - /> - - */} + {/* - */} + {/* + /> */} {/* Email field is hidden but data remains in form state */} { value={info.isicCode} onChange={handleFieldChange('isicCode')} disabled={true} - /> }; }); + // Add deleted products with is_active: false if we're in draft edit mode + if (location.state?.isEdit && deletedProducts.length > 0) { + const deletedFormattedProducts = deletedProducts.map(product => { + const selectedProduct = productOptions.find(p => p.value === product.product); + const existingProduct = currentSubmission.products?.find(p => + p.product_id === (selectedProduct?.product_id || product.product_id) || + p.product?.id === (selectedProduct?.product_id || product.product_id) + ); + return { + id: existingProduct?.id || 0, + product_id: selectedProduct?.product_id || product.product_id || null, + unit_id: product.unit?.toString() || '0', + annual_installed_capacity: product.capacity || '0', + previous_quantity_period_one: product.octQuantity || '0', + previous_quantity_period_two: product.novQuantity || '0', + previous_quantity_period_three: product.decQuantity || '0', + previous_cost_period_one: product.octCost || '0', + previous_cost_period_two: product.novCost || '0', + previous_cost_period_three: product.decCost || '0', + current_quantity_period_one: product.janQuantity || '0', + current_quantity_period_two: product.febQuantity || '0', + current_quantity_period_three: product.marQuantity || '0', + current_cost_period_one: product.janCost || '0', + current_cost_period_two: product.febCost || '0', + current_cost_period_three: product.marCost || '0', + forecast_quantity_period_one: product.aprQuantity || '0', + forecast_quantity_period_two: product.mayQuantity || '0', + forecast_quantity_period_three: product.junQuantity || '0', + forecast_cost_period_one: product.aprCost || '0', + forecast_cost_period_two: product.mayCost || '0', + forecast_cost_period_three: product.junCost || '0', + previous_quantity: product.octQuantity || '0', + previous_cost: product.octCost || '0', + current_quantity: product.novQuantity || '0', + current_cost: product.novCost || '0', + forecast_quantity: product.decQuantity || '0', + forecast_cost: product.decCost || '0', + variation_reason_master_id: product.variationReason || '0', + other_variation_reason: product.otherVariationReason || '0', + zero_target_reason_master_id: product.zeroTargetReason || '0', + other_zero_target_reason: product.otherZeroTargetReason || '0', + remarks: product.remarks || remarks || '', + is_active: false // Mark as inactive + }; + }); + + // Combine active and deleted products + formattedProducts.push(...deletedFormattedProducts); + } + // Prepare the complete payload with values from currentSubmission const payload = { establishment_id: establishmentId, @@ -1284,6 +1335,11 @@ useEffect(() => { const productToRemove = products.find(p => p.id === id); onProductsChange(products.filter((p) => p.id !== id)); + // Track deleted products if we're in draft edit mode + if (location.state?.isEdit && productToRemove) { + setDeletedProducts(prev => [...prev, productToRemove]); + } + // Remove the product ID from selectedProductIds if it exists if (productToRemove?.product) { setSelectedProductIds(prev => prev.filter(pid => pid !== productToRemove.product)); diff --git a/ipi-survey-platform/src/pages/Admin/configuration/CompanyProfile.jsx b/ipi-survey-platform/src/pages/Admin/configuration/CompanyProfile.jsx index f635b40..1477083 100644 --- a/ipi-survey-platform/src/pages/Admin/configuration/CompanyProfile.jsx +++ b/ipi-survey-platform/src/pages/Admin/configuration/CompanyProfile.jsx @@ -680,7 +680,7 @@ const CompanyProfile = () => { 2: [ { field: 'contactName', label: 'Name' }, { field: 'contactAddress', label: 'Address' }, - { field: 'contactCityTown', label: 'City/Town' }, + // { field: 'contactCityTown', label: 'City/Town' }, { field: 'contactEmirate', label: 'Emirate' }, { field: 'contactMobileNumber', label: 'Mobile Number' }, { field: 'contactEmail', label: 'Email' }, @@ -1127,8 +1127,8 @@ const CompanyProfile = () => { options={contactCityOptions} placeholder="Select City/Town" width="100%" - required - error={fieldErrors.contactCityTown} + // required + // error={fieldErrors.contactCityTown} readOnly={modalMode === 'view'} /> { { field: 'contactName', label: 'Name' }, // { field: 'contactAddress', label: 'Address' }, { field: 'contactEmirate', label: 'Emirate' }, - { field: 'contactCityTown', label: 'City/Town' }, + // { field: 'contactCityTown', label: 'City/Town' }, { field: 'contactEmail', label: 'Email' }, ], 3: [ @@ -699,16 +699,17 @@ const EditCompanyProfile = () => {

Details

- handleFormChange("permanentFactoryCode", e.target.value)} placeholder="Enter Factory Code" width="100%" // required error={fieldErrors.permanentFactoryCode} - /> - */} + {/* handleFormChange("uniqueLicenseNumber", e.target.value)} @@ -716,8 +717,8 @@ const EditCompanyProfile = () => { width="100%" required error={fieldErrors.uniqueLicenseNumber} - /> - */} + {/* handleFormChange("industryCodeBusiness", e.target.value)} @@ -725,7 +726,7 @@ const EditCompanyProfile = () => { width="100%" // required error={fieldErrors.industryCodeBusiness} - /> + /> */}
{ />
- handleFormChange("industryDescription", e.target.value)} @@ -746,7 +747,7 @@ const EditCompanyProfile = () => { width="100%" multiline rows={3} - /> + /> */}
{form.industryCodeBusiness && form.industryCodeBusiness !== form.industryCodeCurrent && (
@@ -782,6 +783,7 @@ const EditCompanyProfile = () => { width="100%" required error={fieldErrors.contactName} + readOnly /> { placeholder="Enter Address" width="100%" // required + readOnly error={fieldErrors.contactAddress} /> { placeholder="Select Emirate" width="100%" required + readOnly error={fieldErrors.contactEmirate} /> { }))} placeholder={form.contactEmirate ? (isLoadingCities ? "Loading cities..." : "Select City/Town") : "Select emirate first"} width="100%" - required + // required disabled={!form.contactEmirate || isLoadingCities} error={fieldErrors.contactCityTown} />