-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed product chip and summary issue #1941
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
<title>DIGIT</title> | ||
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" /> | ||
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" /> | ||
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].52/dist/index.css" /> | ||
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].53/dist/index.css" /> | ||
|
||
<!-- added below css for hcm-workbench module inclusion--> | ||
<!-- <link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" /> --> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]>", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,6 +286,7 @@ | |
} | ||
.add-rule-btn { | ||
margin: auto; | ||
margin-bottom: 1rem; | ||
h2 { | ||
font-family: Roboto; | ||
font-size: 1rem; | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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; | ||||||||||
Comment on lines
+202
to
+203
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Use The variables Suggested fix: const reversedData = [];
- let currentCycleIndex = null;
- let currentCycle = null;
+ const currentCycleIndex = null;
+ const currentCycle = null; 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 202-202: This let declares a variable that is only assigned once. 'currentCycleIndex' is never reassigned. Safe fix: Use const instead. (lint/style/useConst) [error] 203-203: This let declares a variable that is only assigned once. 'currentCycle' is never reassigned. Safe fix: Use const instead. (lint/style/useConst) |
||||||||||
|
||||||||||
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 = []; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Use The variable Suggested fix: - let attributes = [];
+ const attributes = []; 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 228-228: This let declares a variable that is only assigned once. 'attributes' is never reassigned. Safe fix: Use const instead. (lint/style/useConst) |
||||||||||
|
||||||||||
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; | ||||||||||
} | ||||||||||
Comment on lines
+199
to
+324
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider refactoring The 🧰 Tools🪛 Biome (1.9.4)[error] 202-202: This let declares a variable that is only assigned once. 'currentCycleIndex' is never reassigned. Safe fix: Use const instead. (lint/style/useConst) [error] 203-203: This let declares a variable that is only assigned once. 'currentCycle' is never reassigned. Safe fix: Use const instead. (lint/style/useConst) [error] 228-228: This let declares a variable that is only assigned once. 'attributes' is never reassigned. Safe fix: Use const instead. (lint/style/useConst) |
||||||||||
|
||||||||||
// useEffect(() => { | ||||||||||
// if (props?.props?.summaryErrors) { | ||||||||||
// if (props?.props?.summaryErrors?.deliveryErrors) { | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" /> | ||
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" /> | ||
<!-- added below css for hcm-workbench module inclusion--> | ||
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].52/dist/index.css" /> | ||
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].53/dist/index.css" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider documenting the CSS changes. To help with future maintenance, consider documenting the specific product chip and summary issues that were fixed in this CSS version update. 💡 Codebase verification Package version 0.1.53 is not accessible on unpkg CDN The specified CSS package version
🔗 Analysis chainLGTM! Verify the package accessibility. The CSS version update appears to be related to fixing product chip and summary issues. Let's verify that the updated package exists and is accessible: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the health CSS package version exists and is accessible
# Expected: HTTP 200 status code if the package exists and is accessible
curl -I "https://unpkg.com/@egovernments/[email protected]/dist/index.css"
Length of output: 889 |
||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#00bcd1" /> | ||
<title>DIGIT HCM</title> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Consider adding integrity hashes for enhanced security
The CSS resources are loaded from unpkg.com without integrity hashes. Consider adding integrity checks to prevent supply chain attacks.
Example format: