Tally UI

SwitchConfirm

SwitchConfirm asks before a cashier switch, a register switch or a sign-out, and names what the switch leaves behind.

Import

import { SwitchConfirm } from '@tallyui/components';
import { switchWarnings } from '@tallyui/pos';

Usage

const warnings = switchWarnings({
  kind: 'cashier',
  outbox: health,
  parkedSales: parked.length,
  paidMinor: 0,
  sessionStatus: register.session?.status,
});

<SwitchConfirm
  kind="cashier"
  warnings={warnings}
  targetName="Sam"
  registerName="Till 1"
  onConfirm={() => switchCashier()}
  onCancel={() => setConfirmOpen(false)}
  onPrintHandover={() => printHandoverSlip()}
/>

Behaviour

  • Cashier switch: asks "Hand the till to Sam?" and says the drawer stays open on the register. The "Print hand-over slip" action is shown when onPrintHandover is passed.
  • Register switch: asks "Switch to Till 2?". When a session is open, it says that session's drawer stays open for whoever is there.
  • Sign-out with an open session: names the register and the expected amount (no amount while blind), and offers "Close register" when onCloseRegister is passed. Without an open session it asks "Sign out?".
  • Warnings: each warning from switchWarnings is listed: unsent sales, unsent till updates, parked sales and a partly paid sale.
  • Unsent sales: the confirm label gains "anyway", for example "Hand over to Sam anyway".
  • Dismissing: closing the dialog calls onCancel.

Props

PropTypeDefaultDescription
kind'cashier' | 'register' | 'signOut'requiredWhich switch is being confirmed
warningsSwitchWarningsrequiredThe result of switchWarnings(...) from @tallyui/pos
targetNamestring---The cashier or register switched to; unused for signOut
registerNamestring---The bound register's name, used in the descriptions and the sign-out title
amountstring---A formatted expected cash amount for the sign-out title; omit while blind
onConfirm() => voidrequiredCalled on the confirm action
onCancel() => voidrequiredCalled on Cancel or when the dialog is dismissed
onCloseRegister() => void---Sign-out with an open session: shows "Close register", which calls this
onPrintHandover() => void---Cashier switch: shows "Print hand-over slip", which calls this