Skip to content

Add PrintQR page and route for PrintQR page#88

Merged
GilHeller merged 9 commits into
mainfrom
PrintQR
Jun 9, 2026
Merged

Add PrintQR page and route for PrintQR page#88
GilHeller merged 9 commits into
mainfrom
PrintQR

Conversation

@rotemergty5

@rotemergty5 rotemergty5 commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Created the PrintQR page and its styling, built the UI using SGLCard, SGLButton, SGLTypography and SGLImage, and added a React Router DOM route to allow navigation to the PrintQR page.

Summary by CodeRabbit

  • New Features
    • Added a QR Print page at /printQR that displays a centered card with a generated QR code, patient credentials, and an interactive button (label localized).
  • Style
    • Added layout and typography styles for consistent, centered, print-friendly presentation.

@rotemergty5 rotemergty5 requested review from GilHeller and Tamir198 and removed request for Tamir198 June 2, 2026 10:20
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8d31510b-108b-4bab-9694-aad8c5c43216

📥 Commits

Reviewing files that changed from the base of the PR and between fd1b9f0 and 51d3466.

📒 Files selected for processing (1)
  • src/pages/QRPrint/PrintQR.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/QRPrint/PrintQR.tsx

📝 Walkthrough

Walkthrough

Adds a new PrintQR page component and styles, renders a QRGeneration component with hardcoded credentials and a localized button, and registers a new /printQR route to serve the page.

Changes

PrintQR Page Feature

Layer / File(s) Summary
PrintQR page styling constants
src/pages/QRPrint/styles.ts
Exports CSSProperties constants for full-viewport centering (pageContainer), fixed-width card (cardContainer), inner container layout (containerStyle), bold white text (textStyle), and button content layout (submitButtonContent).
PrintQR component implementation
src/pages/QRPrint/PrintQR.tsx
Adds exported PrintQR React component: imports SGL UI primitives, QRGeneration, useTranslation, and styles; defines mock token and credentials; renders an SGLCard with QRGeneration token="mock-token", two hardcoded credential lines, and an i18n-localized SGLButton.
Route registration
src/main.tsx
Adds an import and registers a new createBrowserRouter route for /printQR that renders <PrintQR /> alongside existing routes.

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant Router
  participant PrintQR
  participant SGLCard
  participant QRGeneration
  Browser->>Router: navigate to /printQR
  Router->>PrintQR: render PrintQR component
  PrintQR->>SGLCard: render card (cardContainer)
  SGLCard->>QRGeneration: render QRGeneration token="mock-token"
  PrintQR->>SGLCard: render credentials and localized button
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Tamir198
  • GilHeller

Poem

A rabbit hops to the print view bright, 🐰
A QR in the center, credentials in sight,
A button that speaks in the chosen tongue,
Routes stitched to show what the page has sprung,
Cheers from the burrow — the code's done right! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description lacks required sections from the template (Related Issue and Checklist) and does not follow the expected structure. Add 'Related Issue(s)' and 'Checklist' sections to match the repository template, including issue reference and self-review/warnings checkboxes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly matches the main changes: adding a PrintQR page component and its route to the application.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PrintQR

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/UI/Select/SGLSelect.test.tsx`:
- Around line 33-45: The test currently only checks that "Banana" isn't
selected, which doesn't verify Escape closed the menu; update the assertion to
confirm the dropdown menu/listbox is dismissed after pressing Escape by querying
for the listbox/options (e.g., using queryByRole('listbox') or
queryAllByRole('option')) and asserting they are not present (e.g.,
expect(queryByRole('listbox')).not.toBeInTheDocument()) after
fireEvent.keyDown(select, { key: 'Escape' }); keep the same render and
interactions around SGLSelect and the select variable so the change is minimal.

In `@src/main.tsx`:
- Line 25: The /printQR route is registered publicly (path: '/printQR', element:
<PrintQR />) and exposes sensitive patient credentials; move this route into the
ProtectedRoute children (or wrap its element with the same authentication guard
used by ProtectedRoute) so PrintQR is only reachable after authentication.
Locate the routes array where ProtectedRoute is defined and add the '/printQR'
entry alongside the other protected child routes (or replace its element with
<ProtectedRoute><PrintQR/></ProtectedRoute>) to enforce auth.

In `@src/pages/QRPrint/PrintQR.tsx`:
- Around line 41-45: The two SGLTypography usages render raw patientNumber and
password without labels and the SGLButton uses t('login.login') with no onClick;
update the UI to show labeled fields (e.g., prepend "Patient No:" and
"Password:" or use distinct SGLTypography for labels) so users can identify
patientNumber and password, and replace or repurpose the SGLButton
(styles.submitButtonContent) to match the page intent—either remove it or change
its text from t('login.login') to a proper action like t('print.print') and wire
an onClick handler (e.g., trigger print or the QR export function) in the
PrintQR component so the button performs the relevant print/export action.
- Around line 11-12: The component currently hardcodes and renders sensitive
values (patientNumber and password) in PrintQR; remove those literal assignments
and instead source them from authenticated state or props (e.g., accept
patientNumber/password as props or read from your auth/context hook like
useAuth/getUser) and ensure the route is protected by ProtectedRoute; also avoid
rendering the raw password—either omit it from UI, mask it, or display a
placeholder, and validate that PrintQR no longer contains hardcoded '123456' or
'add123' literals.

In `@src/pages/QRPrint/styles.ts`:
- Line 22: The style rule contains an invalid declaration "gap: '-1rem'";
replace it with a valid spacing approach by either removing the gap property,
using a small positive gap (e.g., "gap: '0.25rem'") or applying negative margins
on the child elements instead (e.g., adjust child marginTop/marginLeft), and
ensure the declaration for the style rule that currently has "gap: '-1rem'" is
updated accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 843122b6-1dca-407c-8b5a-161cfe70cefd

📥 Commits

Reviewing files that changed from the base of the PR and between d0cf6a5 and 015e5ad.

📒 Files selected for processing (4)
  • src/components/UI/Select/SGLSelect.test.tsx
  • src/main.tsx
  • src/pages/QRPrint/PrintQR.tsx
  • src/pages/QRPrint/styles.ts

Comment on lines +33 to +45
it('should not select any item when dropdown is opened and closed', () => {
render(
<ThemeProvider theme={theme}>
<SGLSelect options={options} value="" />
</ThemeProvider>,
)

const select = screen.getByRole('combobox')

fireEvent.mouseDown(select)
fireEvent.keyDown(select, { key: 'Escape' })

expect(select).not.toHaveTextContent('Banana')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Assert that Escape actually closes the menu.

This test currently passes even if Escape does nothing, because Banana was never selected in the first place. Please assert the dismissal outcome directly, e.g. that the listbox/options are no longer present after pressing Escape.

Suggested tightening
   it('should not select any item when dropdown is opened and closed', () => {
     render(
       <ThemeProvider theme={theme}>
         <SGLSelect options={options} value="" />
       </ThemeProvider>,
     )

     const select = screen.getByRole('combobox')

     fireEvent.mouseDown(select)
     fireEvent.keyDown(select, { key: 'Escape' })

-    expect(select).not.toHaveTextContent('Banana')
+    expect(select).not.toHaveTextContent('Banana')
+    expect(screen.queryByRole('listbox')).not.toBeInTheDocument()
   })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('should not select any item when dropdown is opened and closed', () => {
render(
<ThemeProvider theme={theme}>
<SGLSelect options={options} value="" />
</ThemeProvider>,
)
const select = screen.getByRole('combobox')
fireEvent.mouseDown(select)
fireEvent.keyDown(select, { key: 'Escape' })
expect(select).not.toHaveTextContent('Banana')
it('should not select any item when dropdown is opened and closed', () => {
render(
<ThemeProvider theme={theme}>
<SGLSelect options={options} value="" />
</ThemeProvider>,
)
const select = screen.getByRole('combobox')
fireEvent.mouseDown(select)
fireEvent.keyDown(select, { key: 'Escape' })
expect(select).not.toHaveTextContent('Banana')
expect(screen.queryByRole('listbox')).not.toBeInTheDocument()
})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/UI/Select/SGLSelect.test.tsx` around lines 33 - 45, The test
currently only checks that "Banana" isn't selected, which doesn't verify Escape
closed the menu; update the assertion to confirm the dropdown menu/listbox is
dismissed after pressing Escape by querying for the listbox/options (e.g., using
queryByRole('listbox') or queryAllByRole('option')) and asserting they are not
present (e.g., expect(queryByRole('listbox')).not.toBeInTheDocument()) after
fireEvent.keyDown(select, { key: 'Escape' }); keep the same render and
interactions around SGLSelect and the select variable so the change is minimal.

Comment thread src/main.tsx
const router = createBrowserRouter([
{ path: '/', element: <Navigate to="/login" replace /> },
{ path: '/login', element: <Login /> },
{ path: '/printQR', element: <PrintQR /> },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

/printQR is publicly accessible.

This route is registered alongside /login, outside the ProtectedRoute block (Lines 26–40), so it is reachable without authentication. Since PrintQR displays a patient number and password, this exposes sensitive data to anonymous users. If this page should require auth, move it under the ProtectedRoute children.

Proposed change
-  { path: '/printQR', element: <PrintQR /> },
   {
     element: <ProtectedRoute />,
     children: [
       {
         path: '/',
         element: <MainLayout />,
         children: [
           { path: 'home', element: <Home /> },
           { path: 'schedule', element: <Schedule /> },
           { path: 'lifeStyle', element: <LifeStyle /> },
           { path: 'dailyReports', element: <DailyReports /> },
+          { path: 'printQR', element: <PrintQR /> },
         ],
       },
     ],
   },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{ path: '/printQR', element: <PrintQR /> },
{
element: <ProtectedRoute />,
children: [
{
path: '/',
element: <MainLayout />,
children: [
{ path: 'home', element: <Home /> },
{ path: 'schedule', element: <Schedule /> },
{ path: 'lifeStyle', element: <LifeStyle /> },
{ path: 'dailyReports', element: <DailyReports /> },
{ path: 'printQR', element: <PrintQR /> },
],
},
],
},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main.tsx` at line 25, The /printQR route is registered publicly (path:
'/printQR', element: <PrintQR />) and exposes sensitive patient credentials;
move this route into the ProtectedRoute children (or wrap its element with the
same authentication guard used by ProtectedRoute) so PrintQR is only reachable
after authentication. Locate the routes array where ProtectedRoute is defined
and add the '/printQR' entry alongside the other protected child routes (or
replace its element with <ProtectedRoute><PrintQR/></ProtectedRoute>) to enforce
auth.

Comment thread src/pages/QRPrint/PrintQR.tsx Outdated
Comment on lines +11 to +12
const patientNumber = '123456'
const password = 'add123'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Hardcoded credentials displayed in the UI.

patientNumber and password are hardcoded and rendered directly on the page (Lines 41–43). Shipping a literal password string in source and showing it as plain text is a security/PII concern, especially given this route is not behind ProtectedRoute (see src/main.tsx Line 25) and is therefore publicly reachable. These values should come from authenticated state/props rather than being baked into the component.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/QRPrint/PrintQR.tsx` around lines 11 - 12, The component currently
hardcodes and renders sensitive values (patientNumber and password) in PrintQR;
remove those literal assignments and instead source them from authenticated
state or props (e.g., accept patientNumber/password as props or read from your
auth/context hook like useAuth/getUser) and ensure the route is protected by
ProtectedRoute; also avoid rendering the raw password—either omit it from UI,
mask it, or display a placeholder, and validate that PrintQR no longer contains
hardcoded '123456' or 'add123' literals.

Comment thread src/pages/QRPrint/PrintQR.tsx Outdated
Comment on lines +41 to +45
<SGLTypography styles={styles.textStyle}>{patientNumber}</SGLTypography>

<SGLTypography styles={styles.textStyle}>{password}</SGLTypography>

<SGLButton styles={styles.submitButtonContent}>{t('login.login')}</SGLButton>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Unlabeled values and a misleading button.

The two SGLTypography lines render bare values with no labels, so a user cannot tell which is the patient number and which is the password. Additionally, the button uses t('login.login') ("Login") on a print/QR page and has no onClick handler, so it neither matches the page intent nor performs any action. Consider labeling each field and either wiring up a print/relevant action or removing the button.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/QRPrint/PrintQR.tsx` around lines 41 - 45, The two SGLTypography
usages render raw patientNumber and password without labels and the SGLButton
uses t('login.login') with no onClick; update the UI to show labeled fields
(e.g., prepend "Patient No:" and "Password:" or use distinct SGLTypography for
labels) so users can identify patientNumber and password, and replace or
repurpose the SGLButton (styles.submitButtonContent) to match the page
intent—either remove it or change its text from t('login.login') to a proper
action like t('print.print') and wire an onClick handler (e.g., trigger print or
the QR export function) in the PrintQR component so the button performs the
relevant print/export action.

Comment thread src/pages/QRPrint/styles.ts Outdated
cleanup()
})

describe('SGLSelect', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I dont think that those changes are related to this pr, fix it

@rotemergty5 rotemergty5 Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, removed the unrelated SGLSelect changes from this PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, removed the unrelated SGLSelect changes.

Comment thread src/pages/QRPrint/PrintQR.tsx Outdated

return (
<div
style={{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No inline styles

Comment thread src/pages/QRPrint/PrintQR.tsx Outdated
const { t } = useTranslation()

const patientNumber = '123456'
const password = 'add123'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this is a mock user you should call your variables MOCK_PATIENT_NUMBER and MOCK_PASSWORD

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comment thread src/pages/QRPrint/PrintQR.tsx Outdated
minHeight: '100vh',
}}
>
<div

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here no inline style

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Comment thread src/pages/QRPrint/PrintQR.tsx Outdated
<SGLCard>
<div style={styles.containerStyle}>
<SGLImage
src="https://www.dangot.com/Media/Uploads/2D-BAROCDE(1).png"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Who told you to create image of qr code? we already have a code to generate qr code. what you are doing right now is not dynamic or scalable

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The implementation was based on the task requirements I received, which explicitly included using an image component (SGLImage) as part of the PrintQR page.

I found the existing QRGeneration component and can update the implementation to use it instead.

However, QRGeneration currently requires a token, and this page doesn't have a token generation flow yet. Would you like me to use a mock token for now, or should I connect it to the actual QR login flow?

@GilHeller

Copy link
Copy Markdown
Collaborator

@rotemergty5 There are a few comments from @Tamir198 that haven't been addressed yet. Please take a look and update accordingly.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/QRPrint/styles.ts`:
- Around line 12-14: The cardContainer style currently forces width: '400px'
which overflows on narrow screens; update the cardContainer CSSProperties (the
exported cardContainer object) to use a responsive sizing pattern such as width:
'100%' with maxWidth: '400px' and include boxSizing: 'border-box' so the element
scales down on small viewports while keeping the 400px target on larger screens.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 219d0f42-36de-4f70-8e7d-b82d2e57d157

📥 Commits

Reviewing files that changed from the base of the PR and between 2a7c0e9 and fd1b9f0.

📒 Files selected for processing (2)
  • src/pages/QRPrint/PrintQR.tsx
  • src/pages/QRPrint/styles.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/QRPrint/PrintQR.tsx

Comment on lines +12 to +14
export const cardContainer: CSSProperties = {
width: '400px',
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the card responsive on narrow screens.

width: '400px' can cause horizontal overflow on mobile widths below 400px. Keep the target size but cap it responsively.

Proposed fix
 export const cardContainer: CSSProperties = {
-  width: '400px',
+  width: '400px',
+  maxWidth: '100%',
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const cardContainer: CSSProperties = {
width: '400px',
}
export const cardContainer: CSSProperties = {
width: '400px',
maxWidth: '100%',
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/QRPrint/styles.ts` around lines 12 - 14, The cardContainer style
currently forces width: '400px' which overflows on narrow screens; update the
cardContainer CSSProperties (the exported cardContainer object) to use a
responsive sizing pattern such as width: '100%' with maxWidth: '400px' and
include boxSizing: 'border-box' so the element scales down on small viewports
while keeping the 400px target on larger screens.

@rotemergty5

Copy link
Copy Markdown
Collaborator Author

I went through all of Tamir's comments and updated the PR accordingly.
If there's anything I missed, could you please point me to the specific comment or change you're referring to?
@GilHeller

@GilHeller GilHeller left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I comment your name on @Tamir198 's comment.

You can see it also at the Files changed tab

Comment thread src/pages/QRPrint/PrintQR.tsx Outdated
const { t } = useTranslation()

const patientNumber = '123456'
const password = 'add123'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@GilHeller GilHeller merged commit 4632e01 into main Jun 9, 2026
2 checks passed
@GilHeller GilHeller deleted the PrintQR branch June 9, 2026 18:37
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