Add PC processed reports admin page#440
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR introduces a reusable processed-reports admin component suite and integrates it into both PC and handheld processed-listings pages. It adds PC listings router support for viewing and overriding processed reports, updates handheld admin router for trust actions and new notification patterns, and includes analytics, caching, and database script improvements. ChangesProcessed Reports Admin System
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/data/storageKeys.ts (1)
40-41: 💤 Low valueStorage key rename will reset user preferences.
Renaming
adminProcessedListingsfromadmin_processed_listings_column_visibilitytoadmin_processed_reports_column_visibilitywill cause existing users to lose their saved column visibility settings for the handheld processed listings admin page. This is acceptable as part of the refactoring but worth noting.🤖 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/data/storageKeys.ts` around lines 40 - 41, The constant adminProcessedListings was renamed to use key string admin_processed_reports_column_visibility which will reset existing users' saved preferences; to avoid data loss, update the storage key handling so that on read/write the code first checks for the old key admin_processed_listings_column_visibility (or migrates it) and copies its value to the new key, or alternatively revert the value used in adminProcessedListings back to the previous string; refer to the adminProcessedListings and adminPcProcessedListings constants and the PREFIX symbol to locate the change and implement the migration/read-fallback logic.src/app/admin/components/processed-reports/ProcessedReportsTable.tsx (1)
166-166: 💤 Low valueInternal component props interface naming.
The guideline specifies that component props interfaces should be named
Props. However, sinceProcessedReportRowis an internal helper (not exported) and naming itPropswould conflict with the outer component's interface,RowPropsis acceptable here.🤖 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/app/admin/components/processed-reports/ProcessedReportsTable.tsx` at line 166, The interface name RowProps for the internal helper component ProcessedReportRow is acceptable to avoid clashing with the outer component's Props; leave RowProps as-is and add a short inline comment above the interface (mentioning ProcessedReportRow) indicating it's intentionally named differently to avoid export/name conflicts so future maintainers understand the rationale.Source: Learnings
src/server/api/utils/processedStatusTrust.ts (1)
14-27: 💤 Low valueAdd explicit default case for future-proofing.
The switch statement lacks a default case. If
ApprovalStatusis extended with a new value, the function would returnundefinedinstead ofnull, which could cause subtle bugs in callers that check for truthiness.🛡️ Suggested defensive addition
switch (input.newStatus) { case ApprovalStatus.APPROVED: return { userId: input.authorId, action: TrustAction.LISTING_APPROVED } case ApprovalStatus.REJECTED: return { userId: input.authorId, action: TrustAction.LISTING_REJECTED } case ApprovalStatus.PENDING: return null + default: + return null } }🤖 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/server/api/utils/processedStatusTrust.ts` around lines 14 - 27, The switch in getProcessedStatusTrustAction can return undefined if ApprovalStatus gains new values; update the switch over ApprovalStatus to include an explicit default case that returns null (or add a final return null after the switch) so the function always returns a ProcessedStatusTrustAction | null; reference ApprovalStatus cases (APPROVED, REJECTED, PENDING) and ensure unknown enums fall through to null to maintain the declared return type.
🤖 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/app/admin/components/processed-reports/ProcessedReportsTable.tsx`:
- Line 166: The interface name RowProps for the internal helper component
ProcessedReportRow is acceptable to avoid clashing with the outer component's
Props; leave RowProps as-is and add a short inline comment above the interface
(mentioning ProcessedReportRow) indicating it's intentionally named differently
to avoid export/name conflicts so future maintainers understand the rationale.
In `@src/data/storageKeys.ts`:
- Around line 40-41: The constant adminProcessedListings was renamed to use key
string admin_processed_reports_column_visibility which will reset existing
users' saved preferences; to avoid data loss, update the storage key handling so
that on read/write the code first checks for the old key
admin_processed_listings_column_visibility (or migrates it) and copies its value
to the new key, or alternatively revert the value used in adminProcessedListings
back to the previous string; refer to the adminProcessedListings and
adminPcProcessedListings constants and the PREFIX symbol to locate the change
and implement the migration/read-fallback logic.
In `@src/server/api/utils/processedStatusTrust.ts`:
- Around line 14-27: The switch in getProcessedStatusTrustAction can return
undefined if ApprovalStatus gains new values; update the switch over
ApprovalStatus to include an explicit default case that returns null (or add a
final return null after the switch) so the function always returns a
ProcessedStatusTrustAction | null; reference ApprovalStatus cases (APPROVED,
REJECTED, PENDING) and ensure unknown enums fall through to null to maintain the
declared return type.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4ee7f0b1-f5e1-461a-8156-b6139df64dd1
📒 Files selected for processing (33)
package.jsonscripts/db-backup-supabase.shscripts/db-backup.shsrc/app/admin/components/AdminNavIcon.tsxsrc/app/admin/components/AdminQuickNavigation.tsxsrc/app/admin/components/processed-reports/ApprovalStatusOverrideModal.tsxsrc/app/admin/components/processed-reports/ProcessedReportsAdminPage.tsxsrc/app/admin/components/processed-reports/ProcessedReportsTable.tsxsrc/app/admin/components/processed-reports/index.tssrc/app/admin/components/processed-reports/types.tssrc/app/admin/config/routes.tssrc/app/admin/dashboard/AdminDashboard.tsxsrc/app/admin/data.tssrc/app/admin/pc-processed-listings/page.tsxsrc/app/admin/processed-listings/components/OverrideStatusModal.tsxsrc/app/admin/processed-listings/page.tsxsrc/app/api/retrocatalog/[brandName]/[modelName]/route.test.tssrc/app/api/retrocatalog/[brandName]/[modelName]/route.tssrc/app/layout.tsxsrc/components/retrocatalog/RetroCatalogButton.tsxsrc/components/verify/GenericVerifyButton.tsxsrc/data/storageKeys.tssrc/lib/analytics/utils/sendAnalyticsEvent.test.tssrc/lib/analytics/utils/sendAnalyticsEvent.tssrc/schemas/pcListing.tssrc/server/api/routers/listings/admin.test.tssrc/server/api/routers/listings/admin.tssrc/server/api/routers/pcListings.test.tssrc/server/api/routers/pcListings.tssrc/server/api/utils/pcListingHelpers.tssrc/server/api/utils/processedStatusTrust.tssrc/server/notifications/eventEmitter.tssrc/server/notifications/service.ts
💤 Files with no reviewable changes (4)
- scripts/db-backup-supabase.sh
- src/server/notifications/eventEmitter.ts
- src/app/admin/processed-listings/components/OverrideStatusModal.tsx
- package.json
Description
Adds the missing PC processed reports admin flow and keeps it aligned with the existing handheld processed reports page.
pcListings.getProcessedwith status filtering, search, sorting, and paginationFixes #379
Type of change
How Has This Been Tested?
Ran:
pnpm lint pnpm types pnpm test git diff --check origin/staging...HEADpnpm lintcompleted with 0 errors. The existing React Compiler warnings are still present.Screenshots (if applicable)
N/A
Checklist
Notes for reviewers
This keeps the shared processed reports UI under
src/app/admin/components/processed-reportsbecause it is admin-only UI shared by two admin routes. It does not move this intofeatures.Summary by CodeRabbit
New Features
Bug Fixes
Chores