@tallyui/components 3.20.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1114 -90
- package/dist/index.js +8077 -3352
- package/package.json +10 -11
- package/src/cart/cart-charge-line.tsx +58 -0
- package/src/cart/cart-columns-form.tsx +98 -0
- package/src/cart/cart-columns.tsx +49 -18
- package/src/cart/cart-foot.tsx +7 -2
- package/src/cart/cart-line-strip.tsx +59 -0
- package/src/cart/cart-line.tsx +20 -8
- package/src/cart/cart-note-row.tsx +30 -0
- package/src/cart/cart-panel.tsx +9 -1
- package/src/cart/cart-row-motion.tsx +125 -0
- package/src/cart/cart-total.tsx +44 -15
- package/src/cart/index.ts +2 -1
- package/src/checkout/cash-tendered.tsx +8 -7
- package/src/checkout/change-display.tsx +2 -1
- package/src/checkout/index.ts +1 -1
- package/src/checkout/payment-selector.tsx +6 -2
- package/src/checkout/payment-types.test-d.ts +28 -0
- package/src/customer/address-editor.tsx +87 -0
- package/src/customer/address-fields.tsx +120 -0
- package/src/customer/customer-dropdown.tsx +200 -0
- package/src/customer/customer-editor.tsx +99 -0
- package/src/customer/customer-form.tsx +39 -5
- package/src/customer/customer-picker.tsx +38 -14
- package/src/customer/customers-list.tsx +83 -0
- package/src/customer/index.ts +5 -0
- package/src/filter/filter-pills.tsx +63 -0
- package/src/i18n/locales/en/components.json +85 -0
- package/src/index.ts +40 -2
- package/src/input/decimal-entry.ts +21 -0
- package/src/layout/checkout-layout.tsx +1 -1
- package/src/layout/live-tab-screen.tsx +1 -1
- package/src/layout/pos-layout.tsx +80 -4
- package/src/layout/settings-layout.tsx +1 -1
- package/src/layout/store-settings-choice-screen.tsx +1 -1
- package/src/lib/current-row.ts +13 -0
- package/src/lib/money-input.ts +16 -0
- package/src/lib/motion.ts +22 -0
- package/src/lib/use-reduced-motion.ts +20 -0
- package/src/order/index.ts +1 -1
- package/src/order/order-detail.tsx +123 -5
- package/src/order/order-filter-bar.tsx +7 -57
- package/src/order/order-status-badge.tsx +42 -19
- package/src/order/refund-form.tsx +7 -5
- package/src/product/camera-scan-button.tsx +2 -0
- package/src/product/category-nav.tsx +8 -0
- package/src/product/category-tile.tsx +65 -15
- package/src/product/in-cart-badge.tsx +55 -6
- package/src/product/index.ts +1 -0
- package/src/product/press-veil.tsx +7 -0
- package/src/product/product-card.tsx +5 -1
- package/src/product/product-grid.tsx +5 -0
- package/src/product/product-price.tsx +6 -3
- package/src/product/product-stock-badge.tsx +3 -2
- package/src/product/product-table.tsx +96 -8
- package/src/product/products-screen-columns.tsx +74 -0
- package/src/product/variant-tile.tsx +68 -0
- package/src/product/variation-picker.tsx +3 -3
- package/src/product/view-toggle.tsx +33 -4
- package/src/register/cashier-sheet.tsx +195 -0
- package/src/register/closure-sheet.tsx +54 -3
- package/src/register/handover-slip.tsx +2 -1
- package/src/register/index.ts +2 -1
- package/src/register/movement-sheet.tsx +66 -7
- package/src/register/open-register-card.tsx +11 -11
- package/src/register/register-bar.helpers.ts +17 -4
- package/src/register/register-bar.tsx +26 -5
- package/src/register/register-count.tsx +158 -24
- package/src/register/register-panel.tsx +16 -5
- package/src/register/register-side-sheet.tsx +32 -8
- package/src/register/switch-confirm.tsx +2 -2
- package/src/reports/card-panel.tsx +131 -0
- package/src/reports/cards.tsx +53 -36
- package/src/reports/hero.tsx +2 -1
- package/src/reports/index.ts +1 -0
- package/src/reports/sales-room.tsx +4 -2
- package/src/sale/breadcrumb.tsx +48 -0
- package/src/sale/cart-bar.tsx +2 -1
- package/src/sale/cart.tsx +127 -38
- package/src/sale/catalogue-settings-form.tsx +92 -0
- package/src/sale/catalogue.tsx +304 -42
- package/src/sale/category-browse.tsx +27 -0
- package/src/sale/charge-form.tsx +85 -21
- package/src/sale/customer-display-screen.tsx +22 -6
- package/src/sale/discount-form.tsx +132 -28
- package/src/sale/index.ts +6 -3
- package/src/sale/line-popover.tsx +72 -36
- package/src/sale/offered-methods.ts +16 -0
- package/src/sale/open-sale-tabs.tsx +58 -10
- package/src/sale/order-note-sheet.tsx +37 -0
- package/src/sale/order-reference.ts +3 -0
- package/src/sale/orders-list.tsx +76 -37
- package/src/sale/parked-sales.tsx +2 -1
- package/src/sale/price-form.tsx +7 -5
- package/src/sale/product-filter-bar.tsx +38 -5
- package/src/sale/receipt-sheet.tsx +243 -0
- package/src/sale/receipt.tsx +19 -9
- package/src/sale/sync-status.tsx +10 -0
- package/src/sale/tender-ledger.tsx +92 -0
- package/src/sale/tender-pane.tsx +159 -73
- package/src/sale/tender.tsx +10 -7
- package/src/sale/use-tender.ts +63 -0
- package/src/scale/min-target.tsx +36 -0
- package/src/settings/barcode-scanning-settings.tsx +164 -0
- package/src/settings/connector-status.tsx +1 -1
- package/src/settings/customer-display-settings.tsx +12 -25
- package/src/settings/index.ts +5 -0
- package/src/settings/printer-form.tsx +161 -0
- package/src/settings/printing-settings.tsx +268 -0
- package/src/settings/settings-group.tsx +2 -1
- package/src/settings/tax-calculation-settings.tsx +1 -1
- package/src/shell/added-to-cart-toast.tsx +61 -0
- package/src/shell/app-shell.tsx +5 -1
- package/src/shell/connectivity-toast.tsx +70 -0
- package/src/shell/index.ts +2 -0
- package/src/shell/nav-drawer.tsx +5 -2
- package/src/shell/nav-item.tsx +7 -4
- package/src/shell/nav-rail.tsx +9 -2
- package/src/ui/accordion/index.tsx +86 -8
- package/src/ui/alert-dialog/index.tsx +19 -5
- package/src/ui/combobox/index.tsx +21 -2
- package/src/ui/confirm-dialog/index.tsx +53 -0
- package/src/ui/dialog/index.tsx +68 -14
- package/src/ui/dialog/motion.ts +54 -0
- package/src/ui/icon/activity-heartbeat-icon.tsx +7 -0
- package/src/ui/icon/alert-circle-icon.tsx +5 -0
- package/src/ui/icon/alert-triangle-icon.tsx +7 -0
- package/src/ui/icon/banknote-icon.tsx +11 -0
- package/src/ui/icon/cash-register-icon.tsx +10 -0
- package/src/ui/icon/category-icon.tsx +7 -0
- package/src/ui/icon/chart-line-icon.tsx +5 -0
- package/src/ui/icon/check-icon.tsx +5 -0
- package/src/ui/icon/chevron-left-icon.tsx +4 -0
- package/src/ui/icon/chevron-right-icon.tsx +4 -0
- package/src/ui/icon/credit-card-icon.tsx +10 -0
- package/src/ui/icon/discount-icon.tsx +11 -0
- package/src/ui/icon/gift-icon.tsx +10 -0
- package/src/ui/icon/info-circle-icon.tsx +10 -0
- package/src/ui/icon/map-pin-icon.tsx +10 -0
- package/src/ui/icon/message-question-icon.tsx +7 -0
- package/src/ui/icon/pencil-icon.tsx +10 -0
- package/src/ui/icon/plus-icon.tsx +9 -0
- package/src/ui/icon/printer-icon.tsx +10 -0
- package/src/ui/icon/receipt-icon.tsx +7 -0
- package/src/ui/icon/settings-icon.tsx +10 -0
- package/src/ui/icon/sticky-note-icon.tsx +10 -0
- package/src/ui/icon/user-icon.tsx +4 -0
- package/src/ui/icon/users-icon.tsx +7 -0
- package/src/ui/icon/view-grid-icon.tsx +7 -0
- package/src/ui/icon/view-list-icon.tsx +7 -0
- package/src/ui/index.ts +24 -1
- package/src/ui/list-row/index.tsx +93 -0
- package/src/ui/notice/index.tsx +65 -0
- package/src/ui/select/index.tsx +2 -0
- package/src/ui/skeleton/index.tsx +37 -0
- package/src/ui/status-badge/index.tsx +43 -0
- package/src/ui/switch/index.tsx +1 -1
- package/src/ui/tabs/index.tsx +11 -2
- package/src/ui/toggle-group/index.tsx +3 -1
- package/src/ui/tone-disc/index.tsx +41 -0
|
@@ -3,9 +3,10 @@ import { Pressable, View } from 'react-native';
|
|
|
3
3
|
import type { useRegisterSession } from '@tallyui/pos';
|
|
4
4
|
|
|
5
5
|
import { cn } from '@tallyui/theme';
|
|
6
|
+
import { MinTargetBand, useMinTarget } from '../scale/min-target';
|
|
7
|
+
import { usePointer } from '../scale/use-pointer';
|
|
6
8
|
import { useShell } from '../shell/shell-context';
|
|
7
9
|
import { Avatar, avatarInitials } from '../ui/avatar';
|
|
8
|
-
import { Badge } from '../ui/badge';
|
|
9
10
|
import { Button } from '../ui/button';
|
|
10
11
|
import { HStack } from '../ui/hstack';
|
|
11
12
|
import { IconButton } from '../ui/icon-button';
|
|
@@ -20,6 +21,8 @@ export interface RegisterBarProps {
|
|
|
20
21
|
registerId: string | null;
|
|
21
22
|
/** `false` when the store, or the app itself, can't be reached — reads to the cashier as offline. */
|
|
22
23
|
online: boolean;
|
|
24
|
+
/** Sales taken that the store has still to hear: "Offline · N sales to send" offline, "N sales awaiting store" online when no other pill shows (v2). */
|
|
25
|
+
awaitingStore?: number;
|
|
23
26
|
/** Hidden when `multiRegister` is `false`: a single-register store doesn't need to name it. */
|
|
24
27
|
registerName?: string;
|
|
25
28
|
multiRegister: boolean;
|
|
@@ -37,6 +40,17 @@ export interface RegisterBarProps {
|
|
|
37
40
|
className?: string;
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
// v2's StatusBadge (packages/components/src/status-badge): the dot carries the warning colour, the word stays in
|
|
44
|
+
// the foreground, so the state never reads by colour alone. MIT, WCPOS.
|
|
45
|
+
function PillDot({ label, testID }: { label: string; testID?: string }) {
|
|
46
|
+
return (
|
|
47
|
+
<View testID={testID} className="shrink flex-row items-center gap-1.5">
|
|
48
|
+
<View aria-hidden className="size-2 shrink-0 rounded-full bg-warning" />
|
|
49
|
+
<Text className="shrink text-sm text-foreground" numberOfLines={1}>{label}</Text>
|
|
50
|
+
</View>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
40
54
|
/**
|
|
41
55
|
* The till's one status bar: the menu (phones), the place (the store, and the register for
|
|
42
56
|
* multi-register stores), one status pill (LEDGER 48), the sync state, the button that opens the
|
|
@@ -51,6 +65,7 @@ export function RegisterBar({
|
|
|
51
65
|
register,
|
|
52
66
|
registerId,
|
|
53
67
|
online,
|
|
68
|
+
awaitingStore,
|
|
54
69
|
registerName,
|
|
55
70
|
multiRegister,
|
|
56
71
|
onOpenPanel,
|
|
@@ -64,9 +79,13 @@ export function RegisterBar({
|
|
|
64
79
|
const { session, overdue, enabled, lastClosure, closing } = register;
|
|
65
80
|
const shell = useShell();
|
|
66
81
|
const openMenu = onOpenMenu ?? shell?.openMenu;
|
|
82
|
+
// h-12 is 42 px at Compact, which clips the menu button's band: under a coarse pointer the bar is the band's height.
|
|
83
|
+
const band = useMinTarget();
|
|
84
|
+
const coarse = usePointer() === 'coarse';
|
|
67
85
|
const pill = describeRegisterBarPill({
|
|
68
86
|
registerId,
|
|
69
87
|
online,
|
|
88
|
+
awaitingStore,
|
|
70
89
|
sessionStatus: session?.status ?? null,
|
|
71
90
|
overdue,
|
|
72
91
|
approvalRequired: session?.approval_required,
|
|
@@ -77,12 +96,14 @@ export function RegisterBar({
|
|
|
77
96
|
// Store · Register: the larger container first, as every v2 line that names both reads.
|
|
78
97
|
const place = storeName ? (named ? `${storeName} · ${named}` : storeName) : named;
|
|
79
98
|
return (
|
|
80
|
-
<HStack testID="register-bar" className={cn('bg-card border-border h-12 gap-2 border-b px-2', className)}
|
|
99
|
+
<HStack testID="register-bar" className={cn('bg-card border-border h-12 gap-2 border-b px-2', className)}
|
|
100
|
+
style={coarse ? { minHeight: band } : undefined}>
|
|
81
101
|
{openMenu && (
|
|
82
102
|
<IconButton testID="register-bar-menu" accessibilityLabel="Open menu" onPress={openMenu}>
|
|
83
103
|
<View className="text-foreground">
|
|
84
104
|
<MenuIcon size={24} />
|
|
85
105
|
</View>
|
|
106
|
+
<MinTargetBand square />
|
|
86
107
|
</IconButton>
|
|
87
108
|
)}
|
|
88
109
|
<View className="min-w-0 flex-1 shrink">
|
|
@@ -94,10 +115,10 @@ export function RegisterBar({
|
|
|
94
115
|
</View>
|
|
95
116
|
{pill && (onPressPill ? (
|
|
96
117
|
<Pressable testID="register-bar-pill" accessibilityRole="button" accessibilityLabel={pill} onPress={onPressPill}>
|
|
97
|
-
<
|
|
118
|
+
<PillDot label={pill} />
|
|
98
119
|
</Pressable>
|
|
99
120
|
) : (
|
|
100
|
-
<
|
|
121
|
+
<PillDot testID="register-bar-pill" label={pill} />
|
|
101
122
|
))}
|
|
102
123
|
{syncStatus}
|
|
103
124
|
{(session || lastClosure) && (
|
|
@@ -108,7 +129,7 @@ export function RegisterBar({
|
|
|
108
129
|
accessibilityLabel="Open register panel"
|
|
109
130
|
onPress={onOpenPanel}
|
|
110
131
|
>
|
|
111
|
-
<Text className={overdue ? 'text-warning' : undefined}>Register ›</Text>
|
|
132
|
+
<Text className={overdue ? 'text-warning-text' : undefined}>Register ›</Text>
|
|
112
133
|
</Button>
|
|
113
134
|
)}
|
|
114
135
|
{cashier && (
|
|
@@ -6,16 +6,20 @@ import {
|
|
|
6
6
|
countVariance,
|
|
7
7
|
denominationTotal,
|
|
8
8
|
denominations,
|
|
9
|
-
minorToDecimal,
|
|
10
9
|
parseMinor,
|
|
11
10
|
validAmount,
|
|
12
11
|
varianceText,
|
|
13
12
|
} from '@tallyui/pos';
|
|
14
13
|
|
|
15
|
-
import {
|
|
14
|
+
import { useCurrencySymbol, useFormatMoney, useMoneyFormat, minorUnitDigits } from '@tallyui/core';
|
|
16
15
|
import { cn } from '@tallyui/theme';
|
|
16
|
+
import { decimalRows, typeDecimal } from '../input/decimal-entry';
|
|
17
|
+
import { Keypad } from '../input/keypad';
|
|
17
18
|
import { errorText } from '../lib/error-text';
|
|
19
|
+
import { moneyInputText, readMoneyText } from '../lib/money-input';
|
|
18
20
|
import { Button } from '../ui/button';
|
|
21
|
+
import { ChevronDownIcon } from '../ui/icon/chevron-down-icon';
|
|
22
|
+
import { ChevronRightIcon } from '../ui/icon/chevron-right-icon';
|
|
19
23
|
import { Input } from '../ui/input';
|
|
20
24
|
import { Label } from '../ui/label';
|
|
21
25
|
import { Text } from '../ui/text';
|
|
@@ -126,19 +130,41 @@ export interface RegisterCountProps {
|
|
|
126
130
|
approval?: string;
|
|
127
131
|
approvedVariance?: Record<string, number>;
|
|
128
132
|
} | null>;
|
|
133
|
+
/** The host's Z-report print, as `ClosureSheet`'s: given, Close reads "Close & print" and awaits it after a successful close; a print failure is the host's to show. */
|
|
134
|
+
onPrint?: () => void | Promise<void>;
|
|
135
|
+
/** Shown instead of the store's message when closing the register or going back to selling fails; the host's `approve` and `onPrint` failures, and the approval-required and sale-in-progress refusals, keep their own text. */
|
|
136
|
+
failureText?: string;
|
|
129
137
|
className?: string;
|
|
130
138
|
}
|
|
131
139
|
|
|
140
|
+
/** A store call's rejection, marked so `attempt` can show `failureText` for it and not for the host's own. */
|
|
141
|
+
class StoreCallFailed { constructor(readonly cause: unknown) {} }
|
|
142
|
+
async function saving(call: () => Promise<unknown>) {
|
|
143
|
+
try {
|
|
144
|
+
await call();
|
|
145
|
+
} catch (e) {
|
|
146
|
+
// The hook's own refusals keep their text (by name: components import no class from pos, ADR-064).
|
|
147
|
+
const own = e instanceof Error && (e.name === 'RegisterApprovalRequiredError' || e.name === 'RegisterTenderInProgressError');
|
|
148
|
+
throw own ? e : new StoreCallFailed(e);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
132
152
|
/**
|
|
133
|
-
* Counts the drawer at close
|
|
134
|
-
*
|
|
153
|
+
* Counts the drawer at close, keypad first as v2: the cash amount typed by its keypad (which folds
|
|
154
|
+
* away once a valid amount loses focus) or by notes and coins (a section closed by default), other
|
|
155
|
+
* tenders kept as typed, a live variance line, and Close (gated by `approve` over threshold, then
|
|
156
|
+
* `onPrint` when given) or Back to selling. Keypad and fold: WCPOS v2 (monorepo main) `register-count.tsx`.
|
|
135
157
|
* Port provenance (ADR-032 amendment 1): WCPOS `next` `3b5331b5c` `register-count.tsx` (LEDGER
|
|
136
158
|
* 59, 60, 65, 67). Leaves out WCPOS's ApproveSheet and server-demanded `approval_required`
|
|
137
159
|
* (registers c2) — `approve` is the host's own gate, and it runs regardless of `blind`: dropping
|
|
138
160
|
* the server flag would otherwise leave a blind count with no gate at all over threshold.
|
|
139
161
|
*/
|
|
140
|
-
export function RegisterCount({ register, currency, approve, className }: RegisterCountProps) {
|
|
162
|
+
export function RegisterCount({ register, currency, approve, onPrint, failureText, className }: RegisterCountProps) {
|
|
163
|
+
const formatMoney = useFormatMoney();
|
|
164
|
+
const currencySymbol = useCurrencySymbol();
|
|
141
165
|
const { session, expected, blind, varianceThreshold, actions } = register;
|
|
166
|
+
const format = useMoneyFormat();
|
|
167
|
+
const separator = format?.decimalSeparator || '.';
|
|
142
168
|
const digits = minorUnitDigits(currency);
|
|
143
169
|
const faces = denominations[currency] ?? denominations.default;
|
|
144
170
|
// Below 480px, a note's full label ('€500') and its count badge collide across 4 columns; 3
|
|
@@ -148,24 +174,29 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
148
174
|
const [pieces, setPieces] = useState<Record<number, number>>({});
|
|
149
175
|
// Resumes an interrupted close's persisted count (LEDGER 59); ordinary counting starts blank.
|
|
150
176
|
const [cashText, setCashText] = useState(() =>
|
|
151
|
-
session?.counted?.cash != null ?
|
|
177
|
+
session?.counted?.cash != null ? moneyInputText(session.counted.cash, currency, format) : '',
|
|
152
178
|
);
|
|
153
179
|
const [others, setOthers] = useState<Record<string, string>>(() =>
|
|
154
180
|
Object.fromEntries(
|
|
155
181
|
Object.entries(session?.counted ?? {})
|
|
156
182
|
.filter(([method]) => method !== 'cash')
|
|
157
|
-
.map(([method, minor]) => [method,
|
|
183
|
+
.map(([method, minor]) => [method, moneyInputText(minor, currency, format)]),
|
|
158
184
|
),
|
|
159
185
|
);
|
|
160
186
|
const [busy, setBusy] = useState(false);
|
|
161
187
|
const [error, setError] = useState('');
|
|
162
188
|
const [refusal, setRefusal] = useState('');
|
|
189
|
+
const [keypadOpen, setKeypadOpen] = useState(true);
|
|
190
|
+
const [notesOpen, setNotesOpen] = useState(false);
|
|
191
|
+
const [tendersOpen, setTendersOpen] = useState(false);
|
|
192
|
+
const [note, setNote] = useState('');
|
|
163
193
|
|
|
164
194
|
const usingTiles = Object.keys(pieces).length > 0;
|
|
165
195
|
const tilesTotal = denominationTotal(pieces);
|
|
166
|
-
const displayAmount = usingTiles ?
|
|
167
|
-
const
|
|
168
|
-
const
|
|
196
|
+
const displayAmount = usingTiles ? moneyInputText(tilesTotal, currency, format) : cashText;
|
|
197
|
+
const cashCanonical = readMoneyText(cashText, format);
|
|
198
|
+
const valid = usingTiles || (cashCanonical !== undefined && validAmount(cashCanonical, digits));
|
|
199
|
+
const amountMinor = usingTiles ? tilesTotal : valid && cashCanonical !== undefined ? parseMinor(cashCanonical, digits) : NaN;
|
|
169
200
|
const variance = countVariance(amountMinor, expected.cash ?? 0);
|
|
170
201
|
const needsApproval = valid && closeNeedsApproval(amountMinor, expected.cash ?? 0, varianceThreshold);
|
|
171
202
|
|
|
@@ -173,15 +204,54 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
173
204
|
const otherCounted = otherMethods
|
|
174
205
|
.map((method) => [method, others[method] ?? ''] as const)
|
|
175
206
|
.filter(([, value]) => value !== '');
|
|
176
|
-
const
|
|
207
|
+
const otherCanonical = otherCounted.map(([method, value]) => [method, readMoneyText(value, format)] as const);
|
|
208
|
+
const otherTendersInvalid = otherCanonical.some(([, value]) => value === undefined || !validAmount(value, digits));
|
|
177
209
|
const counted: Record<string, number> = {
|
|
178
210
|
cash: amountMinor,
|
|
179
|
-
...Object.fromEntries(
|
|
211
|
+
...Object.fromEntries(otherCanonical.map(([method, value]) => [method, value === undefined ? NaN : parseMinor(value, digits)])),
|
|
180
212
|
};
|
|
181
213
|
// The count on screen now, for an approval that resolves after the cashier edited it.
|
|
182
214
|
const shownCount = useRef('');
|
|
183
215
|
shownCount.current = JSON.stringify(counted);
|
|
184
216
|
|
|
217
|
+
// The amount and its keypad are one focus region: on the web a key takes focus before its press
|
|
218
|
+
// lands, and a cashier may enter the count by keys alone, so the keypad collapses when focus
|
|
219
|
+
// LEAVES the region (to a tile, another tender, the footer), never on a move within it (v2).
|
|
220
|
+
const regionRef = useRef<View>(null);
|
|
221
|
+
const pressing = useRef(false);
|
|
222
|
+
const cancelFold = useRef(() => {});
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
if (Platform.OS !== 'web') return;
|
|
225
|
+
const mark = (event: Event) => { pressing.current = event.type === 'pointerdown'; };
|
|
226
|
+
for (const type of ['pointerdown', 'pointerup']) document.addEventListener(type, mark, true);
|
|
227
|
+
return () => {
|
|
228
|
+
for (const type of ['pointerdown', 'pointerup']) document.removeEventListener(type, mark, true);
|
|
229
|
+
cancelFold.current();
|
|
230
|
+
};
|
|
231
|
+
}, []);
|
|
232
|
+
const leaveRegion = (event?: { nativeEvent?: unknown }) => {
|
|
233
|
+
const next = (event?.nativeEvent as { relatedTarget?: unknown } | undefined)?.relatedTarget;
|
|
234
|
+
const region = regionRef.current as unknown as { contains?: (node: unknown) => boolean } | null;
|
|
235
|
+
if ((next && region?.contains?.(next)) || !valid) return;
|
|
236
|
+
if (!pressing.current) return setKeypadOpen(false);
|
|
237
|
+
// A press blurs on pointerdown; folding then shifts the layout before release and swallows its click.
|
|
238
|
+
const fold = () => { cancelFold.current(); setKeypadOpen(false); };
|
|
239
|
+
cancelFold.current();
|
|
240
|
+
cancelFold.current = () => ['pointerup', 'click'].forEach((type) => window.removeEventListener(type, fold));
|
|
241
|
+
['pointerup', 'click'].forEach((type) => window.addEventListener(type, fold));
|
|
242
|
+
};
|
|
243
|
+
const pressKey = (key: string) => {
|
|
244
|
+
// Leaving the tiles starts a fresh count: the typed buffer behind them is stale. So does a zero
|
|
245
|
+
// whose places are full (Clear writes 0.00): a digit could not join it (v2).
|
|
246
|
+
const fresh = usingTiles;
|
|
247
|
+
setPieces({});
|
|
248
|
+
setCashText((previous) => {
|
|
249
|
+
const point = previous.indexOf(separator);
|
|
250
|
+
const fullZero = Number(previous.replace(separator, '.')) === 0 && point >= 0 && previous.length - point - 1 >= digits;
|
|
251
|
+
return typeDecimal(fresh || fullZero ? '' : previous, key, digits, separator);
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
|
|
185
255
|
const attempt = async (action: () => Promise<unknown>) => {
|
|
186
256
|
setBusy(true);
|
|
187
257
|
setError('');
|
|
@@ -190,14 +260,17 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
190
260
|
} catch (e) {
|
|
191
261
|
// The hook's own gate (by name: components import no class from pos, ADR-064).
|
|
192
262
|
if (e instanceof Error && e.name === 'RegisterApprovalRequiredError') setRefusal(APPROVAL_REQUIRED_TEXT);
|
|
263
|
+
else if (e instanceof StoreCallFailed) setError(failureText ?? errorText(e.cause));
|
|
193
264
|
else setError(errorText(e));
|
|
194
265
|
} finally {
|
|
195
266
|
setBusy(false);
|
|
196
267
|
}
|
|
197
268
|
};
|
|
198
269
|
|
|
199
|
-
const addPieces = (value: number, n: number) =>
|
|
270
|
+
const addPieces = (value: number, n: number) => {
|
|
200
271
|
setPieces((previous) => ({ ...previous, [value]: (previous[value] ?? 0) + n }));
|
|
272
|
+
setKeypadOpen(false);
|
|
273
|
+
};
|
|
201
274
|
|
|
202
275
|
const onClose = () => {
|
|
203
276
|
setRefusal('');
|
|
@@ -219,14 +292,18 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
219
292
|
return;
|
|
220
293
|
}
|
|
221
294
|
const { approvedBy, approvedByName, approval, approvedVariance } = result;
|
|
222
|
-
await actions.closeSession({
|
|
223
|
-
counted, approvedBy, approvedByName,
|
|
295
|
+
await saving(() => actions.closeSession({
|
|
296
|
+
counted, approvedBy, approvedByName, ...(note ? { note } : {}),
|
|
224
297
|
...(approval ? { approval } : {}), ...(approvedVariance ? { approvedVariance } : {}),
|
|
225
|
-
});
|
|
298
|
+
}));
|
|
299
|
+
await onPrint?.();
|
|
226
300
|
});
|
|
227
301
|
return;
|
|
228
302
|
}
|
|
229
|
-
void attempt(() =>
|
|
303
|
+
void attempt(async () => {
|
|
304
|
+
await saving(() => actions.closeSession({ counted, ...(note ? { note } : {}) }));
|
|
305
|
+
await onPrint?.();
|
|
306
|
+
});
|
|
230
307
|
};
|
|
231
308
|
|
|
232
309
|
// Guarded as RegisterPanel is, for a caller rendering this before the hook's first snapshot.
|
|
@@ -239,9 +316,19 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
239
316
|
<Label testID="count-amount-label" nativeID={AMOUNT_LABEL_ID}>
|
|
240
317
|
{`Cash counted (${currencySymbol(currency)})`}
|
|
241
318
|
</Label>
|
|
242
|
-
|
|
319
|
+
{/* The region: a blur leaving the field or a key for a target outside it collapses the keypad. */}
|
|
320
|
+
<View ref={regionRef} testID="count-entry" className="gap-3" onBlur={leaveRegion}>
|
|
321
|
+
{/* v2's count: the amount is a hero figure typed in place, its currency symbol in the field. */}
|
|
322
|
+
<Input className="h-16">
|
|
323
|
+
<Input.Left>
|
|
324
|
+
<Text testID="count-amount-symbol" className="text-2xl text-muted-foreground tabular-nums">
|
|
325
|
+
{currencySymbol(currency)}
|
|
326
|
+
</Text>
|
|
327
|
+
</Input.Left>
|
|
243
328
|
<Input.Field
|
|
244
329
|
testID="count-amount"
|
|
330
|
+
className="text-4xl font-bold tabular-nums pl-1.5"
|
|
331
|
+
placeholder={moneyInputText(0, currency, format)}
|
|
245
332
|
value={displayAmount}
|
|
246
333
|
onChangeText={(value) => {
|
|
247
334
|
// Typing clears the tiles, and a later tile tap replaces the typed amount (LEDGER 65).
|
|
@@ -251,8 +338,19 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
251
338
|
keyboardType="decimal-pad"
|
|
252
339
|
accessibilityLabel={`Cash counted (${currencySymbol(currency)})`}
|
|
253
340
|
accessibilityLabelledBy={AMOUNT_LABEL_ID}
|
|
341
|
+
onBlur={leaveRegion}
|
|
342
|
+
onFocus={() => setKeypadOpen(true)}
|
|
343
|
+
onPressIn={() => setKeypadOpen(true)}
|
|
254
344
|
/>
|
|
255
345
|
</Input>
|
|
346
|
+
{keypadOpen ? (
|
|
347
|
+
<View testID="count-keypad">
|
|
348
|
+
<Keypad testID="count" rows={decimalRows(digits, separator)} onPress={pressKey} />
|
|
349
|
+
</View>
|
|
350
|
+
) : (
|
|
351
|
+
<Text testID="count-tap-to-change" className="text-muted-foreground">Tap the amount to edit it</Text>
|
|
352
|
+
)}
|
|
353
|
+
</View>
|
|
256
354
|
{!blind && valid && (
|
|
257
355
|
<Text testID="count-variance" className="min-h-11 tabular-nums">
|
|
258
356
|
{`Expected ${formatMoney({ amount: expected.cash ?? 0, currency })} · ${varianceText(
|
|
@@ -263,7 +361,29 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
263
361
|
)}`}
|
|
264
362
|
</Text>
|
|
265
363
|
)}
|
|
266
|
-
|
|
364
|
+
{/* v2's count note, blind or not; the store keeps a blank one as null. */}
|
|
365
|
+
<Label testID="count-note-label" nativeID="count-note-label">Note</Label>
|
|
366
|
+
<Input>
|
|
367
|
+
<Input.Field
|
|
368
|
+
testID="count-note"
|
|
369
|
+
placeholder="Explain any difference"
|
|
370
|
+
value={note}
|
|
371
|
+
onChangeText={setNote}
|
|
372
|
+
accessibilityLabelledBy="count-note-label"
|
|
373
|
+
/>
|
|
374
|
+
</Input>
|
|
375
|
+
<Button
|
|
376
|
+
testID="count-denominations"
|
|
377
|
+
variant="ghost"
|
|
378
|
+
className="min-h-11 flex-row justify-start gap-2 self-start px-0"
|
|
379
|
+
aria-expanded={notesOpen}
|
|
380
|
+
onPress={() => setNotesOpen(!notesOpen)}
|
|
381
|
+
>
|
|
382
|
+
<View className="text-muted-foreground">{notesOpen ? <ChevronDownIcon size={18} /> : <ChevronRightIcon size={18} />}</View>
|
|
383
|
+
<Text>Count by notes and coins</Text>
|
|
384
|
+
</Button>
|
|
385
|
+
{notesOpen && (
|
|
386
|
+
<View testID="count-denomination-tiles" className="gap-2">
|
|
267
387
|
{Array.from({ length: Math.ceil(faces.length / columns) }, (_, row) => (
|
|
268
388
|
<View key={row} className="flex-row gap-2">
|
|
269
389
|
{Array.from({ length: columns }, (_, column) => {
|
|
@@ -288,13 +408,27 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
288
408
|
className="min-h-11 self-end"
|
|
289
409
|
onPress={() => {
|
|
290
410
|
setPieces({});
|
|
291
|
-
setCashText(
|
|
411
|
+
setCashText(moneyInputText(0, currency, format));
|
|
292
412
|
}}
|
|
293
413
|
>
|
|
294
414
|
<Text>Clear</Text>
|
|
295
415
|
</Button>
|
|
296
416
|
</View>
|
|
297
|
-
|
|
417
|
+
)}
|
|
418
|
+
{/* Deviation from v2: v2 shows this toggle even when there is no other tender to open. */}
|
|
419
|
+
{otherMethods.length > 0 && (
|
|
420
|
+
<Button
|
|
421
|
+
testID="count-other-tenders"
|
|
422
|
+
variant="ghost"
|
|
423
|
+
className="min-h-11 flex-row justify-start gap-2 self-start px-0"
|
|
424
|
+
aria-expanded={tendersOpen}
|
|
425
|
+
onPress={() => setTendersOpen(!tendersOpen)}
|
|
426
|
+
>
|
|
427
|
+
<View className="text-muted-foreground">{tendersOpen ? <ChevronDownIcon size={18} /> : <ChevronRightIcon size={18} />}</View>
|
|
428
|
+
<Text>Other tenders</Text>
|
|
429
|
+
</Button>
|
|
430
|
+
)}
|
|
431
|
+
{tendersOpen && otherMethods.map((method) => {
|
|
298
432
|
const labelId = `count-tender-${method}-label`;
|
|
299
433
|
const label = `${tenderLabel(method)} counted (${currencySymbol(currency)})`;
|
|
300
434
|
return (
|
|
@@ -316,7 +450,7 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
316
450
|
);
|
|
317
451
|
})}
|
|
318
452
|
{!!refusal && (
|
|
319
|
-
<Text testID="count-manager-line" className="text-warning min-h-11">
|
|
453
|
+
<Text testID="count-manager-line" className="text-warning-text min-h-11">
|
|
320
454
|
{refusal}
|
|
321
455
|
</Text>
|
|
322
456
|
)}
|
|
@@ -334,7 +468,7 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
334
468
|
variant="outline"
|
|
335
469
|
className="min-h-11"
|
|
336
470
|
disabled={busy}
|
|
337
|
-
onPress={() => attempt(actions.backToSelling)}
|
|
471
|
+
onPress={() => attempt(() => saving(actions.backToSelling))}
|
|
338
472
|
>
|
|
339
473
|
<Text>Back to selling</Text>
|
|
340
474
|
</Button>
|
|
@@ -344,7 +478,7 @@ export function RegisterCount({ register, currency, approve, className }: Regist
|
|
|
344
478
|
disabled={!valid || otherTendersInvalid || busy}
|
|
345
479
|
onPress={onClose}
|
|
346
480
|
>
|
|
347
|
-
<Text>{busy ? 'Closing…' : 'Close register'}</Text>
|
|
481
|
+
<Text>{busy ? 'Closing…' : onPrint ? 'Close & print' : 'Close register'}</Text>
|
|
348
482
|
</Button>
|
|
349
483
|
</View>
|
|
350
484
|
</View>
|
|
@@ -2,7 +2,7 @@ import { useState } from 'react';
|
|
|
2
2
|
import { ScrollView, useWindowDimensions, View } from 'react-native';
|
|
3
3
|
import type { ApprovalNeeded, MovementType, useRegisterSession } from '@tallyui/pos';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useFormatMoney } from '@tallyui/core';
|
|
6
6
|
import { errorText } from '../lib/error-text';
|
|
7
7
|
import { Button } from '../ui/button';
|
|
8
8
|
import { Dialog, DialogClose, DialogContent, DialogTitle } from '../ui/dialog';
|
|
@@ -11,7 +11,7 @@ import { XIcon } from '../ui/icon/x-icon';
|
|
|
11
11
|
import { Text } from '../ui/text';
|
|
12
12
|
import { MovementSheet } from './movement-sheet';
|
|
13
13
|
import { tenderLabel } from './register-count';
|
|
14
|
-
import { RegisterSideFooter, RegisterSideHeader, RegisterSideHero, RegisterSideLedger } from './register-side-sheet';
|
|
14
|
+
import { RegisterSideFooter, RegisterSideHeader, RegisterSideHero, RegisterSideLedger, RegisterSideOpener } from './register-side-sheet';
|
|
15
15
|
|
|
16
16
|
/** Margin kept clear above and below the dialog (LEDGER-free layout fix, 2026-09-28 review):
|
|
17
17
|
* a phone-height viewport must never let the panel's top go under the page header. */
|
|
@@ -45,6 +45,14 @@ export interface RegisterPanelProps {
|
|
|
45
45
|
onPrintXReport?: () => void | Promise<void>;
|
|
46
46
|
/** `'side'`: the clock for the session's age; defaults to `new Date()`. */
|
|
47
47
|
now?: () => Date;
|
|
48
|
+
/**
|
|
49
|
+
* `'side'`: who opened the session (WCPOS v2's opener: its display name and avatar URL). Its name
|
|
50
|
+
* ends the header line in place of "Cashier", and v2's "opened HH:MM by" line with its avatar (or
|
|
51
|
+
* initials) sits under the drawer figure. Without it, the header reads "Cashier" and there is no line.
|
|
52
|
+
*/
|
|
53
|
+
openedBy?: { name: string; avatar?: string };
|
|
54
|
+
/** Replaces MovementSheet's default reason chips per movement type (`MovementSheet.reasons`); a type left out keeps v2's defaults. */
|
|
55
|
+
movementReasons?: Partial<Record<MovementType, readonly string[]>>;
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
/**
|
|
@@ -57,8 +65,9 @@ export interface RegisterPanelProps {
|
|
|
57
65
|
* Z, reprint and the print sheet, the last-closure badge, and the Reports deep link.
|
|
58
66
|
*/
|
|
59
67
|
export function RegisterPanel({
|
|
60
|
-
register, currency, registerName, open, onOpenChange, reapprove, className, presentation = 'dialog', storeName, onPrintXReport, now,
|
|
68
|
+
register, currency, registerName, open, onOpenChange, reapprove, className, presentation = 'dialog', storeName, onPrintXReport, now, openedBy, movementReasons,
|
|
61
69
|
}: RegisterPanelProps) {
|
|
70
|
+
const formatMoney = useFormatMoney();
|
|
62
71
|
const { session, expected, salesCount, blind, movements, lastClosure, approvalNeeded, actions, terms } = register;
|
|
63
72
|
const side = presentation === 'side';
|
|
64
73
|
const [reapproving, setReapproving] = useState(false);
|
|
@@ -101,7 +110,7 @@ export function RegisterPanel({
|
|
|
101
110
|
header (the Front desk review, 2026-09-28) — only the body below it scrolls. */}
|
|
102
111
|
<View className="flex-row items-center justify-between gap-2">
|
|
103
112
|
{side ? (
|
|
104
|
-
<RegisterSideHeader session={session} registerName={registerName} storeName={storeName} now={now} />
|
|
113
|
+
<RegisterSideHeader session={session} registerName={registerName} storeName={storeName} now={now} openedBy={openedBy} />
|
|
105
114
|
) : (
|
|
106
115
|
<DialogTitle testID="register-panel-amount">{registerName ?? 'Register'}</DialogTitle>
|
|
107
116
|
)}
|
|
@@ -111,7 +120,7 @@ export function RegisterPanel({
|
|
|
111
120
|
</IconButton>
|
|
112
121
|
</DialogClose>
|
|
113
122
|
</View>
|
|
114
|
-
|
|
123
|
+
<Text testID="register-panel-sales-count">{salesCount} sale{salesCount === 1 ? '' : 's'} this session</Text>
|
|
115
124
|
<ScrollView testID="register-panel-body" className="flex-1" contentContainerClassName={side ? 'gap-4' : 'gap-3'}>
|
|
116
125
|
{/* Here, not in RegisterCount: a refused closure's session is already closed, and the
|
|
117
126
|
panel is what still shows once a closure exists. Title and button: WCPOS v2's
|
|
@@ -147,6 +156,7 @@ export function RegisterPanel({
|
|
|
147
156
|
</View>
|
|
148
157
|
)}
|
|
149
158
|
{side && <RegisterSideHero terms={terms} blind={blind} currency={currency} salesCount={salesCount} />}
|
|
159
|
+
{side && session && openedBy && <RegisterSideOpener session={session} openedBy={openedBy} />}
|
|
150
160
|
<View className="flex-row gap-2">
|
|
151
161
|
{(['paid_in', 'paid_out', 'no_sale'] as const).map((type) => (
|
|
152
162
|
<Button
|
|
@@ -225,6 +235,7 @@ export function RegisterPanel({
|
|
|
225
235
|
register={register}
|
|
226
236
|
type={movementType}
|
|
227
237
|
currency={currency}
|
|
238
|
+
reasons={movementReasons?.[movementType]}
|
|
228
239
|
onOpenChange={(value) => {
|
|
229
240
|
if (!value) setMovementType(null);
|
|
230
241
|
}}
|
|
@@ -3,7 +3,8 @@ import { View } from 'react-native';
|
|
|
3
3
|
import { Path, Rect } from 'react-native-svg';
|
|
4
4
|
import type { DrawerTerms, RegisterSession } from '@tallyui/pos';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { useFormatMoney } from '@tallyui/core';
|
|
7
|
+
import { Avatar, avatarInitials } from '../ui/avatar';
|
|
7
8
|
import { Button } from '../ui/button';
|
|
8
9
|
import { DialogDescription, DialogTitle } from '../ui/dialog';
|
|
9
10
|
import { createSvgIcon } from '../ui/icon/svg-icon';
|
|
@@ -24,24 +25,25 @@ const clock = (date: Date) => `${String(date.getHours()).padStart(2, '0')}:${Str
|
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* v2's header line (`register-panel.tsx:318-326`): store · open since {time} (or closed {time})
|
|
27
|
-
* · age · opener. The session row holds only the opener's id, never a name, so the
|
|
28
|
-
* v2's own fallback, "Cashier" (`register.unknown_cashier`).
|
|
28
|
+
* · age · opener. The session row holds only the opener's id, never a name, so the host may name
|
|
29
|
+
* the opener (`openerName`); otherwise it is v2's own fallback, "Cashier" (`register.unknown_cashier`).
|
|
29
30
|
*/
|
|
30
|
-
export function describeSession(session: RegisterSession | null, storeName: string | undefined, now: Date) {
|
|
31
|
+
export function describeSession(session: RegisterSession | null, storeName: string | undefined, now: Date, openerName?: string) {
|
|
31
32
|
const parts = [storeName];
|
|
32
33
|
if (session) {
|
|
33
34
|
const opened = new Date(session.opened_at_gmt);
|
|
34
35
|
const closed = session.status === 'closed' && session.closed_at_gmt ? new Date(session.closed_at_gmt) : null;
|
|
35
36
|
const minutes = Math.max(0, Math.floor(((closed ?? now).getTime() - opened.getTime()) / 60_000));
|
|
36
37
|
parts.push(closed ? `closed ${clock(closed)}` : `open since ${clock(opened)}`,
|
|
37
|
-
minutes >= 60 ? `${Math.floor(minutes / 60)} h ${minutes % 60} m` : `${minutes} m`, 'Cashier');
|
|
38
|
+
minutes >= 60 ? `${Math.floor(minutes / 60)} h ${minutes % 60} m` : `${minutes} m`, openerName || 'Cashier');
|
|
38
39
|
}
|
|
39
40
|
return parts.filter(Boolean).join(' · ');
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
/** The sheet's title block: the register mark, the register's name and the header line. */
|
|
43
|
-
export function RegisterSideHeader({ session, registerName, storeName, now }: {
|
|
44
|
+
export function RegisterSideHeader({ session, registerName, storeName, now, openedBy }: {
|
|
44
45
|
session: RegisterSession | null; registerName?: string; storeName?: string; now?: () => Date;
|
|
46
|
+
openedBy?: { name: string; avatar?: string };
|
|
45
47
|
}) {
|
|
46
48
|
return (
|
|
47
49
|
<View className="flex-1 flex-row items-center gap-3">
|
|
@@ -49,15 +51,35 @@ export function RegisterSideHeader({ session, registerName, storeName, now }: {
|
|
|
49
51
|
<RegisterIcon size={18} />
|
|
50
52
|
</View>
|
|
51
53
|
<View className="flex-1 gap-1">
|
|
52
|
-
<DialogTitle testID="register-panel-title">
|
|
54
|
+
<DialogTitle testID="register-panel-title">
|
|
55
|
+
<Text testID="register-panel-amount">{registerName ?? 'Register'}</Text>
|
|
56
|
+
</DialogTitle>
|
|
53
57
|
<DialogDescription testID="register-panel-description">
|
|
54
|
-
{describeSession(session, storeName, now ? now() : new Date())}
|
|
58
|
+
{describeSession(session, storeName, now ? now() : new Date(), openedBy?.name)}
|
|
55
59
|
</DialogDescription>
|
|
56
60
|
</View>
|
|
57
61
|
</View>
|
|
58
62
|
);
|
|
59
63
|
}
|
|
60
64
|
|
|
65
|
+
/** v2's opener line (`user-sheet.tsx:141-159`): "opened HH:MM by" and the opener's avatar or initials. */
|
|
66
|
+
export function RegisterSideOpener({ session, openedBy }: { session: RegisterSession; openedBy: { name: string; avatar?: string } }) {
|
|
67
|
+
return (
|
|
68
|
+
<View testID="register-panel-opened-by" className="flex-row items-center gap-1">
|
|
69
|
+
<Text className="text-muted-foreground text-sm">{`opened ${clock(new Date(session.opened_at_gmt))} by`}</Text>
|
|
70
|
+
<Avatar
|
|
71
|
+
size="sm"
|
|
72
|
+
tone="primary"
|
|
73
|
+
src={openedBy.avatar}
|
|
74
|
+
alt={openedBy.name}
|
|
75
|
+
fallback={avatarInitials(openedBy.name)}
|
|
76
|
+
accessibilityLabel={openedBy.name}
|
|
77
|
+
testID="register-panel-opener-avatar"
|
|
78
|
+
/>
|
|
79
|
+
</View>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
/**
|
|
62
84
|
* The fixed footer: Print X-report (when the host prints one; off while blind, without a
|
|
63
85
|
* session or while printing, and v2's "Printing failed. Try again." on a rejection) and Close
|
|
@@ -120,6 +142,7 @@ interface FiguresProps {
|
|
|
120
142
|
|
|
121
143
|
/** The hero (cash expected, "in the drawer") and the session sales line; `—` and no sales while blind. */
|
|
122
144
|
export function RegisterSideHero({ terms, blind, currency, salesCount }: FiguresProps & { salesCount: number }) {
|
|
145
|
+
const formatMoney = useFormatMoney();
|
|
123
146
|
const shown = !blind && terms ? terms : null;
|
|
124
147
|
return (
|
|
125
148
|
<View className="gap-1">
|
|
@@ -143,6 +166,7 @@ export function RegisterSideHero({ terms, blind, currency, salesCount }: Figures
|
|
|
143
166
|
|
|
144
167
|
/** The drawer ledger (v2 `register-panel.tsx:450-536`) and Other tenders; nothing while blind. */
|
|
145
168
|
export function RegisterSideLedger({ terms, blind, currency }: FiguresProps) {
|
|
169
|
+
const formatMoney = useFormatMoney();
|
|
146
170
|
if (blind || !terms) return null;
|
|
147
171
|
const money = (amount: number) => formatMoney({ amount, currency }) ?? '';
|
|
148
172
|
const rows = [
|
|
@@ -80,11 +80,11 @@ export function SwitchConfirm({
|
|
|
80
80
|
))}
|
|
81
81
|
</View>
|
|
82
82
|
)}
|
|
83
|
-
<Button testID="switch-confirm-confirm" className="min-h-14" onPress={onConfirm}>
|
|
83
|
+
<Button testID="switch-confirm-confirm" variant={kind === 'signOut' && warnings.sessionOpen && !!onCloseRegister ? 'outline' : 'default'} className="min-h-14" onPress={onConfirm}>
|
|
84
84
|
<Text>{confirm}</Text>
|
|
85
85
|
</Button>
|
|
86
86
|
{kind === 'signOut' && warnings.sessionOpen && !!onCloseRegister && (
|
|
87
|
-
<Button testID="switch-confirm-close-register"
|
|
87
|
+
<Button testID="switch-confirm-close-register" className="min-h-14" onPress={onCloseRegister}>
|
|
88
88
|
<Text>Close register</Text>
|
|
89
89
|
</Button>
|
|
90
90
|
)}
|