diff --git a/health/micro-ui/web/micro-ui-internals/example/public/index.html b/health/micro-ui/web/micro-ui-internals/example/public/index.html index 1b6b8b28a72..9c68011184e 100644 --- a/health/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/health/micro-ui/web/micro-ui-internals/example/public/index.html @@ -12,7 +12,7 @@ DIGIT - + diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/package.json b/health/micro-ui/web/micro-ui-internals/packages/css/package.json index 0a1749f727f..96a94cbde92 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/health/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-health-css", - "version": "0.1.52", + "version": "0.1.53", "license": "MIT", "main": "dist/index.css", "author": "Jagankumar ", diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaignCycle.scss b/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaignCycle.scss index 5a40558fc43..f38fc1b0113 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaignCycle.scss +++ b/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/campaignCycle.scss @@ -286,6 +286,7 @@ } .add-rule-btn { margin: auto; + margin-bottom: 1rem; h2 { font-family: Roboto; font-size: 1rem; diff --git a/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss b/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss index 4f542cee092..ebd0224de53 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss +++ b/health/micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss @@ -310,6 +310,7 @@ input[type="date"]::-webkit-calendar-picker-indicator { .campaign-preview-edit-container { display: flex; gap: 1rem; + cursor: pointer; span { color: theme(digitv2.lightTheme.primary); diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js index 7c4e6ce8a8b..a18289428c4 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js @@ -80,95 +80,6 @@ function loopAndReturn(dataa, t) { return format; } -function reverseDeliveryRemap(data, t) { - if (!data) return null; - const reversedData = []; - let currentCycleIndex = null; - let currentCycle = null; - - const operatorMapping = { - "<=": "LESS_THAN_EQUAL_TO", - ">=": "GREATER_THAN_EQUAL_TO", - "<": "LESS_THAN", - ">": "GREATER_THAN", - "==": "EQUAL_TO", - "!=": "NOT_EQUAL_TO", - IN_BETWEEN: "IN_BETWEEN", - }; - - const cycles = data?.[0]?.cycles || []; - const mapProductVariants = (productVariants) => { - return productVariants.map((variant, key) => ({ - key: key + 1, - count: 1, - value: variant.productVariantId, - name: variant.name, - })); - }; - - const parseConditionAndCreateRules = (condition, ruleKey, products) => { - const conditionParts = condition.split("and").map((part) => part.trim()); - let attributes = []; - - conditionParts.forEach((part) => { - const parts = part.split(" ").filter(Boolean); - - // Handle "IN_BETWEEN" operator - if (parts.length === 5 && (parts[1] === "<=" || parts[1] === "<") && (parts[3] === "<" || parts[3] === "<=")) { - const toValue = parts[0]; - const fromValue = parts[4]; - attributes.push({ - key: attributes.length + 1, - operator: { code: operatorMapping["IN_BETWEEN"] }, - attribute: { code: parts[2] }, - fromValue, - toValue, - }); - } else { - const match = part.match(/(.*?)\s*(<=|>=|<|>|==|!=)\s*(.*)/); - if (match) { - const attributeCode = match[1].trim(); - const operatorSymbol = match[2].trim(); - const value = match[3].trim(); - attributes.push({ - key: attributes.length + 1, - value, - operator: { code: operatorMapping[operatorSymbol] }, - attribute: { code: attributeCode }, - }); - } - } - }); - return [{ - ruleKey: ruleKey + 1, - delivery: {}, - products, - attributes, - }]; - }; - const mapDoseCriteriaToDeliveryRules = (doseCriteria) => { - return doseCriteria?.flatMap((criteria, ruleKey) => { - const products = mapProductVariants(criteria.ProductVariants); - return parseConditionAndCreateRules(criteria.condition, ruleKey, products); - }); - }; - - const mapDeliveries = (deliveries) => { - return deliveries?.map((delivery, deliveryIndex) => ({ - active: deliveryIndex === 0, - deliveryIndex: String(deliveryIndex + 1), - deliveryRules: mapDoseCriteriaToDeliveryRules(delivery.doseCriteria), - })); - }; - - const transformedCycles = cycles.map((cycle) => ({ - active: true, - cycleIndex: String(cycle.id), - deliveries: mapDeliveries(cycle.deliveries), - })); - - return transformedCycles; -} function boundaryDataGrp(boundaryData) { // Create an empty object to hold grouped data by type @@ -285,6 +196,133 @@ const CampaignSummary = (props) => { window.dispatchEvent(new Event("checking")); }, [key]); + function reverseDeliveryRemap(data, t) { + if (!data) return null; + const reversedData = []; + let currentCycleIndex = null; + let currentCycle = null; + + const operatorMapping = { + "<=": "LESS_THAN_EQUAL_TO", + ">=": "GREATER_THAN_EQUAL_TO", + "<": "LESS_THAN", + ">": "GREATER_THAN", + "==": "EQUAL_TO", + "!=": "NOT_EQUAL_TO", + IN_BETWEEN: "IN_BETWEEN", + }; + + const cycles = data?.[0]?.cycles || []; + const mapProductVariants = (productVariants) => { + return productVariants.map((variant, key) => ({ + key: key + 1, + count: 1, + value: variant.productVariantId, + name: variant.name, + })); + }; + + const parseConditionAndCreateRules = (condition, ruleKey, products) => { + // const conditionParts = condition.split("and").map((part) => part.trim()); + // let attributes = []; + let attributes = []; + + if (isPreview) { + // Handle preview condition `3<=ageandage<11` or `3 <= Age < 11` in "IN_BETWEEN" style + const inBetweenMatch = condition.match(/(\d+)(<=|<|>=|>)(\w+)and(\w+)(<=|<|>=|>)(\d+)/); + if (inBetweenMatch) { + const toValue = inBetweenMatch[1].trim(); + const fromValue = inBetweenMatch[6].trim(); + const attributeCode = inBetweenMatch[3].trim(); + + attributes.push({ + key: attributes.length + 1, + operator: { code: "IN_BETWEEN" }, + attribute: { code: attributeCode }, + fromValue, + toValue, + }); + } else { + // Handle regular conditions in preview mode + const conditionParts = condition.split("and").map((part) => part.trim()); + conditionParts.forEach((part) => { + const match = part.match(/(.*?)\s*(<=|>=|<|>|==|!=)\s*(.*)/); + if (match) { + const attributeCode = match[1].trim(); + const operatorSymbol = match[2].trim(); + const value = match[3].trim(); + attributes.push({ + key: attributes.length + 1, + value, + operator: { code: operatorMapping[operatorSymbol] }, + attribute: { code: attributeCode }, + }); + } + }); + } + } else { + const conditionParts = condition.split("and").map((part) => part.trim()); + conditionParts.forEach((part) => { + const parts = part.split(" ").filter(Boolean); + + // Handle "IN_BETWEEN" operator + if (parts.length === 5 && (parts[1] === "<=" || parts[1] === "<") && (parts[3] === "<" || parts[3] === "<=")) { + const toValue = parts[0]; + const fromValue = parts[4]; + attributes.push({ + key: attributes.length + 1, + operator: { code: operatorMapping["IN_BETWEEN"] }, + attribute: { code: parts[2] }, + fromValue, + toValue, + }); + } else { + const match = part.match(/(.*?)\s*(<=|>=|<|>|==|!=)\s*(.*)/); + if (match) { + const attributeCode = match[1].trim(); + const operatorSymbol = match[2].trim(); + const value = match[3].trim(); + attributes.push({ + key: attributes.length + 1, + value, + operator: { code: operatorMapping[operatorSymbol] }, + attribute: { code: attributeCode }, + }); + } + } + }); + } + return [{ + ruleKey: ruleKey + 1, + delivery: {}, + products, + attributes, + }]; + }; + const mapDoseCriteriaToDeliveryRules = (doseCriteria) => { + return doseCriteria?.flatMap((criteria, ruleKey) => { + const products = mapProductVariants(criteria.ProductVariants); + return parseConditionAndCreateRules(criteria.condition, ruleKey, products); + }); + }; + + const mapDeliveries = (deliveries) => { + return deliveries?.map((delivery, deliveryIndex) => ({ + active: deliveryIndex === 0, + deliveryIndex: String(deliveryIndex + 1), + deliveryRules: mapDoseCriteriaToDeliveryRules(delivery.doseCriteria), + })); + }; + + const transformedCycles = cycles.map((cycle) => ({ + active: true, + cycleIndex: String(cycle.id), + deliveries: mapDeliveries(cycle.deliveries), + })); + + return transformedCycles; + } + // useEffect(() => { // if (props?.props?.summaryErrors) { // if (props?.props?.summaryErrors?.deliveryErrors) { diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js index 1b4eaf931aa..458a7cccc07 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddDeliverycontext.js @@ -828,7 +828,7 @@ const AddDeliveryRule = ({ targetedData, deliveryRules, setDeliveryRules, index,
{delivery?.products?.length > 0 && delivery?.products?.map((i) => { - return i?.value && i?.count ? ( + return i?.value && i?.quantity ? ( removeProduct(i)} className="multiselectdropdown-tag" hideClose={false} /> ) : null; })} diff --git a/health/micro-ui/web/public/index.html b/health/micro-ui/web/public/index.html index 518d87048df..5fe57a555b0 100644 --- a/health/micro-ui/web/public/index.html +++ b/health/micro-ui/web/public/index.html @@ -10,7 +10,7 @@ - + DIGIT HCM