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: PatientNoteCard Text Overflowing and Current Address #9593

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Dec 27, 2024

Proposed Changes

Previous:-
Screenshot 2024-12-27 at 4 28 31 PM

Fix:

Screenshot 2024-12-27 at 4 27 59 PM

@ohcnetwork/care-fe-code-reviewers
@nihal467

Merge Checklist

  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews

Summary by CodeRabbit

Release Notes

  • UI Improvements

    • Enhanced note display with word-wrapping in patient note cards.
    • Updated button components in patient home interface for volunteer assignment and transfer actions.
    • Added explicit type to back navigation button in breadcrumbs.
  • Behavior Changes

    • Removed ability to submit form by pressing "Enter" key.

These updates focus on improving user interface readability and interaction consistency across various components.

Copy link
Contributor

coderabbitai bot commented Dec 27, 2024

Walkthrough

The pull request encompasses modifications across multiple components, focusing on data handling and UI improvements. Changes include refactoring the PatientNoteCard to streamline data fetching and mutation logic, replacing AuthorizedButton with ButtonV2 in PatientHome, adding a type property to the back navigation button in Breadcrumbs, and removing an onKeyDown event handler in the Form component. These changes primarily enhance functionality and interaction consistency.

Changes

File Change Summary
src/components/Facility/PatientNoteCard.tsx Refactored data fetching and mutation logic; added fetchEditHistory function; updated props to include setReload.
src/components/Patient/PatientHome.tsx Replaced AuthorizedButton with ButtonV2 for volunteer assignment and patient transfer actions.
src/components/Common/Breadcrumbs.tsx Added type="button" to back navigation button.
src/components/Form/Form.tsx Removed onKeyDown event handler for form submission.

Assessment against linked issues

Objective Addressed Explanation
Support multi-lines in doctor notes
Consistent card design for transfer and volunteer actions
Improve text display in patient-related components

Possibly related PRs

Suggested labels

tested

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 A rabbit's tale of code so bright,
Fetching data with all its might,
Buttons swapped, breadcrumbs shine,
In this code, all things align!
With each change, our UI's a delight! 🌟


📜 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 95bb772 and 82fcb57.

📒 Files selected for processing (1)
  • src/components/Facility/PatientNoteCard.tsx (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Facility/PatientNoteCard.tsx

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.

Copy link

netlify bot commented Dec 27, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 82fcb57
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/677170cbf138830008539093
😎 Deploy Preview https://deploy-preview-9593--care-ohc.netlify.app
📱 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.

@AdityaJ2305 AdityaJ2305 marked this pull request as ready for review December 27, 2024 11:08
@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner December 27, 2024 11:08
@nihal467
Copy link
Member

image

@AdityaJ2305 the shift+enter shortcut to send message in doctor notes are not working

@nihal467
Copy link
Member

@AdityaJ2305 allow with the issue with your PR bug, fix another one more UI issue in the patient details page, i have updated the issue, look into it

Comment on lines 47 to 51
onKeyDown={(e) => {
if (e.key === "Enter" && !e.shiftKey && !e.metaKey) {
e.stopPropagation();
}
}}
Copy link
Member

@rithviknishad rithviknishad Dec 27, 2024

Choose a reason for hiding this comment

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

although it may solve the issue, why do we need these hacks? can't we stick with html standards? solve the root cause :) this is just hiding the root cause

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The condition is added to handle different behaviors for components like DiscussNote (where Shift + Enter should send a message) and forms like Add Patient (where just Enter should submit the form). By stopping the propagation only when Enter is pressed, it ensures both use cases work as intended without interference.

Copy link
Member

Choose a reason for hiding this comment

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

are you sure that textarea element triggers a "submit" event when pressing enter in the first place? i don't think the issue is with TextAreaFormField itself in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Add Patient submit action gets trigger on pressing enter key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if (e.key === "Enter") {

Copy link
Member

Choose a reason for hiding this comment

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

and is textarea form field responsible for it?

do try replicating this with simple html textarea and form component. pressing enter on textarea does not trigger form submit by itself.

@rithviknishad rithviknishad added changes required invalid This doesn't seem right labels Dec 27, 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: 0

🧹 Nitpick comments (1)
src/components/Patient/PatientHome.tsx (1)

39-39: Use of multiple button components.

You're importing both ButtonV2 here and Button from "@/components/ui/button". If there is no specific need for both, consider consolidating to a single button component to reduce confusion and ensure consistency.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e72cb1 and 4e905b4.

📒 Files selected for processing (1)
  • src/components/Patient/PatientHome.tsx (4 hunks)
🔇 Additional comments (2)
src/components/Patient/PatientHome.tsx (2)

Line range hint 544-567: Confirm consistent authorization handling.

Double-check that switching from AuthorizedButton to ButtonV2 still restricts transfer actions to authorized users. If ButtonV2 depends on separate logic (e.g., a context or a custom hook) to handle role checks, verify that it’s configured.


Line range hint 526-539: Successful replacement with ButtonV2.

Replacing the volunteer assignment button with ButtonV2 looks good. Ensure you have tested any role or permission differences if ButtonV2 behaves differently from the old button component (e.g., if authorizeFor logic differs).

✅ Verification successful

Let me analyze the usage of ButtonV2 and its authorizeFor prop in the codebase.


Let me try a different approach to understand the ButtonV2 component and its authorization handling.


Let me check the ButtonV2 component implementation directly.


Based on the ButtonV2 implementation, I can now provide a final response about the authorization behavior:

The authorizeFor prop is properly handled in ButtonV2

The ButtonV2 component correctly handles the authorizeFor prop by:

  1. Using the AuthorizedChild component to wrap the button when authorizeFor is provided
  2. Automatically disabling the button when the user is not authorized
  3. Preserving the same behavior as the original button component

The implementation shows that the authorization logic is consistent and properly integrated, making the replacement of the volunteer assignment button with ButtonV2 safe from an authorization perspective.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Confirms usage of `authorizeFor` with ButtonV2.
# We expect references in code to confirm consistent usage.
rg 'ButtonV2' -A 5 -B 5

Length of output: 83264


Script:

#!/bin/bash
# Search for the ButtonV2 component definition to understand how authorizeFor is handled
ast-grep --pattern 'interface ButtonV2Props {
  $$$
  authorizeFor?: $_
  $$$
}'

# Search for authorizeFor implementation
ast-grep --pattern 'function $_($_: ButtonV2Props) {
  $$$
  authorizeFor
  $$$
}'

Length of output: 167


Script:

#!/bin/bash
# Search for ButtonV2 component file
fd ButtonV2.tsx

# Look for authorizeFor usage in ButtonV2 implementation
rg -A 10 -B 10 'authorizeFor.*=.*props\.authorizeFor' 

Length of output: 108


Script:

#!/bin/bash
# Get the ButtonV2 component implementation
cat src/components/Common/ButtonV2.tsx

Length of output: 7095

@nihal467
Copy link
Member

@AdityaJ2305 what is the status on this PR

@AdityaJ2305
Copy link
Contributor Author

In progress, I am discussing about it with rithvik on slack

@AdityaJ2305
Copy link
Contributor Author

@nihal467, ready for review and testing

@rithviknishad rithviknishad added invalid This doesn't seem right and removed needs testing needs review labels Dec 30, 2024
@rithviknishad
Copy link
Member

Closing as solved in #9607

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Patient Registration & Doctor Notes is not supporting multi-lines
3 participants