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

Boundary Management ui Info pending changes #1789

Merged
merged 5 commits into from
Nov 11, 2024
Merged

Conversation

suryansh-egov
Copy link
Contributor

@suryansh-egov suryansh-egov commented Nov 11, 2024

Choose the appropriate template for your PR:

Summary by CodeRabbit

  • New Features

    • Added a loading indicator to the GeoPode component for improved user experience during data processing.
    • Enhanced feedback for file downloads in the ViewHierarchy component with toast notifications for in-progress downloads.
  • Bug Fixes

    • Improved error handling in the createNewHierarchy function to prevent premature exits.
    • Adjusted error notifications for file downloads to provide clearer user prompts.
  • Style

    • Updated the display of boundary types to uppercase for consistency across the UI.

@suryansh-egov suryansh-egov requested a review from a team as a code owner November 11, 2024 07:17
Copy link
Contributor

coderabbitai bot commented Nov 11, 2024

Caution

Review failed

The pull request is closed.

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces several modifications across three files related to the campaign manager's functionality. In useBoundaryHome.js, the hierarchy names are updated while maintaining the existing logic for data fetching. The GeoPode.js component sees the addition of a loading state and refined error handling, enhancing the user experience during asynchronous operations. Lastly, ViewHierarchy.js is updated to improve file download handling and adjust the presentation of boundary types, ensuring they are displayed in uppercase.

Changes

File Change Summary
.../hooks/useBoundaryHome.js Updated hierarchyName and defaultHierarchyName variables; no changes to the fetching logic.
.../pages/employee/GeoPode.js Added showLoader state; refined error handling in createNewHierarchy; updated rendering logic.
.../pages/employee/ViewHierarchy.js Enhanced file download logic; adjusted boundary type string formatting to uppercase.

Possibly related PRs

  • updated summary redirection #1488: The BoundarySummary component has been updated to include a new variable, hierarchyType, which is relevant to the changes made in the useBoundaryHome hook regarding hierarchy handling.
  • added condition for update #1541: The UpdateBoundary component's changes to validation logic and handling of hierarchy types relate to the updates in the useBoundaryHome hook, which also modifies how hierarchy types are processed.
  • fixed NA issue of summary #1681: The SetupCampaign component's enhancements in handling campaign cycle configuration and hierarchy types connect with the changes made in the useBoundaryHome hook regarding hierarchy management.
  • Feature/bugs #1785: The modifications in the UICustomizations object, particularly around handling hierarchy types and user feedback, align with the changes made in the useBoundaryHome hook that also focuses on hierarchy handling.

Suggested reviewers

  • nipunarora-eGov

🐰 In the realm of code, we hop and play,
With loaders and states, we brighten the day.
Hierarchies updated, in uppercase they gleam,
As errors are caught, we follow the dream.
So here’s to the changes, both big and small,
A leap for our project, let's celebrate all! 🌟


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: 12

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between e4e0a5d and 64ed562.

📒 Files selected for processing (3)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useBoundaryHome.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/GeoPode.js (6 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js (5 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useBoundaryHome.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

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

Pattern **/*.js: check

🪛 Biome
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/GeoPode.js

[error] 203-203: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)


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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 211-211: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)


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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 251-251: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)


[error] 257-257: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)


[error] 273-273: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)


[error] 323-323: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)


[error] 327-327: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)


[error] 345-345: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.

(lint/a11y/useKeyWithClickEvents)


[error] 351-351: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)


[error] 206-206: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 237-237: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 282-290: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 291-300: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 331-331: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 373-381: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 382-391: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 375-375: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)


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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 505-505: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)

🔇 Additional comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useBoundaryHome.js (2)

Line range hint 1-138: Implementation looks good!

The hook implementation is well-structured with proper error handling, clean data transformation, and efficient caching using React Query. The changes maintain the existing robust implementation while updating the configuration values.


95-101: Verify hierarchy name handling across components.

The hierarchy name handling logic looks correct, but let's verify that other components are properly passing and handling these hierarchy types.

Let's check for consistency in hierarchy name handling:

✅ Verification successful

Based on the search results, I can now generate the final response:

Hierarchy name handling is properly implemented across components

The codebase shows consistent handling of hierarchy types and names:

  • Hierarchy types are properly passed through props and configurations
  • No hardcoded test values are in use (commented out test values in useBoundaryHome.js)
  • Proper fallback patterns are implemented (e.g. hierarchyType || boundaryConfig?.hierarchy)
  • Consistent usage of hierarchy type for localization keys and boundary configurations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for hierarchy type usage patterns in the codebase
echo "Searching for hierarchy type assignments and usage..."
rg -A 2 "hierarchyType[^a-zA-Z]" --type js

echo "Searching for hierarchy name assignments..."
rg -A 2 "hierarchyName[^a-zA-Z]" --type js

# Search for potential hardcoded test values
echo "Checking for potential hardcoded test values..."
rg -A 2 "test008|DEFAULT-BOUNDARY-DEMO" --type js

Length of output: 95308

<div>
<div style={{ fontWeight: "600", fontSize: "1.2rem" }}>
{/* {item?.boundaryType} */}
{`${t((defaultHierarchyType + "_" + item?.boundaryType).toUpperCase().replace(/\s+/g, "_"))}`}
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)

Use template literals instead of string concatenation

String concatenation can be replaced with template literals for better readability and maintainability.

-{`${t((defaultHierarchyType + "_" + item?.boundaryType).toUpperCase().replace(/\s+/g, "_"))}`}
+{t(`${defaultHierarchyType}_${item?.boundaryType}`.toUpperCase().replace(/\s+/g, "_"))}

Also applies to: 216-216

🧰 Tools
🪛 Biome

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

Comment on lines +113 to +114
// setShowLoader(true);
setShowToast({ label: "HIERARCHY_PLEASE_WAIT", isError: "info", transitionTime:100});
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

Uncomment loader state management for consistent loading feedback

The loader state management is commented out, which could lead to inconsistent UI feedback during async operations.

-// setShowLoader(true);
+setShowLoader(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
// setShowLoader(true);
setShowToast({ label: "HIERARCHY_PLEASE_WAIT", isError: "info", transitionTime:100});
setShowLoader(true);
setShowToast({ label: "HIERARCHY_PLEASE_WAIT", isError: "info", transitionTime:100});

Comment on lines +141 to 146
// setShowLoader(false);
const errorMessage = error.message === "LEVELS_CANNOT_BE_EMPTY"
? t("LEVELS_CANNOT_BE_EMPTY")
: error?.response?.data?.Errors?.[0]?.message || t("HIERARCHY_CREATION_FAILED");
? t("LEVELS_CANNOT_BE_EMPTY")
: error?.response?.data?.Errors?.[0]?.message || t("HIERARCHY_CREATION_FAILED");

setShowToast({ label: errorMessage, isError: "error" });
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve error handling structure

The error handling could be simplified and made more consistent.

-// setShowLoader(false);
-const errorMessage = error.message === "LEVELS_CANNOT_BE_EMPTY"
-    ? t("LEVELS_CANNOT_BE_EMPTY")
-    : error?.response?.data?.Errors?.[0]?.message || t("HIERARCHY_CREATION_FAILED");
+setShowLoader(false);
+const errorMessage = {
+    "LEVELS_CANNOT_BE_EMPTY": t("LEVELS_CANNOT_BE_EMPTY"),
+    "DEFAULT": error?.response?.data?.Errors?.[0]?.message || t("HIERARCHY_CREATION_FAILED")
+}[error.message] || errorMessage.DEFAULT;
📝 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
// setShowLoader(false);
const errorMessage = error.message === "LEVELS_CANNOT_BE_EMPTY"
? t("LEVELS_CANNOT_BE_EMPTY")
: error?.response?.data?.Errors?.[0]?.message || t("HIERARCHY_CREATION_FAILED");
? t("LEVELS_CANNOT_BE_EMPTY")
: error?.response?.data?.Errors?.[0]?.message || t("HIERARCHY_CREATION_FAILED");
setShowToast({ label: errorMessage, isError: "error" });
setShowLoader(false);
const errorMessage = {
"LEVELS_CANNOT_BE_EMPTY": t("LEVELS_CANNOT_BE_EMPTY"),
"DEFAULT": error?.response?.data?.Errors?.[0]?.message || t("HIERARCHY_CREATION_FAILED")
}[error.message] || errorMessage.DEFAULT;
setShowToast({ label: errorMessage, isError: "error" });

@@ -367,14 +370,14 @@ const ViewHierarchy = () => {
<div>
<div style={{fontWeight:"600", fontSize:"1.2rem"}}>
{/* {t(hierItem?.boundaryType)} */}
{`${t(( hierarchyType + "_" + hierItem?.boundaryType).toLowerCase().replace(/\s+/g, "_"))}`}
{`${t(( hierarchyType + "_" + hierItem?.boundaryType).toUpperCase().replace(/\s+/g, "_"))}`}
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)

Use template literals for better readability

Replace string concatenation with template literals for improved code readability and maintainability.

- {`${t(( hierarchyType + "_" + hierItem?.boundaryType).toUpperCase().replace(/\s+/g, "_"))}`}
+ {t(`${hierarchyType}_${hierItem?.boundaryType}`.toUpperCase().replace(/\s+/g, "_"))}

- {`${t(( hierarchyType + "_" + hierItem?.boundaryType).toUpperCase().replace(/\s+/g, "_"))}-geojson.json`}
+ {t(`${hierarchyType}_${hierItem?.boundaryType}`.toUpperCase().replace(/\s+/g, "_"))}-geojson.json`}

Also applies to: 380-380, 391-393

🧰 Tools
🪛 Biome

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

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

@@ -367,14 +370,14 @@ const ViewHierarchy = () => {
<div>
<div style={{fontWeight:"600", fontSize:"1.2rem"}}>
{/* {t(hierItem?.boundaryType)} */}
{`${t(( hierarchyType + "_" + hierItem?.boundaryType).toLowerCase().replace(/\s+/g, "_"))}`}
{`${t(( hierarchyType + "_" + hierItem?.boundaryType).toUpperCase().replace(/\s+/g, "_"))}`}
</div>
<div style={{height:"1rem"}}></div>
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)

Use self-closing tags for empty elements

For consistency with JSX best practices, use self-closing tags for elements without children.

- <div style={{height:"1rem"}}></div>
+ <div style={{height:"1rem"}} />

- <div style={{height:"2rem"}}></div>
+ <div style={{height:"2rem"}} />

Also applies to: 505-505

🧰 Tools
🪛 Biome

[error] 375-375: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.

Unsafe fix: Use a SelfClosingElement instead

(lint/style/useSelfClosingElements)

Comment on lines +118 to +120
else if ( resFile && resFile?.GeneratedResource?.[0]?.status === "inprogress"){
setShowToast({label: "PLEASE_WAIT_AND_RETRY_AFTER_SOME_TIME", isError: "info" });
}
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)

Consider enhancing the in-progress notification message

The notification for in-progress status is good, but could be more informative by including an estimated wait time or providing a way to check the status later.

- setShowToast({label: "PLEASE_WAIT_AND_RETRY_AFTER_SOME_TIME", isError: "info" });
+ setShowToast({
+   label: "PLEASE_WAIT_AND_RETRY_AFTER_SOME_TIME",
+   subLabel: "ESTIMATED_WAIT_TIME_1_MINUTE",
+   isError: "info"
+ });

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +319 to 321
// console.error("Error while polling:", error);
retries++;
setTimeout(poll, pollInterval);
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

Reconsider removing error logging

While adding retry logic is good, completely removing error logging might make it harder to debug issues in production. Consider keeping the logs but with proper error details and logging levels.

- // console.error("Error while polling:", error);
+ console.error("Error during status polling - Attempt ${retries + 1}/${maxRetries}:", {
+   error: error.message,
+   requestId: id,
+   type: typeOfData
+ });

Committable suggestion skipped: line range outside the PR's diff.

…gn-manager/src/hooks/useBoundaryHome.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
jagankumar-egov and others added 2 commits November 11, 2024 13:02
…gn-manager/src/pages/employee/GeoPode.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…gn-manager/src/pages/employee/GeoPode.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@jagankumar-egov jagankumar-egov changed the title pending changes Boundary Management ui Info pending changes Nov 11, 2024
@jagankumar-egov jagankumar-egov merged commit c501b6d into console Nov 11, 2024
3 checks passed
@jagankumar-egov jagankumar-egov deleted the feature/dry-demo branch November 11, 2024 08:13
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