-
Notifications
You must be signed in to change notification settings - Fork 0
Display purchased at data when available #416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes introduce a new optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
💰 Infracost reportMonthly estimate generatedThis comment will be updated when code changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/api/routes/tickets.ts (1)
283-296: Critical: MissingpurchasedAtfield in response object.The response object being pushed to
issuedTicketsis missing thepurchasedAtfield, even though:
- The schema defines it (lines 73-76)
- The sorting logic uses it (lines 311-320)
- The UI displays it (src/ui/pages/tickets/ViewTickets.page.tsx, lines 384-386)
- The database record should contain
purchased_at(unmarshalled from line 282)This will cause the UI to always display "N/A" for purchase times, and the sorting won't work as intended. For comparison,
getUserMerchPurchasesin src/api/functions/tickets.ts correctly includes this field at line 139.Apply this diff to add the missing field:
issuedTickets.push({ type: "merch", valid: true, ticketId: unmarshalled.stripe_pi, refunded: unmarshalled.refunded, fulfilled: unmarshalled.fulfilled, purchaserData: { email: unmarshalled.email, productId: eventId, quantity: unmarshalled.quantity, size: unmarshalled.size, }, totalPaid: unmarshalled.total_paid, + purchasedAt: unmarshalled.purchased_at, });
🧹 Nitpick comments (2)
src/ui/pages/tickets/ViewTickets.page.tsx (2)
270-275: Function is correct, but consider adding error handling.The implementation works, though clipboard operations can fail. Consider wrapping in try-catch similar to the
copyEmailsfunction for consistency.Apply this diff to add error handling:
const copyTicketId = (ticketId: string) => { - navigator.clipboard.writeText(ticketId); - notifications.show({ - message: "Ticket ID copied to clipboard!", - }); + try { + navigator.clipboard.writeText(ticketId); + notifications.show({ + message: "Ticket ID copied to clipboard!", + }); + } catch (e) { + notifications.show({ + title: "Failed to copy ticket ID", + message: "Please try again or contact support.", + color: "red", + }); + } };
364-378: Consider UX: clicking email text copies ticket ID.The tooltip helps clarify the behavior, but users may find it unexpected that clicking email text copies the ticket ID rather than the email itself. Consider alternatives:
- Add a separate copy icon next to the email
- Make the ticket ID visible somewhere in the row with its own copy button
- Display ticket ID in the tooltip itself
This is not a functional issue, just a UX consideration for user expectations.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (3)
src/api/functions/tickets.ts(2 hunks)src/api/routes/tickets.ts(2 hunks)src/ui/pages/tickets/ViewTickets.page.tsx(6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Run Unit Tests
- GitHub Check: Build Application
🔇 Additional comments (8)
src/api/functions/tickets.ts (2)
35-35: LGTM! Optional field correctly added.The
purchased_atfield is appropriately typed as optional since historical records may not have this field.
139-139: LGTM! Field correctly propagated.The
purchasedAtfield is properly propagated from the database result to the API response with appropriate naming convention conversion.src/ui/pages/tickets/ViewTickets.page.tsx (4)
14-14: LGTM!
34-34: LGTM! Schema correctly aligned with backend.
64-69: LGTM! Timestamp formatting is correct.The function properly handles undefined values and correctly converts epoch seconds to milliseconds for JavaScript Date constructor.
384-386: LGTM! Purchase time correctly displayed.src/api/routes/tickets.ts (2)
73-76: LGTM! Schema definition is clear and correct.
304-322: LGTM! Sorting logic is well-structured.The multi-criteria sorting correctly prioritizes valid tickets, then tickets with purchase timestamps, then sorts by most recent first. The logic properly handles all undefined cases.
Summary by CodeRabbit