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

HCMPRE FIX #1648

Merged
merged 8 commits into from
Oct 23, 2024
Merged

HCMPRE FIX #1648

merged 8 commits into from
Oct 23, 2024

Conversation

nabeelmd-eGov
Copy link
Contributor

@nabeelmd-eGov nabeelmd-eGov commented Oct 23, 2024

  • added showtab enhance
  • issue fix
  • css update
  • update styles
  • added chip pop
  • added pagination

Choose the appropriate template for your PR:

Summary by CodeRabbit

  • New Features

    • Added TotalCount property to the response from the plan search, enhancing data visibility.
    • Improved pagination in the Plan Inbox component, allowing users to navigate through data more effectively.
  • Bug Fixes

    • Enhanced error handling in the search functionality to ensure better user feedback.
  • Improvements

    • Updated API calls to support pagination, providing a more controlled data fetching experience.
    • Enhanced the DataTable component to reflect the total number of available rows accurately.

@nabeelmd-eGov nabeelmd-eGov requested a review from a team as a code owner October 23, 2024 11:09
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve modifications to the searchPlanWithCensus function and enhancements to the PlanInbox component. The searchPlanWithCensus function now returns an additional TotalCount property, while the PlanInbox component introduces new state variables for pagination management. These changes include updates to methods for handling page changes and row counts, allowing for more efficient data retrieval and display in the DataTable.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/searchPlanWithCensus.js - Added TotalCount to the return object of searchPlanWithCensus.
- Maintained existing error handling and asynchronous call structure.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js - Added state variables: currentPage, rowsPerPage, totalRows, limitAndOffset.
- Updated handlePageChange and handlePerRowsChange methods for pagination.
- Enhanced API call to include limit and offset.
- Updated DataTable pagination properties to use new state variables.
- Set totalRows based on TotalCount from API response.

Possibly related PRs

  • added jurisdictions in facility serach and updated popinbox #1602: The changes in the main PR regarding the addition of the TotalCount property in the searchPlanWithCensus function are related to the updates in the PopInbox component, which now includes pagination and utilizes the TotalCount for managing the total number of rows displayed.
  • Added action bar for pop inbox screen #1622: The modifications in the PopInbox component to handle pagination and the introduction of new state variables are directly related to the changes made in the main PR, as both involve managing data retrieval and display based on the census data.
  • planInbox console #1623: The addition of the PlanWithCensusInbox component in the retrieved PR aligns with the changes in the main PR, as it also deals with census data and the management of plans, reflecting the overall enhancements in handling census-related functionalities.

Suggested reviewers

  • nipunarora-eGov

🐰 In the meadow, changes bloom,
New counts and pages make room.
With every hop, we fetch and see,
A table of plans, as bright as can be!
Let’s paginate, and dance with cheer,
For census data is finally here! 🌼


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.

coderabbitai[bot]
coderabbitai bot previously requested changes Oct 23, 2024
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 comments (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/searchPlanWithCensus.js (1)

Line range hint 43-49: Enhance error handling with specific error types and logging.

The current error handling could be more robust and informative for debugging purposes.

   } catch (error) {
+    // Log error for debugging
+    console.error("searchPlanWithCensus failed:", error);
+
     if (error?.response?.data?.Errors) {
-      throw new Error(error.response.data.Errors[0].message);
+      const apiError = error.response.data.Errors[0];
+      throw new Error(`API Error: ${apiError.code} - ${apiError.message}`);
+    } else if (error instanceof Error) {
+      throw error;
     }
-    throw new Error("An unknown error occurred");
+    throw new Error("An unknown error occurred while searching plans");
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 8e0e650 and 5157048.

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

Pattern **/*.js: check

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

Pattern **/*.js: check

🔇 Additional comments (5)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/hooks/services/searchPlanWithCensus.js (1)

Line range hint 1-42: Add type safety and response validation.

The function could benefit from better type safety and response validation:

Consider adding:

  1. TypeScript type definitions for API responses
  2. Runtime validation for critical properties:
// Add at the start of the function
const validatePlanResponse = (response) => {
  if (!Array.isArray(response?.Plan)) {
    throw new Error("Invalid plan data received");
  }
  return response;
};

const validateCensusResponse = (response) => {
  if (!Array.isArray(response?.Census)) {
    throw new Error("Invalid census data received");
  }
  return response;
};

This would make the code more maintainable and catch potential API contract changes early.

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

86-87: LGTM! Proper implementation of server-side pagination parameters

The API integration correctly uses the limit and offset parameters from state for server-side pagination.


413-415: LGTM! Proper DataTable pagination configuration

The DataTable component is correctly configured with pagination props using the appropriate state variables and reasonable page size options.


212-213: ⚠️ Potential issue

Remove duplicate setState call

There's a duplicate call to setActiveFilter with the same value.

  setTotalRows(planWithCensus?.TotalCount)
  setActiveFilter(planWithCensus?.StatusCount);
-  setActiveFilter(planWithCensus?.StatusCount);

Likely invalid or redundant comment.


Line range hint 31-415: Verify pagination implementation across the codebase

Let's verify that the pagination implementation is consistent with other similar components in the codebase.

✅ Verification successful

Let me try a different search strategy to verify the pagination implementation.


Based on the search results, I can now provide a final verification response about the pagination implementation.

Pagination implementation is consistent with codebase patterns

The pagination implementation in PlanInbox.js follows the established patterns found across the codebase:

  1. State management is consistent with other components:

    • Uses same state variables (currentPage, rowsPerPage, totalRows)
    • Similar initialization values (currentPage: 1, rowsPerPage: 5)
    • Consistent limitAndOffset pattern found in PopInbox.js and other components
  2. Page change handlers follow the standard pattern:

    • handlePageChange updates currentPage and calculates offset
    • handlePerRowsChange updates both page size and offset
    • Consistent with implementations in PopInbox.js and other components
  3. API integration:

    • Properly uses limit/offset in API criteria
    • Consistent with other paginated API calls in the codebase

The implementation aligns well with the established patterns across the microplan module and other modules in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for similar DataTable implementations with pagination
# to ensure consistency across the codebase

# Search for DataTable components with pagination
echo "Searching for other DataTable implementations with pagination..."
rg -l 'DataTable.*pagination.*paginationServer' --type js

# Search for similar pagination state management
echo "Searching for similar pagination state management..."
rg 'const.*\[.*Page.*setState.*\].*useState' --type js

# Search for similar limit/offset implementations
echo "Searching for similar limit/offset patterns..."
rg 'limit.*offset.*criteria' --type js

Length of output: 514


Script:

#!/bin/bash
# Search for DataTable components with pagination using broader patterns
echo "Searching for DataTable components with pagination..."
rg -A 5 '<DataTable.*pagination' --type js

# Search for pagination-related state management
echo "Searching for pagination state hooks..."
rg -A 3 '\[.*currentPage.*useState\(' --type js

# Search for handlePageChange implementations
echo "Searching for page change handlers..."
rg -A 5 'handlePageChange.*=' --type js

# Search for limit and offset in API calls
echo "Searching for limit/offset in API parameters..."
rg -A 3 'limit:.*offset:' --type js

Length of output: 17332

@nipunarora-eGov nipunarora-eGov dismissed coderabbitai[bot]’s stale review October 23, 2024 11:17

unable to merge even after resolving

@jagankumar-egov jagankumar-egov merged commit 99da16a into console Oct 23, 2024
3 checks passed
@jagankumar-egov jagankumar-egov deleted the HCMPRE_FIX branch October 23, 2024 11:20
This was referenced Nov 8, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 19, 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.

4 participants