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

added hierarchy level for village and enable the edit button based on… #1671

Merged
merged 4 commits into from
Oct 25, 2024

Conversation

rachana-egov
Copy link
Contributor

@rachana-egov rachana-egov commented Oct 25, 2024

… role

Summary by CodeRabbit

  • New Features

    • Enhanced PopInboxTable for simplified URL construction.
    • Improved VillageView component with dynamic management of campaign-related data and user interactions.
    • Added multiple pop-up visibility states and improved loading indicators.
    • Conditional rendering of actions based on user roles.
  • Bug Fixes

    • Streamlined row selection handling in PopInboxTable.
  • Documentation

    • Updated comments and descriptions to reflect new functionalities and state management.

@rachana-egov rachana-egov requested a review from a team as a code owner October 25, 2024 09:18
Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Caution

Review failed

The pull request is closed.

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request involve modifications to two primary components: PopInboxTable and VillageView. In PopInboxTable, the method of constructing URLs has been simplified by concatenating parameters into a single string. Additionally, the handling of row selection has been streamlined. In VillageView, enhancements include the introduction of new state variables for managing pop-up visibility, improved data fetching with custom hooks, and a more dynamic rendering logic for displaying hierarchy and user actions.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/PopInboxTable.js - Simplified history.push URL construction by concatenating pathname and search into a single string.
- Updated handleRowSelect to call props?.onRowSelect(event) directly.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/viewVillage.js - Added campaignId to destructured query parameters.
- Introduced state variables for pop-up visibility.
- Added findHierarchyPath function and updated hierarchy state in useEffect.
- Enhanced data fetching with new hooks for employee and campaign data.
- Modified rendering logic for dynamic hierarchy display and user actions.

Possibly related PRs

Suggested reviewers

  • nipunarora-eGov

🐰 In the garden where data flows,
The PopInboxTable now brightly glows.
With URLs that dance and play,
And VillageView grows day by day.
New hooks and states, a joyful sight,
Hopping along, everything feels right! 🌼


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

🧹 Outside diff range comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/PopInboxTable.js (2)

Line range hint 171-176: Remove commented code and unused state.

The row selection logic has been simplified, but there's some cleanup needed:

  1. Remove the commented code block
  2. Remove the unused isIntermediate state and related logic since it's no longer being used

Apply these changes:

- const [isIntermediate, setIsIntermediate] = useState(false);

  const handleRowSelect = (event) => {
-   // if(!event?.allSelected && event?.selectedCount >0){
-   //     setIsIntermediate(true);
-   // }
    props?.onRowSelect(event);
  };

  const selectProps = {
    hideLabel: true,
-   isIntermediate: isIntermediate,
    mainClassName: "data-table-select-checkbox",
  };

Line range hint 1-249: Consider component decomposition and type safety improvements.

The component handles multiple responsibilities and could benefit from:

  1. Breaking down into smaller, focused components (e.g., separate components for timeline popup, edit popup)
  2. Adding TypeScript for better type safety and improved maintainability
  3. Using a custom hook for pagination logic

Consider creating:

  • useTablePagination hook for pagination logic
  • TimelinePopup and EditVillagePopup as separate components
  • TypeScript interfaces for props and data structures
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 2bd0dda and 41969f9.

📒 Files selected for processing (2)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/PopInboxTable.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/viewVillage.js (6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/PopInboxTable.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/viewVillage.js (1)

Pattern **/*.js: check

🪛 Biome
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/viewVillage.js

[error] 73-73: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)


[error] 115-115: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

🔇 Additional comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/PopInboxTable.js (1)

109-109: ⚠️ Potential issue

Add safety checks for URL parameters.

While the URL construction is simplified, it's vulnerable to potential issues:

  1. Add null checks for url?.microplanId and url?.campaignId
  2. Sanitize the boundaryCode parameter
  3. Validate window.contextPath

Consider applying this safer implementation:

- history.push(`/${window.contextPath}/employee/microplan/village-view?microplanId=${url?.microplanId}&boundaryCode=${row.boundaryCode}&campaignId=${url?.campaignId}`)
+ const contextPath = window.contextPath || '';
+ const params = new URLSearchParams({
+   microplanId: url?.microplanId || '',
+   boundaryCode: row.boundaryCode || '',
+   campaignId: url?.campaignId || ''
+ });
+ history.push(`/${contextPath}/employee/microplan/village-view?${params.toString()}`);
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/viewVillage.js (1)

259-259: 🧹 Nitpick (assertive)

Localize the button label for internationalization

The button label "Edit Confirmed Population" is hard-coded in English. To support internationalization, wrap the label with the t() function for translation.

Apply this diff:

-   label="Edit Confirmed Population"
+   label={t(`HCM_MICROPLAN_EDIT_CONFIRMED_POPULATION_LABEL`)}

Ensure that the translation key HCM_MICROPLAN_EDIT_CONFIRMED_POPULATION_LABEL is added to your localization files.

Likely invalid or redundant comment.

@nipunarora-eGov nipunarora-eGov merged commit b25bd58 into console Oct 25, 2024
3 checks passed
@nipunarora-eGov nipunarora-eGov deleted the demo_issue_fix_3 branch October 25, 2024 09:43
@nabeelmd-eGov nabeelmd-eGov mentioned this pull request Dec 10, 2024
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