Skip to content

Conversation

@jagankumar-egov
Copy link
Collaborator

@jagankumar-egov jagankumar-egov commented Nov 11, 2025

Choose the appropriate template for your PR:

Feature/Bugfix Request

JIRA ID

Module

Description

Summary by CodeRabbit

  • Chores

    • Updated demo environment configuration to route API requests to revised service endpoints
  • Refactor

    • Improved campaign data retrieval and processing logic for better maintainability

…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.
@jagankumar-egov jagankumar-egov requested a review from a team as a code owner November 11, 2025 04:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

📝 Walkthrough

Walkthrough

Environment 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

Cohort / File(s) Change Summary
Environment Configuration
health/micro-ui/web/micro-ui-internals/example/.env-hcm-demo
Updated REACT_APP_PROXY_API and REACT_APP_PROXY_ASSETS URLs from hcm-demo.digit.org to health-demo.digit.org
Campaign Manager Components
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/AddOrEditMapping.js
Added blank line spacing between state declarations
Campaign Manager Pages
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateCampaign.js
Refactored URL parameter handling to use id state; replaced API fetch with custom hook pattern; restructured data access from CampaignData[0] to CampaignData.CampaignDetails[0] throughout; updated dependency arrays, payload construction, and conditional logic accordingly

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • UpdateCampaign.js requires careful attention to verify that all data access paths (hierarchyType, endDate, startDate, parentId, campaignName, boundaries, projectType, additionalDetails.cycleData, deliveryRules) correctly map to the new nested CampaignDetails structure
  • Validate that useEffect and useMemo dependency arrays properly reference the restructured data shape
  • Confirm API payload construction logic accurately pulls and transforms data from CampaignDetails for draft/update/create operations
  • Ensure conditional logic for API enabling (previously currentId, now id) functions correctly in all scenarios

Poem

🐰 A hop through the demo domain we go,
From hcm-demo bright to health-demo's glow!
Campaign data nested, details revealed,
Hooks refactored, new patterns sealed—
Organization blooms in structured code! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the template structure with unfilled placeholders; the JIRA ID, Module, and Description sections are not completed with actual information about the changes. Complete all required template sections: provide the JIRA ID, specify the affected module(s), and write a detailed description explaining the rationale for the environment URL changes and data structure refactoring.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Patch update' is vague and generic, failing to convey the specific nature of the changes (environment URL updates, data structure refactoring, and formatting adjustments). Revise the title to be more descriptive, such as 'Update HCM demo URLs and refactor campaign data structure' to clearly communicate the main changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch PATCH_UPDATE

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 projectType in the useEffect dependency array (Line 201) doesn't appear necessary. The effect only restructures form data from draftData and params, and projectType is 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

📥 Commits

Reviewing files that changed from the base of the PR and between a80af97 and 2f32f30.

⛔ Files ignored due to path filters (1)
  • micro-ui/web/workbench/package.json is 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.js
  • health/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.js
  • 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/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.js
  • health/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 references hcm-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 id state 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 id instead of the removed currentId.


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 for parentId and id.


340-410: LGTM: Draft creation logic correctly implemented.

The initial draft creation properly handles the payload construction with conditional id assignment and correctly updates the local state after successful mutation.


617-620: LGTM: Correct data structure usage.

The boundary restructuring correctly references CampaignData?.CampaignDetails?.[0]?.boundaries consistent with the updated data model.


667-670: LGTM: Correct boundary validation.

The boundary difference check correctly uses CampaignData?.CampaignDetails?.[0]?.boundaries for comparison.


737-743: LGTM: Correct condition update.

The skip API call condition correctly uses id instead of the removed currentId.


936-936: LGTM: Performance optimization added.

Wrapping the component with React.memo is 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 of draftData. This is a significant change in data source:

  • draftData comes from useSearchCampaign hook (lines 125-137)
  • CampaignData?.CampaignDetails?.[0] comes from the new useCustomAPIHook (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:

Comment on lines +84 to +98
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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.

Suggested change
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.

Comment on lines +394 to +396
setId(data?.CampaignDetails?.id);
setIsDraftCreated(true);

Copy link
Contributor

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.

Suggested change
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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants