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

Hrms bounday service #1544

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Hrms bounday service #1544

wants to merge 2 commits into from

Conversation

Swathi-eGov
Copy link
Contributor

@Swathi-eGov Swathi-eGov commented Oct 17, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new proxy route for the /boundary-service endpoint.
    • Enhanced the useLocation hook with additional parameters for improved location data handling.
    • Introduced a new loading state for the Jurisdiction component and refined hierarchy data fetching.
  • Improvements

    • Updated URL paths for localities and wards to improve configurability.
    • Enhanced localization for dropdown options in the LocationDropdownWrapper component.
  • Bug Fixes

    • Improved data processing in the getLocalities function to include full hierarchy information.

Copy link
Contributor

coderabbitai bot commented Oct 17, 2024

📝 Walkthrough

Walkthrough

This pull request introduces several changes across multiple files, primarily focusing on enhancing the proxy middleware setup and modifying the useLocation hook to accept additional parameters. A new route for the boundary service is added to the proxy configuration, and the LocationService and related components are updated to support this new functionality. Additionally, localization improvements are made in the dropdown components. The overall structure of existing functions and components remains intact while adding new capabilities.

Changes

File Change Summary
micro-ui/web/micro-ui-internals/example/src/setupProxy.js Added new proxy route "/boundary-service" to the middleware setup.
micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useLocation.js Updated useLocation hook to accept includeChildren and includeParents parameters.
micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/urls.js Introduced boundarySearchPath and hierarchyType constants; updated URLs in Urls object.
micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/Localities.js Modified ADMIN_CODE function to concatenate tenantId with hierarchyType.
micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/Location.js Updated getWards method to accept includeChildren and includeParents parameters.
micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js Enhanced jurisdiction data handling; integrated loading states and updated data fetching logic.
micro-ui/web/micro-ui-internals/packages/react-components/src/molecules/LocationDropdownWrapper.js Modified dropdown to use localized names for wards and localities; updated useLocation call.

Possibly related PRs

Suggested reviewers

  • nipunarora-eGov
  • jagankumar-egov

🐇 In the code we hop and play,
New routes and hooks come into sway.
With local names that dance and sing,
Our UI shines, a joyful thing.
So let’s embrace this change with cheer,
For a brighter future, drawing near! 🌟


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 do a full 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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: 7

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 62b489b and e5c9582.

📒 Files selected for processing (7)
  • micro-ui/web/micro-ui-internals/example/src/setupProxy.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useLocation.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/urls.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/Localities.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/Location.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js (4 hunks)
  • micro-ui/web/micro-ui-internals/packages/react-components/src/molecules/LocationDropdownWrapper.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
micro-ui/web/micro-ui-internals/example/src/setupProxy.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useLocation.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/urls.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/Localities.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/Location.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/react-components/src/molecules/LocationDropdownWrapper.js (1)

Pattern **/*.js: check

🪛 Biome
micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/Localities.js

[error] 4-4: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

🔇 Additional comments (11)
micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useLocation.js (1)

Line range hint 4-13: Summary of changes and recommendations

The useLocation hook has been updated to support additional parameters for including children and parents in Ward location queries. While the implementation is generally correct, we've identified two areas for improvement:

  1. Add default values for the new parameters in the function signature to maintain backward compatibility.
  2. Update the query key in the 'Ward' case to include the new parameters for proper caching behavior.

These changes will enhance the robustness and reliability of the updated hook while preserving existing functionality.

micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/Localities.js (2)

4-4: 🛠️ Refactor suggestion

Verify the change in hierarchyType usage and consider using template literals.

The function now uses hierarchyType directly instead of hierarchyType.code. Please ensure this change is intentional and consistent with how hierarchyType is passed to this function throughout the codebase.

Additionally, consider using template literals for improved readability and slight performance benefits:

return `${tenantId.replace(".", "_").toUpperCase()}_${hierarchyType}`;

This change addresses both the logical modification and the static analysis suggestion.

To verify the usage of hierarchyType, please run the following script:

This will help ensure that the change is consistent across the codebase.

🧰 Tools
🪛 Biome

[error] 4-4: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


Line range hint 15-24: Verify the impact on getLocalities function

The change in the ADMIN_CODE function might affect the getLocalities function. Please ensure that the tenantBoundry object passed to getLocalities contains the correct hierarchyType property, and that the resulting i18nkey is still correctly formed.

To verify this, please run the following script:

This will help ensure that the getLocalities function and its callers are consistent with the new ADMIN_CODE implementation.

✅ Verification successful

Impact on getLocalities Function Verified Successfully
No issues found with the getLocalities function related to the changes in ADMIN_CODE. All usages of tenantBoundry are consistent, and there are no dependencies involving hierarchyType.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the usage of tenantBoundry and hierarchyType in getLocalities

# Search for getLocalities function calls
echo "Searching for getLocalities function calls:"
rg --type js 'getLocalities\s*\(' -A 5

# Search for tenantBoundry usage
echo "\nSearching for tenantBoundry usage:"
rg --type js 'tenantBoundry'

# Search for hierarchyType usage in relation to tenantBoundry
echo "\nSearching for hierarchyType usage in relation to tenantBoundry:"
rg --type js 'tenantBoundry.*hierarchyType|hierarchyType.*tenantBoundry'

Length of output: 6171

🧰 Tools
🪛 Biome

[error] 4-4: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

micro-ui/web/micro-ui-internals/example/src/setupProxy.js (1)

28-28: LGTM! Verify the new boundary service integration.

The addition of the "/boundary-service" route to the proxy middleware is consistent with the existing code structure and follows the established pattern. This change appears to be correct and well-placed within the list of routes.

To ensure the new boundary service is properly integrated, please run the following verification script:

✅ Verification successful

Verified: Boundary service integration is correctly implemented.

The "/boundary-service" route has been properly added to the proxy middleware and is consistently utilized across multiple components and services within the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the boundary service integration

# Test 1: Check if the boundary service is properly configured in the environment
echo "Checking boundary service configuration..."
rg --type js "REACT_APP_BOUNDARY_SERVICE" .

# Test 2: Verify usage of the boundary service in the codebase
echo "Checking boundary service usage..."
rg --type js "boundary-service" .

# Note: Review the output to ensure the boundary service is properly configured and used in the application.

Length of output: 3279

micro-ui/web/micro-ui-internals/packages/react-components/src/molecules/LocationDropdownWrapper.js (1)

32-32: Please clarify the purpose of the additional argument in useLocation.

A second argument true has been added to the useLocation hook call. The purpose and impact of this change are not immediately clear from the context provided.

Could you please explain:

  1. What does this additional argument do?
  2. How does it affect the behavior of the useLocation hook?
  3. Are there any potential side effects or performance implications of this change?

To help verify the impact of this change, please run the following script:

This will help us understand if this change is consistent with other usages of the useLocation hook in the codebase.

micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/urls.js (2)

3-3: LGTM: Well-implemented configuration constant.

The boundarySearchPath constant is well-implemented. It uses optional chaining for safe access to the global configuration and provides a sensible default value. This approach enhances the configurability of the application while maintaining robustness.


13-15: LGTM: Improved configurability and query specificity.

The updates to the location object effectively utilize the new constants, enhancing configurability. The additional query parameters for localities and wards provide more precise and flexible queries.

However, I noticed that revenue_localities doesn't use the hierarchyType constant:

revenue_localities: `/boundary-service/boundary-relationships/_search?hierarchyType=REVENUE&boundaryType=locality`,

Is this intentional? If not, consider updating it to use the boundarySearchPath constant for consistency:

revenue_localities: `/${boundarySearchPath}hierarchyType=REVENUE&boundaryType=locality`,
micro-ui/web/micro-ui-internals/packages/modules/hrms/src/components/pageComponents/jurisdiction.js (4)

127-130: Verify the mapping of code and name in gethierarchylistdata.

In the gethierarchylistdata function, both code and name are assigned the value of ele.hierarchyType. Please confirm if this is intentional. Typically, code should be a unique identifier, and name should be a human-readable label. Consider updating name to reflect a more descriptive property if available.


141-143: Properly handling additional loading states with isBoundaryServiceLoading.

Including isBoundaryServiceLoading in the loading condition ensures that the loader is displayed correctly while boundary data is being fetched. This improvement enhances user experience during data loading.


165-165: Passing hierarchyOptions prop to Jurisdiction component correctly.

The hierarchyOptions prop is passed down to the Jurisdiction component, allowing it to access the necessary hierarchy data. This change ensures that the component functions with the updated data source.


186-186: Include hierarchyOptions in the Jurisdiction component's props.

Adding hierarchyOptions to the component's props provides access to the updated hierarchy data within the component, enabling proper data handling and rendering.

switch(locationType) {
case 'Locality':
return useQuery(["LOCALITY_DETAILS", tenantId ], () => LocationService.getLocalities(tenantId), config);
case 'Ward':
return useQuery(["WARD_DETAILS", tenantId ], () => LocationService.getWards(tenantId), config);
return useQuery(["WARD_DETAILS", tenantId], () => LocationService.getWards(tenantId,includeChildren,includeParents), config);
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

Update the query key to include new parameters for proper caching.

The 'Ward' case has been correctly updated to pass the new includeChildren and includeParents parameters to LocationService.getWards. However, the query key for this case hasn't been updated to reflect these new parameters.

To ensure proper caching behavior with React Query, update the query key to include the new parameters:

- return useQuery(["WARD_DETAILS", tenantId], () => LocationService.getWards(tenantId,includeChildren,includeParents), config);
+ return useQuery(["WARD_DETAILS", tenantId, includeChildren, includeParents], () => LocationService.getWards(tenantId, includeChildren, includeParents), config);

This change will ensure that React Query creates separate cache entries for different combinations of includeChildren and includeParents, preventing potential issues with stale or incorrect data.

📝 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
return useQuery(["WARD_DETAILS", tenantId], () => LocationService.getWards(tenantId,includeChildren,includeParents), config);
return useQuery(["WARD_DETAILS", tenantId, includeChildren, includeParents], () => LocationService.getWards(tenantId, includeChildren, includeParents), config);

@@ -1,12 +1,12 @@
import { useQuery } from 'react-query';
import { LocationService } from "../services/elements/Location";

const useLocation = (tenantId, locationType, config = {}) => {
const useLocation = (tenantId, locationType, config = {},includeChildren,includeParents) => {
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

Consider adding default values for new parameters to maintain backward compatibility.

The function signature has been updated to include two new parameters, includeChildren and includeParents. While this change allows for more flexibility, it could potentially break existing code that calls this function without providing these new parameters.

To maintain backward compatibility, consider adding default values for these new parameters:

- const useLocation = (tenantId, locationType, config = {},includeChildren,includeParents) => {
+ const useLocation = (tenantId, locationType, config = {}, includeChildren = false, includeParents = false) => {

This change would ensure that existing calls to useLocation continue to work as before, while still allowing the new functionality to be used when needed.

📝 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 useLocation = (tenantId, locationType, config = {},includeChildren,includeParents) => {
const useLocation = (tenantId, locationType, config = {}, includeChildren = false, includeParents = false) => {

Comment on lines +22 to 28
getWards: (tenantId,includeChildren,includeParents) => {
return ServiceRequest({
serviceName: "getWards",
url: Urls.location.wards,
params: { tenantId: tenantId },
params: { tenantId: tenantId,includeChildren: includeChildren, includeParents},
useCache: 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 (assertive)

⚠️ Potential issue

Update getWards method to correctly pass includeParents parameter

The changes to the getWards method look good overall. The method signature has been updated to include the new parameters, and they are being passed to the ServiceRequest function. However, there's a small issue with how the includeParents parameter is being passed.

Apply this diff to fix the includeParents parameter:

   getWards: (tenantId,includeChildren,includeParents) => {
     return ServiceRequest({
       serviceName: "getWards",
       url: Urls.location.wards,
-      params: { tenantId: tenantId,includeChildren: includeChildren, includeParents},
+      params: { tenantId, includeChildren, includeParents },
       useCache: true,
     });
   }

This change ensures that:

  1. The includeParents parameter is correctly passed with its value.
  2. We use object property shorthand for consistency and brevity.

Consider adding spaces after commas in the method signature for better readability:

getWards: (tenantId, includeChildren, includeParents) => {

Comment on lines +24 to +25
localities[item?.code] = item?.children.map(item => ({ code: item.code, name: t(`${headerLocale}_ADMIN_${item?.code}`), i18nKey: `${headerLocale}_ADMIN_${item?.code}`, label: item?.label }))
wards.push({ code: item.code, name: t(`${headerLocale}_ADMIN_${item?.code}`), i18nKey: `${headerLocale}_ADMIN_${item?.code}` })
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

LGTM! Consider extracting the translation key construction.

The changes correctly implement localization for ward and locality names using the t function. This is a good practice for internationalization.

To improve readability, consider extracting the translation key construction into a separate function:

const getTranslationKey = (code) => `${headerLocale}_ADMIN_${code}`;

// Then use it like this:
localities[item?.code] = item?.children.map(item => ({ 
  code: item.code, 
  name: t(getTranslationKey(item?.code)), 
  i18nKey: getTranslationKey(item?.code), 
  label: item?.label 
}));

wards.push({ 
  code: item.code, 
  name: t(getTranslationKey(item?.code)), 
  i18nKey: getTranslationKey(item?.code) 
});

This would make the code more DRY and easier to maintain.

@@ -1,15 +1,18 @@
const mdmsV1Path = window?.globalConfigs?.getConfig("MDMS_V1_CONTEXT_PATH") || "egov-mdms-service";
const mdmsV2Path = window?.globalConfigs?.getConfig("MDMS_V2_CONTEXT_PATH") || "mdms-v2";
const boundarySearchPath = window?.globalConfigs?.getConfig("BOUNDARY_CONTEXT") || "boundary-service/boundary-relationships/_search?";
const hierarchyType = window?.globalConfigs?.getConfig("HIERARCHY_TYPE") || "hierarchyType=ADMIN";
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

LGTM: Well-implemented configuration constant with a minor suggestion.

The hierarchyType constant is well-implemented, consistent with boundarySearchPath. However, consider simplifying the default value:

const hierarchyType = window?.globalConfigs?.getConfig("HIERARCHY_TYPE") || "ADMIN";

Then, when using this constant, you can add the "hierarchyType=" prefix:

`hierarchyType=${hierarchyType}`

This approach separates the configuration value from its usage, potentially making it more flexible for future changes.

Comment on lines +115 to +125
const { isBoundaryServiceLoading, data: hierarchyOptions } = Digit.Hooks.useLocation(
tenantId,
"Ward",
{
select: (data) => {
return data;
},
},
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 (assertive)

Simplify the useLocation hook by removing the redundant select function.

The select function in the Digit.Hooks.useLocation hook is returning the data without any modification, making it unnecessary. Removing it will simplify the code without affecting its functionality.

Apply this diff to simplify the code:

 const { isBoundaryServiceLoading, data: hierarchyOptions } = Digit.Hooks.useLocation(
     tenantId,
     "Ward",
-    {
-      select: (data) => {
-        return data;
-      },
-    },
     true
   );
📝 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 { isBoundaryServiceLoading, data: hierarchyOptions } = Digit.Hooks.useLocation(
tenantId,
"Ward",
{
select: (data) => {
return data;
},
},
true
);
const { isBoundaryServiceLoading, data: hierarchyOptions } = Digit.Hooks.useLocation(
tenantId,
"Ward",
true
);

Comment on lines +191 to +198
const filteredBoundaryTypes = hierarchyOptions?.TenantBoundary?.filter((ele) => ele.hierarchyType === jurisdiction?.hierarchy?.code).map(
(item) => ({
...item.boundary[0],
i18text: Digit.Utils.locale.convertToLocale(item.boundary[0].boundaryType, "EGOV_LOCATION_BOUNDARYTYPE"),
})
);
}, [jurisdiction?.hierarchy, data?.MdmsRes]);
selectBoundaryType(filteredBoundaryTypes);
}, [jurisdiction?.hierarchy, hierarchyOptions]);
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

Ensure safe access to item.boundary[0] to prevent potential runtime errors.

In the mapping function within the useEffect hook, accessing item.boundary[0] without checking if item.boundary exists and contains elements could lead to runtime errors if item.boundary is undefined or empty. Please add a check to ensure item.boundary is defined and not empty before accessing item.boundary[0].

Apply this diff to add safety checks:

 useEffect(() => {
   const filteredBoundaryTypes = hierarchyOptions?.TenantBoundary?.filter(
     (ele) => ele.hierarchyType === jurisdiction?.hierarchy?.code
   ).map((item) => {
+    if (!item.boundary || item.boundary.length === 0) {
+      return null; // or handle the case accordingly
+    }
     return {
       ...item.boundary[0],
       i18text: Digit.Utils.locale.convertToLocale(item.boundary[0].boundaryType, "EGOV_LOCATION_BOUNDARYTYPE"),
     };
   }).filter(Boolean);
   selectBoundaryType(filteredBoundaryTypes);
 }, [jurisdiction?.hierarchy, hierarchyOptions]);
📝 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 filteredBoundaryTypes = hierarchyOptions?.TenantBoundary?.filter((ele) => ele.hierarchyType === jurisdiction?.hierarchy?.code).map(
(item) => ({
...item.boundary[0],
i18text: Digit.Utils.locale.convertToLocale(item.boundary[0].boundaryType, "EGOV_LOCATION_BOUNDARYTYPE"),
})
);
}, [jurisdiction?.hierarchy, data?.MdmsRes]);
selectBoundaryType(filteredBoundaryTypes);
}, [jurisdiction?.hierarchy, hierarchyOptions]);
const filteredBoundaryTypes = hierarchyOptions?.TenantBoundary?.filter((ele) => ele.hierarchyType === jurisdiction?.hierarchy?.code).map(
(item) => {
if (!item.boundary || item.boundary.length === 0) {
return null; // or handle the case accordingly
}
return {
...item.boundary[0],
i18text: Digit.Utils.locale.convertToLocale(item.boundary[0].boundaryType, "EGOV_LOCATION_BOUNDARYTYPE"),
};
}
).filter(Boolean);
selectBoundaryType(filteredBoundaryTypes);
}, [jurisdiction?.hierarchy, hierarchyOptions]);

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.

1 participant