Skip to content
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

HLM-5985_made lowest level changes #708

Merged
merged 2 commits into from
May 28, 2024
Merged

HLM-5985_made lowest level changes #708

merged 2 commits into from
May 28, 2024

Conversation

Bhavya-egov
Copy link
Contributor

No description provided.

Copy link
Contributor

coderabbitai bot commented May 28, 2024

Walkthrough

Walkthrough

The recent changes focus on refactoring and optimizing state management and data handling in the SelectingBoundaries.js and SetupCampaign.js files within the campaign manager module. Key modifications include transitioning certain state variables to constants, introducing new variables for more precise data handling, and updating functions to reflect these changes. The goal is to improve code clarity and efficiency.

Changes

File Path Change Summary
.../campaign-manager/src/components/SelectingBoundaries.js Commented out lowestHierarchy state variable, redefined as constant, introduced lowestChild, searchParams, isDraft, modified fetchBoundaryTypeData and transformedRes logic based on new variables.
.../campaign-manager/src/pages/employee/SetupCampaign.js Commented out state initialization, added hierarchyConfig state, updated lowestHierarchy logic, modified validateBoundaryLevel and recursiveParentFind to use lowestHierarchy.

Poem

In the code where logic lies,
Refactoring brings new sunrise,
Constants firm and states refined,
Efficiency and clarity combined.
Boundaries set with utmost care,
Campaigns flourish everywhere.
🐇✨


Tip

Early Access Features
  • gpt-4o model for chat

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

Outside diff range and nitpick comments (7)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (6)

42-42: Consider removing commented-out code to maintain code cleanliness.


Line range hint 110-112: Consider replacing forEach with for...of for better readability and performance in loops.

- hierarchyTypeDataresult?.boundaryHierarchy?.forEach((boundary) => {
+ for (const boundary of hierarchyTypeDataresult?.boundaryHierarchy || []) {

Also applies to: 141-145, 151-156, 258-262, 341-341, 343-343


Line range hint 259-259: Avoid using hasOwnProperty directly from the object; use Object.prototype.hasOwnProperty.call instead for safety.

- updatedBoundaryData?.hasOwnProperty(type)
+ Object.prototype.hasOwnProperty.call(updatedBoundaryData, type)

Line range hint 270-273: Use optional chaining to safely access properties.

- const existingBoundaryType = selectedData?.length > 0 ? selectedData?.[0]?.type : null;
+ const existingBoundaryType = selectedData?.[0]?.type ?? null;

Line range hint 315-323: Replace .map().flat() with .flatMap() for efficiency.

- const updatedSelectedData = selectedData
-   ?.map((item) => {
-     if (item.type === newBoundaryType) {
-       return transformedRes?.flat();
-     } else {
-       return item;
-     }
-   })
-   .flat();
+ const updatedSelectedData = selectedData?.flatMap((item) => item.type === newBoundaryType ? transformedRes : [item]);

Line range hint 71-71: Add missing dependencies in useEffect to ensure correct re-rendering.

- useEffect(() => {
+ useEffect(() => {
+   // Added missing dependencies
}, [boundaryData, selectedData, onSelect, updateBoundary, props?.props?.sessionData?.HCM_CAMPAIGN_SELECTING_BOUNDARY_DATA?.boundaryType?.boundaryData]);

Also applies to: 107-107

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (1)

Line range hint 879-914: Update recursive parent finding logic to use new state.

The function recursiveParentFind has been updated to use lowestHierarchy instead of lowest. This change aligns with the new state management strategy but ensure that it correctly identifies parent-child relationships in all scenarios.

- const extraParent = missingParents?.filter((i) => i?.type !== lowest?.[0]?.boundaryType);
+ const extraParent = missingParents?.filter((i) => i?.type !== lowestHierarchy);
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5650e62 and f39ec4e.
Files selected for processing (2)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (5 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (4 hunks)
Additional Context Used
Biome (40)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (20)

34-35: Change to an optional chain.


110-112: Prefer for...of instead of forEach.


141-145: Prefer for...of instead of forEach.


151-156: Prefer for...of instead of forEach.


258-262: Prefer for...of instead of forEach.


259-259: Do not access Object.prototype method 'hasOwnProperty' from target object.


270-273: Change to an optional chain.


315-323: The call chain .map().flat() can be replaced with a single .flatMap() call.


319-321: This else clause can be omitted because previous branches break early.


328-328: Unsafe usage of optional chaining.


341-341: Prefer for...of instead of forEach.


343-343: Prefer for...of instead of forEach.


363-363: Do not use template literals if interpolation and special-character handling are not needed.


364-364: Do not use template literals if interpolation and special-character handling are not needed.


384-384: The call chain .map().flat() can be replaced with a single .flatMap() call.


464-464: Template literals are preferred over string concatenation.


71-71: This hook does not specify all of its dependencies: onSelect


71-71: This hook does not specify all of its dependencies: updateBoundary


107-107: This hook does not specify all of its dependencies: boundaryData


107-107: This hook does not specify all of its dependencies: props?.props?.sessionData?.HCM_CAMPAIGN_SELECTING_BOUNDARY_DATA?.boundaryType?.boundaryData

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (20)

25-61: Prefer for...of instead of forEach.


169-175: Prefer for...of instead of forEach.


189-209: Prefer for...of instead of forEach.


218-220: Prefer for...of instead of forEach.


264-264: Do not use template literals if interpolation and special-character handling are not needed.


293-293: Unnecessary use of boolean literals in conditional expression.


355-355: Unsafe usage of optional chaining.


356-356: Unsafe usage of optional chaining.


468-531: Prefer for...of instead of forEach.


470-529: Prefer for...of instead of forEach.


472-472: Use === instead of ==.
== is only allowed when comparing against null


473-473: Use === instead of ==.
== is only allowed when comparing against null


481-518: Prefer for...of instead of forEach.


520-526: Prefer for...of instead of forEach.


555-745: This else clause can be omitted because previous branches break early.


720-720: Avoid the delete operator which can impact performance.


721-721: Avoid the delete operator which can impact performance.


751-751: Unsafe usage of optional chaining.


778-806: Prefer for...of instead of forEach.


779-805: Prefer for...of instead of forEach.

Path-based Instructions (2)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (1)

Pattern **/*.js: check

Additional comments not posted (4)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (3)

48-48: Refactor to use optional chaining to safely access deeply nested properties.

- const lowestHierarchy = hierarchyConfig?.["HCM-ADMIN-CONSOLE"]?.hierarchyConfig?.[0]?.lowestHierarchy;
+ const lowestHierarchy = hierarchyConfig?.["HCM-ADMIN-CONSOLE"]?.hierarchyConfig?.[0]?.lowestHierarchy ?? null;

Likely invalid or redundant comment.


Line range hint 328-328: Ensure safe usage of optional chaining to avoid runtime errors.

Verification successful

Ensure safe usage of optional chaining to avoid runtime errors.

The search results indicate that optional chaining is used extensively throughout the codebase. However, the specific line in question:

const mergedData = [...selectedData?.filter((item) => item?.type !== newBoundaryType), ...transformedRes];

appears to be using optional chaining correctly. The selectedData array is checked for existence before attempting to call filter on it, and each item is checked for existence before accessing its type property.

No issues were found with the usage of optional chaining in the provided snippet.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify safe usage of optional chaining.

# Test: Search for unsafe optional chaining usage. Expect: Safe usage.
rg --type javascript $'?.'

Length of output: 105



Script:

#!/bin/bash
# Description: Verify safe usage of optional chaining.

# Test: Search for unsafe optional chaining usage. Expect: Safe usage.
rg --type javascript '\?\.'

Length of output: 64



Script:

#!/bin/bash
# Description: Verify safe usage of optional chaining.

# Test: Search for unsafe optional chaining usage. Expect: Safe usage.
rg '\?\.'

Length of output: 437165


46-48: Ensure that hierarchyConfig is always defined to avoid runtime errors.

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (1)

855-876: Ensure boundary validation logic matches new requirements.

The refactored validateBoundaryLevel function now uses lowestHierarchy to determine the lowest index, which changes the logic significantly. Verify that this new approach correctly handles all cases, especially edge cases where the boundary hierarchy might not be straightforward or might include unexpected values.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 28, 2024
@jagankumar-egov jagankumar-egov merged commit 3a67d25 into campaign May 28, 2024
2 of 3 checks passed
@jagankumar-egov jagankumar-egov deleted the HLM-5985_v2 branch May 28, 2024 07:17
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: 3

Outside diff range and nitpick comments (11)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (5)

Line range hint 72-72: The useEffect hook does not specify all of its dependencies: onSelect, updateBoundary. This might lead to unexpected behavior if these dependencies change.

- useEffect(() => {
+ useEffect(() => {
+ }, [onSelect, updateBoundary]); // Added missing dependencies

Line range hint 260-260: Avoid using hasOwnProperty directly from the object prototype due to potential shadowing issues.

- if (type !== boundary?.boundaryType && updatedBoundaryData?.hasOwnProperty(type)) {
+ if (type !== boundary?.boundaryType && Object.prototype.hasOwnProperty.call(updatedBoundaryData, type)) {

Line range hint 316-324: Use .flatMap() instead of .map().flat() for better performance and readability.

- const flattenedRes = transformedRes.flat();
+ const flattenedRes = transformedRes.flatMap(item => item);

Line range hint 34-35: Consider using optional chaining to safely access nested properties and avoid potential runtime errors.

- const boundaryType = hierarchyTypeDataresult?.boundaryHierarchy?.find((boundary) => boundary?.parentBoundaryType === null)?.boundaryType;
+ const boundaryType = hierarchyTypeDataresult?.boundaryHierarchy?.find((boundary) => boundary?.parentBoundaryType === null)?.boundaryType || null;

Also applies to: 271-274


Line range hint 111-113: Prefer for...of loops over forEach for better performance and handling of asynchronous operations within loops.

- hierarchyTypeDataresult?.boundaryHierarchy?.forEach((boundary) => {
+ for (const boundary of hierarchyTypeDataresult?.boundaryHierarchy || []) {

Also applies to: 142-146, 152-157, 259-263, 342-344

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (6)

Line range hint 25-61: Optimize loop usage with modern JavaScript syntax.

- data.forEach((item) => {
+ for (const item of data) {

Consider replacing forEach loops with for...of loops for better performance and readability in functions like loopAndReturn, cycleDataRemap, reverseDeliveryRemap, etc.

Also applies to: 169-175, 189-209, 218-220, 469-532, 471-530, 482-519, 521-527, 779-807, 780-806


Line range hint 294-294: Simplify boolean expressions.

- active: index === 0, // Initialize active to false
+ active: !index, // Initialize active to false

You can use a more concise expression to check if index is 0.


Line range hint 473-473: Use strict equality for comparisons.

- if (currentCycleIndex != item.cycleNumber) {
+ if (currentCycleIndex !== item.cycleNumber) {

Replace == with === to ensure type safety during comparisons.

Also applies to: 474-474


Line range hint 721-721: Consider alternatives to the delete operator.

- delete payloadData?.startDate;
- delete payloadData?.endDate;
+ payloadData.startDate = undefined;
+ payloadData.endDate = undefined;

Using undefined instead of delete can improve performance as delete may hinder JavaScript engine optimizations.

Also applies to: 722-722


Line range hint 556-746: Remove unnecessary else clauses.

- } else {
+ }

You can remove the else clause when the preceding if block ends with a return, break, or continue statement to make the code cleaner and more readable.


[!TIP]
Codebase Verification

The search results indicate multiple instances of delivery being used in the codebase, but none of the results show explicit null checks for delivery before accessing its properties. This suggests that there might be potential for null pointer exceptions if delivery is not properly defined.

  • File: micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js
  • Line: 356

Ensure that delivery is properly checked for null or undefined before accessing its properties to avoid runtime errors.

  • Example Code:
    const cycle = delivery?.map((obj) => obj?.cycleNumber)?.length > 0 ? Math.max(...delivery?.map((obj) => obj?.cycleNumber)) : 1;

Consider adding a null check for delivery before this line to ensure it is defined.

Analysis chain

Line range hint 356-356: Check for potential null pointer exceptions due to unsafe usage of optional chaining.

Ensure that hierarchyDefinition and BoundaryHierarchy are always defined before accessing their properties to avoid runtime errors.

Also applies to: 357-357

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `hierarchyDefinition` and `BoundaryHierarchy` are always defined before accessing their properties.

# Test: Search for the usage of `hierarchyDefinition` and `BoundaryHierarchy`. Expect: Proper null checks before usage.
rg --type js $'hierarchyDefinition?.BoundaryHierarchy?.[0]'

Length of output: 60



Script:

#!/bin/bash
# Description: Verify that `delivery` is always defined before accessing its properties.

# Test: Search for the usage of `delivery` and ensure proper null checks before usage.
rg --type js 'delivery?.map' --context 5

Length of output: 42



Script:

#!/bin/bash
# Description: Verify that `delivery` is always defined before accessing its properties.

# Test: Search for the usage of `delivery` and ensure proper null checks before usage.
rg --type js 'delivery' --context 10

Length of output: 284859

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between f39ec4e and a72b2e6.
Files selected for processing (2)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (7 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (5 hunks)
Additional Context Used
Biome (40)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (20)

34-35: Change to an optional chain.


111-113: Prefer for...of instead of forEach.


142-146: Prefer for...of instead of forEach.


152-157: Prefer for...of instead of forEach.


259-263: Prefer for...of instead of forEach.


260-260: Do not access Object.prototype method 'hasOwnProperty' from target object.


271-274: Change to an optional chain.


316-324: The call chain .map().flat() can be replaced with a single .flatMap() call.


320-322: This else clause can be omitted because previous branches break early.


329-329: Unsafe usage of optional chaining.


342-342: Prefer for...of instead of forEach.


344-344: Prefer for...of instead of forEach.


364-364: Do not use template literals if interpolation and special-character handling are not needed.


365-365: Do not use template literals if interpolation and special-character handling are not needed.


378-378: Template literals are preferred over string concatenation.


387-387: The call chain .map().flat() can be replaced with a single .flatMap() call.


399-399: Template literals are preferred over string concatenation.


467-467: Template literals are preferred over string concatenation.


72-72: This hook does not specify all of its dependencies: onSelect


72-72: This hook does not specify all of its dependencies: updateBoundary

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (20)

25-61: Prefer for...of instead of forEach.


169-175: Prefer for...of instead of forEach.


189-209: Prefer for...of instead of forEach.


218-220: Prefer for...of instead of forEach.


265-265: Do not use template literals if interpolation and special-character handling are not needed.


294-294: Unnecessary use of boolean literals in conditional expression.


356-356: Unsafe usage of optional chaining.


357-357: Unsafe usage of optional chaining.


469-532: Prefer for...of instead of forEach.


471-530: Prefer for...of instead of forEach.


473-473: Use === instead of ==.
== is only allowed when comparing against null


474-474: Use === instead of ==.
== is only allowed when comparing against null


482-519: Prefer for...of instead of forEach.


521-527: Prefer for...of instead of forEach.


556-746: This else clause can be omitted because previous branches break early.


721-721: Avoid the delete operator which can impact performance.


722-722: Avoid the delete operator which can impact performance.


752-752: Unsafe usage of optional chaining.


779-807: Prefer for...of instead of forEach.


780-806: Prefer for...of instead of forEach.

Path-based Instructions (2)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (1)

Pattern **/*.js: check

Additional comments not posted (4)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js (3)

42-49: Refactor state to constant for lowestHierarchy using useMemo to optimize performance.


164-164: Optimized the handling of boundary type data fetching and transformation based on isDraft status.

Also applies to: 276-309


Line range hint 366-399: Improved readability by replacing template literals with string concatenation in JSX expressions.

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (1)

920-920: Ensure consistent export of the component.

The export statement for SetupCampaign is consistent and correctly placed at the end of the file.

Comment on lines +50 to +52
const lowestChild = hierarchyTypeDataresult?.boundaryHierarchy.filter((item => item.parentBoundaryType === lowestHierarchy))?.[0]?.boundaryType;
const searchParams = new URLSearchParams(location.search);
const isDraft = searchParams.get("draft");
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The context around the usage of searchParams and searchParams.get has been extracted. Here are the key observations:

  • searchParams is used to parse query parameters from the URL.
  • The values retrieved using searchParams.get are directly assigned to variables or used in state initialization.

There is no evidence of sanitization or validation of these query parameters before they are used. This could potentially lead to security vulnerabilities, such as injection attacks.

Locations that need attention:

  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/deliveryRule/AddProductscontext.js
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/SelectingBoundaries.js
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/CampaignSummary.js
  • micro-ui/web/micro-ui-internals/example/src/UICustomizations.js

Ensure that the values retrieved from searchParams are properly sanitized and validated before use.

Analysis chain

Introduced lowestChild and searchParams to enhance logic. Ensure searchParams is used securely to prevent injection attacks.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `searchParams` to ensure it's sanitized and used securely.

# Test: Search for the usage of `searchParams`. Expect: Proper handling and sanitization.
rg --type javascript $'searchParams.get'

Length of output: 74



Script:

#!/bin/bash
# Description: Verify the usage of `searchParams` to ensure it's sanitized and used securely.

# Test: Search for the usage of `searchParams` and `searchParams.get`. Expect: Proper handling and sanitization.
rg --type js 'searchParams'
rg --type js 'searchParams.get'

Length of output: 5012



Script:

#!/bin/bash
# Description: Extract and review the context around the usage of `searchParams` to ensure it's sanitized and used securely.

# Test: Extract lines around the usage of `searchParams` and `searchParams.get` for context.
rg --type js -C 3 'searchParams' > searchParams_context.txt
rg --type js -C 3 'searchParams.get' >> searchParams_context.txt

# Output the collected context for review.
cat searchParams_context.txt

Length of output: 20067

@@ -1,5 +1,5 @@
import { Loader, FormComposerV2, Header, MultiUploadWrapper, Button, Close, LogoutIcon } from "@egovernments/digit-ui-react-components";
import React, { useState, useEffect } from "react";
import React, { useState, useEffect , useMemo} from "react";
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider consolidating React hook imports.

- import React, { useState, useEffect, useMemo } from "react";
+ import React from "react";

You can import useState, useEffect, and useMemo directly from 'react' as shown, which can help in reducing the import lines and making the code cleaner.

Committable suggestion was skipped due low confidence.

]);

// const lowestHierarchy = hierarchyConfig?.["HCM-ADMIN-CONSOLE"]?.hierarchyConfig?.[0]?.lowestHierarchy;
const lowestHierarchy = useMemo(() => hierarchyConfig?.["HCM-ADMIN-CONSOLE"]?.hierarchyConfig?.[0]?.lowestHierarchy, [hierarchyConfig]);

const reqCriteria = {
url: `/boundary-service/boundary-hierarchy-definition/_search`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid unnecessary template literals.

- url: `/boundary-service/boundary-hierarchy-definition/_search`,
+ url: '/boundary-service/boundary-hierarchy-definition/_search',

Use single or double quotes for strings that do not require interpolation or special characters.


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.

Suggested change
url: `/boundary-service/boundary-hierarchy-definition/_search`,
url: '/boundary-service/boundary-hierarchy-definition/_search',

jagankumar-egov added a commit that referenced this pull request Jun 26, 2024
* Updates the delivery rules logic for gender

* * info message for status creating (#644)

* success message if user cred sheet
* send id with key resourceid
* Send variant in sku also

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Feat : added boundary validation (#643)

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>

* Update campaignValidators.ts (#645)

* added delay in download (#646)

* Update campaignValidators.ts (#647)

* fixes (#649)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* fixed header validation (#648)

* change in filter recursive (#650)

* Update genericUtils.ts (#652)

* fix (#651)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* updated lowest level hierarchy validation for target HLM -5948 (#654)

* Update campaignValidators.ts (#655)

* fixes-> cyclenumber issue, hover issue, dropdown height issue,

* css

* fixes-> cyclenumber issue, hover issue, dropdown height issue, (#656)

* fixes-> cyclenumber issue, hover issue, dropdown height issue,

* css

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Update campaignUtils.ts

* fixed HLM-5970

* Feat : added boundary validation at data level

* fixes

* local add

* Added boundary validation

* Refactor

* fixed HLM-5935 and HLM-5749

* Refactor

* Feat : updated table

* change campaignid in payload

* Feat : added campaignId

* Update campaignApis.ts

* Update campaignValidators.ts

* refactored

* Refactor

* assigned campaignId

* Refactor

* updated createRequest Schema

* Feat : invalid Status Persist

* status fix

* version-fix

* Update CODEOWNERS

* core version updated and css fix for language dropdown

* refactor (#676)

* Uat signoff (#678)

* change in filter recursive

* lowest level

* added validation related to target sheet headers

* HLM-5916

* download button fixes in summary (#682)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Hlm 5927 (#687)

* change in filter recursive

* lowest level

* added validation for boundary codes to be invalid other than that selected from UI in target upload

* Added Delivery and cycle config for LLIN and SMC both (#688)

* no of cycle and deivery drafted changes

* fixes

* add localisation code for boundaries

* fixes

* fixes

* Value localise in summary screen, api error change

* fixes

* genarate api call fix

* font size change for summary

* login css change

* HLM-5718: SMC delivery config enhancement

* config update

* added config for in between

* fix config for llin

* added mdms integration

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Fixed HLM-5988_warning message (#689)

Co-authored-by: nabeelmd-eGov <94039229+nabeelmd-eGov@users.noreply.github.com>

* download filename fixes (#693)

* download button fixes in summary

* download filename with custom name changes added

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* download filename fixes (#694)

* download button fixes in summary

* download filename with custom name changes added

* config fix for llin

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* successful toast message is fixed (#695)

* successful toast message is fixed

* Update UploadData.js

* HLM-5991: Alert Pop UP CR (#696)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* HLM-5718 changes (#703)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Localization cache (#706)

* change in filter recursive

* lowest level

* refactored  localization cache logic

* Update README.md (#707)

* Update README.md

* Update README.md

* Update utilities/project-factory/README.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update README.md

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* HLM-5985_made lowest level changes (#708)

* HLM-5985_made lowest level changes

* resolved codeRabbit comments

* Create LOCALSETUP.md (#709)

* Create LOCALSETUP.md

* Refactored config

* Update LOCALSETUP.md

* Update utilities/project-factory/LOCALSETUP.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/LOCALSETUP.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/LOCALSETUP.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/LOCALSETUP.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update LOCALSETUP.md

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* updated the localisation module config

* Refactor config (#713)

* Refactor config

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update postman_collection.json (#714)

* Update postman_collection.json

* Update postman_collection.json

* Delete utilities/project-factory/project_factory_swagger.yml (#715)

* Feat : removed campaignId validation for boundary upload (#718)

* updated the delay for boundary relationship

* added logger for request TODO TEST

will be reverted

* Revert "added logger for request TODO TEST"

This reverts commit d5c2bf5.

* Schema validation (#719)

* Feat : removed campaignId validation for boundary upload

* Feat : added schema validation

* Fixed mdms host

* updated the logger messages

* updated the loggers

* delivery new changes, toast fix, error fix (#716)

* delivery new changes, toast fix, error fix

* new fixes

* fixes

* change text component to field component

* added hierarchy

* fix

* fix

* fix

* fix

* passing hierarchy from props

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Schema validation2 (#721)

* Feat : removed campaignId validation for boundary upload

* Feat : added schema validation

* Fixed mdms host

* Feat : added boundary validation

* Feat : optimized product search

* Fix : project mapping fixed (#722)

* Fixed project search (#723)

* smc fixes (#724)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Feat : added boundary confirmation (#727)

* Fix: fixed processing boundary

* Refactor

* fixed HLM-6109 (#729)

* gate fixes validation, ui ux (#731)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* integrated panelcard component (#732)

* integrated panelcard component

* Update micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/Response.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update genericUtils.ts (#733)

* Create CHANGELOG.md (#717)

* Update request.ts (#735)

* fixed generate api issue (#734)

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>

* Create CHANGELOG.md

* gate fixes (#736)

* gate fixes validation, ui ux

* gate fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* added loader in the selecting boundaries (#737)

* Update createAndSearch.ts (#738)

* fix (#739)

* fix

* fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Patch 3 (#740)

* change in filter recursive

* lowest level

* trimmed underscore and empty spaces

* boundary fix (#742)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Update genericUtils.ts (#746)

* fixed the delivery products issue

* Fixed delivery conditions issue

* Update campaignApis.ts (#747)

* fixed warning toast (#748)

* fixed warning toast

* Update UploadData.js

* fix (#749)

* fix

* fx

* fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* core -update (#751)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* fixed stepper issue (#752)

* fixed stepper issue

* Update index.html

* Feat : added user validation via individual (#753)

* fixes (#754)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* code fix nabeel (#756)

* fixes

* fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Updated few loggers (#759)

* updated few loggers flow

* Update utilities/project-factory/src/server/api/campaignApis.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/utils/campaignMappingUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/utils/campaignUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/api/campaignApis.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/utils/campaignMappingUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/utils/genericUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Updated the user Password generation logic #761

* Update Listener.ts (#730)

* Update Listener.ts

* added try catch logic in producer

* Feat : added parallel batch execution (#767)

* Feat : added parallel batch execution

* Refactor

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fixed the stepper (#765)

* changes config (#769)

* Project type config and added loggers for process of campaign (#772)

* Feat : added themes in generate template (#773)

* fixed the ajv package version for build issue

* Feat : removed xlsx (#776)

* HLM-6177: PARALLEL SEARCH IMPLEMENT, DELIVERY TYPE IMPLEMENT (#778)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* css update (#780)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* HLM-6179 and HLM-6180 (#777)

* HLM-6179 and HLM-6180

* campaign name changes

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>

* Feat : fixed target generation (#781)

* fixed tenantId issue (#784)

* fix: resolved AJV-related Jenkins build issue reference #783 #786 (#787)

* module ui fix

* updated all the package version for build fixes

* fixed kafka-error at target generation (#789)

* updated core version (#791)

* updated core version

* updated css also

* Update campaignValidators.ts (#794)

* Updated the excel generation logic and files

* added changes for configurable column in target sheet (#779)

* change in filter recursive

* lowest level

* made target headers  genearte through mdms schema

* changed config index.ts

* changed config index.ts

* changes for now

* added configurable column logic from schema HLM-6169

* updated validate of target columns through schema

* added masterForColumnSchema in index.ts

* formatted dataManageService

* refactored lock TargetFields func

* removed console.log

* User creation performance improved (#800)

* Feat : Improved user creation performance

* Change status color

* Update utilities/project-factory/src/server/utils/campaignUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update genericUtils.ts (#801)

* Hlm 6170 (#802)

* change in filter recursive

* lowest level

* HLM -6170 added logic for only village level data in target sheet and some refactoring

* updated css (#804)

* fixed button issue (#805)

* HLM 6177: Error card implementation in summary screen (#806)

* HLM-6177: PARALLEL SEARCH IMPLEMENT, DELIVERY TYPE IMPLEMENT

* Added Error Cards in summary screen and redirection

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* added error button styles (#807)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* updated popUp css (#808)

* HLM 6178: Implementing New Pop up screen in boundaries (#809)

* added error button styles

* Implementing New Pop up screen in boundaries

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Facility changes (#812)

* Feat : changed facility Template

* Feat : locked target templates

* fixed colour issue (#813)

* Updated the project type conversion logic for the             "deliveryType" dont1 and n config

* Unique field added (#814)

* Feat : changed facility Template

* Feat : locked target templates

* Feat : added unique check logic

* Target schema update (#815)

* change in filter recursive

* lowest level

* updated shcema of target columns to be configurable

* removed empty spaces from config index.ts

* Active mapping (#817)

* Feat : changed facility Template

* Feat : locked target templates

* Feat : added unique check logic

* Feat : added mapping via active field

* changes in the schema validation (#816)

* Updated the workbench and css module version

* Feat : added active inactive boundary check (#818)

* Update campaignValidators.ts (#819)

* added active inactive validation (#820)

* changed api call time (#826)

* Feat : added target sum mapping (#825)

* added campaign type as filter (#827)

* Update genericApis.ts (#828)

* Update excelUtils.ts (#829)

* UI issue fixes, icon fix in summary error (#831)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Target columns (#830)

* change in filter recursive

* lowest level

* commit

* Feat : target flow fixed for LLIN-mz

* uat to dev

---------

Co-authored-by: admin1 <nitish@egovernments.org>

* Feat : freezed target columns (#833)

* Target mr dn (#834)

* change in filter recursive

* lowest level

* Feat : skipped validation temporarily

* changes in the target validation (#835)

* fixed error info (#837)

* Added roboto font (#840)

* Feat : added roboto font

* Fixed config

* target validation based on diff campaign types (#843)

* change in filter recursive

* lowest level

* updated validation of target based on campaign type

* fixed validation issue (#844)

* Updated the workbench package version

* fixed validation logic (#846)

* fixed validation logic

* Update micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Error messages improved (#848)

* Feat : imporved error messages and initilised utils for tracking process

* Fix ; unused variables fixed

* Feat : improved error messages

* Fix : download error fix (#850)

* Update campaignUtils.ts (#851)

* Update campaignUtils.ts

* Update utilities/project-factory/src/server/utils/campaignUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update campaignValidators.ts (#853)

* HLM 6210: Toast, error focus fix and project type reset delivery data fix  (#854)

* HLM-6210: campaign type change reset delivery data fix, summary error focus fix

* summary error focus fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* HLM-6225_added time out according to data (#855)

* Update campaignValidators.ts (#859)

* HLM 6210 (#858)

* HLM-6210: campaign type change reset delivery data fix, summary error focus fix

* summary error focus fix

* parallel search fixes

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Remove validation (#852)

* change in filter recursive

* lowest level

* removed unnecessary validation for target

* spacing refactor

* Update campaignValidators.ts (#863)

* Header validation (#861)

* change in filter recursive

* lowest level

* removed unnecessary validation for target

* changed the logic of header validation

* space refactor

* Update campaignUtils.ts (#864)

* fixed ui error (#865)

* Read me (#867)

* change in filter recursive

* lowest level

* removed unnecessary validation for target

* changed the logic of header validation

* fixed portugese language error

* space refactoring

* Update Dockerfile

* Update Dockerfile

* Update migrate.sh

* Update Dockerfile

* Update campaignValidators.ts (#868)

* HLM 6210:campaign type change reset fix (#869)

* HLM-6210: campaign type change reset delivery data fix, summary error focus fix

* summary error focus fix

* parallel search fixes

* campaign type change reset fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Update excelUtils.ts for sheetHeaders wraping (#870)

* Update package.json

* updated error messages (#871)

* feat : added jaeger-client tracing (#872)

* updated the table config

* Update campaignApis.ts (#875)

* removed the schema and updated the db name

* fixing generate API call, file auto delete, date error (#877)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Trim resource (#878)

* Feat : trimmed resource persist message

* Refactor

* Removed reject error in produce message

* fixed min time, draft logic (#879)

* Update index.ts (#880)

* added min ui error and facility usage (#883)

* added min ui error and facility usage

* changes

* Update campaignUtils.ts (#884)

* HLM 6007 (#885)

* fixing generate API call, file auto delete, date error

* generate api fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Update Dockerfile

* Feat : docker config update (#886)

* Update Dockerfile (#887)

* Create buildWorkbenchUI.yml

* Update README.md (#917)

* Update buildWorkbenchUI.yml

* Update README.md

* Updated the DB Schema issue of Project-factory

* fixed hierarchy order (#919)

* User flag hcm (#920)

* Feat : docker config update

* Feat : added user create flag

* Refactored

* Update campaignUtils.ts

* Update campaignMappingUtils.ts (#922)

* Ashish egov patch 2 (#921)

* Update index.ts

* Update campaignApis.ts

* Fixed the project type conversion and product duplicate issue

* Update campaignApis.ts (#924)

* Update campaignMappingUtils.ts (#925)

* Update campaignMappingUtils.ts

* Refactored

* Update publishProjectFactory.yml

* Update buildWorkbenchUI.yml

* Update campaignMappingUtils.ts (#926)

* Update request.ts (#928)

* Update request.ts

* Feat : updated httprequest

* Feat : warning response added

* Refactor

* added start and enddate in cycles

* Update campaignApis.ts (#930)

* Update request.ts (#932)

* fixed generate issue (#933)

* Fixed project-type resources duplication

* updated target error messages (#936)

* fixed stepper from draft (#937)

* Update Listener.ts

* delivery type disable fix, product sku name change (#939)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* fixed error message issue (#941)

* Redis integration (#940)

* Feat : added redis

* Feat : added redis retry

* removed templates folder

* updated the folder structure for health ui and removed utilties

* Update publishAllPackages.yml

* Update buildWorkbenchUI.yml

---------

Co-authored-by: nabeelmd-eGov <94039229+nabeelmd-eGov@users.noreply.github.com>
Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>
Co-authored-by: ashish-egov <137176738+ashish-egov@users.noreply.github.com>
Co-authored-by: Bhavya-egov <137176879+Bhavya-egov@users.noreply.github.com>
Co-authored-by: nitish-egov <137176807+nitish-egov@users.noreply.github.com>
Co-authored-by: Bhavya-egov <bhavya.mangal@egovernments.org>
Co-authored-by: ashish-egov <ashish.tiwari@egovernments.org>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Swathi-eGov <137176788+Swathi-eGov@users.noreply.github.com>
Co-authored-by: admin1 <nitish@egovernments.org>
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