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

Dosage heading is misaligned in the prescription module #8645 #8751

Conversation

Sulochan-khadka
Copy link
Contributor

@Sulochan-khadka Sulochan-khadka commented Oct 9, 2024

Proposed Changes

@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

Summary by CodeRabbit

  • New Features

    • Improved localization for the medicine administration table headers.
    • Introduced a new DosageFrequencyInfo component to enhance the display of dosage information based on prescription details.
  • Bug Fixes

    • Simplified header structure for better clarity and maintainability.

@Sulochan-khadka Sulochan-khadka requested a review from a team as a code owner October 9, 2024 19:33
Copy link

netlify bot commented Oct 9, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 8efe2de
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6706da7935c081000892db42
😎 Deploy Preview https://deploy-preview-8751--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.

Copy link

netlify bot commented Oct 9, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 6040bfd
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6731ef76b35a81000971d1cf
😎 Deploy Preview https://deploy-preview-8751--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.

@Sulochan-khadka
Copy link
Contributor Author

Added elipsis as it seemed a bit clean and aligned.
Screenshot 2024-10-10 at 1 04 11 AM

Whereas with wrapping it in new line, the width adjustment seems somewhat wrong(alignment):
Screenshot 2024-10-10 at 1 04 53 AM

Do let me know in case of any changes.

@Sulochan-khadka
Copy link
Contributor Author

@nihal467 @rithviknishad kindly review the PR .

@nihal467
Copy link
Member

image

  • keep everything in the center , in your current solution heading , excess indicator medicine and medicine with limited indicator, all are in multiple alignment

@Sulochan-khadka
Copy link
Contributor Author

image

  • keep everything in the center , in your current solution heading , excess indicator medicine and medicine with limited indicator, all are in multiple alignment

@nihal467 the parts medicine and dosage are not separate table columns but a single div with "justify-between" . Do you want me to change them to separate table columns?

@rithviknishad
Copy link
Member

Yup, let's try that.

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Oct 23, 2024
Copy link

👋 Hi, @Sulochan-khadka,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@Sulochan-khadka
Copy link
Contributor Author

Here is the improvement @nihal467 @rithviknishad
Screenshot 2024-10-23 at 5 44 53 PM

Improvement:
Screenshot 2024-10-23 at 5 45 18 PM

@nihal467
Copy link
Member

@Sulochan-khadka can you clear the merge conflict

CC: @rithviknishad

@nihal467
Copy link
Member

nihal467 commented Nov 4, 2024

image
image

@Sulochan-khadka

  • In mobile view, the indicator and dosage should be displayed below the medicine and other details, as seen on current develop. This behavior is breaking in your PR, so please ensure it remains consistent.

Copy link
Contributor

coderabbitai bot commented Nov 9, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes made in this pull request focus on the MedicineAdministrationTable and MedicineAdministrationTableRow components. The AdministrationTable.tsx has been updated to improve the localization of header cells by directly rendering translatable text. The AdministrationTableRow.tsx introduces a new DosageFrequencyInfo component that enhances the rendering of dosage information based on the prescription's dosage_type. These modifications aim to streamline the structure and improve the clarity of the components without altering their existing functionalities.

Changes

File Path Change Summary
src/components/Medicine/MedicineAdministrationSheet/AdministrationTable.tsx Modified header cells to directly render translatable text for "medicine" and "frequency/indicator". Removed unnecessary flex container for simplification.
src/components/Medicine/MedicineAdministrationSheet/AdministrationTableRow.tsx Introduced a new DosageFrequencyInfo component for rendering dosage information based on dosage_type. Updated JSX structure to utilize this new component.

Assessment against linked issues

Objective Addressed Explanation
Dosage heading is misaligned in the prescription module (#8645) The changes do not address the alignment issue.

Suggested reviewers

  • shivankacker

🐇 In the meadow, we hop and play,
With dosage headers brightening the day.
Localization now shines so clear,
In our table, there's nothing to fear!
So let’s celebrate with a joyful cheer! 🎉

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

In case the error is due to missing dependencies, please add them to the package.json file. In case of unrecoverable error (e.g. due to private dependencies), please disable the tool within CodeRabbit configuration.

src/components/Medicine/MedicineAdministrationSheet/AdministrationTableRow.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc.json': Cannot find module '@typescript-eslint/parser'
Require stack:

  • /.eslintrc.json
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object.resolve (/git/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2346:46)
    at ConfigArrayFactory._loadParser (/home/jailuser/git/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3325:39)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/home/jailuser/git/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3099:43)
    at _normalizeObjectConfigDataBody.next ()
    at ConfigArrayFactory._normalizeObjectConfigData (/home/jailuser/git/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3040:20)
    at _normalizeObjectConfigData.next ()
    at ConfigArrayFactory.loadInDirectory (/home/jailuser/git/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2886:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/home/jailuser/git/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3871:46)

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.

@Sulochan-khadka
Copy link
Contributor Author

image image

@Sulochan-khadka

  • In mobile view, the indicator and dosage should be displayed below the medicine and other details, as seen on current develop. This behavior is breaking in your PR, so please ensure it remains consistent.

made the necessary changes. The result is:

Screenshot 2024-11-09 at 5 34 03 AM

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

🧹 Outside diff range and nitpick comments (1)
src/components/Medicine/MedicineAdministrationSheet/AdministrationTableRow.tsx (1)

62-80: LGTM! The TableContent implementation effectively addresses the alignment issues.

The component successfully implements:

  • Center alignment using flex layout
  • Text truncation for long content
  • Responsive design with different layouts for mobile/desktop
  • Proper handling of different dosage types

Consider these minor improvements:

  1. Extract the magic number for truncation width into a constant:
-<p className="max-w-[6rem] truncate">
+<p className="max-w-[var(--dosage-max-width)] truncate">
  1. Add type safety for the frequency translation key:
-t("PRESCRIPTION_FREQUENCY_" + prescription.frequency)
+t(`PRESCRIPTION_FREQUENCY_${prescription.frequency as FrequencyType}`)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6bd2aa8 and 5a43440.

📒 Files selected for processing (2)
  • src/components/Medicine/MedicineAdministrationSheet/AdministrationTable.tsx (1 hunks)
  • src/components/Medicine/MedicineAdministrationSheet/AdministrationTableRow.tsx (2 hunks)
🔇 Additional comments (4)
src/components/Medicine/MedicineAdministrationSheet/AdministrationTable.tsx (2)

34-35: LGTM! Simplified header structure.

The simplified structure with direct translation helps maintain consistent alignment.


37-44: ⚠️ Potential issue

Several improvements needed for the dosage header.

  1. The "Dosage &" text should be internationalized
  2. The mobile view hiding might affect the alignment objectives mentioned in the PR
  3. The current structure with separate <p> tags might contribute to alignment issues
  4. Need to handle the case when prescriptions array is empty

Apply this diff to address the issues:

-              <span className="hidden px-2 text-center text-xs leading-none lg:block">
-                <p>Dosage &</p>
-                <p>
-                  {prescriptions[0]?.dosage_type !== "PRN"
-                    ? t("frequency")
-                    : t("indicator")}
-                </p>
-              </span>
+              <span className="px-2 text-center text-xs leading-none">
+                <div className="flex flex-col items-center">
+                  {t("dosage_and")}
+                  {prescriptions.length > 0 && (
+                    <span>
+                      {prescriptions[0].dosage_type !== "PRN"
+                        ? t("frequency")
+                        : t("indicator")}
+                    </span>
+                  )}
+                </div>
+              </span>

Let's verify the mobile view behavior:

src/components/Medicine/MedicineAdministrationSheet/AdministrationTableRow.tsx (2)

238-245: LGTM! Responsive integration maintains consistent alignment.

The dual rendering approach with proper visibility control ensures consistent alignment across viewports while maintaining the content structure.


238-245: Verify mobile view layout implementation.

The current implementation appears to meet the mobile view requirements, but let's verify the complete structure.

✅ Verification successful

Mobile view implementation verified and correctly structured

The implementation follows responsive design best practices:

  • Uses block lg:hidden for mobile-only content
  • Uses hidden lg:table-cell for desktop-only content
  • TableContent component is rendered appropriately in both views
  • No conflicting layout directives found between mobile and desktop views
  • Consistent with other responsive implementations in the codebase (as seen in multiple files using similar patterns)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify mobile layout implementation across related components

# Test 1: Check for mobile-specific layout classes
echo "Checking mobile layout implementation..."
rg -l "flex-col.*lg:flex-row|block.*lg:hidden|hidden.*lg:block" --type tsx

# Test 2: Verify consistent usage of breakpoints
echo "Verifying breakpoint consistency..."
rg "lg:[a-zA-Z-]+" --type tsx

# Test 3: Check for any conflicting layout directives
echo "Checking for layout conflicts..."
rg "flex.*(row|col).*lg:" --type tsx

Length of output: 478


Script:

#!/bin/bash
# Description: Verify mobile layout implementation across related components

# Test 1: Check for mobile-specific layout classes
echo "Checking mobile layout implementation..."
rg -l "flex-col.*lg:flex-row|block.*lg:hidden|hidden.*lg:block"

# Test 2: Verify consistent usage of breakpoints
echo "Verifying breakpoint consistency..."
rg "lg:[a-zA-Z-]+"

# Test 3: Check TableContent component usage
echo "Checking TableContent component usage..."
rg -A 5 "TableContent"

# Test 4: Check for any conflicting layout directives
echo "Checking for layout conflicts..."
rg "flex.*(row|col).*lg:"

Length of output: 33975

</th>
<th>
<span className="hidden px-2 text-center text-xs leading-none lg:block">
<p>Dosage &</p>
Copy link
Member

@rithviknishad rithviknishad Nov 10, 2024

Choose a reason for hiding this comment

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

use translations for the text "Dosage"

@rithviknishad rithviknishad merged commit 8a9078d into ohcnetwork:develop Nov 11, 2024
19 of 20 checks passed
Copy link

@Sulochan-khadka Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dosage heading is misaligned in the prescription module
5 participants