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

FEATURE/HCMPRE-1712: Facility Dropdown for plan Inbox #2096

Merged
merged 27 commits into from
Jan 3, 2025

Conversation

abishekTa-egov
Copy link
Contributor

@abishekTa-egov abishekTa-egov commented Jan 3, 2025

FEATURE/HCMPRE-1712: Filter for facility and drop down for filter

Summary by CodeRabbit

  • New Features
    • Added facility selection dropdown to the inbox filter.
    • Implemented loading state management for facility data retrieval.
  • Improvements
    • Enhanced filter component with more dynamic data fetching capabilities.
    • Improved user interface for facility-based filtering.

@abishekTa-egov abishekTa-egov requested a review from a team as a code owner January 3, 2025 07:54
Copy link
Contributor

coderabbitai bot commented Jan 3, 2025

Warning

Rate limit exceeded

@abishekTa-egov has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 65245d3 and c423746.

📒 Files selected for processing (1)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (4 hunks)
📝 Walkthrough

Walkthrough

The pull request enhances the InboxFilterWrapper component in the microplan module by introducing a facility selection feature. The changes include adding a new import for the Loader component, implementing a method to transform facility data, and creating a new dropdown for facility selection. The component now uses query parameters and tenant ID to fetch and display facility options, with improved loading state management.

Changes

File Changes
health/micro-ui/.../InboxFilterWrapper.js - Added Loader import
- Introduced createFacilityOptions method
- Added planFacilitySearchConfig for API configuration
- Implemented facility dropdown with loading state

Sequence Diagram

sequenceDiagram
    participant UI as InboxFilterWrapper
    participant Hook as useQueryParams
    participant Service as ULBService
    participant API as Facility API
    
    UI->>Hook: Retrieve query parameters
    UI->>Service: Get current tenant ID
    UI->>API: Fetch facility data
    API-->>UI: Return facility list
    UI->>UI: Transform facility options
    UI->>UI: Render facility dropdown
Loading

Possibly related PRs

Suggested reviewers

  • nipunarora-eGov
  • Swathi-eGov

Poem

🐰 Hop, hop, filter with grace,
Facilities dancing in their space,
Loading spinner twirls around,
Dropdown magic newly found,
Microplan's UI takes its place! 🌟


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@abishekTa-egov abishekTa-egov changed the title FEATURE/HCMPRE-1712: Filter for facility FEATURE/HCMPRE-1712: Facility Dropdown for planInbox Jan 3, 2025
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc5e629 and 85ea908.

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

Pattern **/*.js: check

📓 Learnings (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (1)
Learnt from: Ramkrishna-egov
PR: egovernments/DIGIT-Frontend#1562
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js:57-57
Timestamp: 2024-11-12T10:40:17.779Z
Learning: In the `InboxFilterWrapper` component, `optionsKey` should always be set to `"name"` because options are transformed and created within the component.
🔇 Additional comments (2)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (2)

3-3: Import usage verified.
The Loader import appears to be properly utilized (see lines 134-136), so this addition is valid.


11-12: Consider input validation or fallback for query parameters.
Currently, url?.microplanId is used directly in planFacilitySearchConfig. Ensure this property is always defined or provide a fallback if url?.microplanId is absent, to avoid potential runtime errors.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23ebb4d and f85e32d.

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

Pattern **/*.js: check

🔇 Additional comments (6)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (6)

3-3: Use the newly introduced Loader more selectively.
Great job leveraging the Loader for partial updates. Ensure you only block the facility-related portion so users can still interact with other filters.


54-54: No actions needed.
This blank line seems intentional for code clarity.


122-122: Add error handling for API call.
You already destructure panFacilityerror, but it isn’t handled. Consider adding a fallback UI or error state for a more robust user experience.


177-190: Partial loading is properly implemented.
Nicely done showing a loader only for facilities. This preserves access to the other filters while data is fetched.


98-120: 🧹 Nitpick (assertive)

Ensure consistent data shape for facility dropdown.
You are mapping { code: facility.facilityName, Id: facility.facilityId }. Elsewhere, dropdowns often view code as an ID and name as a display label. Consider reversing them to avoid confusion in future maintenance.

-    const facilityOptions = data.PlanFacility.map((facility) => ({
-      code: facility.facilityName,
-      Id: facility.facilityId
-    }));
+    const facilityOptions = data.PlanFacility.map((facility) => ({
+      code: facility.facilityId,
+      name: facility.facilityName,
+    }));

Likely invalid or redundant comment.


12-12: Validate tenant ID usage.
Confirm that the tenant ID returned by Digit.ULBService.getCurrentTenantId() always matches the tenant you're filtering on. If you expect to override it in certain contexts, consider receiving it via props.

✅ Verification successful

Let me analyze the usage of getCurrentTenantId() to verify if it's being used consistently for filtering.


Let me check how the tenantId is being used in the InboxFilterWrapper component and its related filter logic.


Based on the code analysis, I can now provide a final response about the tenant ID usage:

The tenant ID usage is appropriate and consistent with filtering requirements

The tenant ID from getCurrentTenantId() is being used correctly in the InboxFilterWrapper component as part of the plan facility search criteria. Specifically:

  1. It's used in the planFacilitySearchConfig to scope the facility search to the current tenant:
PlanFacilitySearchCriteria: {
  tenantId: tenantId,
  planConfigurationId: url?.microplanId,
}
  1. The tenant ID is combined with other filter parameters and used alongside the microplan ID to ensure proper scoping of facility data
  2. The implementation follows the standard pattern where tenant ID is used as a mandatory filter parameter for data access

The current implementation ensures that facility data is properly filtered by tenant context, and there's no need to override it via props since it's correctly scoped to the user's current tenant context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Searching for references to getCurrentTenantId usage
rg -A 5 "getCurrentTenantId"

Length of output: 68613


Script:

#!/bin/bash
# Search for tenantId filter usage in the file and related components
rg -A 5 "tenantId.*filter" health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/

# Search for any filter-related code in the InboxFilterWrapper component
ast-grep --pattern 'const $_ = {
  $$$
  tenantId: $_,
  $$$
}' health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

Length of output: 3970


Script:

#!/bin/bash
# Check the InboxFilterWrapper component implementation
cat health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

# Search for any filter-related hooks or context usage
rg -A 5 "useFilter|FilterContext" health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/

Length of output: 8135

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 3, 2025
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f85e32d and dd4d02f.

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

Pattern **/*.js: check

🪛 Biome (1.9.4)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js

[error] 119-119: Use Number.POSITIVE_INFINITY instead of the equivalent global.

ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.POSITIVE_INFINITY instead.

(lint/style/useNumberNamespace)

🔇 Additional comments (5)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js (5)

3-3: Appropriate import for partial loading
Bringing in “Loader” from the digit-ui-components library is a suitable approach to handle loading states in a modular way.


54-54: No code changes here
No meaningful changes detected in this blank line.


112-115: Ensure consistent data shape in dropdown options
The facility dropdown expects a uniform structure (typically { code, name }). Currently, “code“ holds the facility name while “Id” holds the facility ID. Aligning them with standard conventions helps reduce confusion.

- code: facility.facilityName,
- Id: facility.facilityId
+ name: facility.facilityName,
+ code: facility.facilityId

123-123: Handle API errors
planFacilityerror remains unused. Displaying an error fallback or message would improve resilience.

 const { isLoading: isPlanFacilityLoading, error: planFacilityerror, data: planFacility }
   = Digit.Hooks.useCustomAPIHook(planFacilitySearchConfig);

+ if (planFacilityerror) {
+   return <div style={{ color: "red" }}>{t("PLAN_FACILITY_ERROR")}</div>;
+ }

179-191: Partial loader implementation approved
Showing a loader specifically for facility data while preserving access to other filters is a user-friendly approach. Nicely done!

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 3, 2025
@nipunarora-eGov nipunarora-eGov changed the title FEATURE/HCMPRE-1712: Facility Dropdown for planInbox FEATURE/HCMPRE-1712: Facility Dropdown for plan Inbox Jan 3, 2025
@nipunarora-eGov nipunarora-eGov merged commit 0b3dee9 into console Jan 3, 2025
4 checks passed
@nipunarora-eGov nipunarora-eGov deleted the FEATURE/HCMPRE-1712 branch January 3, 2025 11:12
nipunarora-eGov pushed a commit that referenced this pull request Jan 15, 2025
* Adding filters

* Working Filter Search

* InboxFilter Changes

* removing console.log

* Css package update

* changes

* changes

* changes

* changes

* changes

* A lot of changes

* changes

* changes

* changes

* uniform payload structure

* Adding Facility Dropdown

* code replacing name attribute

* Loader changes

* comments resolved

* Loader change

* Id to id
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.

3 participants