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

Fix: Enhance LocationMap with interactive features and tooltips #11142

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

abhimanyurajeesh
Copy link
Contributor

@abhimanyurajeesh abhimanyurajeesh commented Mar 8, 2025

Proposed Changes

Screenshot

Screenshot
Screen.Recording.2025-03-08.at.4.56.36.PM.mov

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA in Mobile Devices
  • Completion of QA in Desktop Devices

Summary by CodeRabbit

  • New Features
    • Enhanced the location map with an interactive editing mode that preserves the current viewport for a consistent experience.
    • Updated facility icons for clearer visual identification.
    • Added tooltips for location names under certain conditions.
    • Included a toggle for enabling or disabling node dragging for improved interaction during editing.

@abhimanyurajeesh abhimanyurajeesh requested a review from a team as a code owner March 8, 2025 11:30
Copy link
Contributor

coderabbitai bot commented Mar 8, 2025

Walkthrough

The changes update the facility location pages by introducing an isEditing prop that controls the editing state. In LocationList.tsx, the new prop is forwarded to the LocationMap component based on the isSheetOpen state. In LocationMap.tsx, the prop is integrated into the component’s interface, and modifications include switching the icon from a Folder to a Hospital, using the viewport hook in custom nodes, and managing state for draggable functionality and viewport preservation during editing.

Changes

File(s) Change Summary
src/.../LocationList.tsx Added a new isEditing prop to LocationMap component, set to the value of isSheetOpen to indicate if the location editing sheet is open.
src/.../LocationMap.tsx Updated LocationMapProps to include an optional isEditing property. Replaced the Folder icon with a Hospital icon, integrated the useViewport hook in CustomNode, added tooltip functionality, and modified state management for draggable nodes and viewport preservation in editing mode.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant LS as LocationList
    participant LM as LocationMap
    participant LC as LocationMapContent
    participant RF as ReactFlow
    participant CN as CustomNode

    U->>LS: Opens location editing sheet
    LS->>LM: Passes isEditing (from isSheetOpen)
    LM->>LC: Initializes editing mode based on isEditing
    LC->>RF: Configures draggable state and fitView accordingly
    LM->>CN: Utilizes viewport hook to update icons/tooltips
    U->>LM: Toggles interactive mode via Controls
    LM->>LC: Updates draggable state dynamically
Loading

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • Jacobjeevan
  • rithviknishad

Poem

I'm a cheerful rabbit, code at my feet,
Hopping through changes with a rhythmic beat.
New props and icons make the map so bright,
Draggable dreams in soft editing light.
In a world of code and joy, everything feels right!
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e4570f7 and 96631fc.

📒 Files selected for processing (2)
  • src/pages/Facility/settings/locations/LocationList.tsx (1 hunks)
  • src/pages/Facility/settings/locations/LocationMap.tsx (11 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: cypress-run (1)
🔇 Additional comments (11)
src/pages/Facility/settings/locations/LocationList.tsx (1)

303-303: Good enhancement with isEditing prop addition.

The prop isEditing={isSheetOpen} allows the LocationMap component to be aware of the editing state, enabling it to adjust its behavior accordingly. This creates a clean connection between the sheet's open state and the map's editing mode.

src/pages/Facility/settings/locations/LocationMap.tsx (10)

1-1: Better icon choice with Hospital instead of Folder.

The Hospital icon provides a more intuitive visual representation for facility nodes than the previously used Folder icon, aligning better with the medical context of the application.


46-46: Good interface extension with isEditing prop.

Adding the optional isEditing property to the LocationMapProps interface properly types the new prop being passed from LocationList. This creates a clear contract for the component's behavior when in editing mode.


51-57: Enhanced user experience with viewport-aware tooltips.

Using the useViewport hook to access the current zoom level and conditionally showing tooltips based on zoom level or name length is an excellent enhancement. This improves readability when location names are truncated or hard to read at lower zoom levels.


99-112: Great tooltip implementation for improved readability.

The tooltip implementation provides an excellent solution for displaying full location names when they exceed the visible area or when the user is zoomed out. The conditional rendering based on the showTooltip variable ensures tooltips only appear when necessary.


326-326: Good state management for editing and viewport persistence.

The addition of the isEditing prop to component parameters and the implementation of viewport state management allow the map to maintain context when entering and exiting edit mode. This significantly improves user experience by preserving their view position.

Also applies to: 330-341


343-357: Excellent viewport persistence implementation.

The implementation of saving the viewport when entering edit mode and restoring it when exiting ensures a seamless user experience. This prevents disorientation that could occur if the view were to reset after each edit.


513-516: Good user control with interactive mode toggle.

The handleInteractiveChange callback provides users with the ability to toggle between interactive (draggable) and static modes, giving them more control over how they interact with the map.


530-530: Well-implemented draggable state management.

Applying the isDraggable state to both the facility root node and all location nodes ensures consistent behavior throughout the map. This coordinated approach to interactivity creates a predictable user experience.

Also applies to: 565-568


615-615: Important ReactFlow property updates for consistent behavior.

Updating the ReactFlow component's draggable property to reflect the isDraggable state and conditionally setting fitView based on viewport and editing state ensures the map behaves consistently with user expectations.

Also applies to: 618-618


634-639: Excellent addition of interactive controls.

Adding the interactive mode toggle to the Controls component gives users direct access to change the interaction mode. The showInteractive and onInteractiveChange props create a clean integration with the draggable state management.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @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

netlify bot commented Mar 8, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 96631fc
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67cc2a5321600500084bf2fd
😎 Deploy Preview https://deploy-preview-11142.preview.ohc.network
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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.

Enhance LocationMap with interactive features and tooltips
1 participant