-
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
Redirect to edit screen #1951
base: console
Are you sure you want to change the base?
Redirect to edit screen #1951
Conversation
Warning Rate limit exceeded@abishekTa-egov has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 50 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThe pull request introduces several enhancements to the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
row.campaignDetails.id | ||
}`; | ||
} | ||
const searchPlanConfig = async (body) => { |
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.
this is wrong @abishekTa-egov directly access from row object you can't make any api calls here this is sync logic not async
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.
resolved
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.
Actionable comments posted: 3
🧹 Outside diff range comments (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (1)
Line range hint
819-819
: Provide user feedback when the download failsIn the
handleDownload
function, when thefileId
is not found, it logs an error to the console but doesn't inform the user. To enhance user experience, consider displaying an error message to the user.Apply this diff to provide user feedback:
const handleDownload = () => { const files = row?.files; const file = files.find((item) => item.templateIdentifier === "Population"); const fileId = file?.filestoreId; if (!fileId) { - console.error("Population template file not found"); + // Display an error message to the user + Digit.Utils.toast.error(t("ERROR_POPULATION_TEMPLATE_NOT_FOUND")); return; } const campaignName = row?.name || ""; Digit.Utils.campaign.downloadExcelWithCustomName({ fileStoreId: fileId, customName: campaignName }); };Also applies to: 864-864
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (3)
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js
(3 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js (1)
Pattern **/*.js
: check
🔇 Additional comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (1)
Line range hint 828-851
: Duplicate 'searchPlanConfig' function found
The searchPlanConfig
function within the onActionSelect
method is duplicated from earlier code (lines 111-119). Refactoring this function into a shared utility will prevent redundancy and simplify maintenance.
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js (1)
819-819
: Approve variable assignment
The assignment of campaignName
with a default value is appropriate and follows best practices.
const searchPlanConfig = async (body) => { | ||
//assuming it will be success | ||
const response = await Digit.CustomService.getResponse({ | ||
url: "/plan-service/config/_search", | ||
useCache: false, | ||
method: "POST", | ||
userService: true, | ||
body | ||
}); |
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.
🛠️ Refactor suggestion
Refactor 'searchPlanConfig' function to reduce code duplication
The searchPlanConfig
function is defined within the onActionSelect
method and is duplicated elsewhere in the code (see lines 828-851). To improve maintainability and reduce code duplication, consider extracting this function into a shared utility or moving it to a higher scope.
@@ -236,7 +238,7 @@ const createUpdatePlanProject = async (req) => { | |||
//later this object must have an invalidation config which can be used to invalidate data such as files uploaded,assumptions,formulas etc... | |||
|
|||
const { totalFormData, state, setShowToast, setCurrentKey, setCurrentStep, config, invalidateConfig } = req; | |||
const { microplanId, campaignId } = Digit.Hooks.useQueryParams(); | |||
const { microplanId, campaignId} = Digit.Hooks.useQueryParams(); |
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.
Avoid calling hooks inside non-react functions
Similar to the previous comment, calling Digit.Hooks.useQueryParams()
inside the createUpdatePlanProject
function, which is not a React component or custom hook, can cause issues.
Pass microplanId
and campaignId
as parameters to the function instead:
-const createUpdatePlanProject = async (req) => {
+const createUpdatePlanProject = async (req, params) => {
try {
const { totalFormData, state, setShowToast, setCurrentKey, setCurrentStep, config, invalidateConfig } = req;
- const { microplanId, campaignId } = Digit.Hooks.useQueryParams();
+ const { microplanId, campaignId } = params;
Ensure to pass the params
when calling createUpdatePlanProject
.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const { microplanId, campaignId} = Digit.Hooks.useQueryParams(); | |
const createUpdatePlanProject = async (req, params) => { | |
const { microplanId, campaignId } = params; |
const { key} = Digit.Hooks.useQueryParams(); | ||
req.additionalDetails.key=key; |
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.
Ensure 'useQueryParams' is called correctly
The Digit.Hooks.useQueryParams()
hook should be called inside a React component or a custom hook. Using it directly within a non-react function (updatePlan
) may lead to unexpected behavior.
Consider refactoring to pass key
as a parameter to the updatePlan
function:
-const updatePlan = async (req) => {
- const { key } = Digit.Hooks.useQueryParams();
- req.additionalDetails.key = key;
+const updatePlan = async (req, key) => {
+ req.additionalDetails.key = key;
And update the places where updatePlan
is called to pass the key
appropriately.
Committable suggestion skipped: line range outside the PR's diff.
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsForm.js
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsForm.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js (1)
Pattern **/*.js
: check
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js
[error] 120-120: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js
[error] 772-799: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
[error] 802-807: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
🔇 Additional comments (4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (1)
111-133
:
Avoid making asynchronous API calls inside synchronous action handlers
Making an asynchronous API call within the onActionSelect
function can lead to unexpected behavior since this logic is expected to be synchronous. Consider accessing the required data directly from row
or refactoring the function to handle asynchronous operations appropriately.
🧰 Tools
🪛 Biome (1.9.4)
[error] 120-120: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsForm.js (1)
71-74
: State synchronization looks good
The added useEffect
correctly updates the state based on session data changes.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js (2)
225-226
:
Avoid calling React hooks inside non-React functions
Using Digit.Hooks.useQueryParams()
inside updatePlan
, which is not a React component or custom hook, can lead to unexpected behavior. React hooks should only be called at the top level of React components or custom hooks. Consider passing key
as a parameter instead.
241-241
:
Avoid calling React hooks inside non-React functions
Using Digit.Hooks.useQueryParams()
inside createUpdatePlanProject
may cause issues since it's not a React component or custom hook. Consider passing microplanId
and campaignId
as parameters to the function instead.
userService: true, | ||
body | ||
}); | ||
window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(parseInt(response?.PlanConfiguration[0]?.additionalDetails?.key || "0")+1)}µplanId=${row.id}&campaignId=${ |
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)
Use Number.parseInt
instead of global parseInt
ES2015 moved some globals into the Number
namespace for consistency. Using Number.parseInt
is preferred over the global parseInt
.
Apply this diff to update the code:
-window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(parseInt(response?.PlanConfiguration[0]?.additionalDetails?.key || "0")+1)}µplanId=${row.id}&campaignId=${
+window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(Number.parseInt(response?.PlanConfiguration[0]?.additionalDetails?.key || "0")+1)}µplanId=${row.id}&campaignId=${
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(parseInt(response?.PlanConfiguration[0]?.additionalDetails?.key || "0")+1)}µplanId=${row.id}&campaignId=${ | |
window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(Number.parseInt(response?.PlanConfiguration[0]?.additionalDetails?.key || "0")+1)}µplanId=${row.id}&campaignId=${ |
🧰 Tools
🪛 Biome (1.9.4)
[error] 120-120: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
case "ROLE_ACCESS_CONFIGURATION": | ||
// Function to run API validations | ||
const searchAndUpdatePlanConfig = async (body) => { | ||
try { | ||
// Make the API call | ||
const { key} = Digit.Hooks.useQueryParams(); | ||
const fetchedPlanConfig = await searchPlanConfig({ | ||
PlanConfigurationSearchCriteria: { | ||
tenantId, | ||
id: microplanId, | ||
}, | ||
}); | ||
|
||
const response = await Digit.CustomService.getResponse({ | ||
url: "/plan-service/config/_update", | ||
body: { | ||
PlanConfiguration: {...fetchedPlanConfig, | ||
additionalDetails:{...fetchedPlanConfig.additionalDetails,key:key | ||
}}, | ||
}, | ||
}); | ||
|
||
// Process the response if necessary | ||
console.log("API Response:", response); | ||
return response; // Return the response for further usage if needed | ||
} catch (error) { | ||
console.error("Error in searchPlanConfig:", error); | ||
throw error; // Rethrow error to handle it further up the chain if needed | ||
} | ||
}; | ||
|
||
// Request body for the API call | ||
const reqBody = { | ||
PlanConfigurationSearchCriteria: { | ||
id: microplanId, | ||
tenantId: Digit.ULBService.getCurrentTenantId(), | ||
}, | ||
}; | ||
|
||
// Execute the API call | ||
try { | ||
const apiResponse = await searchAndUpdatePlanConfig(reqBody); // Wait for the API call to complete | ||
console.log("API call completed successfully:", apiResponse); | ||
|
||
// Proceed with the rest of the logic | ||
setCurrentKey((prev) => prev + 1); | ||
setCurrentStep((prev) => prev + 1); | ||
window.dispatchEvent(new Event("isLastStep")); | ||
Digit.Utils.microplanv1.updateUrlParams({ isLastVerticalStep: null }); | ||
Digit.Utils.microplanv1.updateUrlParams({ internalKey: null }); | ||
|
||
// Return as expected | ||
return { | ||
triggeredFrom, | ||
}; | ||
} catch (error) { | ||
console.error("Error during ROLE_ACCESS_CONFIGURATION flow:", error); | ||
// Optionally handle the error here, e.g., show an error message to the user | ||
return { | ||
error: "API call failed. Please try again.", | ||
}; | ||
} | ||
|
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.
Wrap switch case body in braces to limit scope of declarations
Declaring functions and variables within a switch case without wrapping the case body in braces can cause scope leakage where other cases may access these declarations unexpectedly. Wrap the code inside the 'ROLE_ACCESS_CONFIGURATION'
case with braces {}
to ensure proper scoping.
Apply this diff to fix the scoping issue:
case "ROLE_ACCESS_CONFIGURATION":
+ {
// Function to run API validations
const searchAndUpdatePlanConfig = async (body) => {
// code
};
// Request body for the API call
const reqBody = {
// ...
};
// Execute the API call
try {
// code
} catch (error) {
// code
}
+ }
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
case "ROLE_ACCESS_CONFIGURATION": | |
// Function to run API validations | |
const searchAndUpdatePlanConfig = async (body) => { | |
try { | |
// Make the API call | |
const { key} = Digit.Hooks.useQueryParams(); | |
const fetchedPlanConfig = await searchPlanConfig({ | |
PlanConfigurationSearchCriteria: { | |
tenantId, | |
id: microplanId, | |
}, | |
}); | |
const response = await Digit.CustomService.getResponse({ | |
url: "/plan-service/config/_update", | |
body: { | |
PlanConfiguration: {...fetchedPlanConfig, | |
additionalDetails:{...fetchedPlanConfig.additionalDetails,key:key | |
}}, | |
}, | |
}); | |
// Process the response if necessary | |
console.log("API Response:", response); | |
return response; // Return the response for further usage if needed | |
} catch (error) { | |
console.error("Error in searchPlanConfig:", error); | |
throw error; // Rethrow error to handle it further up the chain if needed | |
} | |
}; | |
// Request body for the API call | |
const reqBody = { | |
PlanConfigurationSearchCriteria: { | |
id: microplanId, | |
tenantId: Digit.ULBService.getCurrentTenantId(), | |
}, | |
}; | |
// Execute the API call | |
try { | |
const apiResponse = await searchAndUpdatePlanConfig(reqBody); // Wait for the API call to complete | |
console.log("API call completed successfully:", apiResponse); | |
// Proceed with the rest of the logic | |
setCurrentKey((prev) => prev + 1); | |
setCurrentStep((prev) => prev + 1); | |
window.dispatchEvent(new Event("isLastStep")); | |
Digit.Utils.microplanv1.updateUrlParams({ isLastVerticalStep: null }); | |
Digit.Utils.microplanv1.updateUrlParams({ internalKey: null }); | |
// Return as expected | |
return { | |
triggeredFrom, | |
}; | |
} catch (error) { | |
console.error("Error during ROLE_ACCESS_CONFIGURATION flow:", error); | |
// Optionally handle the error here, e.g., show an error message to the user | |
return { | |
error: "API call failed. Please try again.", | |
}; | |
} | |
case "ROLE_ACCESS_CONFIGURATION": { | |
// Function to run API validations | |
const searchAndUpdatePlanConfig = async (body) => { | |
try { | |
// Make the API call | |
const { key} = Digit.Hooks.useQueryParams(); | |
const fetchedPlanConfig = await searchPlanConfig({ | |
PlanConfigurationSearchCriteria: { | |
tenantId, | |
id: microplanId, | |
}, | |
}); | |
const response = await Digit.CustomService.getResponse({ | |
url: "/plan-service/config/_update", | |
body: { | |
PlanConfiguration: {...fetchedPlanConfig, | |
additionalDetails:{...fetchedPlanConfig.additionalDetails,key:key | |
}}, | |
}, | |
}); | |
// Process the response if necessary | |
console.log("API Response:", response); | |
return response; // Return the response for further usage if needed | |
} catch (error) { | |
console.error("Error in searchPlanConfig:", error); | |
throw error; // Rethrow error to handle it further up the chain if needed | |
} | |
}; | |
// Request body for the API call | |
const reqBody = { | |
PlanConfigurationSearchCriteria: { | |
id: microplanId, | |
tenantId: Digit.ULBService.getCurrentTenantId(), | |
}, | |
}; | |
// Execute the API call | |
try { | |
const apiResponse = await searchAndUpdatePlanConfig(reqBody); // Wait for the API call to complete | |
console.log("API call completed successfully:", apiResponse); | |
// Proceed with the rest of the logic | |
setCurrentKey((prev) => prev + 1); | |
setCurrentStep((prev) => prev + 1); | |
window.dispatchEvent(new Event("isLastStep")); | |
Digit.Utils.microplanv1.updateUrlParams({ isLastVerticalStep: null }); | |
Digit.Utils.microplanv1.updateUrlParams({ internalKey: null }); | |
// Return as expected | |
return { | |
triggeredFrom, | |
}; | |
} catch (error) { | |
console.error("Error during ROLE_ACCESS_CONFIGURATION flow:", error); | |
// Optionally handle the error here, e.g., show an error message to the user | |
return { | |
error: "API call failed. Please try again.", | |
}; | |
} | |
} |
🧰 Tools
🪛 Biome (1.9.4)
[error] 772-799: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
[error] 802-807: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
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.
Actionable comments posted: 3
🧹 Outside diff range comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (2)
Line range hint
827-827
: Use strict equality operator===
instead of==
For type-safe comparison, use
===
instead of==
when comparing values.Apply this diff to update the code:
- if (e.name == "MP_ACTIONS_EDIT_SETUP") { + if (e.name === "MP_ACTIONS_EDIT_SETUP") {🧰 Tools
🪛 Biome (1.9.4)
[error] 111-111: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.(lint/style/useNumberNamespace)
Line range hint
832-832
: Use strict equality operator===
instead of==
To ensure correct type comparison, use
===
instead of==
.Apply this diff to update the code:
- if (e.name == "MP_ACTIONS_VIEW_SUMMARY") { + if (e.name === "MP_ACTIONS_VIEW_SUMMARY") {🧰 Tools
🪛 Biome (1.9.4)
[error] 111-111: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.(lint/style/useNumberNamespace)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (2)
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js
(2 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js (1)
Pattern **/*.js
: check
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js
[error] 111-111: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js
[error] 828-828: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
🔇 Additional comments (4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (2)
111-111
: Use Number.parseInt
instead of global parseInt
ES2015 introduced Number.parseInt
for consistency. Replace the global parseInt
with Number.parseInt
.
Apply this diff to update the code:
- window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${
+ window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(Number.parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${
🧰 Tools
🪛 Biome (1.9.4)
[error] 111-111: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
Line range hint 828-828
: Use Number.parseInt
instead of global parseInt
Replace the global parseInt
with Number.parseInt
for consistency with ES2015 standards.
Apply this diff to update the code:
- window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${
+ window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(Number.parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${
🧰 Tools
🪛 Biome (1.9.4)
[error] 111-111: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js (2)
832-832
: 🧹 Nitpick (assertive)
Use strict equality operator ===
instead of ==
For accurate type comparison, replace ==
with ===
.
Apply this diff to update the code:
- if (e.name == "MP_ACTIONS_VIEW_SUMMARY") {
+ if (e.name === "MP_ACTIONS_VIEW_SUMMARY") {
Likely invalid or redundant comment.
828-828
: 🧹 Nitpick (assertive)
Use strict equality operator ===
instead of ==
It's best practice to use ===
for strict equality comparisons in JavaScript.
Apply this diff to update the code:
- if (e.name == "MP_ACTIONS_EDIT_SETUP") {
+ if (e.name === "MP_ACTIONS_EDIT_SETUP") {
Likely invalid or redundant comment.
🧰 Tools
🪛 Biome (1.9.4)
[error] 828-828: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
row.campaignDetails.id | ||
}`; | ||
} | ||
if (e.name == "MP_ACTIONS_EDIT_SETUP") { |
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)
Use strict equality operator ===
instead of ==
To ensure type-safe comparisons in JavaScript, it's recommended to use ===
instead of ==
.
Apply this diff to update the code:
- if (e.name == "MP_ACTIONS_EDIT_SETUP") {
+ if (e.name === "MP_ACTIONS_EDIT_SETUP") {
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (e.name == "MP_ACTIONS_EDIT_SETUP") { | |
if (e.name === "MP_ACTIONS_EDIT_SETUP") { |
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.
resolved
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.
@TAAbishek, thank you for resolving the issue!
(^‿^)/
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
if (e.name == "MP_ACTIONS_EDIT_SETUP") { | ||
window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${ | ||
row.campaignDetails.id | ||
}`; | ||
} | ||
|
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)
Refactor 'onActionSelect' function to reduce code duplication
The onActionSelect
function appears to be duplicated across different configurations. Consider extracting it into a shared utility to enhance maintainability.
🧰 Tools
🪛 Biome (1.9.4)
[error] 828-828: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
}`; | ||
} | ||
if (e.name == "MP_ACTIONS_EDIT_SETUP") { | ||
window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${ |
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.
🛠️ Refactor suggestion
Use Number.parseInt
instead of global parseInt
Replace the global parseInt
with Number.parseInt
for consistency and adherence to ES2015 standards.
Apply this diff to update the code:
- window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${
+ window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(Number.parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${ | |
window.location.href = `/${window.contextPath}/employee/microplan/setup-microplan?key=${String(Number.parseInt(row?.additionalDetails?.key || '0') + 1)}µplanId=${row.id}&campaignId=${ |
🧰 Tools
🪛 Biome (1.9.4)
[error] 828-828: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (4)
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js
(2 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsForm.js
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/AssumptionsForm.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js (1)
Pattern **/*.js
: check
🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js
[error] 111-111: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
[error] 112-112: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js
[error] 828-828: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
[error] 829-829: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
🔇 Additional comments (4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/configs/UICustomizations.js (1)
111-112
: Use Number.parseInt
instead of global parseInt
Replace the global parseInt
with Number.parseInt
for consistency and adherence to ES2015 standards.
Also applies to: 828-829
🧰 Tools
🪛 Biome (1.9.4)
[error] 111-111: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
[error] 112-112: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
health/micro-ui/web/micro-ui-internals/example/src/UICustomizations.js (1)
828-829
: Use Number.parseInt
instead of global parseInt
Replace the global parseInt
with Number.parseInt
for consistency and adherence to ES2015 standards.
🧰 Tools
🪛 Biome (1.9.4)
[error] 828-828: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
[error] 829-829: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.
(lint/style/useNumberNamespace)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/createUpdatePlanProject.js (2)
263-264
:
Avoid calling hooks inside non-React functions
Hooks like useQueryParams
should be called only within React components or custom hooks, not inside regular functions. Calling them here may lead to unexpected behavior.
Also applies to: 279-279
808-871
:
Avoid calling hooks inside non-React functions and wrap switch case body in braces
Calling useQueryParams
inside a regular function within a switch case is not appropriate and can cause issues. Additionally, declaring functions inside a switch case without wrapping the case body in braces can lead to scope leakage.
useEffect(()=>{ | ||
setSelectedDistributionProcess(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedDistributionProcess); | ||
setSelectedRegistrationProcess(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationProcess); | ||
setSelectedRegistrationDistributionMode(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationDistributionMode ) | ||
},[props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm]) |
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)
Simplify state updates by destructuring props
To improve readability, consider destructuring props
to avoid repetitive nested property access.
Apply this diff to simplify the code:
+ const { selectedDistributionProcess, selectedRegistrationProcess, selectedRegistrationDistributionMode } = props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm;
useEffect(() => {
- setSelectedDistributionProcess(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedDistributionProcess);
- setSelectedRegistrationProcess(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationProcess);
- setSelectedRegistrationDistributionMode(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationDistributionMode);
+ setSelectedDistributionProcess(selectedDistributionProcess);
+ setSelectedRegistrationProcess(selectedRegistrationProcess);
+ setSelectedRegistrationDistributionMode(selectedRegistrationDistributionMode);
}, [props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm]);
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
useEffect(()=>{ | |
setSelectedDistributionProcess(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedDistributionProcess); | |
setSelectedRegistrationProcess(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationProcess); | |
setSelectedRegistrationDistributionMode(props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm?.selectedRegistrationDistributionMode ) | |
},[props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm]) | |
const { selectedDistributionProcess, selectedRegistrationProcess, selectedRegistrationDistributionMode } = props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm; | |
useEffect(()=>{ | |
setSelectedDistributionProcess(selectedDistributionProcess); | |
setSelectedRegistrationProcess(selectedRegistrationProcess); | |
setSelectedRegistrationDistributionMode(selectedRegistrationDistributionMode); | |
},[props?.props?.sessionData?.ASSUMPTIONS_FORM?.assumptionsForm]) |
Redirect to edit screen
Summary by CodeRabbit
New Features
Bug Fixes
Documentation