-
Notifications
You must be signed in to change notification settings - Fork 47
Patch update #3338
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
base: master
Are you sure you want to change the base?
Patch update #3338
Conversation
…ntid override in health packages since we have a flag to override in core itself (#3288) * updated with new version for better stability * update css versions * Updated the package version for beta 2 * upgraded the package versions * versions upgraded for core * Updated the packge version of workbench * Revert "BUGFIX:: injected the custom hook to override the getStateId method (#3265)" This reverts commit 613926d.
📝 WalkthroughWalkthroughEnvironment configuration URLs updated from hcm-demo to health-demo domain. AddOrEditMapping.js receives minor formatting adjustment. UpdateCampaign.js refactored to access campaign data through nested CampaignDetails structure and replaced custom API fetching with hook pattern, affecting multiple data dependencies and API payload construction. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Component as UpdateCampaign
participant Hook as useCustomAPIHook
participant API as API Service
rect rgb(220, 240, 250)
Note over Component: Old Pattern
Component->>Component: currentId from urlParams
Component->>Component: Direct CampaignData[0] access
end
rect rgb(240, 250, 220)
Note over Component: New Pattern
Component->>Component: id from location query params
Component->>Hook: reqCriteriaCampaign {id/parentId}
Hook->>API: Fetch campaign by criteria
API-->>Hook: Response data
Hook-->>Component: CampaignData.CampaignDetails
Component->>Component: Access CampaignData.CampaignDetails[0]
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings, 1 inconclusive)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js (1)
170-201: Remove unnecessary dependency.The
projectTypein the useEffect dependency array (Line 201) doesn't appear necessary. The effect only restructures form data fromdraftDataandparams, andprojectTypeis only checked for loading state, not used within the effect logic.Apply this diff:
- }, [params, draftData, isLoading, projectType]); + }, [params, draftData, isLoading]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
micro-ui/web/workbench/package.jsonis excluded by!**/*.json
📒 Files selected for processing (3)
health/micro-ui/web/micro-ui-internals/example/.env-hcm-demo(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js(17 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
check
Files:
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.jshealth/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
🧠 Learnings (10)
📓 Common learnings
Learnt from: jagankumar-egov
Repo: egovernments/DIGIT-Frontend PR: 3275
File: health/micro-ui/web/micro-ui-internals/packages/modules/health-hrms/src/services/urls.js:49-52
Timestamp: 2025-10-23T10:53:42.448Z
Learning: In the DIGIT-Frontend health modules (health-hrms and health-payments), service endpoint URLs should always be config-driven using window.globalConfigs.getConfig() with fallback defaults, never hardcoded. Established config keys include: HRMS_CONTEXT_PATH, ATTENDANCE_CONTEXT_PATH, INDIVIDUAL_CONTEXT_PATH, PROJECT_CONTEXT_PATH, MUSTER_ROLL_CONTEXT_PATH, EXPENSE_CONTEXT_PATH, EXPENSE_CALCULATOR_CONTEXT_PATH, and BOUNDARY_CONTEXT_PATH. The setupProxy.js file may be an exception as it's development-only.
Learnt from: Hari-egov
Repo: egovernments/DIGIT-Frontend PR: 2788
File: micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js:26-26
Timestamp: 2025-07-15T04:58:30.634Z
Learning: In the HRMS module (micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js), the team has moved away from using MDMS hooks for boundary data fetching and now uses direct API calls to the boundary service endpoint `/boundary-service/boundary-relationships/_search` instead of the `useHrmsMDMS` hook with "FetchBoundaries" parameter.
Learnt from: siddhant-nawale-egov
Repo: egovernments/DIGIT-Frontend PR: 606
File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js:276-276
Timestamp: 2024-10-08T20:11:07.772Z
Learning: The `addResourcesToFilteredDataToShow` function in `micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js` now includes checks for data integrity, such as validation of `previewData`, the common column, and `resources`, along with error logging for invalid data formats.
Learnt from: siddhant-nawale-egov
Repo: egovernments/DIGIT-Frontend PR: 606
File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js:276-276
Timestamp: 2024-06-10T19:25:42.992Z
Learning: The `addResourcesToFilteredDataToShow` function in `micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js` now includes checks for data integrity, such as validation of `previewData`, the common column, and `resources`, along with error logging for invalid data formats.
📚 Learning: 2024-11-07T11:02:33.520Z
Learnt from: rachana-egov
Repo: egovernments/DIGIT-Frontend PR: 1770
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/viewVillage.js:320-322
Timestamp: 2024-11-07T11:02:33.520Z
Learning: In `health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/viewVillage.js`, the `data?.additionalFields` object is guaranteed to be defined, so checking for its existence before accessing its keys is unnecessary.
Applied to files:
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.jshealth/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
📚 Learning: 2024-06-10T19:25:42.992Z
Learnt from: siddhant-nawale-egov
Repo: egovernments/DIGIT-Frontend PR: 606
File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js:276-276
Timestamp: 2024-06-10T19:25:42.992Z
Learning: The `addResourcesToFilteredDataToShow` function in `micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/utils/index.js` now includes checks for data integrity, such as validation of `previewData`, the common column, and `resources`, along with error logging for invalid data formats.
Applied to files:
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js
📚 Learning: 2025-07-15T04:58:30.634Z
Learnt from: Hari-egov
Repo: egovernments/DIGIT-Frontend PR: 2788
File: micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js:26-26
Timestamp: 2025-07-15T04:58:30.634Z
Learning: In the HRMS module (micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js), the team has moved away from using MDMS hooks for boundary data fetching and now uses direct API calls to the boundary service endpoint `/boundary-service/boundary-relationships/_search` instead of the `useHrmsMDMS` hook with "FetchBoundaries" parameter.
Applied to files:
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js
📚 Learning: 2024-06-10T19:25:42.992Z
Learnt from: nitish-egov
Repo: egovernments/DIGIT-Frontend PR: 0
File: :0-0
Timestamp: 2024-06-10T19:25:42.992Z
Learning: The `boundaryData` null check is performed at a higher level before calling the `getDataSheetReady` function in `utilities/project-factory/src/server/utils/genericUtils.ts`.
Applied to files:
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.jshealth/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
📚 Learning: 2025-10-23T10:53:42.448Z
Learnt from: jagankumar-egov
Repo: egovernments/DIGIT-Frontend PR: 3275
File: health/micro-ui/web/micro-ui-internals/packages/modules/health-hrms/src/services/urls.js:49-52
Timestamp: 2025-10-23T10:53:42.448Z
Learning: In the DIGIT-Frontend health modules (health-hrms and health-payments), service endpoint URLs should always be config-driven using window.globalConfigs.getConfig() with fallback defaults, never hardcoded. Established config keys include: HRMS_CONTEXT_PATH, ATTENDANCE_CONTEXT_PATH, INDIVIDUAL_CONTEXT_PATH, PROJECT_CONTEXT_PATH, MUSTER_ROLL_CONTEXT_PATH, EXPENSE_CONTEXT_PATH, EXPENSE_CALCULATOR_CONTEXT_PATH, and BOUNDARY_CONTEXT_PATH. The setupProxy.js file may be an exception as it's development-only.
Applied to files:
health/micro-ui/web/micro-ui-internals/example/.env-hcm-demo
📚 Learning: 2024-09-30T05:45:14.549Z
Learnt from: ashish-egov
Repo: egovernments/DIGIT-Frontend PR: 1441
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/useGenerateIdCampaign.js:1-1
Timestamp: 2024-09-30T05:45:14.549Z
Learning: In the `useGenerateIdCampaign` function, auto assignment of default parameter values is needed in parameter destructuring.
Applied to files:
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
📚 Learning: 2024-11-07T07:17:27.636Z
Learnt from: jagankumar-egov
Repo: egovernments/DIGIT-Frontend PR: 1763
File: health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/MyCampaign.js:65-75
Timestamp: 2024-11-07T07:17:27.636Z
Learning: In `MyCampaign.js`, when suggesting code improvements for the `onClickRow` function, keep suggestions simple and avoid unnecessary complexity.
Applied to files:
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
📚 Learning: 2024-06-10T19:25:42.992Z
Learnt from: siddhant-nawale-egov
Repo: egovernments/DIGIT-Frontend PR: 606
File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/hooks/index.js:19-19
Timestamp: 2024-06-10T19:25:42.992Z
Learning: The `useGenerateIdCampaign` hook is planned to be used in the Upload section in the future.
Applied to files:
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
📚 Learning: 2024-06-10T19:25:42.992Z
Learnt from: siddhant-nawale-egov
Repo: egovernments/DIGIT-Frontend PR: 803
File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Upload.js:300-341
Timestamp: 2024-06-10T19:25:42.992Z
Learning: If the `boundaryDataGeneration` function in `Upload.js` fails, it indicates that there is no data for that campaign, and this is an acceptable outcome. Retrying the operation is unnecessary as it would yield the same result.
Applied to files:
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
🔇 Additional comments (13)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js (1)
13-13: Formatting change only.This extra blank line has no functional impact.
health/micro-ui/web/micro-ui-internals/example/.env-hcm-demo (1)
5-7: Verify the environment configuration consistency.Lines 5-6 update the proxy endpoints to
health-demo.digit.org, but Line 7 still referenceshcm-demo-assets. Confirm whether this is intentional or if Line 7 should also point to health-demo resources.health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js (11)
42-42: LGTM: Simplified state management.Replacing urlParams/currentId with a single
idstate initialized from query parameters streamlines the code.
101-102: LGTM: Correct data structure reference.The useEffect correctly accesses the hierarchyType from the updated nested CampaignDetails structure.
125-137: LGTM: Consistent with state management update.The enabled condition correctly uses
idinstead of the removedcurrentId.
226-236: LGTM: Correct configuration update.The useEffect properly updates the campaign configuration based on the CampaignDetails data structure and includes the appropriate dependencies.
258-277: LGTM: Correct condition and payload construction.The condition correctly uses
id, and the payload properly constructs data from CampaignDetails with appropriate conditional logic forparentIdandid.
340-410: LGTM: Draft creation logic correctly implemented.The initial draft creation properly handles the payload construction with conditional
idassignment and correctly updates the local state after successful mutation.
617-620: LGTM: Correct data structure usage.The boundary restructuring correctly references
CampaignData?.CampaignDetails?.[0]?.boundariesconsistent with the updated data model.
667-670: LGTM: Correct boundary validation.The boundary difference check correctly uses
CampaignData?.CampaignDetails?.[0]?.boundariesfor comparison.
737-743: LGTM: Correct condition update.The skip API call condition correctly uses
idinstead of the removedcurrentId.
936-936: LGTM: Performance optimization added.Wrapping the component with
React.memois a good practice to prevent unnecessary re-renders when props haven't changed.
411-489: Verify the data source change for payload construction.Line 413 now spreads
CampaignData?.CampaignDetails?.[0]instead ofdraftData. This is a significant change in data source:
draftDatacomes fromuseSearchCampaignhook (lines 125-137)CampaignData?.CampaignDetails?.[0]comes from the newuseCustomAPIHook(line 98)Ensure this change is intentional and that both hooks return compatible data structures. If they fetch from different endpoints or have different response shapes, this could cause data loss or incorrect updates.
Run the following script to verify the API endpoints and response structures:
| const reqCriteriaCampaign = { | ||
| url: `/project-factory/v1/project-type/search`, | ||
| body: { | ||
| CampaignDetails: { | ||
| tenantId: tenantId, | ||
| ids: [id?id:parentId], | ||
| ...(isDraftCampaign && { status: ["drafted"] }), | ||
| }, | ||
| }, | ||
| config: { | ||
| enabled: currentId ? true : parentId ? true : false, | ||
| enabled: parentId ? true : false, | ||
| }, | ||
| }); | ||
| }; | ||
|
|
||
| const { data: CampaignData } = Digit.Hooks.useCustomAPIHook(reqCriteriaCampaign); |
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.
Fix the enabled condition logic.
Line 94 enables the API call only when parentId is truthy, but Line 89 accepts either id or parentId. This creates a scenario where if only id exists (without parentId), the API call won't execute even though it should.
Apply this diff:
config: {
- enabled: parentId ? true : false,
+ enabled: !!(id || parentId),
},📝 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 reqCriteriaCampaign = { | |
| url: `/project-factory/v1/project-type/search`, | |
| body: { | |
| CampaignDetails: { | |
| tenantId: tenantId, | |
| ids: [id?id:parentId], | |
| ...(isDraftCampaign && { status: ["drafted"] }), | |
| }, | |
| }, | |
| config: { | |
| enabled: currentId ? true : parentId ? true : false, | |
| enabled: parentId ? true : false, | |
| }, | |
| }); | |
| }; | |
| const { data: CampaignData } = Digit.Hooks.useCustomAPIHook(reqCriteriaCampaign); | |
| const reqCriteriaCampaign = { | |
| url: `/project-factory/v1/project-type/search`, | |
| body: { | |
| CampaignDetails: { | |
| tenantId: tenantId, | |
| ids: [id?id:parentId], | |
| ...(isDraftCampaign && { status: ["drafted"] }), | |
| }, | |
| }, | |
| config: { | |
| enabled: !!(id || parentId), | |
| }, | |
| }; | |
| const { data: CampaignData } = Digit.Hooks.useCustomAPIHook(reqCriteriaCampaign); |
🤖 Prompt for AI Agents
In
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
around lines 84 to 98, the API call is only enabled when parentId is truthy
which breaks the intended behavior that it should run when either id or parentId
exists; change the config.enabled logic to be true when either id or parentId is
present (e.g., use a boolean test for id OR parentId), and also ensure the ids
array is constructed to use id if present otherwise parentId so the request body
matches the same id-or-parentId semantics.
| setId(data?.CampaignDetails?.id); | ||
| setIsDraftCreated(true); | ||
|
|
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 | 🔵 Trivial
Remove the stray empty line.
Line 396 appears to be a leftover from refactoring, possibly where a comment or TODO was removed.
Apply this diff:
setId(data?.CampaignDetails?.id);
setIsDraftCreated(true);
-
draftRefetch();📝 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.
| setId(data?.CampaignDetails?.id); | |
| setIsDraftCreated(true); | |
| setId(data?.CampaignDetails?.id); | |
| setIsDraftCreated(true); | |
| draftRefetch(); |
🤖 Prompt for AI Agents
In
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
around lines 394 to 396, there is a stray empty line after
setIsDraftCreated(true);—remove that blank line so the block has no extra empty
line (keep the two statements adjacent and save the file).
Choose the appropriate template for your PR:
Feature/Bugfix Request
JIRA ID
Module
Description
Summary by CodeRabbit
Chores
Refactor