fix(cash-in): restore cancel button and add displayingQR timeout

Cancel button is now always visible during the cash-in flow. The state
machine routes CANCEL to confirmAbandon when bills are present, so the
user always has an exit path with appropriate warnings. Also adds a
5-minute auto-timeout on displayingQR and allows cancel during
generatingNdebit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-02-25 20:19:01 -05:00
commit 0406a21b0e
2 changed files with 17 additions and 8 deletions

View file

@ -16,15 +16,19 @@ const atmStore = useAtmStore()
const isElectron = typeof window !== 'undefined' && window.electronAPI !== undefined const isElectron = typeof window !== 'undefined' && window.electronAPI !== undefined
// Whether the header cancel button should be visible // Whether the header cancel button should be visible
// Hide after bills are inserted — state machine routes to confirmAbandon instead // State machine routes CANCEL to confirmAbandon when bills are present
const showCancelButton = computed(() => { const showCancelButton = computed(() => {
const state = atmStore.nestedState const state = atmStore.nestedState
const hasBills = (atmStore.context?.billsInserted.length ?? 0) > 0 // Show cancel in states where user might want to exit
// Show in fetchingRate (no bills yet) and insertingBills only before bills are in // State machine handles routing: no bills → idle, bills → confirmAbandon
if (state === 'fetchingRate') return true if (
if (state === 'insertingBills' && !hasBills) return true state === 'fetchingRate' ||
if (state === 'error' && !hasBills) return true state === 'insertingBills' ||
// Hide when bills are in the cash box state === 'generatingNdebit' ||
state === 'displayingQR' ||
state === 'error'
)
return true
return false return false
}) })

View file

@ -449,7 +449,6 @@ export function createATMMachine(
}, },
}, },
generatingNdebit: { generatingNdebit: {
// No CANCEL here — bills are already in the cash box
invoke: { invoke: {
src: 'generateNdebit', src: 'generateNdebit',
input: ({ context }) => context, input: ({ context }) => context,
@ -465,8 +464,14 @@ export function createATMMachine(
actions: 'setError', actions: 'setError',
}, },
}, },
on: {
CANCEL: 'confirmAbandon',
},
}, },
displayingQR: { displayingQR: {
after: {
TIMEOUT_MS: 'confirmAbandon',
},
on: { on: {
PAYMENT_RECEIVED: { PAYMENT_RECEIVED: {
target: 'askForReceipt', target: 'askForReceipt',