Skip to content

Update shipping management module to use info banners#3627

Merged
Baalmart merged 5 commits into
airqo-platform:stagingfrom
BwanikaRobert:Update-Shipping-Management-Module-to-use-InfoBanners
Jun 16, 2026
Merged

Update shipping management module to use info banners#3627
Baalmart merged 5 commits into
airqo-platform:stagingfrom
BwanikaRobert:Update-Shipping-Management-Module-to-use-InfoBanners

Conversation

@BwanikaRobert

@BwanikaRobert BwanikaRobert commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes (What does this PR do?)

Migrates all user-facing notifications in the Shipping Management modules away from native alert() calls and ReusableToast to the centralised useBanner / useBannerWithDelay .

Shipping Management


Status of maturity (all need to be checked before merging):


How should this be manually tested?

  1. Navigate to Admin → Shipping and open any batch with generated labels.
  2. Open the Shipping Labels Print Modal and click Print Labels.
  3. If your browser blocks pop-ups, confirm the inline error banner appears inside the dialog (not a native browser alert()).

What are the relevant tickets?


Screenshots

shp1 shp2

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for shipping label printing by replacing system alert dialogs with in-app banner notifications.
    • Users now see clearer messages when pop-ups are blocked and when a shipping label contains an invalid QR code image.
    • Invalid QR scenarios now ensure the print window is properly closed before showing the error.
    • Prevented an unnecessary “successfully generated” banner from showing when opening the print modal instead.
  • Documentation
    • Added a changelog entry for the Shipping Management banner migration and related updates.

Copilot AI review requested due to automatic review settings June 11, 2026 03:02
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

ShippingLabelPrintModal integrates the useBanner hook to replace browser alert() calls with in-app error banners when print pop-ups are blocked or QR code images have invalid URLs. The component tightens type safety on its URL validation and orphans the print window when QR errors occur. The batch details page removes a redundant success notification, letting the modal's feedback dominate the user experience.

Changes

Shipping Label Print Modal Banner Migration

Layer / File(s) Summary
Modal error banner integration with type-safe validation
src/vertex/components/features/shipping/ShippingLabelPrintModal.tsx
ShippingLabelPrintModal imports useBanner, initializes showBanner from the hook, tightens isValidDataUrl to accept unknown and function as a proper type guard, and replaces alert() calls with showBanner({ severity: 'error', ... }) for pop-up blocker and invalid QR code scenarios. When QR validation fails, the print window closes before the error banner appears.
Simplify batch details success flow
src/vertex/app/(authenticated)/admin/shipping/[batchId]/page.tsx
The useGenerateShippingLabels success handler removes the redundant "Successfully generated shipping label(s)" banner and now only opens the label print modal, reducing notification noise and letting the modal's feedback take the lead.
Changelog entry for Version 2.0.3
src/vertex/app/changelog.md
New changelog section documents the Shipping Management module's InfoBanner migration, detailing the alert-to-banner transitions, orphaned print window handling, type-safe validation improvements, and success banner removal.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • Baalmart
  • OchiengPaul442
  • Codebmk

Poem

📋 Alert dialogs fade to banners bright,
QR codes validated with type-safe might—
Print windows close before errors show,
success flows quiet, letting modals glow. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses issue #3496 requirements. ShippingLabelPrintModal correctly implements scoped banners for pop-up blocker and invalid QR errors, but the batch details page removes a success banner rather than adding global banners, and other required components (PrepareShippingModal, ShippingBatchesTable) remain unaddressed. Complete the full scope of issue #3496 by implementing BannerSlot in PrepareShippingModal, updating ShippingBatchesTable, and properly handling success banners on the batch details page with scoped: false configuration.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: migrating the Shipping Management module to use info banners instead of alert() dialogs.
Out of Scope Changes check ✅ Passed All changes directly relate to the linked issue #3496 objective of migrating notifications to the InfoBanner system. No unrelated code modifications were detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR replaces blocking alert() calls in the shipping label print flow with the app’s banner/toast system to provide non-blocking, scoped error feedback when printing can’t proceed.

Changes:

  • Add useBanner to the shipping label print modal.
  • Replace pop-up blocked and invalid QR URL alert() messages with showBanner(...) errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 19 to 21
const isValidDataUrl = (url: string) => {
return url.startsWith('data:image/') || /^https?:\/\//i.test(url);
};
@github-actions

Copy link
Copy Markdown
Contributor

New azure docs changes available for preview here

@github-actions

Copy link
Copy Markdown
Contributor

New azure website changes available for preview here

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/vertex/components/features/shipping/ShippingLabelPrintModal.tsx (1)

196-254: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: Missing BannerSlot — scoped banners won't render.

The component calls showBanner({ scoped: true }) at lines 28 and 34, but never renders the BannerSlot component inside the modal. According to the banner context contract, scoped banners only appear where BannerSlot is placed. Without it, your error messages will be silently dropped.

Add BannerSlot at the top of the dialog content, immediately after the ReusableDialog opening tag (before line 220).

🔧 Proposed fix
+import { useBanner } from '`@/context/banner-context`';
+
 const ShippingLabelPrintModal: React.FC<ShippingLabelPrintModalProps> = ({ labels, isOpen, onClose }) => {
-    const { showBanner } = useBanner();
+    const { showBanner, BannerSlot } = useBanner();
 
     // ... handlePrint logic ...
 
     return (
         <ReusableDialog
             isOpen={isOpen}
             onClose={onClose}
             title="Shipping Labels"
             // ... other props ...
         >
+            <BannerSlot />
             <div className="print-container">
                 {labels.map((label, index) => (
🤖 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/vertex/components/features/shipping/ShippingLabelPrintModal.tsx` around
lines 196 - 254, The modal invokes showBanner({ scoped: true }) but never
renders BannerSlot, so scoped banners are dropped; inside the
ShippingLabelPrintModal add the BannerSlot component into the ReusableDialog
content area immediately after the ReusableDialog opening tag (i.e., at the top
of the returned JSX inside ReusableDialog) so scoped banners will render; ensure
you import BannerSlot where ShippingLabelPrintModal uses ReusableDialog and
place a single <BannerSlot /> before the existing .print-container content.
🤖 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/vertex/components/features/shipping/ShippingLabelPrintModal.tsx`:
- Around line 32-36: The pop-up opened via window.open is left open when QR
validation fails; capture the window reference (e.g., const printWindow =
window.open(...)) and, inside the invalid QR handling branch (the
invalidLabels.length > 0 block that uses isValidDataUrl and showBanner), call
printWindow?.close() (guarding for null) before showing the banner and returning
so the empty pop-up is closed on validation failure.

---

Outside diff comments:
In `@src/vertex/components/features/shipping/ShippingLabelPrintModal.tsx`:
- Around line 196-254: The modal invokes showBanner({ scoped: true }) but never
renders BannerSlot, so scoped banners are dropped; inside the
ShippingLabelPrintModal add the BannerSlot component into the ReusableDialog
content area immediately after the ReusableDialog opening tag (i.e., at the top
of the returned JSX inside ReusableDialog) so scoped banners will render; ensure
you import BannerSlot where ShippingLabelPrintModal uses ReusableDialog and
place a single <BannerSlot /> before the existing .print-container content.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05099d0b-3b14-4f87-8ed7-4f1cf517ad11

📥 Commits

Reviewing files that changed from the base of the PR and between 941a515 and bf3e408.

📒 Files selected for processing (1)
  • src/vertex/components/features/shipping/ShippingLabelPrintModal.tsx

Comment thread src/vertex/components/features/shipping/ShippingLabelPrintModal.tsx
@github-actions

Copy link
Copy Markdown
Contributor

New azure analytics_platform changes available for preview here

@github-actions

Copy link
Copy Markdown
Contributor

New azure vertex changes available for preview here

@github-actions

Copy link
Copy Markdown
Contributor

New azure website changes available for preview here

@github-actions

Copy link
Copy Markdown
Contributor

New azure docs changes available for preview here

@github-actions

Copy link
Copy Markdown
Contributor

New azure vertex changes available for preview here

@github-actions

Copy link
Copy Markdown
Contributor

New azure analytics_platform changes available for preview here

@BwanikaRobert
BwanikaRobert marked this pull request as draft June 11, 2026 04:09
@Codebmk

Codebmk commented Jun 14, 2026

Copy link
Copy Markdown
Member

@BwanikaRobert pr is still marked as draft. Are you still working on it? Any blockers?

@BwanikaRobert

Copy link
Copy Markdown
Contributor Author

@Codebmk I'm still waiting for feedback from @Baalmart about the shipping apis.

@BwanikaRobert
BwanikaRobert marked this pull request as ready for review June 15, 2026 09:34
@BwanikaRobert
BwanikaRobert requested a review from Copilot June 15, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

New azure vertex changes available for preview here

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/vertex/components/features/shipping/ShippingLabelPrintModal.tsx (1)

29-37: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add BannerSlot in the modal content so scoped errors are actually visible.

showBanner(... scoped: true) is correct, but this component doesn’t render <BannerSlot />, so these errors can be dropped instead of appearing inline in the dialog.

Suggested fix
-    const { showBanner } = useBanner();
+    const { showBanner, BannerSlot } = useBanner();
...
         <ReusableDialog
             isOpen={isOpen}
             onClose={onClose}
@@
         >
+            <BannerSlot />
             <div className="print-container">
                 {labels.map((label, index) => (

Based on learnings from the provided PR objectives and banner-context contract, scoped banners must have a BannerSlot in the active dialog to render inline.

Also applies to: 222-223

🤖 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/vertex/components/features/shipping/ShippingLabelPrintModal.tsx` around
lines 29 - 37, The ShippingLabelPrintModal component is using showBanner() with
scoped: true to display error messages, but the component does not render a
BannerSlot component. Without the BannerSlot in the modal content, scoped banner
errors will not be displayed inline in the dialog. Add a BannerSlot component to
the modal's JSX content (in the return statement) to ensure that scoped error
banners from showBanner() calls are visible to users when validation failures
occur.
🤖 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.

Outside diff comments:
In `@src/vertex/components/features/shipping/ShippingLabelPrintModal.tsx`:
- Around line 29-37: The ShippingLabelPrintModal component is using showBanner()
with scoped: true to display error messages, but the component does not render a
BannerSlot component. Without the BannerSlot in the modal content, scoped banner
errors will not be displayed inline in the dialog. Add a BannerSlot component to
the modal's JSX content (in the return statement) to ensure that scoped error
banners from showBanner() calls are visible to users when validation failures
occur.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: df2685c9-e516-48a2-8e95-fc35243c3527

📥 Commits

Reviewing files that changed from the base of the PR and between bf3e408 and 0d73ef8.

📒 Files selected for processing (3)
  • src/vertex/app/(authenticated)/admin/shipping/[batchId]/page.tsx
  • src/vertex/app/changelog.md
  • src/vertex/components/features/shipping/ShippingLabelPrintModal.tsx
💤 Files with no reviewable changes (1)
  • src/vertex/app/(authenticated)/admin/shipping/[batchId]/page.tsx
✅ Files skipped from review due to trivial changes (1)
  • src/vertex/app/changelog.md

@Baalmart
Baalmart merged commit 620b98e into airqo-platform:staging Jun 16, 2026
15 checks passed
@Baalmart Baalmart mentioned this pull request Jun 16, 2026
3 tasks
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.

[Vertex: Migration] Update Shipping Management Module to use InfoBanners

4 participants