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

Referral letter preview desktop #8954

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from

Conversation

modamaan
Copy link
Contributor

@modamaan modamaan commented Oct 28, 2024

Proposed Changes

Referral letter preview desktop and responsive

Before
Image

After
Screenshot 2024-10-29 064626

@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

Release Notes

  • New Features

    • Enhanced print functionality for referral letters with improved layout and visual appeal.
    • Introduced a new UI card system, including components for headers, titles, descriptions, content, and footers.
  • Improvements

    • QR code rendering updated for better presentation.
    • Patient information now displayed in a structured grid layout.
  • User Interface

    • Minor adjustments to print mode toggle and button layout for improved usability.

@modamaan modamaan requested a review from a team as a code owner October 28, 2024 15:19
Copy link

netlify bot commented Oct 28, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit ee2f480
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/674839bea81b440008b00c31
😎 Deploy Preview https://deploy-preview-8954--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.

@github-actions github-actions bot added the Deploy-Failed Deplyment is not showing preview label Oct 28, 2024
@modamaan
Copy link
Contributor Author

@bodhish should i update anything?

@modamaan
Copy link
Contributor Author

Screenshot 2024-10-29 192122

@modamaan
Copy link
Contributor Author

@rithviknishad can you check

src/CAREUI/misc/PrintPreview.tsx Outdated Show resolved Hide resolved
@rithviknishad rithviknishad added changes required and removed Deploy-Failed Deplyment is not showing preview labels Oct 30, 2024
@nihal467
Copy link
Member

nihal467 commented Nov 4, 2024

image
@modamaan

  • the close and print buttons in the mobile responsive view is not properly aligned

@modamaan
Copy link
Contributor Author

@khavinshankar can you check

@rithviknishad
Copy link
Member

@modamaan could you resolve conflicts

src/CAREUI/misc/PrintPreview.tsx Outdated Show resolved Hide resolved
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: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 28f8bd8 and 41fc423.

📒 Files selected for processing (2)
  • src/CAREUI/misc/PrintPreview.tsx (2 hunks)
  • src/components/ui/separator.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/components/ui/separator.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
src/CAREUI/misc/PrintPreview.tsx

[error] 34-34: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (2)
src/CAREUI/misc/PrintPreview.tsx (2)

34-34: 🛠️ Refactor suggestion

Use optional chaining for better code safety

If these changes must stay (which is not recommended), use optional chaining for better code safety.

-onClick={() => props.closeFeature && props.closeFeature(false)}
+onClick={() => props.closeFeature?.(false)}

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome (1.9.4)

[error] 34-34: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


Line range hint 1-54: Verify the impact on existing usages

Let's check how many other components are using PrintPreview and could be affected by these changes.

✅ Verification successful

Changes to PrintPreview component have potential impact on multiple components

The verification shows that PrintPreview is used in several components:

  • src/components/Shifting/ShiftDetails.tsx
  • src/components/Medicine/PrintPreview.tsx
  • src/components/Facility/TreatmentSummary.tsx
  • src/components/Facility/Investigations/InvestigationsPrintPreview.tsx

All these components use the PrintPreview with compatible props:

  • title (required): All components provide it
  • onClose (optional): Used by ShiftDetails
  • closeFeature (optional): Used with onClose in ShiftDetails
  • children (required): All components provide content
  • className (optional): No direct impact
  • disabled (optional): No direct impact

The changes in the component appear safe as they maintain backward compatibility with existing usages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all usages of PrintPreview component
echo "Searching for PrintPreview usages..."
rg --type tsx --type ts "PrintPreview" -B 2 -A 2

Length of output: 159


Script:

#!/bin/bash
# Search for PrintPreview usages with ripgrep, without file type filters
echo "Searching for PrintPreview usages..."
rg "PrintPreview" -B 2 -A 2

# Also search for the file name itself to understand its location
echo -e "\nSearching for PrintPreview file..."
fd "PrintPreview.tsx"

Length of output: 9382

🧰 Tools
🪛 Biome (1.9.4)

[error] 34-34: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

src/CAREUI/misc/PrintPreview.tsx Outdated Show resolved Hide resolved
src/CAREUI/misc/PrintPreview.tsx Outdated Show resolved Hide resolved
@modamaan
Copy link
Contributor Author

modamaan commented Nov 27, 2024

@rithviknishad Create a new ReferralLetterPreview component that wraps PrintPreview, shall i do it like this

@modamaan
Copy link
Contributor Author

The problem is that we need both the print button and the close button in a single div to manage responsiveness. However, the print button is inside the PrintPreview component, while the close button is outside the component.

@github-actions github-actions bot added needs-triage question Further information is requested labels Nov 27, 2024
@rithviknishad
Copy link
Member

The breadcrumbs providing back button is equivalent of having the close button as both does the same thing. So we can remove the close button since it's redundant.

@rithviknishad rithviknishad removed question Further information is requested tested needs-triage labels Nov 27, 2024
@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Nov 28, 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

🧹 Outside diff range and nitpick comments (2)
src/components/Shifting/ShiftDetails.tsx (2)

280-281: Remove development comment.

The "deploytest" comment should be removed as it appears to be a development artifact.

-      // deploytest

419-419: Consider adding explicit type for printData argument.

The printData function's argument would benefit from an explicit type definition for better type safety.

-        <div className="my-4">{printData(data)}</div>
+        <div className="my-4">{printData(data as ShiftingDetails)}</div>

Consider adding a type definition:

interface ShiftingDetails {
  id: string;
  patient_object: PatientModel;
  is_kasp: boolean;
  // ... other properties
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f20709b and 82e1442.

📒 Files selected for processing (1)
  • src/components/Shifting/ShiftDetails.tsx (3 hunks)
🧰 Additional context used
📓 Learnings (1)
src/components/Shifting/ShiftDetails.tsx (1)
Learnt from: modamaan
PR: ohcnetwork/care_fe#8954
File: src/components/Shifting/ShiftDetails.tsx:432-433
Timestamp: 2024-11-12T10:23:10.322Z
Learning: In `src/components/Shifting/ShiftDetails.tsx`, the `print` button is inside the `PrintPreview` component and the `close` button is outside, so aligning them with flexbox within the same container isn't feasible.
🔇 Additional comments (3)
src/components/Shifting/ShiftDetails.tsx (3)

8-13: LGTM! Import changes align with the UI modernization.

The switch to QRCodeSVG and addition of new UI components improve the codebase's modularity and maintainability.


282-408: LGTM! Well-structured print layout implementation.

The new Card-based layout provides a clean and organized structure for the referral letter. The component hierarchy and spacing are well thought out.


361-365: ⚠️ Potential issue

Add null check for consultation object.

The date formatting could throw an error if the consultation object is undefined.

-                  {formatDateTime(
-                    consultation.encounter_date || consultation.created_date,
-                  ) || "-"}
+                  {consultation
+                    ? formatDateTime(
+                        consultation.encounter_date || consultation.created_date
+                      )
+                    : "-"}

Likely invalid or redundant comment.

@modamaan
Copy link
Contributor Author

@rithviknishad @nihal467

src/components/Shifting/ShiftDetails.tsx Outdated Show resolved Hide resolved
src/components/ui/separator.tsx Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix: referral letter responsiveness
4 participants