Skip to content

feat(sponsor-reports): port Sponsor Reports FE into Summit Admin (Sponsors → Reports)#997

Open
caseylocker wants to merge 37 commits into
masterfrom
feature/sponsor-reports-port
Open

feat(sponsor-reports): port Sponsor Reports FE into Summit Admin (Sponsors → Reports)#997
caseylocker wants to merge 37 commits into
masterfrom
feature/sponsor-reports-port

Conversation

@caseylocker

@caseylocker caseylocker commented Jun 25, 2026

Copy link
Copy Markdown

ref: https://app.clickup.com/t/86bak754x

Ports the two sponsor reports (Purchase Details + Sponsor Assets, incl. the per-sponsor asset drill-down) out of sponsor-services and into summit-admin as an admin-only "Reports" sub-item under the Sponsors menu, reading the in-context summit. Backend (sponsor-reports-api) is unchanged. This is Phase 1 — parity port; the JP-pivot logistics/finance features are Phase 2 follow-ons.

What's included

  • Placement & access: Sponsors → Reports sub-item; layout wrapped Restrict(withRouter(SponsorReportsLayout), "admin-sponsors") — an explicit admin-only gate that reuses the existing admin-sponsors key and closes the direct-URL gap for the reports area. Summit is in-context (summit picker + /reports/summits dropped).
  • Re-implementation on summit-admin's stack (not a copy of the source): react-redux 5 connect() (no hooks), react-router 4 withRouter (no v6 hooks), i18n-react T.translate (no react-i18next), uicore MuiTable (no @mui/x-data-grid), CSV via uicore getCSV.
  • Purchase Details: OrdersTable rebuilt on MuiTable; formatCheckoutTime handles both ISO and epoch; Total Refunded tile renders only when summary.total_refunded != null (auto-appears once that field ships — no FE change needed).
  • Sponsor Assets: group-by sponsor/component views + per-sponsor drill-down; hard-coded drill-down links rewired to /app/summits/:summitId/sponsors/reports/sponsor-assets/sponsors/:sponsorId.
  • Landing with two report cards; breadcrumb trail Sponsors → Reports → <page>.
  • Env: SPONSOR_REPORTS_API_URL injected in app.js + .env/.env.example.

Tests / quality

  • yarn jest: 915 passing, 0 regressions vs master. yarn lint: 0 new errors (only the repo's pre-existing prop-types warnings).
  • Reviewed per-task (opus) + whole-branch (opus) + an independent Codex pass — all clean (0 Critical / 0 Important).

Deploy note (not blocking this PR)

Backend auth wiring (D5) is done on dev — repointed the deployed sponsor-reports-api scope env to reports/all + added the admin groups; verified both reports load real data on dev. Staging/prod need the same env at launch (tracked in the ClickUp ticket). No IDP change was needed (summit-admin already carries reports/all).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a new Sponsor Reports area in the app, including a landing page, Purchase Details (Orders + Line Items), Sponsor Assets, and sponsor drill-down pages.
    • Introduced filtering, grouping, pagination, status rollups, and CSV export with print-friendly reporting layout.
  • Bug Fixes
    • Improved handling of loading, empty, validation, and read-error states, including clearer behavior when CSV export is disabled.
    • Added more robust display formatting for dates, currency, and rich-text content.

caseylocker and others added 10 commits June 24, 2026 16:36
…nsors

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tCSV)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… refund tile)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…gial SORT_FIELD_MAP

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…utes)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace placeholder with two MUI card links (Purchase Details,
Sponsor Assets); add breadcrumb; add landing_title i18n key;
update layout test for card assertions; 6 new tests, 912 total.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…, prop, route test

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…EAD_ERROR

Remove *_EXPORT_DISABLED action constants (purchase-details, sponsor-asset, drilldown)
and their dead reducer arms. Route onExportDisabled → READ_ERROR in getPurchaseDetailsReport
and getSponsorAssetReport thunks (mirrors the already-fixed drilldown), so a 503
export-disabled on a read path clears loading via the same arm as not-found/unauthorized.
Remove exportDisabled and exportError from all three reducer DEFAULT_STATEs, drop
disabled={exportDisabled} from all three ExportCsvButton usages, and clean up all test
references to the deleted constants and unreachable state. Add 503 export-disabled coverage
for getPurchaseDetailsReport and getSponsorAssetReport matching the existing drilldown tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- SummaryPanel tile labels overline -> subtitle1 (bigger; both reports)
- GroupByToggle small -> medium + larger button text
- SponsorReportsLayout renders a persistent Reports crumb + per-route page
  crumb so the trail reads .../Sponsors/Reports/<page> (was dropping to
  .../Sponsors on sub-pages); landing's own crumb removed (no dup)
- Sponsor Assets: gap between Report Filters and summary cards
- tests updated (landing breadcrumb moved to layout; layout trail test added)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds sponsor reports configuration, Redux wiring, shared report UI, routes, and two sponsor report pages with supporting utilities and tests.

Changes

Sponsor reports feature

Layer / File(s) Summary
Helpers and query shaping
src/app.js, .env.example, src/utils/*, src/utils/__tests__/*, src/hooks/usePrint.js, src/hooks/__tests__/usePrint.test.js
Environment config, report error/query utilities, formatting helpers, manifest grouping, and hook support are added with tests.
Async actions
src/actions/sponsor-reports-actions.js, src/actions/__tests__/sponsor-reports-actions.test.js
Sponsor report thunks fetch purchase details, purchase-detail lines, sponsor assets, and drilldown data and route read, validation, export-disabled, and reauth outcomes.
Reducers and store
src/reducers/sponsors/*, src/reducers/sponsors/__tests__/*, src/store.js
New reducer slices track purchase-details, purchase-details lines, sponsor-asset, and drilldown state, and the store persists the corresponding keys.
Report controls and print support
src/components/sponsors/reports/{ReportShell,FilterBar,ExportCsvButton,GroupByToggle,ReportViewToggle}.js, src/components/sponsors/reports/report-print.css, src/components/sponsors/reports/__tests__/{ReportShell,FilterBar,ExportCsvButton,GroupByToggle,ReportViewToggle}.test.js
Reusable report shell, filters, CSV export, grouping toggles, view toggle, and print stylesheet are added with tests.
Status and display primitives
src/components/sponsors/reports/{statusTone,StatusPill,StatusRollupChips,SummaryPanel,TierBadge,SponsorAvatar}.js, src/components/sponsors/reports/__tests__/{StatusPill,StatusRollupChips,SummaryPanel,TierBadge,SponsorAvatar}.test.js
Status tone mapping, pills, rollup chips, summary tiles, tier badges, and sponsor avatars are added with tests.
Tables and line manifests
src/components/sponsors/reports/{OrdersTable,LinesManifestView}.js, src/components/sponsors/reports/__tests__/{OrdersTable,LinesManifestView}.test.js
Orders tables and line manifests render report data and add view-specific tests.
Grouped sponsor and component cards
src/components/sponsors/reports/{GroupBySponsorView,GroupByComponentView}.js, src/components/sponsors/reports/__tests__/{GroupBySponsorView,GroupByComponentView}.test.js
Sponsor and component grouped cards render report data and add view-specific tests.
Navigation and landing
src/components/menu/menu-definition.js, src/i18n/en.json, src/layouts/sponsor-layout.js, src/layouts/sponsor-reports-layout.js, src/layouts/__tests__/sponsor-reports-layout.test.js, src/pages/sponsors/sponsor-reports/reports-landing-page/*
The sponsor reports menu entry, translations, routes, breadcrumbs, landing cards, and layout tests are added.
Purchase details page
src/pages/sponsors/sponsor-reports/purchase-details-report-page/*
The purchase-details page builds report queries from filters, sort, and pagination, renders summary tiles and actions, and dispatches report and filter thunks with validation handling.
Sponsor asset pages
src/pages/sponsors/sponsor-reports/{sponsor-asset-report-page,sponsor-asset-drilldown-page}/*
The sponsor-asset report and drilldown pages load grouped data, render sponsor and component views, export CSV, and show per-module content states.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • smarcet
  • martinquiroga-exo

Poem

🐰 I sniffed the carrots, crisp and bright,
and hopped through reports by day and night.
CSV trails and badges in sight,
sponsor cards gleam soft and light.
Hop-hop, these changes feel just right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 clearly matches the main change: porting Sponsor Reports into Summit Admin under Sponsors → Reports.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/sponsor-reports-port

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.

@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: 2

🧹 Nitpick comments (3)
src/pages/sponsors/sponsor-reports/__tests__/routing.test.js (1)

33-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Test replicates route ordering instead of asserting on the real layout.

Because renderSwitch hand-copies the <Switch> table rather than mounting sponsor-reports-layout.js, it validates React Router's behavior, not the production ordering. If the real layout's route order drifts, this test won't catch it. The drilldown-vs-landing ordering is already covered against the real component in sponsor-reports-layout.test.js, so this can either be removed or driven through the actual layout to guard against regressions.

🤖 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/sponsors/sponsor-reports/__tests__/routing.test.js` around lines 33
- 65, This test is duplicating the route table instead of exercising the real
sponsor-reports layout, so it won’t catch regressions in the production
ordering. Update the routing coverage to mount sponsor-reports-layout.js
directly (using the existing SponsorReportsLayout or equivalent wrapper) instead
of the local renderSwitch Switch copy, or remove this redundant spec if
sponsor-reports-layout.test.js already covers the drilldown-vs-list ordering.
src/components/sponsors/reports/FilterBar.js (1)

28-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

draft won't re-sync if the value prop changes after mount.

useState(value) only seeds the initial state; later changes to the value prop (e.g. an external filter reset) won't be reflected in draft. Current flows keep parent/child in sync manually (Apply commits the draft, Clear resets both to {}), so there's no active bug, but this coupling is fragile if value ever becomes externally driven. Consider syncing via an effect keyed on value if that scenario is anticipated.

🤖 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/sponsors/reports/FilterBar.js` around lines 28 - 29, The local
draft state in FilterBar is only initialized from the value prop and will not
update if that prop changes later. If external changes to value are expected,
add synchronization in FilterBar using an effect keyed on value so setDraft
stays aligned; keep the update helper unchanged and make sure the draft state
refreshes whenever the incoming value object changes.
src/reducers/sponsors/__tests__/sponsor-reports-reducers.test.js (1)

110-124: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for PURCHASE_DETAILS_VALIDATION_CLEAR.

This file validates the set path for validationError, but not the clear action branch; add one test to prevent regressions in inline/toast reset flow.

🤖 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/reducers/sponsors/__tests__/sponsor-reports-reducers.test.js` around
lines 110 - 124, Add a test for the PURCHASE_DETAILS_VALIDATION_CLEAR branch in
purchaseDetailsReducer to cover the reset path for validationError and loading
state. Use the existing PURCHASE_DETAILS_VALIDATION_ERROR test in
sponsor-reports-reducers.test.js as a guide, but assert that dispatching
PURCHASE_DETAILS_VALIDATION_CLEAR clears validationError without replacing the
current data/body so the inline/toast reset flow stays protected.
🤖 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/actions/sponsor-reports-actions.js`:
- Around line 34-54: Add an early guard in getPurchaseDetailsReport and
getPurchaseDetailsFilters to check that currentSummit and currentSummit.id exist
before calling dispatch(startLoading()) or base(currentSummit.id). If the summit
is missing, exit the thunk immediately (optionally dispatch a validation/error
action) so the synchronous throw never happens and stopLoading() is not skipped.
Keep the fix localized in sponsor-reports-actions.js and use the existing thunk
names to update both purchase-details actions consistently.

In `@src/utils/reports-money.js`:
- Around line 10-13: Update formatUsd in reports-money.js so blank or
whitespace-only strings are treated as missing values instead of being converted
by Number(). Add an explicit check before parsing string input (for example in
the formatUsd path) to return "—" when the value is empty after trimming, while
keeping the existing USD.format behavior for valid numeric values.

---

Nitpick comments:
In `@src/components/sponsors/reports/FilterBar.js`:
- Around line 28-29: The local draft state in FilterBar is only initialized from
the value prop and will not update if that prop changes later. If external
changes to value are expected, add synchronization in FilterBar using an effect
keyed on value so setDraft stays aligned; keep the update helper unchanged and
make sure the draft state refreshes whenever the incoming value object changes.

In `@src/pages/sponsors/sponsor-reports/__tests__/routing.test.js`:
- Around line 33-65: This test is duplicating the route table instead of
exercising the real sponsor-reports layout, so it won’t catch regressions in the
production ordering. Update the routing coverage to mount
sponsor-reports-layout.js directly (using the existing SponsorReportsLayout or
equivalent wrapper) instead of the local renderSwitch Switch copy, or remove
this redundant spec if sponsor-reports-layout.test.js already covers the
drilldown-vs-list ordering.

In `@src/reducers/sponsors/__tests__/sponsor-reports-reducers.test.js`:
- Around line 110-124: Add a test for the PURCHASE_DETAILS_VALIDATION_CLEAR
branch in purchaseDetailsReducer to cover the reset path for validationError and
loading state. Use the existing PURCHASE_DETAILS_VALIDATION_ERROR test in
sponsor-reports-reducers.test.js as a guide, but assert that dispatching
PURCHASE_DETAILS_VALIDATION_CLEAR clears validationError without replacing the
current data/body so the inline/toast reset flow stays protected.
🪄 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: 878ce767-9e7a-43b8-97cf-abd302c54c9b

📥 Commits

Reviewing files that changed from the base of the PR and between d3f018b and 07c3261.

📒 Files selected for processing (57)
  • .env.example
  • src/actions/__tests__/sponsor-reports-actions.test.js
  • src/actions/sponsor-reports-actions.js
  • src/app.js
  • src/components/menu/menu-definition.js
  • src/components/sponsors/reports/ExportCsvButton.js
  • src/components/sponsors/reports/FilterBar.js
  • src/components/sponsors/reports/GroupByComponentView.js
  • src/components/sponsors/reports/GroupBySponsorView.js
  • src/components/sponsors/reports/GroupByToggle.js
  • src/components/sponsors/reports/OrdersTable.js
  • src/components/sponsors/reports/ReportShell.js
  • src/components/sponsors/reports/StatusPill.js
  • src/components/sponsors/reports/StatusRollupChips.js
  • src/components/sponsors/reports/SummaryPanel.js
  • src/components/sponsors/reports/TierBadge.js
  • src/components/sponsors/reports/__tests__/ExportCsvButton.test.js
  • src/components/sponsors/reports/__tests__/FilterBar.test.js
  • src/components/sponsors/reports/__tests__/GroupByComponentView.test.js
  • src/components/sponsors/reports/__tests__/GroupBySponsorView.test.js
  • src/components/sponsors/reports/__tests__/GroupByToggle.test.js
  • src/components/sponsors/reports/__tests__/OrdersTable.test.js
  • src/components/sponsors/reports/__tests__/ReportShell.test.js
  • src/components/sponsors/reports/__tests__/StatusPill.test.js
  • src/components/sponsors/reports/__tests__/StatusRollupChips.test.js
  • src/components/sponsors/reports/__tests__/SummaryPanel.test.js
  • src/components/sponsors/reports/__tests__/TierBadge.test.js
  • src/components/sponsors/reports/__tests__/statusTone.test.js
  • src/components/sponsors/reports/__tests__/usePrint.test.js
  • src/components/sponsors/reports/report-print.css
  • src/components/sponsors/reports/statusTone.js
  • src/components/sponsors/reports/usePrint.js
  • src/i18n/en.json
  • src/layouts/__tests__/sponsor-reports-layout.test.js
  • src/layouts/sponsor-layout.js
  • src/layouts/sponsor-reports-layout.js
  • src/pages/sponsors/sponsor-reports/__tests__/routing.test.js
  • src/pages/sponsors/sponsor-reports/purchase-details-report-page/__tests__/index.test.js
  • src/pages/sponsors/sponsor-reports/purchase-details-report-page/index.js
  • src/pages/sponsors/sponsor-reports/reports-landing-page/__tests__/index.test.js
  • src/pages/sponsors/sponsor-reports/reports-landing-page/index.js
  • src/pages/sponsors/sponsor-reports/sponsor-asset-drilldown-page/__tests__/index.test.js
  • src/pages/sponsors/sponsor-reports/sponsor-asset-drilldown-page/index.js
  • src/pages/sponsors/sponsor-reports/sponsor-asset-report-page/__tests__/index.test.js
  • src/pages/sponsors/sponsor-reports/sponsor-asset-report-page/index.js
  • src/reducers/sponsors/__tests__/sponsor-reports-reducers.test.js
  • src/reducers/sponsors/sponsor-reports-drilldown-reducer.js
  • src/reducers/sponsors/sponsor-reports-purchase-details-reducer.js
  • src/reducers/sponsors/sponsor-reports-sponsor-asset-reducer.js
  • src/store.js
  • src/utils/constants.js
  • src/utils/report-errors.js
  • src/utils/report-query.js
  • src/utils/reports-api.js
  • src/utils/reports-money.js
  • src/utils/reports-text.js
  • src/utils/section-csv-query.js

Comment thread src/actions/sponsor-reports-actions.js
Comment thread src/pages/sponsors/sponsor-reports/reports-money.js Outdated
- guard all report thunks against a missing currentSummit (prevents a stuck
  spinner from base(currentSummit.id) throwing after startLoading)
- formatUsd: treat blank/whitespace strings + non-finite numbers as missing
  (em dash) instead of $0.00; add reports-money tests
- FilterBar: re-sync draft when the committed value prop changes externally
- drop redundant routing.test.js (real-layout integration test in
  sponsor-reports-layout.test.js already covers route ordering)
- add PURCHASE_DETAILS_VALIDATION_CLEAR reducer test

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Ports the Sponsor Reports frontend (Purchase Details + Sponsor Assets, including per-sponsor drill-down) into summit-admin under Sponsors → Reports, using the existing admin-sponsors access gate and the in-context summit selection.

Changes:

  • Adds a new Sponsor Reports layout + routes (landing, purchase details, sponsor assets, drill-down) and wires it into the Sponsors menu.
  • Implements report UI building blocks (report shell, filters, grouping views, CSV export, print) plus supporting query/text/money utilities.
  • Introduces Redux actions/reducers for sponsor reports and adds extensive unit/integration test coverage + i18n strings.

Reviewed changes

Copilot reviewed 57 out of 57 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/section-csv-query.js Builds section-scoped CSV export query while preserving unrelated query params.
src/utils/reports-text.js HTML-to-plain-text helper for report text fields.
src/utils/reports-money.js USD formatting helper for report summary/rows.
src/utils/reports-api.js Reports API base URL helper + positive-int route ID validator.
src/utils/report-query.js Translates report filter UI state into base-api-utils query params.
src/utils/report-errors.js Normalizes/classifies report API errors and provides a getRequest-shaped handler factory.
src/utils/constants.js Adds HTTP 503 constant used by report error classification.
src/utils/tests/reports-money.test.js Unit tests for USD formatting helper.
src/store.js Registers sponsor reports reducers and excludes their state from persistence.
src/reducers/sponsors/sponsor-reports-sponsor-asset-reducer.js Sponsor Assets grouped report reducer.
src/reducers/sponsors/sponsor-reports-purchase-details-reducer.js Purchase Details report reducer (incl. validation vs read-error split).
src/reducers/sponsors/sponsor-reports-drilldown-reducer.js Sponsor Assets drill-down reducer.
src/reducers/sponsors/tests/sponsor-reports-reducers.test.js Reducer unit tests covering all sponsor reports reducers.
src/pages/sponsors/sponsor-reports/sponsor-asset-report-page/index.js Sponsor Assets grouped report page (group-by, filters, pagination, CSV/print).
src/pages/sponsors/sponsor-reports/sponsor-asset-report-page/tests/index.test.js Sponsor Assets report page tests (dispatching, toggles, states, CSV props).
src/pages/sponsors/sponsor-reports/sponsor-asset-drilldown-page/index.js Per-sponsor drill-down page (section cards, content rendering, per-section CSV).
src/pages/sponsors/sponsor-reports/sponsor-asset-drilldown-page/tests/index.test.js Drill-down page tests including ContentCell behaviors.
src/pages/sponsors/sponsor-reports/reports-landing-page/index.js Reports landing page with two navigation cards.
src/pages/sponsors/sponsor-reports/reports-landing-page/tests/index.test.js Landing page tests for cards and links.
src/pages/sponsors/sponsor-reports/purchase-details-report-page/index.js Purchase Details report page (filters, sorting, pagination, CSV/print, tiles).
src/pages/sponsors/sponsor-reports/purchase-details-report-page/tests/index.test.js Purchase Details page tests including filter->query behavior and CSV dispatch.
src/layouts/sponsor-reports-layout.js Sponsor Reports sub-router + breadcrumb composition + admin gate.
src/layouts/sponsor-layout.js Adds /reports route under Sponsors layout.
src/layouts/tests/sponsor-reports-layout.test.js Layout routing + Restrict gate integration tests (landing, unauthorized, drilldown, crumbs).
src/i18n/en.json Adds menu label + Sponsor Reports page strings.
src/components/sponsors/reports/usePrint.js Hook wrapper around window.print() for reports.
src/components/sponsors/reports/TierBadge.js Tier badge chip with explicit tier color mapping.
src/components/sponsors/reports/SummaryPanel.js Shared summary tiles panel component.
src/components/sponsors/reports/statusTone.js Central status->chip-tone mapping helper.
src/components/sponsors/reports/StatusRollupChips.js Renders stable-order rollup chips for grouped Sponsor Assets cards.
src/components/sponsors/reports/StatusPill.js Single status chip component with shared tone mapping.
src/components/sponsors/reports/ReportShell.js Shared report page shell (header, action slot, filter slot, print CSS hook).
src/components/sponsors/reports/report-print.css Print-only CSS to print report body.
src/components/sponsors/reports/OrdersTable.js Purchase Details table built on uicore MuiTable + date/time formatting helpers.
src/components/sponsors/reports/GroupByToggle.js Toggle for sponsor/component grouping mode.
src/components/sponsors/reports/GroupBySponsorView.js Sponsor-grouped card list with drill-down links.
src/components/sponsors/reports/GroupByComponentView.js Component-grouped card list with per-sponsor links and content previews.
src/components/sponsors/reports/FilterBar.js Shared report filter bar (sponsor multiselect + optional search + extra controls).
src/components/sponsors/reports/ExportCsvButton.js CSV export button integrating uicore getCSV and access token retrieval.
src/components/sponsors/reports/tests/usePrint.test.js Unit test for print hook.
src/components/sponsors/reports/tests/TierBadge.test.js Unit tests for TierBadge rendering behavior.
src/components/sponsors/reports/tests/SummaryPanel.test.js Unit tests for SummaryPanel rendering and empty behavior.
src/components/sponsors/reports/tests/statusTone.test.js Unit tests for status tone mapping helper.
src/components/sponsors/reports/tests/StatusRollupChips.test.js Unit tests for rollup chips ordering and null rollup behavior.
src/components/sponsors/reports/tests/StatusPill.test.js Unit tests for StatusPill label behavior and tone mapping re-export.
src/components/sponsors/reports/tests/ReportShell.test.js Unit tests for ReportShell slots and icon rendering.
src/components/sponsors/reports/tests/OrdersTable.test.js Unit tests for table helpers and basic rendering/sort interactions.
src/components/sponsors/reports/tests/GroupByToggle.test.js Unit tests for group toggle behavior (ignore null toggle).
src/components/sponsors/reports/tests/GroupBySponsorView.test.js Unit tests for sponsor-grouped card rendering and link targets.
src/components/sponsors/reports/tests/GroupByComponentView.test.js Unit tests for component-grouped rendering, content hints, and links.
src/components/sponsors/reports/tests/FilterBar.test.js Unit tests for FilterBar sponsorIds emission and optional search box.
src/components/sponsors/reports/tests/ExportCsvButton.test.js Unit tests for CSV dispatch args, disabling, and in-flight click guard.
src/components/menu/menu-definition.js Adds Sponsors → Reports menu entry guarded by admin-sponsors.
src/app.js Injects SPONSOR_REPORTS_API_URL into window config.
src/actions/sponsor-reports-actions.js Thunks for reports endpoints (purchase details, sponsor assets, filters, drilldown).
src/actions/tests/sponsor-reports-actions.test.js Unit tests for sponsor reports thunks and read-error handler behavior.
.env.example Adds SPONSOR_REPORTS_API_URL example env var.

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

Comment thread src/utils/reports-text.js Outdated
Comment thread src/utils/report-errors.js
Comment thread src/utils/report-query.js Outdated
- reports-text: decode uppercase/mixed-case HTML entities (the case-insensitive
  match was missing the lowercase ENTITIES map); add toPlainText tests
- report-errors: export-disabled now dispatches { kind, status, message } to
  match the other error branches
- report-query: coerce sponsorIds to positive integers and drop the rest so the
  filter never emits sponsor_id==NaN/==0; add buildReportQuery tests

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@smarcet smarcet requested a review from santipalenque June 25, 2026 14:03
…iew)

Per Sebastian's PR review: summit-admin now requests the new microservice's own
scopes (sponsor-reports/read, sponsor-reports/export) instead of relying on the
broad reports/all. Adds SPONSOR_REPORTS_SCOPES and wires it into SCOPES
(reports/all kept for the legacy summit-reports-api). Requires the IDP to grant
these two scopes to the summit-admin client.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@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 @.env.example:
- Line 26: The SCOPES aggregate still includes reports/all, which is broader
than needed and conflicts with the dedicated sponsor report scopes. Update the
SCOPES value in .env.example to remove reports/all while keeping the existing
scoped report permissions such as SPONSOR_REPORTS_SCOPES and the other named
scope variables intact.
🪄 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: 05a2e27c-7d13-497e-bd72-9787506508fa

📥 Commits

Reviewing files that changed from the base of the PR and between 07c3261 and d342f26.

📒 Files selected for processing (12)
  • .env.example
  • src/actions/__tests__/sponsor-reports-actions.test.js
  • src/actions/sponsor-reports-actions.js
  • src/components/sponsors/reports/FilterBar.js
  • src/reducers/sponsors/__tests__/sponsor-reports-reducers.test.js
  • src/utils/__tests__/report-query.test.js
  • src/utils/__tests__/reports-money.test.js
  • src/utils/__tests__/reports-text.test.js
  • src/utils/report-errors.js
  • src/utils/report-query.js
  • src/utils/reports-money.js
  • src/utils/reports-text.js
✅ Files skipped from review due to trivial changes (2)
  • src/utils/tests/reports-text.test.js
  • src/utils/tests/reports-money.test.js
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/utils/reports-money.js
  • src/utils/report-query.js
  • src/utils/report-errors.js
  • src/reducers/sponsors/tests/sponsor-reports-reducers.test.js
  • src/actions/tests/sponsor-reports-actions.test.js

Comment thread .env.example
caseylocker and others added 7 commits June 25, 2026 12:53
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…istration

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ifest

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tails page

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@smarcet smarcet 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.

Two low-severity findings from the deep review — both are code-quality nits with no functional impact on the feature. @caseylocker tagging you for awareness.

Comment thread src/utils/section-csv-query.js Outdated
// Defense-in-depth: callers pass route/backend integer ids (the drill-down page
// validates :sponsorId/:summitId before rendering). Never interpolate a
// non-integer value into a filter clause sent to the CSV endpoint.
if (Number.isInteger(sid)) kept.push(`sponsor_id==${sid}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW] Defense-in-depth guard does not match its comment.

Number.isInteger(0) is true, so a sponsorId of "0" would emit sponsor_id==0 into the filter clause. The drilldown page validates upstream with isPositiveIntId, so there is no live attack path — but the guard here does not live up to the comment above it ("Never interpolate a non-integer value").

Suggestion: change to sid > 0 (also handles NaN since NaN > 0 is false), and same for pid on the next line.

@caseylocker

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in e06b1e9e. Reworded the comment to match the guard — it now describes the sponsor_id/page_id integer check and drops the stale :summitId reference (this function doesn't touch summit).

// MuiTable keys rows on row.id; the API exposes purchase_id, not id.
// The page must call rows.map(r => ({ ...r, id: r.purchase_id })) before
// passing data, or use this helper for explicit mapping.
export const getOrderRowId = (row) => row.purchase_id;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW] Dead export with a misleading comment.

The comment on lines 43–45 says "The page must call rows.map(r => ({ ...r, id: r.purchase_id })) before passing data, or use this helper" — but OrdersTable already does that remapping internally in the data prop passed to MuiTable. getOrderRowId is never imported anywhere in the codebase.

A future developer reading this comment might add a redundant .map() in the page component, producing double-mapped rows.

Suggestion: either remove the export entirely, or update the comment to clarify the remapping is already done inside OrdersTable.

@caseylocker

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in e06b1e9e. Confirmed unused — the table maps purchase_id → id inline at the data= prop; only its own test referenced it. Removed the export, comment, and test.

@smarcet smarcet 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.

Convention audit against the established codebase patterns. 4 inline findings below — none are blockers, but two are 1-line fixes. @caseylocker

PURCHASE_DETAILS_VALIDATION_CLEAR
} from "../../../../actions/sponsor-reports-actions";

const DEFAULT_PAGE_SIZE = 10;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Convention] DEFAULT_PAGE_SIZE should be imported from constants.js, not redefined locally.

src/utils/constants.js already exports DEFAULT_PER_PAGE = 10. Defining the same value under a different name here is a 1-line fix:

import { DEFAULT_PER_PAGE } from '../../../../utils/constants';
// then replace DEFAULT_PAGE_SIZE → DEFAULT_PER_PAGE below

@caseylocker

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in e06b1e9e — now imports DEFAULT_PER_PAGE from constants.js. (The Line Items view keeps a local LINES_DEFAULT_PAGE_SIZE = 50, since there's no matching constant for 50.)


// Local pagination/sort state. MuiTable dir = 1 (asc) | -1 (desc).
const [filters, setFilters] = useState({});
const [currentPage, setCurrentPage] = useState(1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Convention] Pagination/sort state is in local useState instead of Redux — deviation from the list-page pattern.

The established pattern (summit-admin-list-page-pattern.md) stores currentPage, perPage, order, orderDir in the Redux reducer via the 5th argument of getRequest, so the REQUEST_* case can sync them:

// Standard pattern
case REQUEST_ITEMS: {
  const { currentPage, perPage, order, orderDir, term } = payload;
  return { ...state, currentPage, perPage, order, orderDir, term };
}

Here those four values live in useState and REQUEST_PURCHASE_DETAILS only sets loading: true. Same deviation exists in sponsor-asset-report-page.

Practical difference: a page refresh or summit switch always resets pagination to page 1 (because local state is lost on unmount). That may be intentional for a report view — if so, worth a brief comment saying so to signal it was a deliberate choice rather than an oversight.

@caseylocker

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Left as local useState for now. These are read-only report views with ephemeral, page-local pagination/sort that nothing else in the app reads — a Redux slice would add actions/reducer for state that never leaves the component. The Line Items view stacked on this PR mirrors the same local pattern, so moving it would be a broader change across both grids. I'd lean toward keeping it local and revisiting if another view ever needs to read this state — happy to match the list-page pattern if you feel strongly.

// Function form of mapDispatchToProps: injects raw dispatch (needed for the
// PURCHASE_DETAILS_VALIDATION_CLEAR action in the Snackbar handler) alongside
// the bound action creators.
const mapDispatchToProps = (dispatch) => ({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Convention] mapDispatchToProps in function form — the rest of the codebase uses the object shorthand.

The function form is used here to get raw dispatch for the Snackbar's onClose handler (dispatch({ type: PURCHASE_DETAILS_VALIDATION_CLEAR })). The conventional fix is to export a named action creator and map it normally:

// In sponsor-reports-actions.js
export const clearPurchaseDetailsValidation = () => ({
  type: PURCHASE_DETAILS_VALIDATION_CLEAR
});

// In the page
export default connect(mapStateToProps, {
  getPurchaseDetailsReport,
  getPurchaseDetailsFilters,
  clearPurchaseDetailsValidation
})(PurchaseDetailsReportPage);

Not a blocker, but keeps the pattern consistent across all pages.

@caseylocker

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in e06b1e9e. Converted to object shorthand. The function form only needed raw dispatch to clear the validation toast, so I added a clearPurchaseDetailsValidation() action creator and bound it via the object form — the raw dispatch prop is gone.

Comment thread src/hooks/usePrint.js
// Prints the currently loaded report body only (server-paginated page).
// v1 caveat: captures only the currently loaded page, not the full filtered view.
// A true full-report print would need a print-mode fetch of all pages — out of scope.
const usePrint = () => useCallback(() => window.print(), []);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Convention] Custom hook should live in src/hooks/, not co-located with components.

The project's canonical location for custom hooks is src/hooks/ (see src/hooks/useScrollToError.js). Moving this file there is a 1-line import path change in the two pages that consume it.

@caseylocker

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in e06b1e9e. Moved to src/hooks/usePrint.js (next to useScrollToError) and updated the three reports pages' imports.


const query = {};
if (filter.length > 0) query["filter[]"] = filter;
if (search) query.search = search;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Convention] Free-text search param is not passed through escapeFilterValue.

The project rule (summit-admin-redux-actions.md) says: "Always use escapeFilterValue(term) before inserting user input into filters." Here search goes directly as a query param rather than into a filter[] clause, so the immediate injection risk is lower — but the guidance covers user-supplied strings broadly.

Worth confirming with the backend team whether the search param on the reports API needs escaping on the client side, or whether the server handles it. If not needed, a short comment here would clarify why the escape was intentionally omitted.

@caseylocker

@caseylocker caseylocker Jun 25, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The search value goes through as a top-level query param, not into a filter[] clause, so escapeFilterValue (which escapes filter operators) doesn't directly apply.

@smarcet

smarcet commented Jun 25, 2026

Copy link
Copy Markdown

Addressing the two remaining false positives from CodeRabbit's nitpick summary (review #4567585391):


FilterBar.js:28-29 — draft won't re-sync if value prop changes after mount

The useEffect that re-syncs draft to the committed value prop is already there:

useEffect(() => {
  setDraft(value);
}, [value]);

The comment above it even explains the intent: "Re-sync the draft when the committed value prop changes externally (e.g. a parent-driven reset)." The finding describes exactly what the code already does.


sponsor-reports-reducers.test.js:110-124 — missing test for PURCHASE_DETAILS_VALIDATION_CLEAR

The test is present, starting at line 127:

describe("PURCHASE_DETAILS_VALIDATION_CLEAR", () => {
  it("clears validationError without replacing the body", () => {
    ...
    expect(result.validationError).toBeNull();
  });
});

CodeRabbit scanned lines 110–124 (the set path) and didn't look at the lines immediately following.

@smarcet smarcet 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.

@caseylocker please review

@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/sponsors/sponsor-reports/purchase-details-report-page/index.js`:
- Around line 126-141: The three effects in
purchase-details-report-page/index.js are missing the in-context summit as a
dependency, so they won’t rerun when the summit changes after mount. Update the
useEffect hooks that call fetchFilters, fetchReport, and fetchLinesReport to
depend on currentSummit?.id (or the equivalent summit identifier from the
component scope) along with the existing inputs so the page refetches filters
and reports when the active summit is hydrated or switched. Keep the mount-only
behavior only if it still includes summit changes as a trigger for the
data-loading effects.
🪄 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: aceb4674-64b2-4907-afd9-8c0ad10a05a7

📥 Commits

Reviewing files that changed from the base of the PR and between d342f26 and c1cc057.

📒 Files selected for processing (14)
  • src/actions/__tests__/sponsor-reports-actions.test.js
  • src/actions/sponsor-reports-actions.js
  • src/components/sponsors/reports/LinesManifestView.js
  • src/components/sponsors/reports/ReportViewToggle.js
  • src/components/sponsors/reports/__tests__/LinesManifestView.test.js
  • src/components/sponsors/reports/__tests__/ReportViewToggle.test.js
  • src/i18n/en.json
  • src/pages/sponsors/sponsor-reports/purchase-details-report-page/__tests__/index.test.js
  • src/pages/sponsors/sponsor-reports/purchase-details-report-page/index.js
  • src/reducers/sponsors/__tests__/sponsor-reports-purchase-details-lines-reducer.test.js
  • src/reducers/sponsors/sponsor-reports-purchase-details-lines-reducer.js
  • src/store.js
  • src/utils/__tests__/manifest-grouping.test.js
  • src/utils/manifest-grouping.js
✅ Files skipped from review due to trivial changes (1)
  • src/utils/manifest-grouping.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/store.js
  • src/i18n/en.json
  • src/actions/tests/sponsor-reports-actions.test.js

caseylocker and others added 6 commits June 25, 2026 14:50
- index.js: import DEFAULT_PER_PAGE from constants (drop local DEFAULT_PAGE_SIZE dup)
- index.js: mapDispatchToProps to object shorthand via new clearPurchaseDetailsValidation
  action creator (removes the raw dispatch prop)
- OrdersTable.js: remove dead getOrderRowId export + its test (page maps id inline)
- usePrint: move to src/hooks/ per the codebase custom-hook convention
- section-csv-query.js: align defense-in-depth comment with the sponsor_id/page_id guard

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Purchase Details page mapStateToProps reads sponsorReportsPurchaseDetailsLinesState.data;
the SponsorReportsLayout test mounts the real page, so its mock store must include that slice.
Missing it threw 'Cannot read properties of undefined (reading data)' under the full yarn test
run (CI), though the scoped report-suite runs passed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…inks

Hashed asset filenames (32-char hex prefix, no spaces) overflowed their card.
The link Typography had noWrap (white-space:nowrap). Switch the link to a flex
row with overflowWrap:anywhere + minWidth:0 on the filename so the unbroken hash
wraps within the card; icons get flexShrink:0 so they don't squash.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The app sets html root font-size to 62.5% (10px), so rem-based sizes render
tiny: the toggle override read 8.75px and subtitle1 tile labels 10px. Pin px
instead — toggles to 14px/500 to match the Print/Export action buttons, and the
summary-tile labels to 14px.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add SponsorAvatar: logo-first with a colored-initials fallback so a no-logo
(or white-on-white) sponsor is never an invisible blank. Styled to mimic the
ReportShell title icon — single primary.light rounded square with white
foreground — and used in both group-by views and the drill-down header. Switch
the ReportShell title icon glyph to white to match. Also wrap the component-view
asset filename (was truncated by noWrap+maxWidth) so the full name is readable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render the Export CSV button on the Line Items (per-line) view of the
Purchase Details report, wired to the new backend
GET .../purchase-details/lines/csv endpoint. One ExportCsvButton switched
by view; lines query strips only pagination (preserves filters incl. the
derived include_cancelled). Orders export unchanged. Label stays 'Export CSV';
filename purchase-details-lines-summit-<id>.csv.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@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.

🧹 Nitpick comments (1)
src/pages/sponsors/sponsor-reports/purchase-details-report-page/index.js (1)

196-208: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: fold the duplicated CSV url/query derivation into a small helper.

linesCsvUrl/linesCsvQuery repeat the exact base-URL construction and page/per_page stripping already done for the orders export just above. A tiny helper (e.g. buildCsv(path, srcQuery) returning { url, query }) would remove the copy and keep both exports in sync if the strip rules change.

🤖 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/sponsors/sponsor-reports/purchase-details-report-page/index.js`
around lines 196 - 208, The CSV export setup for purchase details duplicates the
same URL construction and pagination-stripping logic already used for the orders
export. Extract that repeated logic into a small shared helper in this page (for
example, a function that builds the CSV url and query from a path and source
query), then use it for both exports so `linesCsvUrl` and `linesCsvQuery` stay
aligned with the existing order export behavior.
🤖 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.

Nitpick comments:
In `@src/pages/sponsors/sponsor-reports/purchase-details-report-page/index.js`:
- Around line 196-208: The CSV export setup for purchase details duplicates the
same URL construction and pagination-stripping logic already used for the orders
export. Extract that repeated logic into a small shared helper in this page (for
example, a function that builds the CSV url and query from a path and source
query), then use it for both exports so `linesCsvUrl` and `linesCsvQuery` stay
aligned with the existing order export behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a24726cb-2af3-4f33-a505-8cb87decc70c

📥 Commits

Reviewing files that changed from the base of the PR and between 645fe0c and 809356f.

📒 Files selected for processing (2)
  • src/pages/sponsors/sponsor-reports/purchase-details-report-page/__tests__/index.test.js
  • src/pages/sponsors/sponsor-reports/purchase-details-report-page/index.js

@santipalenque santipalenque 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.

Hey @caseylocker, this PR doesn't follow our codebase's coding patterns. For example, you added several files to the utils dir that are specific to these reports. No other page or section of the admin does this — if it did, utils would end up with dozens of one-off files, defeating the purpose of having a generic utils dir.

I left a few examples inline. Could you go through the PR and align the solution with summit-admin's coding patterns?

Comment thread src/utils/reports-api.js Outdated
@@ -0,0 +1,7 @@
export const getReportsApiBaseUrl = () => window.SPONSOR_REPORTS_API_URL;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

having one utils file per page is not scalable, please remove this unnecessary helper method and move isPositiveIntId to utils/method.js file since it is a generic helper not tied to reports api

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — moved isPositiveIntId to utils/methods.js (fd1296c0) and deleted reports-api.js, repointing the import (6757a71d). No per-page utils file remains.


// Formats a DOLLAR amount (number or numeric string) as "$1,234.56".
// Non-numeric / null → em dash.
export const formatUsd = (value) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we already have a currency parser in uicore, please use that and remove this file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — switched to uicore currencyAmountFromCents and deleted reports-money.js (a18a6d5c). Since the uicore parser is cents-based, I also moved the reports JSON API to a cents contract (it was returning dollar strings): fntechgit/sponsor-reports-api#29. The CSV export stays in dollars for readability.

Two notes: that backend PR must deploy before/with this one (the FE now feeds these values straight to currencyAmountFromCents), and money renders without a thousands separator ($1536.00) to match the rest of summit-admin.

Comment thread src/utils/reports-text.js Outdated
"&nbsp;": " "
};

export const toPlainText = (html) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we already have a method that does this in uicore, please use that and remove this file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — deleted reports-text.js (500cab97). I checked uicore first: neither utils/methods nor anywhere else in the package exports an html→text helper, and summit-admin's existing htmlToString uses documentElement.textContent, which fuses adjacent-tag text (<p>a</p><b>b</b>ab). So I added a generic htmlToPlainText to methods.js (fd1296c0) — tags→space + DOMParser entity decode — and pointed both consumers at it. If you did have a specific uicore helper in mind, point me at it and I'll switch.

Comment thread src/utils/section-csv-query.js Outdated
// stripping the sponsor clause and re-emitting `status==Paid` as its own bracket turns
// OR into AND. The v1 query builder never emits mixed brackets (sponsor is always its
// own bracket), so this is a defensive edge, not a live path.
export const buildSectionCsvQuery = (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this is only used in reports action file, lets move it there and remove this file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — folded into the exportSponsorAssetSectionCsv action thunk and deleted the file (306ce261).

setBusy(true);
try {
const token = await getAccessTokenSafely();
dispatch(getCSV(url, { ...query, access_token: token }, filename));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

create a method in actions file the builds the query based on page, id , filters props like every other export method in summit_admin. We need to keep a pattern in our code ir order to make it easier to understand it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — all four CSV exports are now action thunks that own url/params/filename like exportEventRsvpsCSV: exportPurchaseDetailsCsv/exportPurchaseDetailsLinesCsv (a0310a18) and exportSponsorAssetCsv/exportSponsorAssetSectionCsv (306ce261); the pages dispatch them from a plain MUI button and ExportCsvButton.js is gone.

Two intentional consequences worth flagging: (1) the plain buttons drop the old in-flight double-click guard — that matches every other export in summit-admin (none debounce), so I left it off rather than re-add a bespoke wrapper; (2) the thunks put access_token first ({ access_token, ...query }) to match the sibling fetch thunks in the same file, so the serialized query-string order differs from the old button — param values are identical and the backend is order-independent.

caseylocker and others added 11 commits June 27, 2026 14:24
…ethods.js

Generic helpers move to the shared methods.js home (convention). htmlToPlainText
preserves tag-boundary whitespace + decodes entities (htmlToString fuses words).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…se query builders

Move report-query under the feature folder (feature helper convention). Add
buildPurchaseQuery/buildPurchaseLinesQuery so the on-screen fetch and the upcoming
export thunks share one date/order normalization (no duplication, no regression).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…text util

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move orders/lines CSV URL+params+filename building into exportPurchaseDetailsCsv/
exportPurchaseDetailsLinesCsv (cf. exportEventRsvpsCSV); page dispatches them from
a plain MUI Button. Orders CSV keeps the on-screen sort. base() now reads
window.SPONSOR_REPORTS_API_URL directly (drops getReportsApiBaseUrl import).
currentSummit removed from component props/mapStateToProps (no longer needed
after CSV URL building moved to the thunks).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…; drop ExportCsvButton

Add exportSponsorAssetCsv/exportSponsorAssetSectionCsv (section logic folded in,
simplified); pages dispatch from plain buttons. Remove the ported ExportCsvButton
and section-csv-query util.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tId from methods

- sponsor-asset-report-page/index.js: repoint isPositiveIntId import to utils/methods
- sponsor-asset-drilldown-page/index.js: merge htmlToPlainText + isPositiveIntId into one
  import from utils/methods (fixes import/no-duplicates)
- sponsor-asset-report-page/__tests__: remove jest.mock("reports-api") — pure fn, no mock needed
- sponsor-asset-drilldown-page/__tests__: same
- layouts/__tests__/sponsor-reports-layout.test.js: remove obsolete reports-api mock + comment
- purchase-details-report-page/__tests__: rename stale "ExportCsvButton" test label to
  "export button" (authorized micro-cleanup; component deleted in Task 5)
- git rm src/utils/reports-api.js — no longer consumed by any source or test
- 115 suites / 966 tests passing; 0 new lint errors

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…t of shared utils

Both files moved into src/pages/sponsors/sponsor-reports/ per §2 (feature helpers
never in shared utils/); test for reports-money co-located alongside. Internal
./constants import in report-errors updated to ../../../utils/constants.
formatUsd logic unchanged — uicore/cents contract deferred to PR-B.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rors.js

./constants was not re-staged after the path update; this corrects it to
../../../utils/constants (resolves from the new feature folder location).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…998)

Keep the branch current with the master tip per smarcet's request (Core Team Sync 2026-06-26). Picks up 350c73d (#998 speaker-list activity count); clean auto-merge, en.json edits are in non-overlapping regions. No sponsor-reports files affected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Backend now emits money fields as integer cents. Drop the bespoke
reports-money.js formatter (per santi PR #997 review) and use the
platform-wide currencyAmountFromCents from openstack-uicore-foundation.
Null guard via inline/local const rather than a new shared helper file.
Test fixtures updated to cents input; assertions to no-comma "$X.XX" output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codex follow-up: the reducer passes summary payload through unchanged, so the
dollar-string fixtures were not a live bug, but they're stale under the cents
contract. Switch total_paid fixtures to integer cents to stay representative.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@caseylocker

Copy link
Copy Markdown
Author

Hey @caseylocker, this PR doesn't follow our codebase's coding patterns. For example, you added several files to the utils dir that are specific to these reports. No other page or section of the admin does this — if it did, utils would end up with dozens of one-off files, defeating the purpose of having a generic utils dir.

I left a few examples inline. Could you go through the PR and align the solution with summit-admin's coding patterns?

@santipalenque Thank you very much for the excellent review. These are great callouts and will help me to align closer with code patterns in the project going forward. I believe that I've addressed all of your concerns with the latest push. Let me know if I missed something, especially with this one #997 (comment).

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.

4 participants