You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(pos): resolve three support ticket follow-ups - #1636
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
Resolve POS support, cash-close export, and waiter PIN follow-ups
🐞 Bug fix🧪 Tests🕐 20-40 Minutes
AI Description
• Reuse support tickets for repeated POS failures instead of submitting duplicates.
• Offer a permission-gated, full-business-day product sales PDF from cash close.
• Explain waiter PIN roster states and let staff retry failed loads.
The changed path starts at the cash-close dashboard action, selects the closeout business date, and invokes the existing daily-sales export for that reporting workflow.
The changed behavior concerns the Server App PIN-user roster and its login-screen feedback; it does not change the separate email/password authentication path or KDS consumers.
The changed behavior begins when POS presents an operation failure and ends at support-ticket submission and queued-status UI; it does not alter the underlying order or payment operation.
Before, each displayed failure generated a fresh client ticket ID and submission state.
After, correlated failures share a mutable ticket record and asynchronous submission checks its status and session token.
New correctness conditions: identical failures must reuse one ID, distinct failures must remain independent, and stale completions must not mutate the current failure UI.
Potential damage 🟡 Medium🩹 Incorrect results
A date-selection or close-step regression could generate a product report for the wrong business date or fail to reflect the closeout being reviewed.
No persistent sales state is modified.
Re-running the export after correcting the date or code restores the report; stored sales data and external financial records do not require repair.
The following are alternative approaches to this PR:
1. Backend-enforced ticket idempotency
➕ Could prevent duplicate submissions across page reloads, sessions, or devices.
➖ Requires backend identity and retention rules for deciding when failures represent the same ticket.
Recommendation: Keep the scoped frontend ticket cache for these repeated failures: it reuses the existing submission API without changing backend semantics. Consider backend idempotency separately if duplicate prevention must extend beyond the current POS session.
Files changed (39) +251 / -25
Bug fix (4) +130 / -24
page.tsxPass business-date PDF export into cash close+15/-6
Pass business-date PDF export into cash close
• Allows daily sales export to use an explicit business date and exposes the PDF action to the cash-close modal only for tenants with the existing export permission.
page.tsxReuse support tickets for matching POS failures+53/-11
Reuse support tickets for matching POS failures
• Keys ticket IDs and draft, submitting, or queued status to the operation failure and session context. Repeated failures retain queued status; new failures receive new tickets, and asynchronous completion updates only the relevant visible ticket.
page.tsxDistinguish PIN roster loading, failure, and emptiness+39/-6
Distinguish PIN roster loading, failure, and emptiness
• Replaces the ambiguous empty roster state with explicit loading, error, and ready states. Shows guidance when no staff have PIN access and offers a retry after a failed request.
CashCloseModal.tsxOffer full-day product PDF during cash close+23/-1
Offer full-day product PDF during cash close
• Adds a permission-dependent PDF action and explanatory hint. Uses the X-report or completed Z-report business date rather than restricting the product report to a shift.
server-app-ordering.spec.tsCover PIN roster failure and retry+22/-0
Cover PIN roster failure and retry
• Simulates a failed roster request followed by an empty successful response, checking the retry action, empty-state guidance, and continued password access.
1. A failed help request can go unreported 🐞 Bug◔ Observability
Description
The catch block shows supportRequestQueueFailed only when `supportSubmitTokenRef.current ===
submitToken, but dismissing the card runs clearSupportErrorState()`, which nulls that token. When
the same failure comes back, the recreated card picks up the in-flight request
(setSupportSubmitting(true) from the submitting status). If that request then fails, the
finally block resets the ticket to draft and turns the Get Help button back on with no error
toast, so staff can't tell the report was never queued.
+ if (ticket?.status === 'submitting') ticket.status = 'draft';
if (supportSubmitTokenRef.current === submitToken) {
supportSubmitTokenRef.current = null;
+ }+ if (currentSupportTicketRef.current === targetError.clientTicketId) {
setSupportSubmitting(false);
}
Evidence
clearSupportErrorState (the dismiss handler) sets supportSubmitTokenRef.current = null. When the
card is recreated, the new branch at 972-978 leaves the token null and sets submitting to true
because the stored ticket status is submitting. When the original request fails, the catch guard
supportSubmitTokenRef.current === submitToken is false, so no toast appears. The finally block
then resets the status to draft and clears submitting because currentSupportTicketRef matches.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
If a support submit is in flight and the card is dismissed and then recreated for the same failure, a later request failure re-enables Get Help without any error toast. The toast is gated on a submit token that the dismiss handler cleared.
## Fix Focus Areas
- frontend/src/app/(dashboard)/pos/page.tsx[4406-4421]
## Recommended Fix
In the `catch` block, show `toast.error(t('supportRequestQueueFailed'))` when `supportSubmitTokenRef.current === submitToken` OR `currentSupportTicketRef.current === targetError.clientTicketId`, so the card currently on screen for that ticket always reports the failure.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Tip of the day
💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Closes #1632
Closes #1633
Closes #1634
Verification