@tallyui/components 3.9.2 → 3.11.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 +12 -4
- package/dist/index.js +13 -6
- package/package.json +9 -9
- package/src/cart/cart-line.tsx +6 -1
- package/src/cart/cart-total.tsx +6 -0
- package/src/customer/customer-picker.tsx +4 -2
- package/src/sale/cart.tsx +6 -4
- package/src/sale/orders-list.tsx +3 -3
- package/src/sale/receipt.tsx +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -589,6 +589,8 @@ declare function ProductVariantPicker({ options, selected, onSelect, className,
|
|
|
589
589
|
|
|
590
590
|
interface CartLineProps extends Omit<HStackProps, 'children'> {
|
|
591
591
|
name: string;
|
|
592
|
+
/** The variant's chosen options, one "Name: Value" row each under the name. */
|
|
593
|
+
attributes?: Record<string, string>;
|
|
592
594
|
quantity: number;
|
|
593
595
|
unitPrice: Money;
|
|
594
596
|
lineTotal: Money;
|
|
@@ -602,7 +604,7 @@ interface CartLineProps extends Omit<HStackProps, 'children'> {
|
|
|
602
604
|
* <CartLine name="Coffee" quantity={2} unitPrice={unitPrice} lineTotal={lineTotal} />
|
|
603
605
|
* ```
|
|
604
606
|
*/
|
|
605
|
-
declare function CartLine({ name, quantity, unitPrice, lineTotal, locale, className, ...props }: CartLineProps): react_jsx_runtime.JSX.Element;
|
|
607
|
+
declare function CartLine({ name, attributes, quantity, unitPrice, lineTotal, locale, className, ...props }: CartLineProps): react_jsx_runtime.JSX.Element;
|
|
606
608
|
|
|
607
609
|
interface CartTotalProps extends Omit<VStackProps, 'children'> {
|
|
608
610
|
subtotal: Money;
|
|
@@ -616,6 +618,8 @@ interface CartTotalProps extends Omit<VStackProps, 'children'> {
|
|
|
616
618
|
taxInclusive?: boolean;
|
|
617
619
|
locale?: string;
|
|
618
620
|
className?: string;
|
|
621
|
+
/** Rows rendered directly under Subtotal, e.g. a platform's coupon chips. */
|
|
622
|
+
afterSubtotal?: ReactNode;
|
|
619
623
|
}
|
|
620
624
|
/**
|
|
621
625
|
* Displays a cart summary: subtotal, optional discount, optional tax, and total, in the receipt's order.
|
|
@@ -624,7 +628,7 @@ interface CartTotalProps extends Omit<VStackProps, 'children'> {
|
|
|
624
628
|
* <CartTotal subtotal={subtotal} discount={discount} taxLines={taxLines} total={total} />
|
|
625
629
|
* ```
|
|
626
630
|
*/
|
|
627
|
-
declare function CartTotal({ subtotal, taxLines, discount, total, taxInclusive, locale, className, ...props }: CartTotalProps): react_jsx_runtime.JSX.Element;
|
|
631
|
+
declare function CartTotal({ subtotal, taxLines, discount, total, taxInclusive, locale, className, afterSubtotal, ...props }: CartTotalProps): react_jsx_runtime.JSX.Element;
|
|
628
632
|
|
|
629
633
|
interface CartPanelProps<T> extends Omit<VStackProps, 'children'> {
|
|
630
634
|
/** Cart line items to render */
|
|
@@ -802,8 +806,10 @@ interface CustomerPickerProps {
|
|
|
802
806
|
/** Debounce before a search, ms. */
|
|
803
807
|
debounceMs?: number;
|
|
804
808
|
className?: string;
|
|
809
|
+
/** testID of the search field, for e2e tests. Default `customer-picker-search`. */
|
|
810
|
+
testID?: string;
|
|
805
811
|
}
|
|
806
|
-
declare function CustomerPicker({ search, create, selected, onSelect, onError, online, debounceMs, className }: CustomerPickerProps): react_jsx_runtime.JSX.Element;
|
|
812
|
+
declare function CustomerPicker({ search, create, selected, onSelect, onError, online, debounceMs, className, testID }: CustomerPickerProps): react_jsx_runtime.JSX.Element;
|
|
807
813
|
|
|
808
814
|
interface PaymentMethodCardProps extends Omit<PressableProps, 'children'> {
|
|
809
815
|
label: string;
|
|
@@ -1269,7 +1275,7 @@ interface ConnectorStatusProps extends Omit<ViewProps, 'children'> {
|
|
|
1269
1275
|
declare function ConnectorStatus({ name, status, lastSync, error, className, unsoldCount, unsoldStale, formatUnsold, ...viewProps }: ConnectorStatusProps): react_jsx_runtime.JSX.Element;
|
|
1270
1276
|
|
|
1271
1277
|
/** `taxLabel` names each tax row; VAT isn't universal, so a platform passes its own (medusapos passes `VAT ${rate}%`). */
|
|
1272
|
-
declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, taxClasses }: {
|
|
1278
|
+
declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, taxClasses, afterSubtotal }: {
|
|
1273
1279
|
sale: ReturnType<typeof useSale>;
|
|
1274
1280
|
taxLabel?: (ratePpm: number) => string;
|
|
1275
1281
|
taxClasses?: ReadonlyArray<{
|
|
@@ -1285,6 +1291,8 @@ declare function Cart({ sale, taxLabel, canEditPrice, onPriceChange, taxClasses
|
|
|
1285
1291
|
toMinor: number;
|
|
1286
1292
|
reason?: string;
|
|
1287
1293
|
}) => void;
|
|
1294
|
+
/** Rows under the totals' Subtotal, e.g. the platform's coupon chips (passed to CartTotal). */
|
|
1295
|
+
afterSubtotal?: ReactNode;
|
|
1288
1296
|
}): react_jsx_runtime.JSX.Element;
|
|
1289
1297
|
|
|
1290
1298
|
/** Phone mode's cart summary (medusapos ADR 0009): the whole bar is one button; the total is the cart's own Total row. */
|
package/dist/index.js
CHANGED
|
@@ -2126,10 +2126,11 @@ function ProductVariantPicker({
|
|
|
2126
2126
|
import { formatMoney as formatMoney2 } from "@tallyui/core";
|
|
2127
2127
|
import { cn as cn48 } from "@tallyui/theme";
|
|
2128
2128
|
import { jsx as jsx51, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2129
|
-
function CartLine({ name, quantity, unitPrice, lineTotal, locale, className, ...props }) {
|
|
2129
|
+
function CartLine({ name, attributes, quantity, unitPrice, lineTotal, locale, className, ...props }) {
|
|
2130
2130
|
return /* @__PURE__ */ jsxs13(HStack, { className: cn48("px-3 py-2.5", className), ...props, children: [
|
|
2131
2131
|
/* @__PURE__ */ jsxs13(VStack, { space: "none", className: "flex-1 gap-0.5", children: [
|
|
2132
2132
|
/* @__PURE__ */ jsx51(Text, { className: "text-sm font-medium", numberOfLines: 1, children: name }),
|
|
2133
|
+
Object.entries(attributes ?? {}).map(([key, value]) => /* @__PURE__ */ jsx51(Text, { className: "text-xs text-muted-foreground", children: `${key}: ${value}` }, key)),
|
|
2133
2134
|
/* @__PURE__ */ jsx51(Text, { className: "text-xs text-muted-foreground", children: `${formatMoney2(unitPrice, locale) ?? "\u2014"} \xD7 ${quantity}` })
|
|
2134
2135
|
] }),
|
|
2135
2136
|
/* @__PURE__ */ jsx51(Text, { className: "text-sm font-semibold", children: formatMoney2(lineTotal, locale) ?? "\u2014" })
|
|
@@ -2148,6 +2149,7 @@ function CartTotal({
|
|
|
2148
2149
|
taxInclusive,
|
|
2149
2150
|
locale,
|
|
2150
2151
|
className,
|
|
2152
|
+
afterSubtotal,
|
|
2151
2153
|
...props
|
|
2152
2154
|
}) {
|
|
2153
2155
|
return /* @__PURE__ */ jsxs14(VStack, { space: "none", className: cn49("gap-1.5 px-3 py-3", className), ...props, children: [
|
|
@@ -2155,6 +2157,7 @@ function CartTotal({
|
|
|
2155
2157
|
/* @__PURE__ */ jsx52(Text, { className: "text-sm text-muted-foreground", children: "Subtotal" }),
|
|
2156
2158
|
/* @__PURE__ */ jsx52(Text, { className: "text-sm", children: formatMoney3(subtotal, locale) ?? "\u2014" })
|
|
2157
2159
|
] }),
|
|
2160
|
+
afterSubtotal,
|
|
2158
2161
|
discount && discount.amount > 0 && /* @__PURE__ */ jsxs14(HStack, { space: "none", className: "justify-between", children: [
|
|
2159
2162
|
/* @__PURE__ */ jsx52(Text, { className: "text-sm text-muted-foreground", children: "Discount" }),
|
|
2160
2163
|
/* @__PURE__ */ jsxs14(Text, { className: "text-sm", children: [
|
|
@@ -2611,7 +2614,7 @@ import { cn as cn61 } from "@tallyui/theme";
|
|
|
2611
2614
|
import { jsx as jsx64, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2612
2615
|
var EMAIL_MAX = 254;
|
|
2613
2616
|
var EMAIL_SHAPE = /^[^\s@\u0000]+@[^\s@\u0000]+\.[^\s@\u0000]+$/u;
|
|
2614
|
-
function CustomerPicker({ search, create, selected, onSelect, onError, online, debounceMs = 250, className }) {
|
|
2617
|
+
function CustomerPicker({ search, create, selected, onSelect, onError, online, debounceMs = 250, className, testID = "customer-picker-search" }) {
|
|
2615
2618
|
const [query, setQuery] = useState8("");
|
|
2616
2619
|
const [customers, setCustomers] = useState8([]);
|
|
2617
2620
|
const [error, setError] = useState8(null);
|
|
@@ -2686,6 +2689,7 @@ function CustomerPicker({ search, create, selected, onSelect, onError, online, d
|
|
|
2686
2689
|
TextInput7,
|
|
2687
2690
|
{
|
|
2688
2691
|
accessibilityLabel: "Search customers",
|
|
2692
|
+
testID,
|
|
2689
2693
|
value: query,
|
|
2690
2694
|
onChangeText: setQuery,
|
|
2691
2695
|
editable: online,
|
|
@@ -4374,7 +4378,7 @@ function ChargeForm({ currency, lineTax, taxClasses, shippingTaxFromStore, onApp
|
|
|
4374
4378
|
|
|
4375
4379
|
// src/sale/cart.tsx
|
|
4376
4380
|
import { Fragment as Fragment6, jsx as jsx93, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
4377
|
-
function Cart({ sale, taxLabel = (ratePpm) => `Tax ${ratePpm / 1e4}%`, canEditPrice = false, onPriceChange, taxClasses }) {
|
|
4381
|
+
function Cart({ sale, taxLabel = (ratePpm) => `Tax ${ratePpm / 1e4}%`, canEditPrice = false, onPriceChange, taxClasses, afterSubtotal }) {
|
|
4378
4382
|
const { order } = sale;
|
|
4379
4383
|
const money = (amount) => ({ amount, currency: order.currency });
|
|
4380
4384
|
const { totals } = buildReceiptData(order, { storeName: "" });
|
|
@@ -4402,6 +4406,7 @@ function Cart({ sale, taxLabel = (ratePpm) => `Tax ${ratePpm / 1e4}%`, canEditPr
|
|
|
4402
4406
|
CartLine,
|
|
4403
4407
|
{
|
|
4404
4408
|
name: line.name,
|
|
4409
|
+
attributes: line.attributes,
|
|
4405
4410
|
quantity: line.quantity,
|
|
4406
4411
|
unitPrice: money(line.unitPriceMinor),
|
|
4407
4412
|
lineTotal: money(display(line.id).amountMinor)
|
|
@@ -4534,7 +4539,8 @@ function Cart({ sale, taxLabel = (ratePpm) => `Tax ${ratePpm / 1e4}%`, canEditPr
|
|
|
4534
4539
|
discount: money(totals.discountMinor),
|
|
4535
4540
|
total: money(totals.totalMinor),
|
|
4536
4541
|
taxLines: taxRows,
|
|
4537
|
-
taxInclusive: totals.taxInclusive
|
|
4542
|
+
taxInclusive: totals.taxInclusive,
|
|
4543
|
+
afterSubtotal
|
|
4538
4544
|
}
|
|
4539
4545
|
),
|
|
4540
4546
|
sale.error ? /* @__PURE__ */ jsx93(Text36, { accessibilityRole: "alert", className: "text-destructive", children: sale.error }) : null,
|
|
@@ -5069,6 +5075,7 @@ function Receipt({
|
|
|
5069
5075
|
] }),
|
|
5070
5076
|
receipt.lineItems.map((line, index) => /* @__PURE__ */ jsxs56(View63, { children: [
|
|
5071
5077
|
/* @__PURE__ */ jsx98(Text41, { className: "text-foreground", children: line.name }),
|
|
5078
|
+
Object.entries(line.attributes ?? {}).map(([name, value]) => /* @__PURE__ */ jsx98(Text41, { className: "text-muted-foreground", children: `${name}: ${value}` }, name)),
|
|
5072
5079
|
row(`${line.quantity} \xD7 ${money(line.unitPriceMinor)}`, money(line.displayAmountMinor)),
|
|
5073
5080
|
line.displayDiscounts.map((discount, i) => /* @__PURE__ */ jsx98(View63, { className: "pl-4", children: row(`${discountLabel(
|
|
5074
5081
|
order.lineItems[index].discounts[i],
|
|
@@ -5203,7 +5210,7 @@ function SyncStatus({ state, registerState, pluginName = "the POS plugin", pullN
|
|
|
5203
5210
|
import { useEffect as useEffect8, useRef as useRef8, useState as useState24 } from "react";
|
|
5204
5211
|
import { Pressable as Pressable34, ScrollView as ScrollView13, Text as Text43, View as View65 } from "react-native";
|
|
5205
5212
|
import { formatMoney as formatMoney17, knownWarnings } from "@tallyui/core";
|
|
5206
|
-
import { needsAttention } from "@tallyui/pos";
|
|
5213
|
+
import { isRequeueable, needsAttention } from "@tallyui/pos";
|
|
5207
5214
|
import { jsx as jsx100, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
5208
5215
|
var STATUS_LABEL = { pending: "Waiting to sync", applied: "Synced", rejected: "Not accepted" };
|
|
5209
5216
|
var FIGURE_LABELS = /* @__PURE__ */ new Map([["subtotalMinor", "Subtotal"], ["taxMinor", "Tax"], ["discountMinor", "Discount"]]);
|
|
@@ -5301,7 +5308,7 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
5301
5308
|
order.syncStatus === "rejected" ? /* @__PURE__ */ jsx100(Text43, { className: "text-destructive", children: refusalSentence(order.error?.code) }) : null,
|
|
5302
5309
|
order.lateSessionId !== void 0 ? /* @__PURE__ */ jsx100(Text43, { className: "text-foreground", children: "Taken after the register closed. It is not in that register's closure." }) : null,
|
|
5303
5310
|
order.localWarnings?.map((warning, index) => /* @__PURE__ */ jsx100(Text43, { className: "text-foreground", children: warning.code === "customer_omitted" ? `The customer's ${warning.field} couldn't be sent to the store, so the order isn't linked to them.` : "The terminal's payment reference couldn't be kept; the payment is recorded without it." }, index)),
|
|
5304
|
-
section.title === "Needs attention" && order.syncStatus === "rejected" && order.error?.code
|
|
5311
|
+
section.title === "Needs attention" && order.syncStatus === "rejected" && isRequeueable(order.error?.code) ? /* @__PURE__ */ jsx100(Pressable34, { accessibilityRole: "button", disabled: retryingIds.has(order.id), onPress: async () => {
|
|
5305
5312
|
if (retrying.current.has(order.id)) return;
|
|
5306
5313
|
retrying.current.add(order.id);
|
|
5307
5314
|
setRetryingIds(new Set(retrying.current));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tallyui/components",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Universal POS UI components for Tally UI",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,22 +28,22 @@
|
|
|
28
28
|
"directory": "packages/components"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@tallyui/core": "^3.
|
|
32
|
-
"@tallyui/primitives": "^3.
|
|
33
|
-
"@tallyui/theme": "^3.
|
|
31
|
+
"@tallyui/core": "^3.11.0",
|
|
32
|
+
"@tallyui/primitives": "^3.11.0",
|
|
33
|
+
"@tallyui/theme": "^3.11.0",
|
|
34
34
|
"react": ">=18",
|
|
35
35
|
"react-native": ">=0.74",
|
|
36
36
|
"react-native-svg": ">=15"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"class-variance-authority": "^0.7.1",
|
|
40
|
-
"@tallyui/pos": "3.
|
|
40
|
+
"@tallyui/pos": "3.11.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@tallyui/connector-medusa": "3.
|
|
44
|
-
"@tallyui/connector-vendure": "3.
|
|
45
|
-
"@tallyui/connector-woocommerce": "3.
|
|
46
|
-
"@tallyui/mock-api": "3.
|
|
43
|
+
"@tallyui/connector-medusa": "3.11.0",
|
|
44
|
+
"@tallyui/connector-vendure": "3.11.0",
|
|
45
|
+
"@tallyui/connector-woocommerce": "3.11.0",
|
|
46
|
+
"@tallyui/mock-api": "3.11.0",
|
|
47
47
|
"@types/react": ">=18",
|
|
48
48
|
"react": "^19.2.4",
|
|
49
49
|
"react-native-svg": "15.12.1",
|
package/src/cart/cart-line.tsx
CHANGED
|
@@ -4,6 +4,8 @@ import { Text, HStack, VStack, type HStackProps } from '../ui';
|
|
|
4
4
|
|
|
5
5
|
export interface CartLineProps extends Omit<HStackProps, 'children'> {
|
|
6
6
|
name: string;
|
|
7
|
+
/** The variant's chosen options, one "Name: Value" row each under the name. */
|
|
8
|
+
attributes?: Record<string, string>;
|
|
7
9
|
quantity: number;
|
|
8
10
|
unitPrice: Money;
|
|
9
11
|
lineTotal: Money;
|
|
@@ -18,11 +20,14 @@ export interface CartLineProps extends Omit<HStackProps, 'children'> {
|
|
|
18
20
|
* <CartLine name="Coffee" quantity={2} unitPrice={unitPrice} lineTotal={lineTotal} />
|
|
19
21
|
* ```
|
|
20
22
|
*/
|
|
21
|
-
export function CartLine({ name, quantity, unitPrice, lineTotal, locale, className, ...props }: CartLineProps) {
|
|
23
|
+
export function CartLine({ name, attributes, quantity, unitPrice, lineTotal, locale, className, ...props }: CartLineProps) {
|
|
22
24
|
return (
|
|
23
25
|
<HStack className={cn('px-3 py-2.5', className)} {...props}>
|
|
24
26
|
<VStack space="none" className="flex-1 gap-0.5">
|
|
25
27
|
<Text className="text-sm font-medium" numberOfLines={1}>{name}</Text>
|
|
28
|
+
{Object.entries(attributes ?? {}).map(([key, value]) => (
|
|
29
|
+
<Text key={key} className="text-xs text-muted-foreground">{`${key}: ${value}`}</Text>
|
|
30
|
+
))}
|
|
26
31
|
<Text className="text-xs text-muted-foreground">
|
|
27
32
|
{`${formatMoney(unitPrice, locale) ?? '—'} × ${quantity}`}
|
|
28
33
|
</Text>
|
package/src/cart/cart-total.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import { formatMoney, type Money } from '@tallyui/core';
|
|
2
3
|
import { cn } from '@tallyui/theme';
|
|
3
4
|
import { Text, HStack, VStack, type VStackProps } from '../ui';
|
|
@@ -11,6 +12,8 @@ export interface CartTotalProps extends Omit<VStackProps, 'children'> {
|
|
|
11
12
|
taxInclusive?: boolean;
|
|
12
13
|
locale?: string;
|
|
13
14
|
className?: string;
|
|
15
|
+
/** Rows rendered directly under Subtotal, e.g. a platform's coupon chips. */
|
|
16
|
+
afterSubtotal?: ReactNode;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -28,6 +31,7 @@ export function CartTotal({
|
|
|
28
31
|
taxInclusive,
|
|
29
32
|
locale,
|
|
30
33
|
className,
|
|
34
|
+
afterSubtotal,
|
|
31
35
|
...props
|
|
32
36
|
}: CartTotalProps) {
|
|
33
37
|
return (
|
|
@@ -37,6 +41,8 @@ export function CartTotal({
|
|
|
37
41
|
<Text className="text-sm">{formatMoney(subtotal, locale) ?? '—'}</Text>
|
|
38
42
|
</HStack>
|
|
39
43
|
|
|
44
|
+
{afterSubtotal}
|
|
45
|
+
|
|
40
46
|
{discount && discount.amount > 0 && (
|
|
41
47
|
<HStack space="none" className="justify-between">
|
|
42
48
|
<Text className="text-sm text-muted-foreground">Discount</Text>
|
|
@@ -20,6 +20,8 @@ export interface CustomerPickerProps {
|
|
|
20
20
|
/** Debounce before a search, ms. */
|
|
21
21
|
debounceMs?: number;
|
|
22
22
|
className?: string;
|
|
23
|
+
/** testID of the search field, for e2e tests. Default `customer-picker-search`. */
|
|
24
|
+
testID?: string;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/** `@tallyui/core/server`'s `payloadBoundErrors` bound on `customer.email`, in UTF-16 code units. */
|
|
@@ -27,7 +29,7 @@ const EMAIL_MAX = 254;
|
|
|
27
29
|
/** A simple shape, not RFC 5322: one `@`, a non-empty local part, a domain with text either side of a dot, no whitespace or NUL. */
|
|
28
30
|
const EMAIL_SHAPE = /^[^\s@\u0000]+@[^\s@\u0000]+\.[^\s@\u0000]+$/u;
|
|
29
31
|
|
|
30
|
-
export function CustomerPicker({ search, create, selected, onSelect, onError, online, debounceMs = 250, className }: CustomerPickerProps) {
|
|
32
|
+
export function CustomerPicker({ search, create, selected, onSelect, onError, online, debounceMs = 250, className, testID = 'customer-picker-search' }: CustomerPickerProps) {
|
|
31
33
|
const [query, setQuery] = useState('');
|
|
32
34
|
const [customers, setCustomers] = useState<Customer[]>([]);
|
|
33
35
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -96,7 +98,7 @@ export function CustomerPicker({ search, create, selected, onSelect, onError, on
|
|
|
96
98
|
<Pressable accessibilityRole="button" className="items-center rounded-lg border border-border px-4 py-3" onPress={() => onSelect(null)}><Text className="text-sm font-semibold text-foreground">Remove customer</Text></Pressable>
|
|
97
99
|
</View>}
|
|
98
100
|
<Text className="text-xs font-medium text-muted-foreground">Search customers</Text>
|
|
99
|
-
<TextInput accessibilityLabel="Search customers" value={query} onChangeText={setQuery} editable={online}
|
|
101
|
+
<TextInput accessibilityLabel="Search customers" testID={testID} value={query} onChangeText={setQuery} editable={online}
|
|
100
102
|
className="rounded-lg border border-border bg-card px-3 py-2 text-sm text-foreground"
|
|
101
103
|
placeholderTextColorClassName="accent-muted-foreground" placeholder="Name or email" />
|
|
102
104
|
{!online && <Text className="text-sm text-muted-foreground">Connect to search or add customers.</Text>}
|
package/src/sale/cart.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import { useState, type ReactNode } from 'react';
|
|
2
2
|
import { Pressable, Text, View } from 'react-native';
|
|
3
3
|
import { formatMoney } from '@tallyui/core';
|
|
4
4
|
import { buildReceiptData } from '@tallyui/pos';
|
|
@@ -9,13 +9,15 @@ import { PriceForm } from './price-form';
|
|
|
9
9
|
import { ChargeForm } from './charge-form';
|
|
10
10
|
|
|
11
11
|
/** `taxLabel` names each tax row; VAT isn't universal, so a platform passes its own (medusapos passes `VAT ${rate}%`). */
|
|
12
|
-
export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10000}%`, canEditPrice = false, onPriceChange, taxClasses }:
|
|
12
|
+
export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10000}%`, canEditPrice = false, onPriceChange, taxClasses, afterSubtotal }:
|
|
13
13
|
{ sale: ReturnType<typeof useSale>; taxLabel?: (ratePpm: number) => string;
|
|
14
14
|
taxClasses?: ReadonlyArray<{ id: string; label: string }>;
|
|
15
15
|
/** Shows a Price action on each line. Pass the till's own permission; the control isn't shown without it. */
|
|
16
16
|
canEditPrice?: boolean;
|
|
17
17
|
/** Called after a price is applied, for the app's audit log. The reason is kept only here. */
|
|
18
18
|
onPriceChange?: (change: { lineId: string; fromMinor: number; toMinor: number; reason?: string }) => void;
|
|
19
|
+
/** Rows under the totals' Subtotal, e.g. the platform's coupon chips (passed to CartTotal). */
|
|
20
|
+
afterSubtotal?: ReactNode;
|
|
19
21
|
}) {
|
|
20
22
|
const { order } = sale;
|
|
21
23
|
const money = (amount: number) => ({ amount, currency: order.currency });
|
|
@@ -39,7 +41,7 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
|
|
|
39
41
|
{ id: 'discount', label: 'Discount', color: 'text-primary', onPress: () => setForm({ type: 'discount', lineId: line.id }) },
|
|
40
42
|
...(canEditPrice ? [{ id: 'price', label: 'Price', color: 'text-primary', onPress: () => setForm({ type: 'price', lineId: line.id }) }] : []),
|
|
41
43
|
]}>
|
|
42
|
-
<CartLine name={line.name} quantity={line.quantity} unitPrice={money(line.unitPriceMinor)}
|
|
44
|
+
<CartLine name={line.name} attributes={line.attributes} quantity={line.quantity} unitPrice={money(line.unitPriceMinor)}
|
|
43
45
|
lineTotal={money(display(line.id).amountMinor)} />
|
|
44
46
|
</CartLineActions>
|
|
45
47
|
<DiscountChips discounts={line.discounts} amounts={display(line.id).discounts} currency={order.currency} onRemove={sale.removeDiscount} />
|
|
@@ -95,7 +97,7 @@ export function Cart({ sale, taxLabel = (ratePpm: number) => `Tax ${ratePpm / 10
|
|
|
95
97
|
footer={<View testID="cart-footer" className="gap-3 pb-4">
|
|
96
98
|
{/* Exclusive: subtotal − discount + tax = total. Inclusive: subtotal − discount = total, the tax "incl.", not added. */}
|
|
97
99
|
<CartTotal subtotal={money(totals.subtotalMinor)} discount={money(totals.discountMinor)} total={money(totals.totalMinor)}
|
|
98
|
-
taxLines={taxRows} taxInclusive={totals.taxInclusive} />
|
|
100
|
+
taxLines={taxRows} taxInclusive={totals.taxInclusive} afterSubtotal={afterSubtotal} />
|
|
99
101
|
{sale.error ? <Text accessibilityRole="alert" className="text-destructive">{sale.error}</Text> : null}
|
|
100
102
|
<View className="flex-row gap-3">
|
|
101
103
|
<Pressable accessibilityRole="button" disabled={!order.lineItems.length} onPress={() => sale.startTender('cash')} className={pay}>
|
package/src/sale/orders-list.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
|
2
2
|
import { Pressable, ScrollView, Text, View } from 'react-native';
|
|
3
3
|
import { formatMoney, knownWarnings } from '@tallyui/core';
|
|
4
|
-
import { needsAttention, type OutboxState, type PosOrder } from '@tallyui/pos';
|
|
4
|
+
import { isRequeueable, needsAttention, type OutboxState, type PosOrder } from '@tallyui/pos';
|
|
5
5
|
import { orderReference } from './order-reference';
|
|
6
6
|
import { sinceText } from './since-text';
|
|
7
7
|
|
|
@@ -115,8 +115,8 @@ export function OrdersList({ orders, onRetry, formatDate = defaultFormatDate, fo
|
|
|
115
115
|
? `The customer's ${warning.field} couldn't be sent to the store, so the order isn't linked to them.`
|
|
116
116
|
: "The terminal's payment reference couldn't be kept; the payment is recorded without it."}
|
|
117
117
|
</Text>)}
|
|
118
|
-
{/*
|
|
119
|
-
{section.title === 'Needs attention' && order.syncStatus === 'rejected' && order.error?.code
|
|
118
|
+
{/* Retry is offered only for a code the outbox resends (isRequeueable). */}
|
|
119
|
+
{section.title === 'Needs attention' && order.syncStatus === 'rejected' && isRequeueable(order.error?.code)
|
|
120
120
|
? <Pressable accessibilityRole="button" disabled={retryingIds.has(order.id)} onPress={async () => {
|
|
121
121
|
if (retrying.current.has(order.id)) return;
|
|
122
122
|
retrying.current.add(order.id);
|
package/src/sale/receipt.tsx
CHANGED
|
@@ -48,6 +48,7 @@ export function Receipt({ order, posOrder, store, cashier, registerId, registerN
|
|
|
48
48
|
{receipt.header.customer && <Text className="text-muted-foreground">Customer: {receipt.header.customer}</Text>}
|
|
49
49
|
{receipt.lineItems.map((line, index) => <View key={index}>
|
|
50
50
|
<Text className="text-foreground">{line.name}</Text>
|
|
51
|
+
{Object.entries(line.attributes ?? {}).map(([name, value]) => <Text key={name} className="text-muted-foreground">{`${name}: ${value}`}</Text>)}
|
|
51
52
|
{/* Before any discount, then the line's own discounts as sub-rows (TallyUI ADR-063); they add up to the subtotal. */}
|
|
52
53
|
{row(`${line.quantity} × ${money(line.unitPriceMinor)}`, money(line.displayAmountMinor))}
|
|
53
54
|
{line.displayDiscounts.map((discount, i) => <View key={i} className="pl-4">{row(`${discountLabel(
|