From 2b4029a72576f343cefc38f95096202e9b3a2d92 Mon Sep 17 00:00:00 2001 From: kams Date: Wed, 4 Sep 2024 15:39:55 +0530 Subject: [PATCH 1/2] UCEM-727+react-component-error-fix --- .../micro-ui-internals/example/package.json | 2 +- .../packages/modules/Expenditure/package.json | 64 +++++++++---------- .../CreateBills/CreatePurchaseBillForm.js | 22 ++++++- .../src/atoms/CitizenInfoLabel.js | 2 +- frontend/micro-ui/web/package.json | 2 +- 5 files changed, 54 insertions(+), 38 deletions(-) diff --git a/frontend/micro-ui/web/micro-ui-internals/example/package.json b/frontend/micro-ui/web/micro-ui-internals/example/package.json index 34bdb84da0..a3c2628e14 100644 --- a/frontend/micro-ui/web/micro-ui-internals/example/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/example/package.json @@ -20,7 +20,7 @@ "@egovernments/digit-ui-module-estimate": "0.4.5", "@egovernments/digit-ui-module-masters": "0.4.5", "@egovernments/digit-ui-module-project": "0.4.1", - "@egovernments/digit-ui-module-expenditure": "0.4.1", + "@egovernments/digit-ui-module-expenditure": "0.4.2", "@egovernments/digit-ui-customisation-mukta": "0.2.1", "@egovernments/digit-ui-module-rate-analysis": "0.4.0", "http-proxy-middleware": "^1.0.5", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/package.json index 12dfcbd490..c74b7d938a 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/package.json @@ -1,33 +1,33 @@ { - "name": "@egovernments/digit-ui-module-expenditure", - "version": "0.4.1", - "description": "Expenditure Management Module UI", - "main": "dist/index.js", - "module": "dist/index.modern.js", - "source": "src/Module.js", - "files": [ - "dist" - ], - "scripts": { - "start": "microbundle-crl watch --no-compress --format modern,cjs", - "build": "microbundle-crl --compress --no-sourcemap --format cjs", - "prepublish": "yarn build" - }, - "peerDependencies": { - "react": "17.0.2", - "react-router-dom": "5.3.0" - }, - "dependencies": { - "@egovernments/digit-ui-react-components": "^1.5.0", - "lodash": "^4.17.21", - "react": "17.0.2", - "react-date-range": "^1.4.0", - "react-dom": "17.0.2", - "react-hook-form": "6.15.8", - "react-i18next": "11.16.2", - "react-query": "3.6.1", - "react-router-dom": "5.3.0" - }, - "author": "", - "license": "MIT" - } + "name": "@egovernments/digit-ui-module-expenditure", + "version": "0.4.2", + "description": "Expenditure Management Module UI", + "main": "dist/index.js", + "module": "dist/index.modern.js", + "source": "src/Module.js", + "files": [ + "dist" + ], + "scripts": { + "start": "microbundle-crl watch --no-compress --format modern,cjs", + "build": "microbundle-crl --compress --no-sourcemap --format cjs", + "prepublish": "yarn build" + }, + "peerDependencies": { + "react": "17.0.2", + "react-router-dom": "5.3.0" + }, + "dependencies": { + "@egovernments/digit-ui-react-components": "^1.5.0", + "lodash": "^4.17.21", + "react": "17.0.2", + "react-date-range": "^1.4.0", + "react-dom": "17.0.2", + "react-hook-form": "6.15.8", + "react-i18next": "11.16.2", + "react-query": "3.6.1", + "react-router-dom": "5.3.0" + }, + "author": "", + "license": "MIT" +} diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/src/pages/employee/CreateBills/CreatePurchaseBillForm.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/src/pages/employee/CreateBills/CreatePurchaseBillForm.js index c23543efae..a5cf397430 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/src/pages/employee/CreateBills/CreatePurchaseBillForm.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/src/pages/employee/CreateBills/CreatePurchaseBillForm.js @@ -81,12 +81,28 @@ const CreatePurchaseBillForm = ({ setValue("billDetails_billAmt", parseInt(formData.invoiceDetails_materialCost)+parseInt(gstAmount)); } - if(difference?.invoiceDetails_organisationType) - { + if (formData?.invoiceDetails_organisationType?.code === "CBO") { + setValue("invoiceDetails_vendor", contract.additionalDetails?.cboName); + setValue("invoiceDetails_vendorId", contract.additionalDetails?.cboOrgNumber); + // Disabling and converting the field to text input + createPurchaseBillConfig.form[2].body[1].disable = true; + createPurchaseBillConfig.form[2].body[1].type = "text"; + createPurchaseBillConfig.form[2].body[1].populators.customClass = "disabled-text-field"; + } else { setValue("invoiceDetails_vendor", ''); - setValue("invoiceDetails_vendorId", undefined); + setValue("invoiceDetails_vendorId", ''); + // Enabling and converting the field to dropdown + createPurchaseBillConfig.form[2].body[1].disable = false; + createPurchaseBillConfig.form[2].body[1].type = "dropdown"; + createPurchaseBillConfig.form[2].body[1].populators.customClass = undefined; } + // if(difference?.invoiceDetails_organisationType) + // { + // setValue("invoiceDetails_vendor", ''); + // setValue("invoiceDetails_vendorId", undefined); + // } + if(formData.billDetails_billAmt) { let gstAmount = formData.invoiceDetails_gst ? formData.invoiceDetails_gst : 0; let value = parseFloat(formData.invoiceDetails_materialCost)+ parseFloat(gstAmount); diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/CitizenInfoLabel.js b/frontend/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/CitizenInfoLabel.js index b52af4aa03..a551fb648a 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/CitizenInfoLabel.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/CitizenInfoLabel.js @@ -8,7 +8,7 @@ const CitizenInfoLabel = (props) => { const showInfo = props?.showInfo ? props?.showInfo : true; return ( -
+
{showInfo && (
diff --git a/frontend/micro-ui/web/package.json b/frontend/micro-ui/web/package.json index 9b7b73f719..ac7af21413 100644 --- a/frontend/micro-ui/web/package.json +++ b/frontend/micro-ui/web/package.json @@ -29,7 +29,7 @@ "@egovernments/digit-ui-module-estimate": "0.4.5", "@egovernments/digit-ui-module-masters": "0.4.5", "@egovernments/digit-ui-module-project": "0.4.1", - "@egovernments/digit-ui-module-expenditure": "0.4.1", + "@egovernments/digit-ui-module-expenditure": "0.4.2", "@egovernments/digit-ui-customisation-mukta": "0.2.1", "@egovernments/digit-ui-module-rate-analysis": "0.4.0", "babel-loader": "8.1.0", From 8b33398368047fe3b30588768352b4654921394b Mon Sep 17 00:00:00 2001 From: kams Date: Thu, 5 Sep 2024 12:27:14 +0530 Subject: [PATCH 2/2] searching by key instead of selecting index --- .../CreateBills/CreatePurchaseBillForm.js | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/src/pages/employee/CreateBills/CreatePurchaseBillForm.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/src/pages/employee/CreateBills/CreatePurchaseBillForm.js index a5cf397430..dec2605aec 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/src/pages/employee/CreateBills/CreatePurchaseBillForm.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/Expenditure/src/pages/employee/CreateBills/CreatePurchaseBillForm.js @@ -84,18 +84,37 @@ const CreatePurchaseBillForm = ({ if (formData?.invoiceDetails_organisationType?.code === "CBO") { setValue("invoiceDetails_vendor", contract.additionalDetails?.cboName); setValue("invoiceDetails_vendorId", contract.additionalDetails?.cboOrgNumber); - // Disabling and converting the field to text input - createPurchaseBillConfig.form[2].body[1].disable = true; - createPurchaseBillConfig.form[2].body[1].type = "text"; - createPurchaseBillConfig.form[2].body[1].populators.customClass = "disabled-text-field"; + + const organizationDetailsSection = createPurchaseBillConfig.form.find(item => item.head === "EXP_ORGANIZATION_DETAILS"); + + if (organizationDetailsSection) { + const vendorField = organizationDetailsSection.body.find(item => item.key === "invoiceDetails_vendor"); + + if (vendorField) { + // Disabling and converting the field to text input + vendorField.disable = true; + vendorField.type = "text"; + vendorField.populators.customClass = "disabled-text-field"; + } + } } else { setValue("invoiceDetails_vendor", ''); setValue("invoiceDetails_vendorId", ''); - // Enabling and converting the field to dropdown - createPurchaseBillConfig.form[2].body[1].disable = false; - createPurchaseBillConfig.form[2].body[1].type = "dropdown"; - createPurchaseBillConfig.form[2].body[1].populators.customClass = undefined; + + const organizationDetailsSection = createPurchaseBillConfig.form.find(item => item.head === "EXP_ORGANIZATION_DETAILS"); + + if (organizationDetailsSection) { + const vendorField = organizationDetailsSection.body.find(item => item.key === "invoiceDetails_vendor"); + + if (vendorField) { + // Enabling and converting back to dropdown + vendorField.disable = false; + vendorField.type = "dropdown"; + vendorField.populators.customClass = undefined; + } + } } + // if(difference?.invoiceDetails_organisationType) // {