feat(cme): wire CmeClaimPackButton onto annual summary with example and zero-cost guards

Merged
BI
1mo ago
+141-20

User description

Summary

  • Renders CmeClaimPackButton on the reachable CPD annual summary export bar (src/components/cme/cme-annual-summary.tsx, follow-up to #G20QE6 / inbox 8c549632).
  • Guards CmeClaimPackButton (src/components/cme/cme-claim-pack.tsx) with guardExampleAction(example, "export") (useExampleData("cpd").active) so clicking it while viewing example/demo data triggers the example-data export guard instead of downloading sample entries.
  • Prevents CmeClaimPackButton from downloading an empty .txt file or showing a misleading success state when no active entries have positive costCents, and cleans up the state-reset timer on unmount.
  • Adds DOM test coverage in tests/cme-example-exports.dom.test.tsx (1 -> 3 test cases) covering the example-data guard, valid claim-pack export from /cme/summary, and zero-cost guard.

Validation

  • npx vitest run tests/cme-example-exports.dom.test.tsx tests/cme-claim-pack.test.ts tests/cme-annual-summary-months.dom.test.tsx tests/cme-archive-export.dom.test.tsx tests/cme-phone-design.dom.test.tsx tests/cme-source-label.dom.test.tsx tests/cme-year-close.dom.test.tsx (7 test files, 45/45 tests passing)
  • npx eslint src/components/cme/cme-claim-pack.tsx src/components/cme/cme-annual-summary.tsx tests/cme-example-exports.dom.test.tsx (0 errors)
  • npm run typecheck (passed)
  • node scripts/check-diff-integrity.mjs (PASS — 1 changed test file(s), 1 -> 3 test case(s))

Clinical / RAG / Privacy / Security Impact

  • Zero RAG, retrieval, ranking, or database schema changes.
  • Enforces the CPD example-data export boundary (guardExampleAction) on claim-pack exports so sample data is never exported as a personal reimbursement claim.

Summary by cubic

Adds the "Export claim pack" button to the reachable CPD annual summary export bar so users can download an itemized, year-specific claim pack directly from the summary.

Guards the button against three edge cases, each surfacing a semantic-toned toast:

  • Clicking it while example or demo data is active triggers the example-data export guard instead of downloading sample entries.
  • When no active entries have positive costCents, it shows a "No claimable expenses recorded" info toast instead of downloading an empty .txt file.
  • When the download fails, it shows a "Could not export claim pack" danger toast instead of a misleading success state.

Also removes the implicit clipboard copy behavior, cleans up the success-state reset timer on unmount, and adds DOM test coverage for the example-data guard, a valid claim-pack export from /cme/summary, the zero-cost guard, and a failed download.

Bug Fixes

  • Claim-pack exports no longer bypass the CPD example-data boundary, including in demoMode.
  • Claim-pack export no longer produces an empty file or false success message when nothing is claimable or when the download fails.
  • Claim-pack export no longer touches the clipboard.

CodeAnt-AI Description

Add claim-pack exports to the CPD annual summary

What Changed

  • Export and copy an itemized claim pack from the annual summary when entries have claimable expenses.
  • Block claim-pack exports while example data is active, so sample entries cannot be submitted as personal expenses.
  • When there are no expenses with a positive cost, show a message instead of downloading an empty file.

Impact

✅ Claim packs available from the annual summary
✅ No sample entries exported as personal claims
✅ No empty claim-pack downloads

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • New Features
    • Added a claim-pack export option to the annual summary. Claim packs download as year-specific text files, and the button confirms a successful export.
  • Bug Fixes
    • Claim-pack exports are blocked for example data.
    • When there are no claimable expenses, the app displays a notification instead of downloading an empty file.
    • Download failures are reported, and the button remains in its initial state if a download cannot be started.