-
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
project type config simplified #1539
Changes from 1 commit
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 | ||||
---|---|---|---|---|---|---|
|
@@ -85,44 +85,92 @@ function reverseDeliveryRemap(data, t) { | |||||
let currentCycleIndex = null; | ||||||
let currentCycle = null; | ||||||
|
||||||
// data.forEach((item, index) => { | ||||||
// if (currentCycleIndex !== item.cycleNumber) { | ||||||
// currentCycleIndex = item.cycleNumber; | ||||||
// currentCycle = { | ||||||
// cycleIndex: currentCycleIndex.toString(), | ||||||
// startDate: item?.startDate ? Digit.Utils.date.convertEpochToDate(item?.startDate) : null, | ||||||
// endDate: item?.endDate ? Digit.Utils.date.convertEpochToDate(item?.endDate) : null, | ||||||
// active: index === 0, // Initialize active to false | ||||||
// deliveries: [], | ||||||
// }; | ||||||
// reversedData.push(currentCycle); | ||||||
// } | ||||||
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 transformedCycles = cycles.map((cycle) => { | ||||||
const deliveries = cycle.deliveries?.map((delivery, deliveryIndex) => { | ||||||
const doseCriteria = delivery.doseCriteria?.flatMap((criteria, ruleKey) => { | ||||||
const products = criteria.ProductVariants.map((variant, key) => ({ | ||||||
key: key + 1, | ||||||
count: 1, | ||||||
value: variant.productVariantId, | ||||||
name: variant.name | ||||||
})); | ||||||
|
||||||
const condition = criteria.condition; | ||||||
let conditionParts = condition.split("and").map(part => part.trim()); | ||||||
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. Use The variable Apply this fix: - let conditionParts = condition.split("and").map(part => part.trim());
+ const conditionParts = condition.split("and").map(part => part.trim()); 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||
let rules = []; | ||||||
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. Use The variable Apply this fix: - let rules = [];
+ const rules = []; 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||
conditionParts.forEach((part) => { | ||||||
const parts = part.split(' ').filter(Boolean); | ||||||
|
||||||
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. Use The variable Apply this fix: - let attributes = [];
+ const attributes = []; 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||
if (parts.length === 5 && (parts[1] === "<=" || parts[1] === "<") && (parts[3] === "<" || parts[3] === "<=")) { | ||||||
const toValue = parts[0]; | ||||||
const fromValue = parts[4]; | ||||||
attributes.push({ | ||||||
key: 1, // Incrementing key for each attribute | ||||||
operator: { code: operatorMapping["IN_BETWEEN"] }, | ||||||
attribute: { code: parts[2] }, | ||||||
fromValue, | ||||||
toValue | ||||||
}); | ||||||
} else { | ||||||
// Parse single conditions using regex | ||||||
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, // Incrementing key for each attribute | ||||||
value, | ||||||
operator: { code: operatorMapping[operatorSymbol] }, | ||||||
attribute: { code: attributeCode } | ||||||
}); | ||||||
} | ||||||
} | ||||||
|
||||||
// const deliveryIndex = item.deliveryNumber.toString(); | ||||||
// Add each part as a new delivery rule | ||||||
rules.push({ | ||||||
ruleKey: ruleKey + 1, | ||||||
delivery: {}, | ||||||
products, | ||||||
attributes | ||||||
}); | ||||||
}); | ||||||
|
||||||
// let delivery = currentCycle.deliveries.find((delivery) => delivery.deliveryIndex === deliveryIndex); | ||||||
return rules; | ||||||
}); | ||||||
|
||||||
// if (!delivery) { | ||||||
// delivery = { | ||||||
// deliveryIndex: deliveryIndex, | ||||||
// active: item.deliveryNumber === 1, // Set active to true only for the first delivery | ||||||
// deliveryRules: [], | ||||||
// }; | ||||||
// currentCycle.deliveries.push(delivery); | ||||||
// } | ||||||
return { | ||||||
active: true, | ||||||
deliveryIndex: String(deliveryIndex + 1), | ||||||
deliveryRules: doseCriteria | ||||||
}; | ||||||
}); | ||||||
|
||||||
return { | ||||||
active: true, | ||||||
cycleIndex: String(cycle.id), | ||||||
deliveries: deliveries | ||||||
}; | ||||||
}); | ||||||
|
||||||
return transformedCycles; | ||||||
|
||||||
// delivery.deliveryRules.push({ | ||||||
// ruleKey: item.deliveryRuleNumber, | ||||||
// delivery: {}, | ||||||
// attributes: loopAndReturn(item.conditions, t), | ||||||
// products: [...item.products], | ||||||
// }); | ||||||
// }); | ||||||
return data; | ||||||
|
||||||
return reversedData; | ||||||
} | ||||||
|
||||||
|
||||||
function boundaryDataGrp(boundaryData) { | ||||||
// Create an empty object to hold grouped data by type | ||||||
const groupedData = {}; | ||||||
|
@@ -406,16 +454,16 @@ const CampaignSummary = (props) => { | |||||
{ | ||||||
key: "CAMPAIGN_NO_OF_CYCLES", | ||||||
value: | ||||||
data?.[0]?.deliveryRules && data?.[0]?.deliveryRules.map((item) => item.cycleIndex)?.length > 0 | ||||||
? Math.max(...data?.[0]?.deliveryRules.map((item) => item.cycleIndex)) | ||||||
data?.[0]?.additionalDetails?.cycleData?.cycleConfgureDate?.cycle ? | ||||||
data?.[0]?.additionalDetails?.cycleData?.cycleConfgureDate?.cycle | ||||||
: t("CAMPAIGN_SUMMARY_NA"), | ||||||
}, | ||||||
{ | ||||||
key: "CAMPAIGN_NO_OF_DELIVERIES", | ||||||
value: | ||||||
data?.[0]?.deliveryRules && data?.[0]?.deliveryRules?.flatMap((rule) => rule?.deliveries?.map((delivery) => delivery?.deliveryIndex))?.length > 0 | ||||||
? Math.max(...data?.[0]?.deliveryRules?.flatMap((rule) => rule?.deliveries?.map((delivery) => delivery?.deliveryIndex))) | ||||||
: t("CAMPAIGN_SUMMARY_NA"), | ||||||
data?.[0]?.additionalDetails?.cycleData?.cycleConfgureDate?.deliveries ? | ||||||
data?.[0]?.additionalDetails?.cycleData?.cycleConfgureDate?.deliveries | ||||||
: t("CAMPAIGN_SUMMARY_NA"), | ||||||
}, | ||||||
], | ||||||
}, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,7 +214,7 @@ const CampaignUpdateSummary = (props) => { | |
}, | ||
cardHeader: { value: t("TARGET_DETAILS"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } }, | ||
cardSecondaryAction: noAction !== "false" && ( | ||
<div className="campaign-preview-edit-container" onClick={() => handleRedirect(2)}> | ||
<div className="campaign-preview-edit-container" onClick={() => handleRedirect(4)}> | ||
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) Approve changes to The updates to the Consider refactoring the URL parameter update logic into a separate function: const updateUrlParams = (params) => {
const urlParams = new URLSearchParams(window.location.search);
Object.entries(params).forEach(([key, value]) => urlParams.set(key, value));
return `${window.location.pathname}?${urlParams.toString()}`;
};
const handleRedirect = (step, activeCycle) => {
const params = { key: step, preview: false };
if (activeCycle) params.activeCycle = activeCycle;
const newUrl = updateUrlParams(params);
history.push(newUrl);
}; This refactoring improves code organization and makes it easier to update URL parameters consistently across the component. Also applies to: 237-237, 257-257 🧰 Tools🪛 Biome
Update redirection steps and improve accessibility for secondary actions. The changes to the redirection steps in the To improve accessibility, add keyboard event handlers to these clickable div elements. Here's an example of how to modify the "target" section (apply similar changes to "facility" and "user" sections): <div
className="campaign-preview-edit-container"
onClick={() => handleRedirect(4)}
onKeyDown={(e) => e.key === 'Enter' && handleRedirect(4)}
tabIndex={0}
role="button"
aria-label={t("CAMPAIGN_EDIT_TARGET")}
>
<span>{t(`CAMPAIGN_EDIT`)}</span>
<EditIcon />
</div> These changes ensure that the edit actions are accessible to keyboard users, improving the overall accessibility of the component. Also applies to: 237-237, 257-257 🧰 Tools🪛 Biome
|
||
<span>{t(`CAMPAIGN_EDIT`)}</span> | ||
<EditIcon /> | ||
</div> | ||
|
@@ -234,7 +234,7 @@ const CampaignUpdateSummary = (props) => { | |
}, | ||
cardHeader: { value: t("FACILITY_DETAILS"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } }, | ||
cardSecondaryAction: noAction !== "false" && ( | ||
<div className="campaign-preview-edit-container" onClick={() => handleRedirect(3)}> | ||
<div className="campaign-preview-edit-container" onClick={() => handleRedirect(2)}> | ||
<span>{t(`CAMPAIGN_EDIT`)}</span> | ||
<EditIcon /> | ||
</div> | ||
|
@@ -254,7 +254,7 @@ const CampaignUpdateSummary = (props) => { | |
}, | ||
cardHeader: { value: t("USER_DETAILS"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } }, | ||
cardSecondaryAction: noAction !== "false" && ( | ||
<div className="campaign-preview-edit-container" onClick={() => handleRedirect(4)}> | ||
<div className="campaign-preview-edit-container" onClick={() => handleRedirect(3)}> | ||
<span>{t(`CAMPAIGN_EDIT`)}</span> | ||
<EditIcon /> | ||
</div> | ||
|
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.
make them into multiple readble functions