@tallyui/components 3.15.0 → 3.16.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 +23 -2
- package/dist/index.js +444 -355
- package/package.json +11 -9
- package/src/i18n/index.tsx +78 -0
- package/src/i18n/locales/en/components.json +30 -0
- package/src/index.ts +3 -0
- package/src/sale/tender-pane.tsx +35 -32
package/dist/index.js
CHANGED
|
@@ -5584,7 +5584,7 @@ import { useReducer } from "react";
|
|
|
5584
5584
|
import { initTenderState, tenderReducer } from "@tallyui/pos";
|
|
5585
5585
|
|
|
5586
5586
|
// src/sale/tender-pane.tsx
|
|
5587
|
-
import { useEffect as
|
|
5587
|
+
import { useEffect as useEffect9, useState as useState26 } from "react";
|
|
5588
5588
|
import { Pressable as Pressable35, Text as Text43, TextInput as TextInput12, View as View72 } from "react-native";
|
|
5589
5589
|
import { defaultPaymentMethods, formatMoney as formatMoney18, minorUnitDigits as minorUnitDigits10 } from "@tallyui/core";
|
|
5590
5590
|
import {
|
|
@@ -5599,14 +5599,100 @@ import {
|
|
|
5599
5599
|
tenderRounding
|
|
5600
5600
|
} from "@tallyui/pos";
|
|
5601
5601
|
import { cn as cn89 } from "@tallyui/theme";
|
|
5602
|
-
|
|
5602
|
+
|
|
5603
|
+
// src/i18n/index.tsx
|
|
5604
|
+
import * as React39 from "react";
|
|
5605
|
+
import { createInstance } from "i18next";
|
|
5606
|
+
import { useTranslation } from "react-i18next";
|
|
5607
|
+
|
|
5608
|
+
// src/i18n/locales/en/components.json
|
|
5609
|
+
var components_default = {
|
|
5610
|
+
"common.back": "Back",
|
|
5611
|
+
"common.backspace": "Delete last digit",
|
|
5612
|
+
"common.total": "Total",
|
|
5613
|
+
"pos_checkout.cancel_payment": "Cancel payment",
|
|
5614
|
+
"pos_checkout.cancelled": "Cancelled",
|
|
5615
|
+
"pos_checkout.change_due": "Change {amount}",
|
|
5616
|
+
"pos_checkout.clear_amount": "Clear",
|
|
5617
|
+
"pos_checkout.exact_amount": "Exact {amount}",
|
|
5618
|
+
"pos_checkout.n_of_ways": "{n} of {ways}",
|
|
5619
|
+
"pos_checkout.next_leg": "Next",
|
|
5620
|
+
"pos_checkout.no_change_for_method": "Only {amount} is due \u2014 {method} can't give change",
|
|
5621
|
+
"pos_checkout.no_payments_yet": "No payments yet",
|
|
5622
|
+
"pos_checkout.paid_in_full": "Paid in full",
|
|
5623
|
+
"pos_checkout.paid_of_total": "{paid} of {total} paid",
|
|
5624
|
+
"pos_checkout.part_payment_left": "Part payment \xB7 {left} left after this",
|
|
5625
|
+
"pos_checkout.remaining": "Remaining",
|
|
5626
|
+
"pos_checkout.rounded_from": "Rounded from {amount}",
|
|
5627
|
+
"pos_checkout.status_authorized": "Authorized",
|
|
5628
|
+
"pos_checkout.status_captured": "Captured",
|
|
5629
|
+
"pos_checkout.status_failed": "Failed",
|
|
5630
|
+
"pos_checkout.status_pending": "Pending",
|
|
5631
|
+
"pos_checkout.status_voided": "Voided",
|
|
5632
|
+
"pos_checkout.take_amount_in": "Take {amount} in {method}",
|
|
5633
|
+
"tender.complete_sale": "Complete sale",
|
|
5634
|
+
"tender.continue": "Continue",
|
|
5635
|
+
"tender.not_taken": "That payment wasn't taken: nothing is due, or the amount isn't valid.",
|
|
5636
|
+
"tender.stored_will_send": "This sale is stored and will be sent. Continue to the next sale.",
|
|
5637
|
+
"tender.terminal_reference": "Terminal reference"
|
|
5638
|
+
};
|
|
5639
|
+
|
|
5640
|
+
// src/i18n/index.tsx
|
|
5641
|
+
import { jsx as jsx109 } from "react/jsx-runtime";
|
|
5642
|
+
var NS = "components";
|
|
5643
|
+
function fallbackLng(code) {
|
|
5644
|
+
const parts = code.split(/[-_]/);
|
|
5645
|
+
return parts.length > 1 ? [parts[0].toLowerCase(), "en"] : ["en"];
|
|
5646
|
+
}
|
|
5647
|
+
function createI18n(locale, resources) {
|
|
5648
|
+
const instance = createInstance();
|
|
5649
|
+
void instance.init({
|
|
5650
|
+
lng: locale,
|
|
5651
|
+
fallbackLng,
|
|
5652
|
+
load: "currentOnly",
|
|
5653
|
+
ns: [NS],
|
|
5654
|
+
defaultNS: NS,
|
|
5655
|
+
// An app's `en` overrides bundled keys and keeps the rest, as addResourceBundle's deep merge does after mount.
|
|
5656
|
+
resources: Object.fromEntries(Object.entries({ ...resources, en: { ...components_default, ...resources.en } }).map(([lng, catalogue]) => [lng, { [NS]: catalogue }])),
|
|
5657
|
+
keySeparator: false,
|
|
5658
|
+
nsSeparator: false,
|
|
5659
|
+
initAsync: false,
|
|
5660
|
+
interpolation: { escapeValue: false, prefix: "{", suffix: "}" },
|
|
5661
|
+
react: { bindI18nStore: "added" }
|
|
5662
|
+
});
|
|
5663
|
+
return instance;
|
|
5664
|
+
}
|
|
5665
|
+
var deviceLocale = () => Intl.DateTimeFormat().resolvedOptions().locale;
|
|
5666
|
+
var I18nContext = React39.createContext(createI18n("en", {}));
|
|
5667
|
+
function I18nProvider({ locale, resources, children }) {
|
|
5668
|
+
const lng = React39.useMemo(() => locale ?? deviceLocale(), [locale]);
|
|
5669
|
+
const [instance] = React39.useState(() => createI18n(lng, resources ?? {}));
|
|
5670
|
+
const added = React39.useRef(resources);
|
|
5671
|
+
React39.useEffect(() => {
|
|
5672
|
+
if (added.current === resources) return;
|
|
5673
|
+
added.current = resources;
|
|
5674
|
+
for (const [code, catalogue] of Object.entries(resources ?? {})) instance.addResourceBundle(code, NS, catalogue, true, true);
|
|
5675
|
+
}, [resources, instance]);
|
|
5676
|
+
React39.useEffect(() => {
|
|
5677
|
+
if (instance.language !== lng) void instance.changeLanguage(lng);
|
|
5678
|
+
}, [lng, instance]);
|
|
5679
|
+
return /* @__PURE__ */ jsx109(I18nContext.Provider, { value: instance, children });
|
|
5680
|
+
}
|
|
5681
|
+
function useT() {
|
|
5682
|
+
const i18n = React39.useContext(I18nContext);
|
|
5683
|
+
const options = React39.useMemo(() => ({ i18n }), [i18n]);
|
|
5684
|
+
return useTranslation(NS, options).t;
|
|
5685
|
+
}
|
|
5686
|
+
|
|
5687
|
+
// src/sale/tender-pane.tsx
|
|
5688
|
+
import { Fragment as Fragment9, jsx as jsx110, jsxs as jsxs62 } from "react/jsx-runtime";
|
|
5603
5689
|
var REFERENCE_MAX = 255;
|
|
5604
5690
|
var STATUS_LABEL = {
|
|
5605
|
-
pending: "
|
|
5606
|
-
authorized: "
|
|
5607
|
-
captured: "
|
|
5608
|
-
failed: "
|
|
5609
|
-
voided: "
|
|
5691
|
+
pending: "pos_checkout.status_pending",
|
|
5692
|
+
authorized: "pos_checkout.status_authorized",
|
|
5693
|
+
captured: "pos_checkout.status_captured",
|
|
5694
|
+
failed: "pos_checkout.status_failed",
|
|
5695
|
+
voided: "pos_checkout.status_voided"
|
|
5610
5696
|
};
|
|
5611
5697
|
var STATUS_TONE = {
|
|
5612
5698
|
pending: "text-muted-foreground",
|
|
@@ -5615,18 +5701,19 @@ var STATUS_TONE = {
|
|
|
5615
5701
|
failed: "text-destructive",
|
|
5616
5702
|
voided: "text-muted-foreground"
|
|
5617
5703
|
};
|
|
5618
|
-
var
|
|
5704
|
+
var keypadRows = (t) => [
|
|
5619
5705
|
...DIGIT_ROWS,
|
|
5620
|
-
[{ name: "clear", label: "
|
|
5706
|
+
[{ name: "clear", label: t("pos_checkout.clear_amount"), text: "C" }, { name: "0", label: "0" }, { name: "backspace", label: t("common.backspace"), text: "\u232B" }]
|
|
5621
5707
|
];
|
|
5622
5708
|
var button5 = "min-h-11 justify-center rounded-md border border-border bg-card px-4 py-2";
|
|
5623
5709
|
var rowsSince = (payments, from) => payments.filter(countsTowardPaid).slice(from).map((leg) => ({ title: leg.method, amountMinor: leg.amountMinor }));
|
|
5624
5710
|
function TenderPane({ sale, state, dispatch, methods }) {
|
|
5625
5711
|
const { order, stage } = sale;
|
|
5626
|
-
const
|
|
5627
|
-
const [
|
|
5712
|
+
const t = useT();
|
|
5713
|
+
const [reference, setReference] = useState26("");
|
|
5714
|
+
const [refusal, setRefusal] = useState26(false);
|
|
5628
5715
|
const balance = order.balanceDueMinor;
|
|
5629
|
-
|
|
5716
|
+
useEffect9(() => {
|
|
5630
5717
|
if (!state.entryDirty) dispatch({ type: "tender-recorded", rowsSinceFrom: rowsSince(order.payments, state.plan?.from ?? 0), balanceMinor: balance });
|
|
5631
5718
|
}, [order.payments, balance, state.entryDirty, state.plan, dispatch]);
|
|
5632
5719
|
if (stage.kind !== "tender") return null;
|
|
@@ -5648,60 +5735,60 @@ function TenderPane({ sale, state, dispatch, methods }) {
|
|
|
5648
5735
|
const firstPending = order.payments.find((leg) => legStatus(leg) === "pending");
|
|
5649
5736
|
const [onlyLeg] = order.payments;
|
|
5650
5737
|
const cardReference = order.payments.length === 1 && onlyLeg.method === "external" && legStatus(onlyLeg) === "captured" && balance === 0;
|
|
5651
|
-
const hint = noChange ?
|
|
5738
|
+
const hint = noChange ? t("pos_checkout.no_change_for_method", { amount: money(balance), method: method?.title }) : entryChange > 0 ? t("pos_checkout.change_due", { amount: money(entryChange) }) : figures.appliedMinor < balance && figures.entryMinor > 0 ? t("pos_checkout.part_payment_left", { left: money(left) }) : "";
|
|
5652
5739
|
const canComplete = balance === 0 && !order.payments.some(isInMotion);
|
|
5653
5740
|
const cannotTake = figures.appliedMinor <= 0 || noChange;
|
|
5654
5741
|
function take() {
|
|
5655
5742
|
if (!method) return;
|
|
5656
5743
|
const id = method.id === "cash" ? sale.addTender({ method: "cash", amountMinor: figures.entryMinor }) : sale.addTender({ method: "external", amountMinor: figures.appliedMinor, ...reference ? { reference } : {} });
|
|
5657
5744
|
if (id === null) {
|
|
5658
|
-
setRefusal(
|
|
5745
|
+
setRefusal(true);
|
|
5659
5746
|
return;
|
|
5660
5747
|
}
|
|
5661
|
-
setRefusal(
|
|
5748
|
+
setRefusal(false);
|
|
5662
5749
|
setReference("");
|
|
5663
5750
|
dispatch({ type: "tender-started" });
|
|
5664
5751
|
}
|
|
5665
5752
|
return /* @__PURE__ */ jsxs62(View72, { dataSet: { print: "hide" }, testID: "tender-pane", className: "gap-4 p-4", children: [
|
|
5666
5753
|
/* @__PURE__ */ jsxs62(View72, { testID: "tender-headline", className: "gap-1", children: [
|
|
5667
|
-
/* @__PURE__ */
|
|
5668
|
-
/* @__PURE__ */
|
|
5669
|
-
order.paidMinor > 0 ? /* @__PURE__ */
|
|
5670
|
-
order.changeDueMinor > 0 ? /* @__PURE__ */
|
|
5754
|
+
/* @__PURE__ */ jsx110(Text43, { className: "text-sm text-muted-foreground", children: order.paidMinor > 0 ? t("pos_checkout.remaining") : t("common.total") }),
|
|
5755
|
+
/* @__PURE__ */ jsx110(Text43, { testID: "tender-balance", className: "text-4xl font-bold text-foreground", children: money(balance) }),
|
|
5756
|
+
order.paidMinor > 0 ? /* @__PURE__ */ jsx110(Text43, { testID: "tender-paid", className: "text-sm text-muted-foreground", children: t("pos_checkout.paid_of_total", { paid: money(order.paidMinor), total: money(order.totalMinor) }) }) : null,
|
|
5757
|
+
order.changeDueMinor > 0 ? /* @__PURE__ */ jsx110(Text43, { testID: "tender-change", className: "text-lg font-semibold text-success", children: t("pos_checkout.change_due", { amount: money(order.changeDueMinor) }) }) : null
|
|
5671
5758
|
] }),
|
|
5672
5759
|
/* @__PURE__ */ jsxs62(View72, { testID: "tender-ledger", className: "gap-1", children: [
|
|
5673
|
-
order.payments.length === 0 ? /* @__PURE__ */
|
|
5760
|
+
order.payments.length === 0 ? /* @__PURE__ */ jsx110(Text43, { className: "text-muted-foreground", children: t("pos_checkout.no_payments_yet") }) : order.payments.map((leg) => {
|
|
5674
5761
|
const status = legStatus(leg);
|
|
5675
5762
|
const voided = status === "voided";
|
|
5676
5763
|
const descriptor = descriptorOf(leg.method);
|
|
5677
5764
|
return /* @__PURE__ */ jsxs62(View72, { testID: `tender-leg-${leg.id}`, className: "gap-1 border-b border-border py-2", children: [
|
|
5678
5765
|
/* @__PURE__ */ jsxs62(View72, { className: "flex-row items-center gap-2", children: [
|
|
5679
|
-
/* @__PURE__ */
|
|
5680
|
-
/* @__PURE__ */
|
|
5681
|
-
/* @__PURE__ */
|
|
5766
|
+
/* @__PURE__ */ jsx110(Text43, { className: cn89("flex-1 font-semibold text-foreground", voided && "line-through"), children: descriptor?.title ?? leg.method }),
|
|
5767
|
+
/* @__PURE__ */ jsx110(Text43, { className: cn89("text-foreground", voided && "line-through"), children: money(leg.amountMinor) }),
|
|
5768
|
+
/* @__PURE__ */ jsx110(Text43, { testID: `tender-leg-${leg.id}-status`, className: cn89("text-sm font-semibold", STATUS_TONE[status]), children: voided ? t("pos_checkout.cancelled") : t(STATUS_LABEL[status]) })
|
|
5682
5769
|
] }),
|
|
5683
|
-
leg.reference ? /* @__PURE__ */
|
|
5684
|
-
leg === firstPending ? /* @__PURE__ */
|
|
5685
|
-
descriptor && canVoidLeg(leg, descriptor) ? /* @__PURE__ */
|
|
5770
|
+
leg.reference ? /* @__PURE__ */ jsx110(Text43, { className: "text-sm text-muted-foreground", children: leg.reference }) : null,
|
|
5771
|
+
leg === firstPending ? /* @__PURE__ */ jsx110(Text43, { className: "text-sm text-muted-foreground", children: t("pos_checkout.next_leg") }) : null,
|
|
5772
|
+
descriptor && canVoidLeg(leg, descriptor) ? /* @__PURE__ */ jsx110(
|
|
5686
5773
|
Pressable35,
|
|
5687
5774
|
{
|
|
5688
5775
|
testID: `tender-leg-${leg.id}-void`,
|
|
5689
5776
|
accessibilityRole: "button",
|
|
5690
|
-
accessibilityLabel: "
|
|
5777
|
+
accessibilityLabel: t("pos_checkout.cancel_payment"),
|
|
5691
5778
|
onPress: () => sale.voidTender(leg.id),
|
|
5692
5779
|
className: "self-start min-h-11 justify-center px-2",
|
|
5693
|
-
children: /* @__PURE__ */
|
|
5780
|
+
children: /* @__PURE__ */ jsx110(Text43, { className: "text-destructive", children: t("pos_checkout.cancel_payment") })
|
|
5694
5781
|
}
|
|
5695
5782
|
) : null
|
|
5696
5783
|
] }, leg.id);
|
|
5697
5784
|
}),
|
|
5698
|
-
balance === 0 && settled ? /* @__PURE__ */
|
|
5785
|
+
balance === 0 && settled ? /* @__PURE__ */ jsx110(Text43, { className: "text-sm text-success", children: t("pos_checkout.paid_in_full") }) : null
|
|
5699
5786
|
] }),
|
|
5700
|
-
cardReference ? /* @__PURE__ */
|
|
5787
|
+
cardReference ? /* @__PURE__ */ jsx110(
|
|
5701
5788
|
TextInput12,
|
|
5702
5789
|
{
|
|
5703
|
-
accessibilityLabel: "
|
|
5704
|
-
placeholder: "
|
|
5790
|
+
accessibilityLabel: t("tender.terminal_reference"),
|
|
5791
|
+
placeholder: t("tender.terminal_reference"),
|
|
5705
5792
|
maxLength: REFERENCE_MAX,
|
|
5706
5793
|
value: onlyLeg.reference ?? "",
|
|
5707
5794
|
onChangeText: (text) => sale.setTender({ method: "external", amountMinor: onlyLeg.amountMinor, reference: text }),
|
|
@@ -5709,7 +5796,7 @@ function TenderPane({ sale, state, dispatch, methods }) {
|
|
|
5709
5796
|
}
|
|
5710
5797
|
) : null,
|
|
5711
5798
|
balance > 0 ? /* @__PURE__ */ jsxs62(View72, { testID: "tender-entry", className: "gap-3", children: [
|
|
5712
|
-
/* @__PURE__ */
|
|
5799
|
+
/* @__PURE__ */ jsx110(View72, { className: "flex-row flex-wrap gap-2", children: offered.map((tile) => /* @__PURE__ */ jsx110(
|
|
5713
5800
|
Pressable35,
|
|
5714
5801
|
{
|
|
5715
5802
|
testID: `tender-method-${tile.id}`,
|
|
@@ -5717,39 +5804,39 @@ function TenderPane({ sale, state, dispatch, methods }) {
|
|
|
5717
5804
|
accessibilityState: { selected: tile.id === state.methodId },
|
|
5718
5805
|
onPress: () => dispatch({ type: "pick-method", methodId: tile.id, prefillMinor: balance, readerId: null }),
|
|
5719
5806
|
className: cn89(button5, tile.id === state.methodId && "border-primary bg-primary"),
|
|
5720
|
-
children: /* @__PURE__ */
|
|
5807
|
+
children: /* @__PURE__ */ jsx110(Text43, { className: cn89("text-center font-semibold", tile.id === state.methodId ? "text-primary-foreground" : "text-foreground"), children: tile.title })
|
|
5721
5808
|
},
|
|
5722
5809
|
tile.id
|
|
5723
5810
|
)) }),
|
|
5724
|
-
planned ? /* @__PURE__ */
|
|
5725
|
-
/* @__PURE__ */
|
|
5726
|
-
figures.roundingMinor !== 0 ? /* @__PURE__ */
|
|
5727
|
-
/* @__PURE__ */
|
|
5728
|
-
method?.id === "external" ? /* @__PURE__ */
|
|
5811
|
+
planned ? /* @__PURE__ */ jsx110(Text43, { testID: "tender-plan", className: "text-sm text-muted-foreground", children: t("pos_checkout.n_of_ways", { n: planned.label.n, ways: planned.label.ways }) }) : null,
|
|
5812
|
+
/* @__PURE__ */ jsx110(Text43, { testID: "tender-entry-amount", className: cn89("text-3xl font-bold text-foreground", !state.entryDirty && "opacity-70"), children: money(figures.entryMinor) }),
|
|
5813
|
+
figures.roundingMinor !== 0 ? /* @__PURE__ */ jsx110(Text43, { className: "text-sm text-muted-foreground", children: t("pos_checkout.rounded_from", { amount: money(balance) }) }) : null,
|
|
5814
|
+
/* @__PURE__ */ jsx110(Text43, { testID: "tender-entry-hint", className: cn89("min-h-6 text-sm", noChange ? "text-warning" : entryChange > 0 ? "text-success" : "text-muted-foreground"), children: hint }),
|
|
5815
|
+
method?.id === "external" ? /* @__PURE__ */ jsx110(
|
|
5729
5816
|
TextInput12,
|
|
5730
5817
|
{
|
|
5731
|
-
accessibilityLabel: "
|
|
5732
|
-
placeholder: "
|
|
5818
|
+
accessibilityLabel: t("tender.terminal_reference"),
|
|
5819
|
+
placeholder: t("tender.terminal_reference"),
|
|
5733
5820
|
maxLength: REFERENCE_MAX,
|
|
5734
5821
|
value: reference,
|
|
5735
5822
|
onChangeText: setReference,
|
|
5736
5823
|
className: "rounded-md border border-border px-3 py-2 text-foreground"
|
|
5737
5824
|
}
|
|
5738
5825
|
) : null,
|
|
5739
|
-
chips.length ? /* @__PURE__ */
|
|
5826
|
+
chips.length ? /* @__PURE__ */ jsx110(View72, { testID: "tender-quick", className: "flex-row flex-wrap gap-2", children: chips.map((minor, index) => /* @__PURE__ */ jsx110(
|
|
5740
5827
|
Pressable35,
|
|
5741
5828
|
{
|
|
5742
5829
|
testID: index === 0 ? "tender-quick-exact" : `tender-quick-${minor}`,
|
|
5743
5830
|
accessibilityRole: "button",
|
|
5744
5831
|
onPress: () => dispatch({ type: "set-entry", minor }),
|
|
5745
5832
|
className: cn89(button5, state.entryDirty && figures.entryMinor === minor && "border-primary"),
|
|
5746
|
-
children: /* @__PURE__ */
|
|
5833
|
+
children: /* @__PURE__ */ jsx110(Text43, { className: "font-semibold text-foreground", children: index === 0 ? t("pos_checkout.exact_amount", { amount: money(minor) }) : money(minor) })
|
|
5747
5834
|
},
|
|
5748
5835
|
minor
|
|
5749
5836
|
)) }) : null,
|
|
5750
|
-
/* @__PURE__ */
|
|
5751
|
-
refusal ? /* @__PURE__ */
|
|
5752
|
-
method ? /* @__PURE__ */
|
|
5837
|
+
/* @__PURE__ */ jsx110(Keypad, { testID: "tender-keypad", rows: keypadRows(t), onPress: (name) => dispatch({ type: "key", key: name }) }),
|
|
5838
|
+
refusal ? /* @__PURE__ */ jsx110(Text43, { accessibilityRole: "alert", className: "text-destructive", children: t("tender.not_taken") }) : null,
|
|
5839
|
+
method ? /* @__PURE__ */ jsx110(
|
|
5753
5840
|
Pressable35,
|
|
5754
5841
|
{
|
|
5755
5842
|
testID: "tender-take",
|
|
@@ -5757,11 +5844,11 @@ function TenderPane({ sale, state, dispatch, methods }) {
|
|
|
5757
5844
|
disabled: cannotTake,
|
|
5758
5845
|
onPress: take,
|
|
5759
5846
|
className: cn89("rounded-md bg-primary px-4 py-3", cannotTake && "opacity-50"),
|
|
5760
|
-
children: /* @__PURE__ */
|
|
5847
|
+
children: /* @__PURE__ */ jsx110(Text43, { className: "text-center font-semibold text-primary-foreground", children: t("pos_checkout.take_amount_in", { amount: money(figures.appliedMinor), method: method.title }) })
|
|
5761
5848
|
}
|
|
5762
5849
|
) : null
|
|
5763
5850
|
] }) : null,
|
|
5764
|
-
/* @__PURE__ */
|
|
5851
|
+
/* @__PURE__ */ jsx110(
|
|
5765
5852
|
Pressable35,
|
|
5766
5853
|
{
|
|
5767
5854
|
testID: "tender-complete",
|
|
@@ -5769,33 +5856,33 @@ function TenderPane({ sale, state, dispatch, methods }) {
|
|
|
5769
5856
|
disabled: !canComplete,
|
|
5770
5857
|
onPress: sale.complete,
|
|
5771
5858
|
className: cn89("rounded-md bg-primary px-4 py-3", !canComplete && "opacity-50"),
|
|
5772
|
-
children: /* @__PURE__ */
|
|
5859
|
+
children: /* @__PURE__ */ jsx110(Text43, { className: "text-center font-semibold text-primary-foreground", children: t("tender.complete_sale") })
|
|
5773
5860
|
}
|
|
5774
5861
|
),
|
|
5775
|
-
sale.error ? /* @__PURE__ */
|
|
5862
|
+
sale.error ? /* @__PURE__ */ jsx110(Text43, { accessibilityRole: "alert", className: "text-destructive", children: sale.error }) : null,
|
|
5776
5863
|
sale.canContinue ? /* @__PURE__ */ jsxs62(Fragment9, { children: [
|
|
5777
|
-
/* @__PURE__ */
|
|
5778
|
-
/* @__PURE__ */
|
|
5864
|
+
/* @__PURE__ */ jsx110(Text43, { className: "text-foreground", children: t("tender.stored_will_send") }),
|
|
5865
|
+
/* @__PURE__ */ jsx110(Pressable35, { accessibilityRole: "button", onPress: () => sale.continueSale(), className: "rounded-md bg-primary px-4 py-3", children: /* @__PURE__ */ jsx110(Text43, { className: "text-center font-semibold text-primary-foreground", children: t("tender.continue") }) })
|
|
5779
5866
|
] }) : null,
|
|
5780
|
-
/* @__PURE__ */
|
|
5867
|
+
/* @__PURE__ */ jsx110(Pressable35, { accessibilityRole: "button", onPress: sale.cancelTender, className: button5, children: /* @__PURE__ */ jsx110(Text43, { className: "text-center text-foreground", children: t("common.back") }) })
|
|
5781
5868
|
] });
|
|
5782
5869
|
}
|
|
5783
5870
|
|
|
5784
5871
|
// src/sale/tender.tsx
|
|
5785
|
-
import { jsx as
|
|
5872
|
+
import { jsx as jsx111 } from "react/jsx-runtime";
|
|
5786
5873
|
function HostedPane({ sale, method, methods }) {
|
|
5787
5874
|
const [state, dispatch] = useReducer(tenderReducer, { methodId: method, balanceMinor: sale.order.balanceDueMinor }, initTenderState);
|
|
5788
|
-
return /* @__PURE__ */
|
|
5875
|
+
return /* @__PURE__ */ jsx111(TenderPane, { sale, state, dispatch, methods });
|
|
5789
5876
|
}
|
|
5790
5877
|
function Tender({ sale, methods }) {
|
|
5791
|
-
return sale.stage.kind === "tender" ? /* @__PURE__ */
|
|
5878
|
+
return sale.stage.kind === "tender" ? /* @__PURE__ */ jsx111(HostedPane, { sale, method: sale.stage.method, methods }) : null;
|
|
5792
5879
|
}
|
|
5793
5880
|
function SplitTender(props) {
|
|
5794
|
-
return /* @__PURE__ */
|
|
5881
|
+
return /* @__PURE__ */ jsx111(Tender, { ...props });
|
|
5795
5882
|
}
|
|
5796
5883
|
|
|
5797
5884
|
// src/sale/catalogue.tsx
|
|
5798
|
-
import { useEffect as
|
|
5885
|
+
import { useEffect as useEffect10, useMemo as useMemo7, useRef as useRef11, useState as useState27 } from "react";
|
|
5799
5886
|
import { Pressable as Pressable37, Text as Text45, View as View74 } from "react-native";
|
|
5800
5887
|
import { useStockOverlaid as useStockOverlaid2, useStockOverlayAsOf } from "@tallyui/core";
|
|
5801
5888
|
import {
|
|
@@ -5817,7 +5904,7 @@ import {
|
|
|
5817
5904
|
// src/sale/product-filter-bar.tsx
|
|
5818
5905
|
import { Pressable as Pressable36, ScrollView as ScrollView14, Text as Text44, View as View73 } from "react-native";
|
|
5819
5906
|
import { cn as cn90 } from "@tallyui/theme";
|
|
5820
|
-
import { jsx as
|
|
5907
|
+
import { jsx as jsx112, jsxs as jsxs63 } from "react/jsx-runtime";
|
|
5821
5908
|
var DEFAULT_PRODUCT_FILTERS = { inStock: true, featured: false, onSale: false };
|
|
5822
5909
|
var PRODUCT_FILTER_CHIPS = ["inStock", "featured", "onSale", "category", "tag", "brand"];
|
|
5823
5910
|
var LABELS2 = {
|
|
@@ -5833,7 +5920,7 @@ function isToggle(chip) {
|
|
|
5833
5920
|
}
|
|
5834
5921
|
function ProductFilterBar({ value, onChange, chips = PRODUCT_FILTER_CHIPS, onTermPress, className }) {
|
|
5835
5922
|
const shown = chips.filter((chip) => isToggle(chip) || onTermPress);
|
|
5836
|
-
return /* @__PURE__ */
|
|
5923
|
+
return /* @__PURE__ */ jsx112(ScrollView14, { horizontal: true, showsHorizontalScrollIndicator: false, className, contentContainerClassName: "flex-row gap-2", children: shown.map((chip) => {
|
|
5837
5924
|
const on = isToggle(chip) && value[chip];
|
|
5838
5925
|
return /* @__PURE__ */ jsxs63(
|
|
5839
5926
|
Pressable36,
|
|
@@ -5847,8 +5934,8 @@ function ProductFilterBar({ value, onChange, chips = PRODUCT_FILTER_CHIPS, onTer
|
|
|
5847
5934
|
on ? "border-primary/30 bg-primary/10" : "border-border bg-card"
|
|
5848
5935
|
),
|
|
5849
5936
|
children: [
|
|
5850
|
-
/* @__PURE__ */
|
|
5851
|
-
on && chip === "inStock" ? /* @__PURE__ */
|
|
5937
|
+
/* @__PURE__ */ jsx112(Text44, { className: cn90("text-sm", on ? "text-primary" : "text-foreground"), children: LABELS2[chip] }),
|
|
5938
|
+
on && chip === "inStock" ? /* @__PURE__ */ jsx112(View73, { className: "text-primary", children: /* @__PURE__ */ jsx112(XIcon, { size: 14 }) }) : null
|
|
5852
5939
|
]
|
|
5853
5940
|
},
|
|
5854
5941
|
chip
|
|
@@ -5857,7 +5944,7 @@ function ProductFilterBar({ value, onChange, chips = PRODUCT_FILTER_CHIPS, onTer
|
|
|
5857
5944
|
}
|
|
5858
5945
|
|
|
5859
5946
|
// src/sale/catalogue.tsx
|
|
5860
|
-
import { jsx as
|
|
5947
|
+
import { jsx as jsx113, jsxs as jsxs64 } from "react/jsx-runtime";
|
|
5861
5948
|
var STOCK_LABEL = {
|
|
5862
5949
|
in_stock: "In Stock",
|
|
5863
5950
|
out_of_stock: "Out of Stock",
|
|
@@ -5906,7 +5993,7 @@ function Catalogue({
|
|
|
5906
5993
|
filters: filtersProp,
|
|
5907
5994
|
onFiltersChange
|
|
5908
5995
|
}) {
|
|
5909
|
-
const [initial] =
|
|
5996
|
+
const [initial] = useState27(() => {
|
|
5910
5997
|
const state2 = normalizeCatalogueViewState({ ...DEFAULT_CATALOGUE_VIEW_STATE, ...defaultViewState });
|
|
5911
5998
|
if (viewState !== void 0 || !loadViewState) return { state: state2 };
|
|
5912
5999
|
try {
|
|
@@ -5918,10 +6005,10 @@ function Catalogue({
|
|
|
5918
6005
|
return { state: state2, failed: true, error };
|
|
5919
6006
|
}
|
|
5920
6007
|
});
|
|
5921
|
-
const [internalState, setInternalState] =
|
|
6008
|
+
const [internalState, setInternalState] = useState27(initial.state);
|
|
5922
6009
|
const state = viewState ?? internalState;
|
|
5923
|
-
const cashierChanged =
|
|
5924
|
-
|
|
6010
|
+
const cashierChanged = useRef11(false);
|
|
6011
|
+
useEffect10(() => {
|
|
5925
6012
|
let mounted = true;
|
|
5926
6013
|
if (initial.loaded) onStateChange?.(initial.loaded);
|
|
5927
6014
|
if (initial.failed) onViewStateError?.(initial.error);
|
|
@@ -5953,40 +6040,40 @@ function Catalogue({
|
|
|
5953
6040
|
onViewStateError?.(error);
|
|
5954
6041
|
}
|
|
5955
6042
|
}
|
|
5956
|
-
const [internalFilters, setInternalFilters] =
|
|
6043
|
+
const [internalFilters, setInternalFilters] = useState27(DEFAULT_PRODUCT_FILTERS);
|
|
5957
6044
|
const filters = filtersProp ?? internalFilters;
|
|
5958
6045
|
function changeFilters(next) {
|
|
5959
6046
|
if (filtersProp === void 0) setInternalFilters(next);
|
|
5960
6047
|
onFiltersChange?.(next);
|
|
5961
6048
|
}
|
|
5962
|
-
const quantities =
|
|
6049
|
+
const quantities = useMemo7(() => cartQuantities(cartLines ?? []), [cartLines]);
|
|
5963
6050
|
const isLoading = loading ?? (lastSyncedAt === null && pullError == null);
|
|
5964
6051
|
const shown = useStockOverlaid2(products);
|
|
5965
|
-
const categoryList =
|
|
6052
|
+
const categoryList = useMemo7(() => categories ?? listCategories(shown, traits), [categories, shown, traits]);
|
|
5966
6053
|
const activeCategory = showCategoryNav ? categoryList.find((category) => category.id === state.categoryId) : void 0;
|
|
5967
6054
|
const suppliedItems = useStockOverlaid2(items ?? products);
|
|
5968
6055
|
const overlayAsOf = useStockOverlayAsOf();
|
|
5969
6056
|
const parsedOverlayAsOf = overlayAsOf ? new Date(overlayAsOf) : void 0;
|
|
5970
6057
|
const validOverlayAsOf = parsedOverlayAsOf && !isNaN(parsedOverlayAsOf.getTime()) ? parsedOverlayAsOf : void 0;
|
|
5971
6058
|
const stockAsOf = laterOf(laterOf(lastStockCheckAt, validOverlayAsOf), lastSyncedAt);
|
|
5972
|
-
const [query, setQuery] =
|
|
5973
|
-
const [chooserId, setChooserId] =
|
|
5974
|
-
const [width, setWidth] =
|
|
6059
|
+
const [query, setQuery] = useState27("");
|
|
6060
|
+
const [chooserId, setChooserId] = useState27(null);
|
|
6061
|
+
const [width, setWidth] = useState27(0);
|
|
5975
6062
|
const columns = resolveGridColumns(state.gridColumns, width);
|
|
5976
|
-
const entries =
|
|
6063
|
+
const entries = useMemo7(() => catalogueEntries(shown, traits, { currency }), [shown, traits, currency]);
|
|
5977
6064
|
const stockFiltered = showFilterBar && filters.inStock;
|
|
5978
|
-
const results =
|
|
6065
|
+
const results = useMemo7(() => {
|
|
5979
6066
|
if (items !== void 0) return suppliedItems;
|
|
5980
6067
|
const matched = searchProducts(activeCategory ? shown.filter((doc) => inCategory(doc, activeCategory.id, traits)) : shown, query, traits);
|
|
5981
6068
|
const filtered = stockFiltered ? matched.filter((doc) => !["out_of_stock", "backorder"].includes(traits.getStock(doc).status)) : matched;
|
|
5982
6069
|
return state.sort ? sortProducts2(filtered, state.sort, (doc, field) => productSortValue2(doc, field, traits, { currency })) : filtered;
|
|
5983
6070
|
}, [items, suppliedItems, shown, query, traits, state.sort, currency, showCategoryNav, activeCategory, stockFiltered]);
|
|
5984
|
-
const choices =
|
|
5985
|
-
|
|
6071
|
+
const choices = useMemo7(() => chooserId === null ? [] : entries.filter((entry) => traits.getId(entry.product) === chooserId), [entries, chooserId, traits]);
|
|
6072
|
+
useEffect10(() => {
|
|
5986
6073
|
if (chooserId !== null && choices.length === 0) setChooserId(null);
|
|
5987
6074
|
}, [chooserId, choices]);
|
|
5988
|
-
const [pickEntry, setPickEntry] =
|
|
5989
|
-
const [picks, setPicks] =
|
|
6075
|
+
const [pickEntry, setPickEntry] = useState27(null);
|
|
6076
|
+
const [picks, setPicks] = useState27({});
|
|
5990
6077
|
function anyGroupsOf(entry) {
|
|
5991
6078
|
const fixed = entry.variant.options ?? {};
|
|
5992
6079
|
return (traits.getVariantOptions?.(entry.product) ?? []).filter(({ id, name, values }) => id === void 0 && !Object.prototype.hasOwnProperty.call(fixed, name) && values.length > 0);
|
|
@@ -5997,7 +6084,7 @@ function Catalogue({
|
|
|
5997
6084
|
setPickEntry(null);
|
|
5998
6085
|
setPicks({});
|
|
5999
6086
|
}
|
|
6000
|
-
|
|
6087
|
+
useEffect10(() => {
|
|
6001
6088
|
if (pickEntry && !entries.some((entry) => traits.getId(entry.product) === traits.getId(pickEntry.product) && entry.variant.id === pickEntry.variant.id)) closePicker();
|
|
6002
6089
|
}, [pickEntry, entries, traits]);
|
|
6003
6090
|
function select(entry) {
|
|
@@ -6015,10 +6102,10 @@ function Catalogue({
|
|
|
6015
6102
|
setChooserId(traits.getId(product));
|
|
6016
6103
|
}
|
|
6017
6104
|
}
|
|
6018
|
-
const emptyState = /* @__PURE__ */
|
|
6105
|
+
const emptyState = /* @__PURE__ */ jsx113(Text45, { className: "mt-10 text-center text-sm text-muted-foreground", children: query.trim() ? `No products match "${query.trim()}".` : activeCategory ? `No products in ${activeCategory.name}.` : stockFiltered && items === void 0 && shown.length > 0 ? "No products in stock." : isLoading ? "Loading products\u2026" : "No products yet." });
|
|
6019
6106
|
return /* @__PURE__ */ jsxs64(View74, { className: "flex-1", onLayout: (event) => setWidth(event.nativeEvent.layout.width), children: [
|
|
6020
6107
|
/* @__PURE__ */ jsxs64(View74, { className: "gap-2 border-b border-border bg-card px-4 pb-3 pt-3", children: [
|
|
6021
|
-
/* @__PURE__ */
|
|
6108
|
+
/* @__PURE__ */ jsx113(
|
|
6022
6109
|
SearchInput,
|
|
6023
6110
|
{
|
|
6024
6111
|
value: query,
|
|
@@ -6038,16 +6125,16 @@ function Catalogue({
|
|
|
6038
6125
|
}
|
|
6039
6126
|
}
|
|
6040
6127
|
),
|
|
6041
|
-
showFilterBar ? /* @__PURE__ */
|
|
6128
|
+
showFilterBar ? /* @__PURE__ */ jsx113(ProductFilterBar, { value: filters, onChange: changeFilters, chips: filterChips }) : null,
|
|
6042
6129
|
statusText || statusAccessory || showViewToggle ? /* @__PURE__ */ jsxs64(View74, { testID: "catalogue-status-row", className: "flex-row items-center gap-2", children: [
|
|
6043
6130
|
statusText ? /* @__PURE__ */ jsxs64(Text45, { className: "flex-1 text-xs text-muted-foreground", numberOfLines: statusAccessory ? 1 : void 0, children: [
|
|
6044
6131
|
statusText,
|
|
6045
6132
|
query.trim() ? ` \xB7 ${results.length.toLocaleString()} matching` : ""
|
|
6046
6133
|
] }) : null,
|
|
6047
6134
|
statusAccessory,
|
|
6048
|
-
showViewToggle ? /* @__PURE__ */
|
|
6135
|
+
showViewToggle ? /* @__PURE__ */ jsx113(ViewToggle, { value: state.view, onChange: (view) => changeState({ type: "setView", view }) }) : null
|
|
6049
6136
|
] }) : null,
|
|
6050
|
-
showCategoryNav ? /* @__PURE__ */
|
|
6137
|
+
showCategoryNav ? /* @__PURE__ */ jsx113(
|
|
6051
6138
|
CategoryNav,
|
|
6052
6139
|
{
|
|
6053
6140
|
categories: [{ id: "", name: "All products" }, ...categoryList],
|
|
@@ -6056,9 +6143,9 @@ function Catalogue({
|
|
|
6056
6143
|
}
|
|
6057
6144
|
) : null,
|
|
6058
6145
|
pickEntry ? /* @__PURE__ */ jsxs64(View74, { accessibilityLabel: "Choose options", className: "gap-2", children: [
|
|
6059
|
-
/* @__PURE__ */
|
|
6060
|
-
/* @__PURE__ */
|
|
6061
|
-
/* @__PURE__ */
|
|
6146
|
+
/* @__PURE__ */ jsx113(Text45, { className: "font-semibold text-foreground", children: pickEntry.variant.title ?? traits.getName(pickEntry.product) }),
|
|
6147
|
+
/* @__PURE__ */ jsx113(ProductVariantPicker, { options: anyGroups.map(({ name, values }) => ({ name, values })), selected: picks, onSelect: setPicks }),
|
|
6148
|
+
/* @__PURE__ */ jsx113(
|
|
6062
6149
|
Pressable37,
|
|
6063
6150
|
{
|
|
6064
6151
|
accessibilityRole: "button",
|
|
@@ -6068,10 +6155,10 @@ function Catalogue({
|
|
|
6068
6155
|
closePicker();
|
|
6069
6156
|
},
|
|
6070
6157
|
className: `rounded-md border border-border bg-card px-4 py-3 ${allPicked ? "" : "opacity-50"}`,
|
|
6071
|
-
children: /* @__PURE__ */
|
|
6158
|
+
children: /* @__PURE__ */ jsx113(Text45, { className: "text-center text-foreground", children: "Add to cart" })
|
|
6072
6159
|
}
|
|
6073
6160
|
),
|
|
6074
|
-
/* @__PURE__ */
|
|
6161
|
+
/* @__PURE__ */ jsx113(Pressable37, { accessibilityRole: "button", onPress: closePicker, className: "rounded-md border border-border bg-card px-4 py-3", children: /* @__PURE__ */ jsx113(Text45, { className: "text-center text-foreground", children: "Cancel" }) })
|
|
6075
6162
|
] }) : choices.length > 0 ? /* @__PURE__ */ jsxs64(View74, { accessibilityLabel: "Choose variant", className: "gap-2", children: [
|
|
6076
6163
|
choices.map((entry) => /* @__PURE__ */ jsxs64(
|
|
6077
6164
|
Pressable37,
|
|
@@ -6080,9 +6167,9 @@ function Catalogue({
|
|
|
6080
6167
|
onPress: () => select(entry),
|
|
6081
6168
|
className: "gap-1 rounded-md border border-border p-3",
|
|
6082
6169
|
children: [
|
|
6083
|
-
/* @__PURE__ */
|
|
6084
|
-
/* @__PURE__ */
|
|
6085
|
-
/* @__PURE__ */
|
|
6170
|
+
/* @__PURE__ */ jsx113(Text45, { className: "font-semibold text-foreground", children: entry.variant.title }),
|
|
6171
|
+
/* @__PURE__ */ jsx113(Text45, { className: "text-muted-foreground", children: entry.variant.sku }),
|
|
6172
|
+
/* @__PURE__ */ jsx113(Text45, { className: "text-foreground", children: variantPriceLabel(entry.variant, currency) }),
|
|
6086
6173
|
/* @__PURE__ */ jsxs64(Text45, { className: "text-muted-foreground", children: [
|
|
6087
6174
|
STOCK_LABEL[entry.variant.stock.status],
|
|
6088
6175
|
" \xB7 ",
|
|
@@ -6092,10 +6179,10 @@ function Catalogue({
|
|
|
6092
6179
|
},
|
|
6093
6180
|
entry.variant.id
|
|
6094
6181
|
)),
|
|
6095
|
-
/* @__PURE__ */
|
|
6182
|
+
/* @__PURE__ */ jsx113(Pressable37, { accessibilityRole: "button", onPress: () => setChooserId(null), className: "rounded-md border border-border bg-card px-4 py-3", children: /* @__PURE__ */ jsx113(Text45, { className: "text-center text-foreground", children: "Cancel" }) })
|
|
6096
6183
|
] }) : null
|
|
6097
6184
|
] }),
|
|
6098
|
-
state.view === "table" ? /* @__PURE__ */
|
|
6185
|
+
state.view === "table" ? /* @__PURE__ */ jsx113(
|
|
6099
6186
|
ProductTable,
|
|
6100
6187
|
{
|
|
6101
6188
|
items: results,
|
|
@@ -6105,7 +6192,7 @@ function Catalogue({
|
|
|
6105
6192
|
onSelect: selectProduct,
|
|
6106
6193
|
emptyState
|
|
6107
6194
|
}
|
|
6108
|
-
) : /* @__PURE__ */
|
|
6195
|
+
) : /* @__PURE__ */ jsx113(
|
|
6109
6196
|
ProductGrid,
|
|
6110
6197
|
{
|
|
6111
6198
|
items: results,
|
|
@@ -6116,12 +6203,12 @@ function Catalogue({
|
|
|
6116
6203
|
// inside the card and centred with the rest, rather than adding a slot to ProductCard (out of scope for TV6b).
|
|
6117
6204
|
/* @__PURE__ */ jsxs64(Pressable37, { accessibilityRole: "button", testID: `product-tile-${traits.getName(product)}`, onPress: () => selectProduct(product), children: [
|
|
6118
6205
|
/* @__PURE__ */ jsxs64(VStack, { space: "sm", className: "items-center rounded-lg border border-border bg-card p-3", children: [
|
|
6119
|
-
/* @__PURE__ */
|
|
6120
|
-
/* @__PURE__ */
|
|
6121
|
-
/* @__PURE__ */
|
|
6122
|
-
/* @__PURE__ */
|
|
6206
|
+
/* @__PURE__ */ jsx113(ProductImage, { doc: product, size: 80, className: "rounded-md" }),
|
|
6207
|
+
/* @__PURE__ */ jsx113(ProductTitle, { doc: product, className: "text-sm", numberOfLines: 2 }),
|
|
6208
|
+
/* @__PURE__ */ jsx113(ProductPrice, { doc: product }),
|
|
6209
|
+
/* @__PURE__ */ jsx113(ProductStockBadge, { doc: product, showAsOf: false, className: "self-center" })
|
|
6123
6210
|
] }),
|
|
6124
|
-
/* @__PURE__ */
|
|
6211
|
+
/* @__PURE__ */ jsx113(
|
|
6125
6212
|
InCartBadge,
|
|
6126
6213
|
{
|
|
6127
6214
|
count: quantities.get(traits.getId(product)) ?? 0,
|
|
@@ -6138,7 +6225,7 @@ function Catalogue({
|
|
|
6138
6225
|
}
|
|
6139
6226
|
|
|
6140
6227
|
// src/sale/receipt.tsx
|
|
6141
|
-
import { useEffect as
|
|
6228
|
+
import { useEffect as useEffect11 } from "react";
|
|
6142
6229
|
import { Pressable as Pressable38, Text as Text46, View as View75 } from "react-native";
|
|
6143
6230
|
import { formatMoney as formatMoney19 } from "@tallyui/core";
|
|
6144
6231
|
import { buildReceiptData as buildReceiptData3, noteDelivery } from "@tallyui/pos";
|
|
@@ -6161,7 +6248,7 @@ function orderReference(order) {
|
|
|
6161
6248
|
var NOTE_NOT_SENT = "The note couldn't be sent to the store.";
|
|
6162
6249
|
|
|
6163
6250
|
// src/sale/receipt.tsx
|
|
6164
|
-
import { Fragment as Fragment10, jsx as
|
|
6251
|
+
import { Fragment as Fragment10, jsx as jsx114, jsxs as jsxs65 } from "react/jsx-runtime";
|
|
6165
6252
|
var defaultFormatDate = (iso) => new Intl.DateTimeFormat(void 0, { dateStyle: "medium", timeStyle: "short" }).format(new Date(iso));
|
|
6166
6253
|
function Receipt(props) {
|
|
6167
6254
|
const {
|
|
@@ -6173,7 +6260,7 @@ function Receipt(props) {
|
|
|
6173
6260
|
footerSlot,
|
|
6174
6261
|
doneLabel = "New sale"
|
|
6175
6262
|
} = props;
|
|
6176
|
-
|
|
6263
|
+
useEffect11(injectPrintStyle, []);
|
|
6177
6264
|
const order = props.receipt === void 0 ? props.order : void 0;
|
|
6178
6265
|
const receipt = props.receipt === void 0 ? buildReceiptData3(props.order, {
|
|
6179
6266
|
storeName: props.store.name,
|
|
@@ -6184,20 +6271,20 @@ function Receipt(props) {
|
|
|
6184
6271
|
}) : props.receipt;
|
|
6185
6272
|
const money = (amount) => formatMoney19({ amount, currency: receipt.currency }) ?? "";
|
|
6186
6273
|
const row = (label, amount, bold = false, key) => /* @__PURE__ */ jsxs65(View75, { accessibilityLabel: `${label}: ${amount}`, className: "flex-row justify-between gap-4", children: [
|
|
6187
|
-
/* @__PURE__ */
|
|
6188
|
-
/* @__PURE__ */
|
|
6274
|
+
/* @__PURE__ */ jsx114(Text46, { className: `text-foreground ${bold ? "font-semibold" : ""}`, children: label }),
|
|
6275
|
+
/* @__PURE__ */ jsx114(Text46, { className: `text-right text-foreground ${bold ? "font-semibold" : ""}`, children: amount })
|
|
6189
6276
|
] }, key);
|
|
6190
6277
|
const { totals } = receipt;
|
|
6191
6278
|
const lineDiscountMinor = totals.discountMinor - receipt.orderDiscountMinor;
|
|
6192
6279
|
const taxRows = totals.taxLines.map((line, index) => row(`${totals.taxInclusive ? "incl. " : ""}${taxLabel(line.ratePpm)}`, money(line.amountMinor), false, index));
|
|
6193
6280
|
return /* @__PURE__ */ jsxs65(Fragment10, { children: [
|
|
6194
|
-
topInset > 0 ? /* @__PURE__ */
|
|
6281
|
+
topInset > 0 ? /* @__PURE__ */ jsx114(View75, { dataSet: { print: "hide" }, style: { height: topInset, flexShrink: 0 } }) : null,
|
|
6195
6282
|
/* @__PURE__ */ jsxs65(View75, { className: "w-full max-w-md self-center gap-3 p-4 bg-card", children: [
|
|
6196
|
-
/* @__PURE__ */
|
|
6197
|
-
receipt.header.storeAddress ? /* @__PURE__ */
|
|
6198
|
-
/* @__PURE__ */
|
|
6199
|
-
receipt.fiscal.is_reprint ? /* @__PURE__ */
|
|
6200
|
-
/* @__PURE__ */
|
|
6283
|
+
/* @__PURE__ */ jsx114(Text46, { className: "text-lg font-semibold text-foreground", children: receipt.header.storeName }),
|
|
6284
|
+
receipt.header.storeAddress ? /* @__PURE__ */ jsx114(Text46, { className: "text-muted-foreground", children: receipt.header.storeAddress }) : null,
|
|
6285
|
+
/* @__PURE__ */ jsx114(Text46, { testID: "receipt-order", className: "text-foreground", children: posOrder ? `Order ${orderReference(posOrder)}` : order ? `Order ${receipt.header.orderNumber.slice(-8)} (draft)` : `Order ${receipt.header.orderNumber}` }),
|
|
6286
|
+
receipt.fiscal.is_reprint ? /* @__PURE__ */ jsx114(Text46, { testID: "receipt-reprint", className: "text-foreground", children: `Reprint ${receipt.fiscal.reprint_count}` }) : null,
|
|
6287
|
+
/* @__PURE__ */ jsx114(Text46, { className: "text-muted-foreground", children: formatDate(order ? posOrder?.createdAt ?? receipt.header.date : receipt.header.date) }),
|
|
6201
6288
|
order || receipt.header.cashier ? /* @__PURE__ */ jsxs65(Text46, { className: "text-muted-foreground", children: [
|
|
6202
6289
|
"Cashier: ",
|
|
6203
6290
|
receipt.header.cashier
|
|
@@ -6211,10 +6298,10 @@ function Receipt(props) {
|
|
|
6211
6298
|
receipt.header.customer
|
|
6212
6299
|
] }),
|
|
6213
6300
|
receipt.lineItems.map((line, index) => /* @__PURE__ */ jsxs65(View75, { children: [
|
|
6214
|
-
/* @__PURE__ */
|
|
6215
|
-
Object.entries(line.attributes ?? {}).map(([name, value]) => /* @__PURE__ */
|
|
6301
|
+
/* @__PURE__ */ jsx114(Text46, { className: "text-foreground", children: line.name }),
|
|
6302
|
+
Object.entries(line.attributes ?? {}).map(([name, value]) => /* @__PURE__ */ jsx114(Text46, { className: "text-muted-foreground", children: `${name}: ${value}` }, name)),
|
|
6216
6303
|
row(`${line.quantity} \xD7 ${money(line.unitPriceMinor)}`, money(line.displayAmountMinor)),
|
|
6217
|
-
line.displayDiscounts.map((discount, i) => /* @__PURE__ */
|
|
6304
|
+
line.displayDiscounts.map((discount, i) => /* @__PURE__ */ jsx114(View75, { className: "pl-4", children: row(`${order ? discountLabel(
|
|
6218
6305
|
order.lineItems[index].discounts[i],
|
|
6219
6306
|
receipt.currency
|
|
6220
6307
|
) : discount.label} off`, `\u2212${money(discount.amountMinor)}`) }, i))
|
|
@@ -6234,22 +6321,22 @@ function Receipt(props) {
|
|
|
6234
6321
|
)),
|
|
6235
6322
|
order || receipt.changeDueMinor > 0 ? row("Change", money(receipt.changeDueMinor)) : null,
|
|
6236
6323
|
receipt.footer.note ? /* @__PURE__ */ jsxs65(View75, { testID: "receipt-note", className: "gap-1", children: [
|
|
6237
|
-
/* @__PURE__ */
|
|
6238
|
-
receipt.footer.noteNotSent || posOrder !== void 0 && noteDelivery(posOrder) === "not_sent" ? /* @__PURE__ */
|
|
6324
|
+
/* @__PURE__ */ jsx114(Text46, { className: "text-foreground", children: receipt.footer.note }),
|
|
6325
|
+
receipt.footer.noteNotSent || posOrder !== void 0 && noteDelivery(posOrder) === "not_sent" ? /* @__PURE__ */ jsx114(View75, { dataSet: { print: "hide" }, children: /* @__PURE__ */ jsx114(Text46, { testID: "receipt-note-not-sent", className: "text-destructive", children: NOTE_NOT_SENT }) }) : null
|
|
6239
6326
|
] }) : null,
|
|
6240
|
-
footerSlot ? /* @__PURE__ */
|
|
6327
|
+
footerSlot ? /* @__PURE__ */ jsx114(View75, { testID: "receipt-footer", className: "mt-3 items-center border-t border-dashed border-border pt-3", children: footerSlot }) : null,
|
|
6241
6328
|
/* @__PURE__ */ jsxs65(View75, { dataSet: { print: "hide" }, className: "flex-row gap-4", children: [
|
|
6242
|
-
/* @__PURE__ */
|
|
6329
|
+
/* @__PURE__ */ jsx114(Pressable38, { accessibilityRole: "button", onPress: () => {
|
|
6243
6330
|
if (typeof window !== "undefined" && typeof window.print === "function") window.print();
|
|
6244
|
-
}, className: "rounded-md border border-border bg-card px-4 py-3", children: /* @__PURE__ */
|
|
6245
|
-
/* @__PURE__ */
|
|
6331
|
+
}, className: "rounded-md border border-border bg-card px-4 py-3", children: /* @__PURE__ */ jsx114(Text46, { className: "text-center text-foreground", children: "Print receipt" }) }),
|
|
6332
|
+
/* @__PURE__ */ jsx114(Pressable38, { accessibilityRole: "button", onPress: newSale, className: "rounded-md bg-primary px-4 py-3", children: /* @__PURE__ */ jsx114(Text46, { className: "text-center font-semibold text-primary-foreground", children: doneLabel }) })
|
|
6246
6333
|
] })
|
|
6247
6334
|
] })
|
|
6248
6335
|
] });
|
|
6249
6336
|
}
|
|
6250
6337
|
|
|
6251
6338
|
// src/sale/sync-status.tsx
|
|
6252
|
-
import { useEffect as
|
|
6339
|
+
import { useEffect as useEffect12, useRef as useRef12, useState as useState28 } from "react";
|
|
6253
6340
|
import { AccessibilityInfo as AccessibilityInfo2, Platform as Platform9, Text as Text47, View as View76 } from "react-native";
|
|
6254
6341
|
|
|
6255
6342
|
// src/sale/since-text.ts
|
|
@@ -6259,7 +6346,7 @@ function sinceText(clock) {
|
|
|
6259
6346
|
}
|
|
6260
6347
|
|
|
6261
6348
|
// src/sale/sync-status.tsx
|
|
6262
|
-
import { Fragment as Fragment11, jsx as
|
|
6349
|
+
import { Fragment as Fragment11, jsx as jsx115, jsxs as jsxs66 } from "react/jsx-runtime";
|
|
6263
6350
|
var PULL_NOTICE_TEXT = {
|
|
6264
6351
|
unauthorized: {
|
|
6265
6352
|
line: () => "Products aren't updating: this till needs to sign in to the online store again.",
|
|
@@ -6301,8 +6388,8 @@ var SALES_REFUSED = "The online store refused the last send. This till will try
|
|
|
6301
6388
|
var TILL_UPDATES_REFUSED = "The online store refused the last send. This till will try again with the next till update, or when the app is reopened.";
|
|
6302
6389
|
var count = (n, noun) => `${n} ${noun}${n === 1 ? "" : "s"}`;
|
|
6303
6390
|
function useAnnounceOnIos(...texts) {
|
|
6304
|
-
const announced =
|
|
6305
|
-
|
|
6391
|
+
const announced = useRef12(texts);
|
|
6392
|
+
useEffect12(() => {
|
|
6306
6393
|
const changed = texts.filter((text, index) => text && text !== announced.current[index]);
|
|
6307
6394
|
announced.current = texts;
|
|
6308
6395
|
if (changed.length > 0 && Platform9.OS === "ios") AccessibilityInfo2.announceForAccessibility(changed.join(" "));
|
|
@@ -6311,8 +6398,8 @@ function useAnnounceOnIos(...texts) {
|
|
|
6311
6398
|
function SyncStatus({ state, registerState, pluginName = "the POS plugin", pullNotice }) {
|
|
6312
6399
|
const updates = registerState?.pending ?? 0;
|
|
6313
6400
|
const outbox = state.pending === 0 && registerState?.pending ? registerState : state;
|
|
6314
|
-
const [now, setNow] =
|
|
6315
|
-
|
|
6401
|
+
const [now, setNow] = useState28(Date.now);
|
|
6402
|
+
useEffect12(() => {
|
|
6316
6403
|
setNow(Date.now());
|
|
6317
6404
|
if (!outbox.nextAttemptAt) return;
|
|
6318
6405
|
const timer = setInterval(() => setNow(Date.now()), 1e3);
|
|
@@ -6337,22 +6424,22 @@ function SyncStatus({ state, registerState, pluginName = "the POS plugin", pullN
|
|
|
6337
6424
|
const oneDetail = pullNotice?.code === "missing_plugin" && !!backendMissing;
|
|
6338
6425
|
return /* @__PURE__ */ jsxs66(View76, { children: [
|
|
6339
6426
|
notice ? /* @__PURE__ */ jsxs66(Fragment11, { children: [
|
|
6340
|
-
/* @__PURE__ */
|
|
6341
|
-
oneDetail ? null : /* @__PURE__ */
|
|
6427
|
+
/* @__PURE__ */ jsx115(Text47, { accessibilityLiveRegion: "polite", className: "px-4 py-2 text-xs text-muted-foreground", children: notice.line }),
|
|
6428
|
+
oneDetail ? null : /* @__PURE__ */ jsx115(Text47, { className: "px-4 pb-2 text-xs text-muted-foreground", children: notice.detail })
|
|
6342
6429
|
] }) : null,
|
|
6343
|
-
/* @__PURE__ */
|
|
6344
|
-
doing ? /* @__PURE__ */
|
|
6345
|
-
refused ? /* @__PURE__ */
|
|
6346
|
-
oneDetail && notice ? /* @__PURE__ */
|
|
6430
|
+
/* @__PURE__ */ jsx115(Text47, { accessibilityLabel: spoken, accessibilityLiveRegion: "polite", className: "px-4 py-2 text-xs text-muted-foreground", children: spoken }),
|
|
6431
|
+
doing ? /* @__PURE__ */ jsx115(Text47, { className: "px-4 pb-2 text-xs text-muted-foreground", children: doing }) : null,
|
|
6432
|
+
refused ? /* @__PURE__ */ jsx115(Text47, { className: "px-4 pb-2 text-xs text-muted-foreground", children: REFUSED_DETAIL }) : null,
|
|
6433
|
+
oneDetail && notice ? /* @__PURE__ */ jsx115(Text47, { className: "px-4 pb-2 text-xs text-muted-foreground", children: notice.detail }) : backendMissing ? /* @__PURE__ */ jsx115(Text47, { className: "px-4 pb-2 text-xs text-muted-foreground", children: BACKEND_MISSING_DETAIL.replace("{pluginName}", () => pluginName).replace("{lastTime}", () => upToDate ? " the last time it checked" : "") }) : null
|
|
6347
6434
|
] });
|
|
6348
6435
|
}
|
|
6349
6436
|
|
|
6350
6437
|
// src/sale/orders-list.tsx
|
|
6351
|
-
import { useEffect as
|
|
6438
|
+
import { useEffect as useEffect13, useRef as useRef13, useState as useState29 } from "react";
|
|
6352
6439
|
import { Pressable as Pressable39, ScrollView as ScrollView15, Text as Text48, View as View77 } from "react-native";
|
|
6353
6440
|
import { formatMoney as formatMoney20, knownWarnings } from "@tallyui/core";
|
|
6354
6441
|
import { isRequeueable, needsAttention, noteDelivery as noteDelivery2 } from "@tallyui/pos";
|
|
6355
|
-
import { jsx as
|
|
6442
|
+
import { jsx as jsx116, jsxs as jsxs67 } from "react/jsx-runtime";
|
|
6356
6443
|
var STATUS_LABEL2 = { pending: "Waiting to sync", applied: "Synced", rejected: "Not accepted" };
|
|
6357
6444
|
var FIGURE_LABELS = /* @__PURE__ */ new Map([["subtotalMinor", "Subtotal"], ["taxMinor", "Tax"], ["discountMinor", "Discount"]]);
|
|
6358
6445
|
var REFUSAL_SENTENCES = /* @__PURE__ */ new Map([
|
|
@@ -6375,10 +6462,10 @@ function defaultFormatDate2(iso) {
|
|
|
6375
6462
|
return Number.isNaN(date.getTime()) ? iso : new Intl.DateTimeFormat(void 0, { dateStyle: "medium", timeStyle: "short" }).format(date);
|
|
6376
6463
|
}
|
|
6377
6464
|
function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer, stuck, history, onOpen }) {
|
|
6378
|
-
const retrying =
|
|
6379
|
-
const [retryingIds, setRetryingIds] =
|
|
6380
|
-
const [expanded, setExpanded] =
|
|
6381
|
-
|
|
6465
|
+
const retrying = useRef13(/* @__PURE__ */ new Set());
|
|
6466
|
+
const [retryingIds, setRetryingIds] = useState29(/* @__PURE__ */ new Set());
|
|
6467
|
+
const [expanded, setExpanded] = useState29(/* @__PURE__ */ new Set());
|
|
6468
|
+
useEffect13(() => {
|
|
6382
6469
|
for (const id of retrying.current) {
|
|
6383
6470
|
if (!orders.some((order) => order.id === id && order.syncStatus === "rejected")) retrying.current.delete(id);
|
|
6384
6471
|
}
|
|
@@ -6394,13 +6481,13 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
6394
6481
|
});
|
|
6395
6482
|
return /* @__PURE__ */ jsxs67(ScrollView15, { className: "flex-1 bg-background p-4", children: [
|
|
6396
6483
|
[{ title: "Needs attention", orders: needsAttention(orders, { stuckCommandIds: stuck?.commandIds }) }, { title: "Recent", orders: recent }].filter((section) => section.title === "Recent" || section.orders.length > 0).map((section) => /* @__PURE__ */ jsxs67(View77, { className: "mb-6 gap-3", children: [
|
|
6397
|
-
/* @__PURE__ */
|
|
6398
|
-
section.title === "Recent" && orders.length === 0 && shown.length === 0 ? /* @__PURE__ */
|
|
6484
|
+
/* @__PURE__ */ jsx116(Text48, { accessibilityRole: "header", className: "text-xl font-semibold text-foreground", children: section.title }),
|
|
6485
|
+
section.title === "Recent" && orders.length === 0 && shown.length === 0 ? /* @__PURE__ */ jsx116(Text48, { testID: "orders-empty", className: "text-muted-foreground", children: "No sales yet. Completed sales appear here." }) : null,
|
|
6399
6486
|
section.orders.map((order) => {
|
|
6400
6487
|
if ("placedAt" in order) {
|
|
6401
6488
|
const row = order;
|
|
6402
6489
|
return /* @__PURE__ */ jsxs67(View77, { testID: `history-row-${row.id}`, className: "gap-1 rounded-md border border-border bg-card p-3", children: [
|
|
6403
|
-
/* @__PURE__ */
|
|
6490
|
+
/* @__PURE__ */ jsx116(Text48, { className: "text-foreground", children: `Order ${row.reference} \xB7 ${row.itemCount} ${row.itemCount === 1 ? "item" : "items"}` }),
|
|
6404
6491
|
/* @__PURE__ */ jsxs67(Text48, { className: "text-muted-foreground", children: [
|
|
6405
6492
|
formatDate(row.placedAt),
|
|
6406
6493
|
" \xB7 ",
|
|
@@ -6408,7 +6495,7 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
6408
6495
|
" \xB7 ",
|
|
6409
6496
|
row.stateLabel
|
|
6410
6497
|
] }),
|
|
6411
|
-
onOpen ? /* @__PURE__ */
|
|
6498
|
+
onOpen ? /* @__PURE__ */ jsx116(
|
|
6412
6499
|
Pressable39,
|
|
6413
6500
|
{
|
|
6414
6501
|
accessibilityRole: "button",
|
|
@@ -6416,7 +6503,7 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
6416
6503
|
testID: `history-open-${row.id}`,
|
|
6417
6504
|
onPress: () => onOpen(row),
|
|
6418
6505
|
className: "rounded-md border border-border px-4 py-2",
|
|
6419
|
-
children: /* @__PURE__ */
|
|
6506
|
+
children: /* @__PURE__ */ jsx116(Text48, { className: "text-center font-semibold text-foreground", children: "Open" })
|
|
6420
6507
|
}
|
|
6421
6508
|
) : null
|
|
6422
6509
|
] }, `history:${row.id}`);
|
|
@@ -6441,7 +6528,7 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
6441
6528
|
return next;
|
|
6442
6529
|
}),
|
|
6443
6530
|
children: [
|
|
6444
|
-
/* @__PURE__ */
|
|
6531
|
+
/* @__PURE__ */ jsx116(Text48, { className: "text-foreground", children: `Order ${orderReference(order)} \xB7 ${count2} ${count2 === 1 ? "item" : "items"}` }),
|
|
6445
6532
|
/* @__PURE__ */ jsxs67(Text48, { className: "text-muted-foreground", children: [
|
|
6446
6533
|
formatDate(order.createdAt),
|
|
6447
6534
|
" \xB7 ",
|
|
@@ -6452,7 +6539,7 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
6452
6539
|
]
|
|
6453
6540
|
}
|
|
6454
6541
|
),
|
|
6455
|
-
onOpen ? /* @__PURE__ */
|
|
6542
|
+
onOpen ? /* @__PURE__ */ jsx116(
|
|
6456
6543
|
Pressable39,
|
|
6457
6544
|
{
|
|
6458
6545
|
accessibilityRole: "button",
|
|
@@ -6460,20 +6547,20 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
6460
6547
|
testID: `order-open-${order.id}`,
|
|
6461
6548
|
onPress: () => onOpen(order),
|
|
6462
6549
|
className: "rounded-md border border-border px-4 py-2",
|
|
6463
|
-
children: /* @__PURE__ */
|
|
6550
|
+
children: /* @__PURE__ */ jsx116(Text48, { className: "text-center font-semibold text-foreground", children: "Open" })
|
|
6464
6551
|
}
|
|
6465
6552
|
) : null,
|
|
6466
6553
|
isExpanded ? /* @__PURE__ */ jsxs67(View77, { testID: `order-detail-${order.id}`, className: "mt-1 gap-1 border-t border-border pt-2", children: [
|
|
6467
|
-
order.lines.map((line) => /* @__PURE__ */
|
|
6468
|
-
order.payments.map((payment) => /* @__PURE__ */
|
|
6469
|
-
order.note ? /* @__PURE__ */
|
|
6554
|
+
order.lines.map((line) => /* @__PURE__ */ jsx116(Text48, { className: "text-foreground", children: `${line.quantity} \xD7 ${line.name}` }, line.id)),
|
|
6555
|
+
order.payments.map((payment) => /* @__PURE__ */ jsx116(Text48, { className: "text-muted-foreground", children: `${payment.method === "cash" ? "Cash" : "Card terminal"} ${formatMoney20({ amount: payment.amountMinor, currency: order.currency })}${payment.reference ? ` \xB7 ${payment.reference}` : ""}` }, payment.id)),
|
|
6556
|
+
order.note ? /* @__PURE__ */ jsx116(Text48, { testID: `order-note-${order.id}`, className: "text-foreground", children: `Note: ${order.note}` }) : null
|
|
6470
6557
|
] }) : null,
|
|
6471
|
-
stuckEntry ? /* @__PURE__ */
|
|
6472
|
-
order.syncStatus === "rejected" ? /* @__PURE__ */
|
|
6473
|
-
order.lateSessionId !== void 0 ? /* @__PURE__ */
|
|
6474
|
-
order.localWarnings?.map((warning, index) => /* @__PURE__ */
|
|
6475
|
-
noteDelivery2(order) === "not_sent" ? /* @__PURE__ */
|
|
6476
|
-
section.title === "Needs attention" && order.syncStatus === "rejected" && isRequeueable(order.error?.code) ? /* @__PURE__ */
|
|
6558
|
+
stuckEntry ? /* @__PURE__ */ jsx116(Text48, { className: "text-destructive", children: `Hasn't reached the online store since ${sinceText(stuckEntry)}.` }) : null,
|
|
6559
|
+
order.syncStatus === "rejected" ? /* @__PURE__ */ jsx116(Text48, { className: "text-destructive", children: refusalSentence(order.error?.code) }) : null,
|
|
6560
|
+
order.lateSessionId !== void 0 ? /* @__PURE__ */ jsx116(Text48, { className: "text-foreground", children: "Taken after the register closed. It is not in that register's closure." }) : null,
|
|
6561
|
+
order.localWarnings?.map((warning, index) => /* @__PURE__ */ jsx116(Text48, { 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)),
|
|
6562
|
+
noteDelivery2(order) === "not_sent" ? /* @__PURE__ */ jsx116(Text48, { testID: `order-note-not-sent-${order.id}`, className: "text-foreground", children: NOTE_NOT_SENT }) : null,
|
|
6563
|
+
section.title === "Needs attention" && order.syncStatus === "rejected" && isRequeueable(order.error?.code) ? /* @__PURE__ */ jsx116(Pressable39, { accessibilityRole: "button", disabled: retryingIds.has(order.id), onPress: async () => {
|
|
6477
6564
|
if (retrying.current.has(order.id)) return;
|
|
6478
6565
|
retrying.current.add(order.id);
|
|
6479
6566
|
setRetryingIds(new Set(retrying.current));
|
|
@@ -6481,8 +6568,8 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
6481
6568
|
retrying.current.delete(order.id);
|
|
6482
6569
|
setRetryingIds(new Set(retrying.current));
|
|
6483
6570
|
}
|
|
6484
|
-
}, className: "rounded-md bg-primary px-4 py-2", children: /* @__PURE__ */
|
|
6485
|
-
knownWarnings(order.warnings).filter((warning) => warning.code !== "register_session_unknown").map((warning, index) => /* @__PURE__ */
|
|
6571
|
+
}, className: "rounded-md bg-primary px-4 py-2", children: /* @__PURE__ */ jsx116(Text48, { className: "text-center font-semibold text-primary-foreground", children: "Retry" }) }) : null,
|
|
6572
|
+
knownWarnings(order.warnings).filter((warning) => warning.code !== "register_session_unknown").map((warning, index) => /* @__PURE__ */ jsx116(View77, { className: "border-l-4 border-warning pl-2", children: /* @__PURE__ */ jsx116(Text48, { className: "text-foreground", children: warning.code === "insufficient_stock" ? `${warning.quantity} sold without stock: ${order.lines.find((line) => line.variantId === warning.variantId)?.name}` : warning.code === "tax_rate_mismatch" ? `Tax at ${(warning.ratePpm / 1e4).toLocaleString(void 0, { maximumFractionDigits: 4 })}%: store ${formatMoney20({ amount: warning.serverMinor, currency: order.currency })} vs POS ${formatMoney20({ amount: warning.expectedMinor, currency: order.currency })}` : warning.code === "customer_ignored" ? `The online store didn't recognise the customer on this sale, so it was saved as a guest sale. Customer id: ${warning.customerId}.` : warning.code === "figures_mismatch" ? `The online store worked out different figures for this sale. ${warning.fields.map(({ field, tillMinor, serverMinor }) => `${FIGURE_LABELS.get(field) ?? field}: till ${formatMoney20({ amount: tillMinor, currency: order.currency })}, store ${formatMoney20({ amount: serverMinor, currency: order.currency })}.`).join(" ")}` : warning.bridgeMinor !== void 0 ? `Store calculated ${formatMoney20({ amount: warning.serverMinor, currency: order.currency })}; a rounding line of ${warning.bridgeMinor > 0 ? "+" : ""}${formatMoney20({ amount: warning.bridgeMinor, currency: order.currency })} brought it to ${formatMoney20({ amount: warning.expectedMinor, currency: order.currency })}` : `Store total ${formatMoney20({ amount: warning.serverMinor, currency: order.currency })} vs POS ${formatMoney20({ amount: warning.expectedMinor, currency: order.currency })}` }) }, index))
|
|
6486
6573
|
] }, order.id);
|
|
6487
6574
|
})
|
|
6488
6575
|
] }, section.title)),
|
|
@@ -6491,15 +6578,15 @@ function OrdersList({ orders, onRetry, formatDate = defaultFormatDate2, footer,
|
|
|
6491
6578
|
}
|
|
6492
6579
|
|
|
6493
6580
|
// src/sale/parked-sales.tsx
|
|
6494
|
-
import { useState as
|
|
6581
|
+
import { useState as useState30 } from "react";
|
|
6495
6582
|
import { ScrollView as ScrollView16, useWindowDimensions as useWindowDimensions6, View as View78 } from "react-native";
|
|
6496
6583
|
import { formatMoney as formatMoney21 } from "@tallyui/core";
|
|
6497
|
-
import { Fragment as Fragment12, jsx as
|
|
6584
|
+
import { Fragment as Fragment12, jsx as jsx117, jsxs as jsxs68 } from "react/jsx-runtime";
|
|
6498
6585
|
function ParkedSales({ sale, parked, onDiscard, onPark, onResume, currency, open, onOpenChange, hour12 }) {
|
|
6499
6586
|
const { height: windowHeight } = useWindowDimensions6();
|
|
6500
6587
|
const maxHeight = Math.max(280, windowHeight - 64);
|
|
6501
|
-
const [confirming, setConfirming] =
|
|
6502
|
-
const [error, setError] =
|
|
6588
|
+
const [confirming, setConfirming] = useState30(null);
|
|
6589
|
+
const [error, setError] = useState30("");
|
|
6503
6590
|
const attempt = async (action) => {
|
|
6504
6591
|
setError("");
|
|
6505
6592
|
try {
|
|
@@ -6508,28 +6595,28 @@ function ParkedSales({ sale, parked, onDiscard, onPark, onResume, currency, open
|
|
|
6508
6595
|
setError(errorText(e));
|
|
6509
6596
|
}
|
|
6510
6597
|
};
|
|
6511
|
-
return /* @__PURE__ */
|
|
6598
|
+
return /* @__PURE__ */ jsx117(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs68(DialogContent, { testID: "parked-sales", className: "flex-col overflow-hidden", style: { maxHeight }, children: [
|
|
6512
6599
|
/* @__PURE__ */ jsxs68(View78, { className: "flex-row items-center justify-between gap-2", children: [
|
|
6513
|
-
/* @__PURE__ */
|
|
6514
|
-
/* @__PURE__ */
|
|
6600
|
+
/* @__PURE__ */ jsx117(DialogTitle, { children: "Parked sales" }),
|
|
6601
|
+
/* @__PURE__ */ jsx117(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx117(IconButton, { variant: "ghost", size: "sm", testID: "parked-sales-dismiss", accessibilityLabel: "Close panel", children: /* @__PURE__ */ jsx117(XIcon, { size: 16 }) }) })
|
|
6515
6602
|
] }),
|
|
6516
6603
|
/* @__PURE__ */ jsxs68(ScrollView16, { className: "flex-1", contentContainerClassName: "gap-3", children: [
|
|
6517
|
-
/* @__PURE__ */
|
|
6604
|
+
/* @__PURE__ */ jsx117(
|
|
6518
6605
|
Button,
|
|
6519
6606
|
{
|
|
6520
6607
|
testID: "parked-sales-park",
|
|
6521
6608
|
accessibilityLabel: "Park this sale",
|
|
6522
6609
|
disabled: sale.order.lineItems.length === 0,
|
|
6523
6610
|
onPress: () => attempt(async () => setError(await (onPark ?? sale.park)() ?? "")),
|
|
6524
|
-
children: /* @__PURE__ */
|
|
6611
|
+
children: /* @__PURE__ */ jsx117(Text, { children: "Park this sale" })
|
|
6525
6612
|
}
|
|
6526
6613
|
),
|
|
6527
|
-
!!error && /* @__PURE__ */
|
|
6528
|
-
parked.length === 0 && /* @__PURE__ */
|
|
6529
|
-
parked.map((row) => /* @__PURE__ */
|
|
6530
|
-
/* @__PURE__ */
|
|
6614
|
+
!!error && /* @__PURE__ */ jsx117(Text, { testID: "parked-sales-error", className: "text-destructive", children: error }),
|
|
6615
|
+
parked.length === 0 && /* @__PURE__ */ jsx117(Text, { testID: "parked-sales-empty", children: "No parked sales." }),
|
|
6616
|
+
parked.map((row) => /* @__PURE__ */ jsx117(View78, { testID: `parked-row-${row.id}`, className: "gap-2 rounded-md border border-border p-3", children: confirming === row.id ? /* @__PURE__ */ jsxs68(Fragment12, { children: [
|
|
6617
|
+
/* @__PURE__ */ jsx117(Text, { children: "Discard this parked sale?" }),
|
|
6531
6618
|
/* @__PURE__ */ jsxs68(View78, { className: "flex-row gap-2", children: [
|
|
6532
|
-
/* @__PURE__ */
|
|
6619
|
+
/* @__PURE__ */ jsx117(
|
|
6533
6620
|
Button,
|
|
6534
6621
|
{
|
|
6535
6622
|
testID: `parked-discard-confirm-${row.id}`,
|
|
@@ -6538,22 +6625,22 @@ function ParkedSales({ sale, parked, onDiscard, onPark, onResume, currency, open
|
|
|
6538
6625
|
await onDiscard(row.id);
|
|
6539
6626
|
setConfirming(null);
|
|
6540
6627
|
}),
|
|
6541
|
-
children: /* @__PURE__ */
|
|
6628
|
+
children: /* @__PURE__ */ jsx117(Text, { children: "Discard" })
|
|
6542
6629
|
}
|
|
6543
6630
|
),
|
|
6544
|
-
/* @__PURE__ */
|
|
6631
|
+
/* @__PURE__ */ jsx117(Button, { testID: `parked-discard-cancel-${row.id}`, variant: "outline", onPress: () => setConfirming(null), children: /* @__PURE__ */ jsx117(Text, { children: "Cancel" }) })
|
|
6545
6632
|
] })
|
|
6546
6633
|
] }) : /* @__PURE__ */ jsxs68(Fragment12, { children: [
|
|
6547
|
-
/* @__PURE__ */
|
|
6634
|
+
/* @__PURE__ */ jsx117(Text, { children: formatStockSyncTime(new Date(row.parkedAt), void 0, hour12) }),
|
|
6548
6635
|
/* @__PURE__ */ jsxs68(Text, { children: [
|
|
6549
6636
|
row.itemCount,
|
|
6550
6637
|
" ",
|
|
6551
6638
|
row.itemCount === 1 ? "item" : "items"
|
|
6552
6639
|
] }),
|
|
6553
|
-
/* @__PURE__ */
|
|
6554
|
-
!!row.customerName && /* @__PURE__ */
|
|
6640
|
+
/* @__PURE__ */ jsx117(Text, { children: formatMoney21({ amount: row.totalMinor, currency }) }),
|
|
6641
|
+
!!row.customerName && /* @__PURE__ */ jsx117(Text, { children: row.customerName }),
|
|
6555
6642
|
/* @__PURE__ */ jsxs68(View78, { className: "flex-row gap-2", children: [
|
|
6556
|
-
/* @__PURE__ */
|
|
6643
|
+
/* @__PURE__ */ jsx117(
|
|
6557
6644
|
Button,
|
|
6558
6645
|
{
|
|
6559
6646
|
testID: `parked-resume-${row.id}`,
|
|
@@ -6563,17 +6650,17 @@ function ParkedSales({ sale, parked, onDiscard, onPark, onResume, currency, open
|
|
|
6563
6650
|
if (refusal === null) onOpenChange(false);
|
|
6564
6651
|
else setError(refusal);
|
|
6565
6652
|
}),
|
|
6566
|
-
children: /* @__PURE__ */
|
|
6653
|
+
children: /* @__PURE__ */ jsx117(Text, { children: "Resume" })
|
|
6567
6654
|
}
|
|
6568
6655
|
),
|
|
6569
|
-
/* @__PURE__ */
|
|
6656
|
+
/* @__PURE__ */ jsx117(
|
|
6570
6657
|
Button,
|
|
6571
6658
|
{
|
|
6572
6659
|
testID: `parked-discard-${row.id}`,
|
|
6573
6660
|
accessibilityLabel: "Discard parked sale",
|
|
6574
6661
|
variant: "outline",
|
|
6575
6662
|
onPress: () => setConfirming(row.id),
|
|
6576
|
-
children: /* @__PURE__ */
|
|
6663
|
+
children: /* @__PURE__ */ jsx117(Text, { children: "Discard" })
|
|
6577
6664
|
}
|
|
6578
6665
|
)
|
|
6579
6666
|
] })
|
|
@@ -6585,7 +6672,7 @@ function ParkedSales({ sale, parked, onDiscard, onPark, onResume, currency, open
|
|
|
6585
6672
|
// src/sale/open-sale-tabs.tsx
|
|
6586
6673
|
import { Pressable as Pressable40, ScrollView as ScrollView17, View as View79 } from "react-native";
|
|
6587
6674
|
import { formatMoney as formatMoney22 } from "@tallyui/core";
|
|
6588
|
-
import { jsx as
|
|
6675
|
+
import { jsx as jsx118, jsxs as jsxs69 } from "react/jsx-runtime";
|
|
6589
6676
|
function who(sale) {
|
|
6590
6677
|
if (sale.customerName) return sale.customerName;
|
|
6591
6678
|
if (sale.itemCount === 0) return "Guest";
|
|
@@ -6594,7 +6681,7 @@ function who(sale) {
|
|
|
6594
6681
|
function OpenSaleTabs({ sales, currency, onSelect, onNew }) {
|
|
6595
6682
|
const blank = !sales.some((sale) => sale.current);
|
|
6596
6683
|
return /* @__PURE__ */ jsxs69(View79, { testID: "open-sale-tabs", className: "h-14 flex-row items-stretch border-t border-border bg-card", children: [
|
|
6597
|
-
/* @__PURE__ */
|
|
6684
|
+
/* @__PURE__ */ jsx118(ScrollView17, { horizontal: true, accessibilityRole: "tablist", showsHorizontalScrollIndicator: false, className: "min-w-0 flex-1", children: sales.map((sale) => {
|
|
6598
6685
|
const partly = sale.paidMinor > 0 && sale.balanceDueMinor > 0;
|
|
6599
6686
|
const status = `Partly paid \xB7 ${formatMoney22({ amount: sale.balanceDueMinor, currency })} due`;
|
|
6600
6687
|
return /* @__PURE__ */ jsxs69(
|
|
@@ -6607,7 +6694,7 @@ function OpenSaleTabs({ sales, currency, onSelect, onNew }) {
|
|
|
6607
6694
|
onPress: () => onSelect(sale.id),
|
|
6608
6695
|
className: `h-full justify-center border-b-2 px-3 ${sale.current ? "border-primary" : "border-transparent"}`,
|
|
6609
6696
|
children: [
|
|
6610
|
-
/* @__PURE__ */
|
|
6697
|
+
/* @__PURE__ */ jsx118(
|
|
6611
6698
|
Text,
|
|
6612
6699
|
{
|
|
6613
6700
|
testID: `open-sale-tab-${sale.id}-who`,
|
|
@@ -6619,10 +6706,10 @@ function OpenSaleTabs({ sales, currency, onSelect, onNew }) {
|
|
|
6619
6706
|
partly && !sale.current ? (
|
|
6620
6707
|
// Inactive tabs carry the chip; the open tab keeps only the muted words (v2 TabChip).
|
|
6621
6708
|
/* @__PURE__ */ jsxs69(View79, { testID: `open-sale-chip-${sale.id}`, className: "flex-row items-center gap-1 self-start rounded-sm bg-info/15 px-1.5 py-0.5", children: [
|
|
6622
|
-
/* @__PURE__ */
|
|
6623
|
-
/* @__PURE__ */
|
|
6709
|
+
/* @__PURE__ */ jsx118(View79, { className: "h-1.5 w-1.5 rounded-full bg-info" }),
|
|
6710
|
+
/* @__PURE__ */ jsx118(Text, { className: "text-xs font-semibold text-foreground", children: status })
|
|
6624
6711
|
] })
|
|
6625
|
-
) : partly ? /* @__PURE__ */
|
|
6712
|
+
) : partly ? /* @__PURE__ */ jsx118(Text, { testID: `open-sale-status-${sale.id}`, className: "text-xs text-muted-foreground", children: status }) : /* @__PURE__ */ jsx118(Text, { testID: `open-sale-tab-${sale.id}-amount`, className: "text-xs text-muted-foreground tabular-nums", children: formatMoney22({ amount: sale.totalMinor, currency }) })
|
|
6626
6713
|
]
|
|
6627
6714
|
},
|
|
6628
6715
|
sale.id
|
|
@@ -6641,8 +6728,8 @@ function OpenSaleTabs({ sales, currency, onSelect, onNew }) {
|
|
|
6641
6728
|
},
|
|
6642
6729
|
className: `h-full flex-row items-center justify-center gap-1.5 px-3 ${blank ? "border-b-2 border-primary" : ""}`,
|
|
6643
6730
|
children: [
|
|
6644
|
-
/* @__PURE__ */
|
|
6645
|
-
blank && /* @__PURE__ */
|
|
6731
|
+
/* @__PURE__ */ jsx118(Text, { className: blank ? "text-primary" : "text-foreground", children: "+" }),
|
|
6732
|
+
blank && /* @__PURE__ */ jsx118(Text, { testID: "new-sale-tab-label", className: "font-semibold", children: "New" })
|
|
6646
6733
|
]
|
|
6647
6734
|
}
|
|
6648
6735
|
)
|
|
@@ -6652,7 +6739,7 @@ function OpenSaleTabs({ sales, currency, onSelect, onNew }) {
|
|
|
6652
6739
|
// src/sale/customer-display-screen.tsx
|
|
6653
6740
|
import { Image as Image4, ScrollView as ScrollView18, Text as Text49, View as View80 } from "react-native";
|
|
6654
6741
|
import { formatMoney as formatMoney23 } from "@tallyui/core";
|
|
6655
|
-
import { jsx as
|
|
6742
|
+
import { jsx as jsx119, jsxs as jsxs70 } from "react/jsx-runtime";
|
|
6656
6743
|
var COPY = {
|
|
6657
6744
|
welcome: "Welcome",
|
|
6658
6745
|
your_items: "Your items",
|
|
@@ -6684,35 +6771,35 @@ function CustomerDisplayScreen({ state }) {
|
|
|
6684
6771
|
if (view.screen === "idle") {
|
|
6685
6772
|
const logo = config?.store.logo;
|
|
6686
6773
|
return /* @__PURE__ */ jsxs70(View80, { testID: "customer-display-idle", className: "flex-1 items-center justify-center gap-6 bg-primary p-8", children: [
|
|
6687
|
-
logo ? /* @__PURE__ */
|
|
6688
|
-
/* @__PURE__ */
|
|
6774
|
+
logo ? /* @__PURE__ */ jsx119(Image4, { source: { uri: logo }, accessibilityLabel: config.store.name, resizeMode: "contain", style: { width: 320, height: 180 } }) : /* @__PURE__ */ jsx119(Text49, { className: "text-5xl font-bold text-primary-foreground", children: config?.store.name ?? "" }),
|
|
6775
|
+
/* @__PURE__ */ jsx119(Text49, { className: "text-2xl text-primary-foreground", children: t("welcome") })
|
|
6689
6776
|
] });
|
|
6690
6777
|
}
|
|
6691
6778
|
const { receipt } = view.cart;
|
|
6692
6779
|
const money = (amount) => formatMoney23({ amount, currency: receipt.currency }, config?.store.locale) ?? "";
|
|
6693
6780
|
const row = (label, amount, key) => /* @__PURE__ */ jsxs70(View80, { className: "flex-row justify-between gap-4 py-1", children: [
|
|
6694
|
-
/* @__PURE__ */
|
|
6695
|
-
/* @__PURE__ */
|
|
6781
|
+
/* @__PURE__ */ jsx119(Text49, { className: "text-lg text-muted-foreground", children: label }),
|
|
6782
|
+
/* @__PURE__ */ jsx119(Text49, { className: "text-lg text-muted-foreground", children: amount })
|
|
6696
6783
|
] }, key);
|
|
6697
6784
|
const total = /* @__PURE__ */ jsxs70(View80, { className: "mt-3 flex-row items-baseline justify-between gap-4 border-t-2 border-foreground pt-4", children: [
|
|
6698
|
-
/* @__PURE__ */
|
|
6699
|
-
/* @__PURE__ */
|
|
6785
|
+
/* @__PURE__ */ jsx119(Text49, { className: "text-base font-semibold uppercase text-foreground", children: t("total") }),
|
|
6786
|
+
/* @__PURE__ */ jsx119(Text49, { className: "text-4xl font-bold text-foreground", children: money(receipt.totals.totalMinor) })
|
|
6700
6787
|
] });
|
|
6701
6788
|
return /* @__PURE__ */ jsxs70(View80, { testID: `customer-display-${view.screen}`, className: "flex-1 flex-col bg-card sm:flex-row", children: [
|
|
6702
6789
|
/* @__PURE__ */ jsxs70(ScrollView18, { className: "flex-1", contentContainerClassName: "p-8 sm:p-12", children: [
|
|
6703
|
-
/* @__PURE__ */
|
|
6704
|
-
receipt.lineItems.length === 0 ? /* @__PURE__ */
|
|
6790
|
+
/* @__PURE__ */ jsx119(Text49, { className: "mb-5 text-sm font-semibold uppercase text-muted-foreground", children: t("your_items") }),
|
|
6791
|
+
receipt.lineItems.length === 0 ? /* @__PURE__ */ jsx119(Text49, { className: "py-8 text-center text-xl text-muted-foreground", children: t("items_appear_here") }) : null,
|
|
6705
6792
|
receipt.lineItems.map((line, index) => /* @__PURE__ */ jsxs70(View80, { className: "flex-row items-baseline gap-4 border-b border-border py-4", children: [
|
|
6706
|
-
/* @__PURE__ */
|
|
6793
|
+
/* @__PURE__ */ jsx119(Text49, { className: "w-14 text-xl text-muted-foreground", children: `${line.quantity} \xD7` }),
|
|
6707
6794
|
/* @__PURE__ */ jsxs70(View80, { className: "flex-1", children: [
|
|
6708
|
-
/* @__PURE__ */
|
|
6709
|
-
Object.entries(line.attributes ?? {}).map(([name, value]) => /* @__PURE__ */
|
|
6795
|
+
/* @__PURE__ */ jsx119(Text49, { className: "text-xl font-semibold text-foreground", children: line.name }),
|
|
6796
|
+
Object.entries(line.attributes ?? {}).map(([name, value]) => /* @__PURE__ */ jsx119(Text49, { className: "text-base text-muted-foreground", children: `${name}: ${value}` }, name))
|
|
6710
6797
|
] }),
|
|
6711
|
-
/* @__PURE__ */
|
|
6798
|
+
/* @__PURE__ */ jsx119(Text49, { className: "text-xl font-semibold text-foreground", children: money(line.displayAmountMinor) })
|
|
6712
6799
|
] }, index))
|
|
6713
6800
|
] }),
|
|
6714
6801
|
/* @__PURE__ */ jsxs70(View80, { className: "justify-end border-t border-border p-8 sm:w-96 sm:border-l sm:border-t-0", children: [
|
|
6715
|
-
/* @__PURE__ */
|
|
6802
|
+
/* @__PURE__ */ jsx119(Text49, { className: "mb-auto text-lg font-bold text-foreground", children: config?.store.name ?? receipt.header.storeName }),
|
|
6716
6803
|
view.screen === "cart" ? /* @__PURE__ */ jsxs70(View80, { children: [
|
|
6717
6804
|
row(t("subtotal"), money(receipt.totals.subtotalMinor)),
|
|
6718
6805
|
receipt.fees.map((charge, index) => row(charge.name, money(charge.amountMinor), `fee-${index}`)),
|
|
@@ -6720,7 +6807,7 @@ function CustomerDisplayScreen({ state }) {
|
|
|
6720
6807
|
receipt.totals.discountMinor > 0 ? row(t("discount"), `-${money(receipt.totals.discountMinor)}`) : null,
|
|
6721
6808
|
receipt.totals.taxMinor > 0 ? row(t(receipt.totals.taxInclusive ? "included_tax" : "total_tax"), money(receipt.totals.taxMinor)) : null,
|
|
6722
6809
|
total
|
|
6723
|
-
] }) : /* @__PURE__ */
|
|
6810
|
+
] }) : /* @__PURE__ */ jsx119(PaymentCard, { receipt, payment: view.payment, money, t, children: total })
|
|
6724
6811
|
] })
|
|
6725
6812
|
] });
|
|
6726
6813
|
}
|
|
@@ -6735,24 +6822,24 @@ function PaymentCard({ receipt, payment, money, t, children }) {
|
|
|
6735
6822
|
complete ? null : /* @__PURE__ */ jsxs70(View80, { children: [
|
|
6736
6823
|
children,
|
|
6737
6824
|
paid > 0 ? /* @__PURE__ */ jsxs70(View80, { className: "flex-row justify-between py-1", children: [
|
|
6738
|
-
/* @__PURE__ */
|
|
6739
|
-
/* @__PURE__ */
|
|
6825
|
+
/* @__PURE__ */ jsx119(Text49, { className: "text-lg text-success", children: t("paid_so_far") }),
|
|
6826
|
+
/* @__PURE__ */ jsx119(Text49, { className: "text-lg text-success", children: money(paid) })
|
|
6740
6827
|
] }) : null
|
|
6741
6828
|
] }),
|
|
6742
6829
|
/* @__PURE__ */ jsxs70(View80, { className: `gap-2 rounded-xl p-6 ${CARD[payment.state]}`, children: [
|
|
6743
|
-
/* @__PURE__ */
|
|
6744
|
-
/* @__PURE__ */
|
|
6745
|
-
complete && receipt.changeDueMinor > 0 ? /* @__PURE__ */
|
|
6746
|
-
message ? /* @__PURE__ */
|
|
6830
|
+
/* @__PURE__ */ jsx119(Text49, { className: `text-sm font-semibold uppercase ${text}`, children: title }),
|
|
6831
|
+
/* @__PURE__ */ jsx119(Text49, { className: `text-4xl font-bold ${text}`, children: money(complete ? receipt.totals.totalMinor : payment.leg?.amountMinor ?? due) }),
|
|
6832
|
+
complete && receipt.changeDueMinor > 0 ? /* @__PURE__ */ jsx119(Text49, { className: `text-lg ${text}`, children: `${t("change")} ${money(receipt.changeDueMinor)}` }) : null,
|
|
6833
|
+
message ? /* @__PURE__ */ jsx119(Text49, { className: `text-lg ${text}`, children: message }) : null
|
|
6747
6834
|
] })
|
|
6748
6835
|
] });
|
|
6749
6836
|
}
|
|
6750
6837
|
|
|
6751
6838
|
// src/layout/pos-layout.tsx
|
|
6752
|
-
import { useState as
|
|
6839
|
+
import { useState as useState31 } from "react";
|
|
6753
6840
|
import { Pressable as Pressable41, Text as Text50, View as View81, useWindowDimensions as useWindowDimensions7 } from "react-native";
|
|
6754
6841
|
import { cn as cn91 } from "@tallyui/theme";
|
|
6755
|
-
import { Fragment as Fragment13, jsx as
|
|
6842
|
+
import { Fragment as Fragment13, jsx as jsx120, jsxs as jsxs71 } from "react/jsx-runtime";
|
|
6756
6843
|
function POSLayout({
|
|
6757
6844
|
browseSlot,
|
|
6758
6845
|
cartSlot,
|
|
@@ -6764,32 +6851,32 @@ function POSLayout({
|
|
|
6764
6851
|
}) {
|
|
6765
6852
|
const { width } = useWindowDimensions7();
|
|
6766
6853
|
const layout = layoutProp ?? (width >= breakpoint ? "split" : "stacked");
|
|
6767
|
-
const [activeTab, setActiveTab] =
|
|
6854
|
+
const [activeTab, setActiveTab] = useState31("browse");
|
|
6768
6855
|
return /* @__PURE__ */ jsxs71(View81, { className: cn91("flex-1 bg-bg", className), ...viewProps, children: [
|
|
6769
|
-
headerSlot && /* @__PURE__ */
|
|
6856
|
+
headerSlot && /* @__PURE__ */ jsx120(View81, { className: "border-b border-border", children: headerSlot }),
|
|
6770
6857
|
layout === "split" ? /* @__PURE__ */ jsxs71(View81, { className: "flex-1 flex-row", children: [
|
|
6771
|
-
/* @__PURE__ */
|
|
6772
|
-
/* @__PURE__ */
|
|
6858
|
+
/* @__PURE__ */ jsx120(View81, { className: "flex-[3]", children: browseSlot }),
|
|
6859
|
+
/* @__PURE__ */ jsx120(View81, { className: "flex-[2] border-l border-border", children: cartSlot })
|
|
6773
6860
|
] }) : /* @__PURE__ */ jsxs71(Fragment13, { children: [
|
|
6774
6861
|
/* @__PURE__ */ jsxs71(View81, { className: "flex-row border-b border-border", children: [
|
|
6775
|
-
/* @__PURE__ */
|
|
6862
|
+
/* @__PURE__ */ jsx120(
|
|
6776
6863
|
Pressable41,
|
|
6777
6864
|
{
|
|
6778
6865
|
onPress: () => setActiveTab("browse"),
|
|
6779
6866
|
className: cn91("flex-1 py-3", activeTab === "browse" && "border-b-2 border-primary"),
|
|
6780
|
-
children: /* @__PURE__ */
|
|
6867
|
+
children: /* @__PURE__ */ jsx120(Text50, { className: cn91("text-center text-sm font-semibold", activeTab === "browse" ? "text-primary" : "text-muted-foreground"), children: "Browse" })
|
|
6781
6868
|
}
|
|
6782
6869
|
),
|
|
6783
|
-
/* @__PURE__ */
|
|
6870
|
+
/* @__PURE__ */ jsx120(
|
|
6784
6871
|
Pressable41,
|
|
6785
6872
|
{
|
|
6786
6873
|
onPress: () => setActiveTab("cart"),
|
|
6787
6874
|
className: cn91("flex-1 py-3", activeTab === "cart" && "border-b-2 border-primary"),
|
|
6788
|
-
children: /* @__PURE__ */
|
|
6875
|
+
children: /* @__PURE__ */ jsx120(Text50, { className: cn91("text-center text-sm font-semibold", activeTab === "cart" ? "text-primary" : "text-muted-foreground"), children: "Cart" })
|
|
6789
6876
|
}
|
|
6790
6877
|
)
|
|
6791
6878
|
] }),
|
|
6792
|
-
/* @__PURE__ */
|
|
6879
|
+
/* @__PURE__ */ jsx120(View81, { className: "flex-1", children: activeTab === "browse" ? browseSlot : cartSlot })
|
|
6793
6880
|
] })
|
|
6794
6881
|
] });
|
|
6795
6882
|
}
|
|
@@ -6797,7 +6884,7 @@ function POSLayout({
|
|
|
6797
6884
|
// src/layout/checkout-layout.tsx
|
|
6798
6885
|
import { ScrollView as ScrollView19, View as View82, useWindowDimensions as useWindowDimensions8 } from "react-native";
|
|
6799
6886
|
import { cn as cn92 } from "@tallyui/theme";
|
|
6800
|
-
import { jsx as
|
|
6887
|
+
import { jsx as jsx121, jsxs as jsxs72 } from "react/jsx-runtime";
|
|
6801
6888
|
function CheckoutLayout({
|
|
6802
6889
|
summarySlot,
|
|
6803
6890
|
paymentSlot,
|
|
@@ -6810,11 +6897,11 @@ function CheckoutLayout({
|
|
|
6810
6897
|
const { width } = useWindowDimensions8();
|
|
6811
6898
|
const layout = layoutProp ?? (width >= breakpoint ? "split" : "stacked");
|
|
6812
6899
|
return /* @__PURE__ */ jsxs72(View82, { className: cn92("flex-1 bg-bg", className), ...viewProps, children: [
|
|
6813
|
-
headerSlot && /* @__PURE__ */
|
|
6900
|
+
headerSlot && /* @__PURE__ */ jsx121(View82, { className: "border-b border-border", children: headerSlot }),
|
|
6814
6901
|
layout === "split" ? /* @__PURE__ */ jsxs72(View82, { className: "flex-1 flex-row", children: [
|
|
6815
|
-
/* @__PURE__ */
|
|
6816
|
-
/* @__PURE__ */
|
|
6817
|
-
] }) : /* @__PURE__ */
|
|
6902
|
+
/* @__PURE__ */ jsx121(View82, { className: "flex-1 border-r border-border", children: summarySlot }),
|
|
6903
|
+
/* @__PURE__ */ jsx121(View82, { className: "flex-1", children: paymentSlot })
|
|
6904
|
+
] }) : /* @__PURE__ */ jsx121(ScrollView19, { className: "flex-1", children: /* @__PURE__ */ jsxs72(View82, { className: "gap-4 p-4", children: [
|
|
6818
6905
|
summarySlot,
|
|
6819
6906
|
paymentSlot
|
|
6820
6907
|
] }) })
|
|
@@ -6822,10 +6909,10 @@ function CheckoutLayout({
|
|
|
6822
6909
|
}
|
|
6823
6910
|
|
|
6824
6911
|
// src/layout/settings-layout.tsx
|
|
6825
|
-
import { useState as
|
|
6912
|
+
import { useState as useState32 } from "react";
|
|
6826
6913
|
import { Pressable as Pressable42, Text as Text51, View as View83, useWindowDimensions as useWindowDimensions9 } from "react-native";
|
|
6827
6914
|
import { cn as cn93 } from "@tallyui/theme";
|
|
6828
|
-
import { jsx as
|
|
6915
|
+
import { jsx as jsx122, jsxs as jsxs73 } from "react/jsx-runtime";
|
|
6829
6916
|
function SettingsLayout({
|
|
6830
6917
|
navSlot,
|
|
6831
6918
|
contentSlot,
|
|
@@ -6837,17 +6924,17 @@ function SettingsLayout({
|
|
|
6837
6924
|
}) {
|
|
6838
6925
|
const { width } = useWindowDimensions9();
|
|
6839
6926
|
const layout = layoutProp ?? (width >= breakpoint ? "split" : "stacked");
|
|
6840
|
-
const [showNav, setShowNav] =
|
|
6927
|
+
const [showNav, setShowNav] = useState32(false);
|
|
6841
6928
|
return /* @__PURE__ */ jsxs73(View83, { className: cn93("flex-1 bg-bg", className), ...viewProps, children: [
|
|
6842
|
-
headerSlot && /* @__PURE__ */
|
|
6929
|
+
headerSlot && /* @__PURE__ */ jsx122(View83, { className: "border-b border-border", children: headerSlot }),
|
|
6843
6930
|
layout === "split" ? /* @__PURE__ */ jsxs73(View83, { className: "flex-1 flex-row", children: [
|
|
6844
|
-
/* @__PURE__ */
|
|
6845
|
-
/* @__PURE__ */
|
|
6846
|
-
] }) : /* @__PURE__ */
|
|
6931
|
+
/* @__PURE__ */ jsx122(View83, { className: "w-64 border-r border-border", children: navSlot }),
|
|
6932
|
+
/* @__PURE__ */ jsx122(View83, { className: "flex-1", children: contentSlot })
|
|
6933
|
+
] }) : /* @__PURE__ */ jsx122(View83, { className: "flex-1", children: showNav ? /* @__PURE__ */ jsxs73(View83, { className: "flex-1", children: [
|
|
6847
6934
|
navSlot,
|
|
6848
|
-
/* @__PURE__ */
|
|
6935
|
+
/* @__PURE__ */ jsx122(Pressable42, { onPress: () => setShowNav(false), className: "border-t border-border p-3", children: /* @__PURE__ */ jsx122(Text51, { className: "text-center text-sm font-medium text-primary", children: "Done" }) })
|
|
6849
6936
|
] }) : /* @__PURE__ */ jsxs73(View83, { className: "flex-1", children: [
|
|
6850
|
-
/* @__PURE__ */
|
|
6937
|
+
/* @__PURE__ */ jsx122(Pressable42, { onPress: () => setShowNav(true), className: "border-b border-border px-4 py-2", children: /* @__PURE__ */ jsx122(Text51, { className: "text-sm font-medium text-primary", children: "Menu" }) }),
|
|
6851
6938
|
contentSlot
|
|
6852
6939
|
] }) })
|
|
6853
6940
|
] });
|
|
@@ -6856,7 +6943,7 @@ function SettingsLayout({
|
|
|
6856
6943
|
// src/layout/live-tab-screen.tsx
|
|
6857
6944
|
import { Pressable as Pressable43, Text as Text52, View as View84 } from "react-native";
|
|
6858
6945
|
import { cn as cn94 } from "@tallyui/theme";
|
|
6859
|
-
import { jsx as
|
|
6946
|
+
import { jsx as jsx123, jsxs as jsxs74 } from "react/jsx-runtime";
|
|
6860
6947
|
function LiveTabScreen({
|
|
6861
6948
|
state,
|
|
6862
6949
|
onUseHere,
|
|
@@ -6874,20 +6961,20 @@ function LiveTabScreen({
|
|
|
6874
6961
|
const buttonLabel = state === "parked" ? useHereLabel : reloadLabel;
|
|
6875
6962
|
const onPress = state === "parked" ? onUseHere : onReload;
|
|
6876
6963
|
return /* @__PURE__ */ jsxs74(View84, { className: cn94("flex-1 items-center justify-center gap-4 bg-bg p-6", className), ...viewProps, children: [
|
|
6877
|
-
/* @__PURE__ */
|
|
6878
|
-
/* @__PURE__ */
|
|
6879
|
-
/* @__PURE__ */
|
|
6964
|
+
/* @__PURE__ */ jsx123(Text52, { className: "text-center text-lg font-bold text-foreground", children: parkedTitle }),
|
|
6965
|
+
/* @__PURE__ */ jsx123(Text52, { className: "text-center text-sm text-muted-foreground", children: body }),
|
|
6966
|
+
/* @__PURE__ */ jsx123(Pressable43, { onPress, className: "items-center rounded-lg bg-primary px-4 py-3", children: /* @__PURE__ */ jsx123(Text52, { className: "text-sm font-semibold text-primary-foreground", children: buttonLabel }) })
|
|
6880
6967
|
] });
|
|
6881
6968
|
}
|
|
6882
6969
|
|
|
6883
6970
|
// src/layout/store-settings-choice-screen.tsx
|
|
6884
|
-
import { useState as
|
|
6971
|
+
import { useState as useState33 } from "react";
|
|
6885
6972
|
import { Pressable as Pressable44, Text as Text53, View as View85 } from "react-native";
|
|
6886
6973
|
import { cn as cn95 } from "@tallyui/theme";
|
|
6887
|
-
import { jsx as
|
|
6974
|
+
import { jsx as jsx124, jsxs as jsxs75 } from "react/jsx-runtime";
|
|
6888
6975
|
function useSectionSelection(options, initialValue) {
|
|
6889
6976
|
const preset = options.length === 1 ? options[0].value : options.find((o) => o.value === initialValue)?.value;
|
|
6890
|
-
return
|
|
6977
|
+
return useState33(preset);
|
|
6891
6978
|
}
|
|
6892
6979
|
function defaultCountryName(code, locale) {
|
|
6893
6980
|
try {
|
|
@@ -6935,27 +7022,27 @@ function StoreSettingsChoiceScreen({
|
|
|
6935
7022
|
};
|
|
6936
7023
|
return /* @__PURE__ */ jsxs75(View85, { className: cn95("w-full max-w-[560px] flex-1 self-center gap-6 bg-bg p-6", className), ...viewProps, children: [
|
|
6937
7024
|
/* @__PURE__ */ jsxs75(View85, { className: "gap-2", children: [
|
|
6938
|
-
/* @__PURE__ */
|
|
6939
|
-
/* @__PURE__ */
|
|
7025
|
+
/* @__PURE__ */ jsx124(Text53, { className: "text-lg font-bold text-foreground", children: title }),
|
|
7026
|
+
/* @__PURE__ */ jsx124(Text53, { className: "text-sm text-muted-foreground", children: body })
|
|
6940
7027
|
] }),
|
|
6941
|
-
showRegions && /* @__PURE__ */
|
|
6942
|
-
showCountries && /* @__PURE__ */
|
|
6943
|
-
showChannels && /* @__PURE__ */
|
|
6944
|
-
/* @__PURE__ */
|
|
7028
|
+
showRegions && /* @__PURE__ */ jsx124(ChoiceSection, { label: regionLabel, options: regionOptions, selected: region, onSelect: setRegion }),
|
|
7029
|
+
showCountries && /* @__PURE__ */ jsx124(ChoiceSection, { label: countryLabel, options: countryOptions, selected: country, onSelect: setCountry }),
|
|
7030
|
+
showChannels && /* @__PURE__ */ jsx124(ChoiceSection, { label: channelLabel, options: channelOptions, selected: channel, onSelect: setChannel }),
|
|
7031
|
+
/* @__PURE__ */ jsx124(
|
|
6945
7032
|
Pressable44,
|
|
6946
7033
|
{
|
|
6947
7034
|
onPress: handleSubmit,
|
|
6948
7035
|
disabled: !complete,
|
|
6949
7036
|
className: cn95("items-center rounded-lg bg-primary px-4 py-3", !complete && "opacity-50"),
|
|
6950
|
-
children: /* @__PURE__ */
|
|
7037
|
+
children: /* @__PURE__ */ jsx124(Text53, { className: "text-sm font-semibold text-primary-foreground", children: submitLabel })
|
|
6951
7038
|
}
|
|
6952
7039
|
)
|
|
6953
7040
|
] });
|
|
6954
7041
|
}
|
|
6955
7042
|
function ChoiceSection({ label, options, selected, onSelect }) {
|
|
6956
7043
|
return /* @__PURE__ */ jsxs75(View85, { className: "gap-1.5", children: [
|
|
6957
|
-
/* @__PURE__ */
|
|
6958
|
-
/* @__PURE__ */
|
|
7044
|
+
/* @__PURE__ */ jsx124(Text53, { className: "text-xs font-semibold text-muted-foreground", children: label }),
|
|
7045
|
+
/* @__PURE__ */ jsx124(View85, { className: "rounded-lg border border-border", children: options.map((option, index) => {
|
|
6959
7046
|
const checked = option.value === selected;
|
|
6960
7047
|
return /* @__PURE__ */ jsxs75(
|
|
6961
7048
|
Pressable44,
|
|
@@ -6966,8 +7053,8 @@ function ChoiceSection({ label, options, selected, onSelect }) {
|
|
|
6966
7053
|
testID: `choice-option-${option.value}`,
|
|
6967
7054
|
className: cn95("flex-row items-center gap-3 px-4 py-3", index > 0 && "border-t border-border", checked && "bg-primary/10"),
|
|
6968
7055
|
children: [
|
|
6969
|
-
/* @__PURE__ */
|
|
6970
|
-
/* @__PURE__ */
|
|
7056
|
+
/* @__PURE__ */ jsx124(View85, { className: "h-4 w-4 items-center justify-center rounded-full border border-primary", children: checked && /* @__PURE__ */ jsx124(View85, { testID: `choice-option-${option.value}-dot`, className: "h-2.5 w-2.5 rounded-full bg-primary" }) }),
|
|
7057
|
+
/* @__PURE__ */ jsx124(Text53, { className: cn95("text-sm", checked ? "font-semibold text-primary" : "text-foreground"), children: option.label })
|
|
6971
7058
|
]
|
|
6972
7059
|
},
|
|
6973
7060
|
option.value
|
|
@@ -6977,23 +7064,23 @@ function ChoiceSection({ label, options, selected, onSelect }) {
|
|
|
6977
7064
|
}
|
|
6978
7065
|
|
|
6979
7066
|
// src/shell/app-shell.tsx
|
|
6980
|
-
import * as
|
|
7067
|
+
import * as React43 from "react";
|
|
6981
7068
|
import { View as View89, useWindowDimensions as useWindowDimensions10 } from "react-native";
|
|
6982
7069
|
import { cn as cn98 } from "@tallyui/theme";
|
|
6983
7070
|
|
|
6984
7071
|
// src/shell/nav-drawer.tsx
|
|
6985
|
-
import * as
|
|
7072
|
+
import * as React41 from "react";
|
|
6986
7073
|
import { Animated as Animated2, Platform as Platform10, Pressable as Pressable46, View as View87 } from "react-native";
|
|
6987
7074
|
|
|
6988
7075
|
// src/shell/nav-item.tsx
|
|
6989
|
-
import * as
|
|
7076
|
+
import * as React40 from "react";
|
|
6990
7077
|
import { Pressable as Pressable45, View as View86 } from "react-native";
|
|
6991
7078
|
import { cn as cn96 } from "@tallyui/theme";
|
|
6992
|
-
import { jsx as
|
|
7079
|
+
import { jsx as jsx125, jsxs as jsxs76 } from "react/jsx-runtime";
|
|
6993
7080
|
function splitGroups(items) {
|
|
6994
7081
|
return [items.filter((item) => item.group !== "bottom"), items.filter((item) => item.group === "bottom")];
|
|
6995
7082
|
}
|
|
6996
|
-
var NavButton =
|
|
7083
|
+
var NavButton = React40.forwardRef(function NavButton2({ item, active, labelled = false, className, ...props }, ref) {
|
|
6997
7084
|
const tint = active ? "text-primary" : "text-muted-foreground";
|
|
6998
7085
|
return /* @__PURE__ */ jsxs76(
|
|
6999
7086
|
Pressable45,
|
|
@@ -7014,30 +7101,30 @@ var NavButton = React39.forwardRef(function NavButton2({ item, active, labelled
|
|
|
7014
7101
|
children: [
|
|
7015
7102
|
/* @__PURE__ */ jsxs76(View86, { className: cn96("h-6 w-6 items-center justify-center", tint), children: [
|
|
7016
7103
|
item.icon,
|
|
7017
|
-
item.badge !== void 0 && item.badge !== 0 && item.badge !== "" && /* @__PURE__ */
|
|
7104
|
+
item.badge !== void 0 && item.badge !== 0 && item.badge !== "" && /* @__PURE__ */ jsx125(
|
|
7018
7105
|
View86,
|
|
7019
7106
|
{
|
|
7020
7107
|
testID: `nav-item-${item.id}-badge`,
|
|
7021
7108
|
className: "absolute -right-2 -top-1 h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1",
|
|
7022
|
-
children: /* @__PURE__ */
|
|
7109
|
+
children: /* @__PURE__ */ jsx125(Text, { className: "text-2xs font-semibold text-destructive-foreground", children: item.badge })
|
|
7023
7110
|
}
|
|
7024
7111
|
)
|
|
7025
7112
|
] }),
|
|
7026
|
-
labelled && /* @__PURE__ */
|
|
7113
|
+
labelled && /* @__PURE__ */ jsx125(Text, { className: cn96("flex-1 text-base", active ? "font-semibold text-primary" : "text-foreground"), numberOfLines: 1, children: item.label })
|
|
7027
7114
|
]
|
|
7028
7115
|
}
|
|
7029
7116
|
);
|
|
7030
7117
|
});
|
|
7031
7118
|
|
|
7032
7119
|
// src/shell/nav-drawer.tsx
|
|
7033
|
-
import { jsx as
|
|
7120
|
+
import { jsx as jsx126, jsxs as jsxs77 } from "react/jsx-runtime";
|
|
7034
7121
|
var DRAWER_WIDTH = 200;
|
|
7035
7122
|
var SLIDE_MS = 200;
|
|
7036
7123
|
var FOCUSABLE2 = 'button, [href], input, [tabindex]:not([tabindex="-1"])';
|
|
7037
7124
|
function useFocusTrap(panel, active, onEscape) {
|
|
7038
|
-
const escape =
|
|
7125
|
+
const escape = React41.useRef(onEscape);
|
|
7039
7126
|
escape.current = onEscape;
|
|
7040
|
-
|
|
7127
|
+
React41.useEffect(() => {
|
|
7041
7128
|
if (!active || Platform10.OS !== "web" || typeof document === "undefined") return;
|
|
7042
7129
|
const root = panel.current;
|
|
7043
7130
|
const previous = document.activeElement;
|
|
@@ -7070,11 +7157,11 @@ function useFocusTrap(panel, active, onEscape) {
|
|
|
7070
7157
|
}, [active, panel]);
|
|
7071
7158
|
}
|
|
7072
7159
|
function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, header, testID = "nav-drawer" }) {
|
|
7073
|
-
const [mounted, setMounted] =
|
|
7074
|
-
const offset =
|
|
7075
|
-
const panel =
|
|
7160
|
+
const [mounted, setMounted] = React41.useState(open);
|
|
7161
|
+
const offset = React41.useRef(new Animated2.Value(open ? 0 : -DRAWER_WIDTH)).current;
|
|
7162
|
+
const panel = React41.useRef(null);
|
|
7076
7163
|
if (open && !mounted) setMounted(true);
|
|
7077
|
-
|
|
7164
|
+
React41.useEffect(() => {
|
|
7078
7165
|
if (!mounted) return;
|
|
7079
7166
|
const animation = Animated2.timing(offset, {
|
|
7080
7167
|
toValue: open ? 0 : -DRAWER_WIDTH,
|
|
@@ -7086,11 +7173,11 @@ function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, header, te
|
|
|
7086
7173
|
});
|
|
7087
7174
|
return () => animation.stop();
|
|
7088
7175
|
}, [open, mounted, offset]);
|
|
7089
|
-
const close =
|
|
7176
|
+
const close = React41.useCallback(() => onOpenChange(false), [onOpenChange]);
|
|
7090
7177
|
useFocusTrap(panel, open && mounted, close);
|
|
7091
7178
|
if (!mounted) return null;
|
|
7092
7179
|
const [top, bottom] = splitGroups(items);
|
|
7093
|
-
const renderItem = (item) => /* @__PURE__ */
|
|
7180
|
+
const renderItem = (item) => /* @__PURE__ */ jsx126(
|
|
7094
7181
|
NavButton,
|
|
7095
7182
|
{
|
|
7096
7183
|
item,
|
|
@@ -7104,12 +7191,12 @@ function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, header, te
|
|
|
7104
7191
|
item.id
|
|
7105
7192
|
);
|
|
7106
7193
|
return /* @__PURE__ */ jsxs77(View87, { testID, className: "absolute inset-0 z-50", pointerEvents: open ? "auto" : "none", children: [
|
|
7107
|
-
/* @__PURE__ */
|
|
7194
|
+
/* @__PURE__ */ jsx126(
|
|
7108
7195
|
Animated2.View,
|
|
7109
7196
|
{
|
|
7110
7197
|
className: "absolute inset-0",
|
|
7111
7198
|
style: { opacity: offset.interpolate({ inputRange: [-DRAWER_WIDTH, 0], outputRange: [0, 1] }) },
|
|
7112
|
-
children: /* @__PURE__ */
|
|
7199
|
+
children: /* @__PURE__ */ jsx126(
|
|
7113
7200
|
Pressable46,
|
|
7114
7201
|
{
|
|
7115
7202
|
testID: `${testID}-backdrop`,
|
|
@@ -7133,8 +7220,8 @@ function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, header, te
|
|
|
7133
7220
|
children: [
|
|
7134
7221
|
header,
|
|
7135
7222
|
/* @__PURE__ */ jsxs77(View87, { role: "navigation", "aria-label": "Main", className: "flex-1 p-2", children: [
|
|
7136
|
-
/* @__PURE__ */
|
|
7137
|
-
bottom.length > 0 && /* @__PURE__ */
|
|
7223
|
+
/* @__PURE__ */ jsx126(View87, { children: top.map(renderItem) }),
|
|
7224
|
+
bottom.length > 0 && /* @__PURE__ */ jsx126(View87, { className: "mt-auto", children: bottom.map(renderItem) })
|
|
7138
7225
|
] })
|
|
7139
7226
|
]
|
|
7140
7227
|
}
|
|
@@ -7143,14 +7230,14 @@ function NavDrawer({ open, onOpenChange, items, activeId, onNavigate, header, te
|
|
|
7143
7230
|
}
|
|
7144
7231
|
|
|
7145
7232
|
// src/shell/nav-rail.tsx
|
|
7146
|
-
import * as
|
|
7233
|
+
import * as React42 from "react";
|
|
7147
7234
|
import { View as View88 } from "react-native";
|
|
7148
7235
|
import { cn as cn97 } from "@tallyui/theme";
|
|
7149
|
-
import { jsx as
|
|
7236
|
+
import { jsx as jsx127, jsxs as jsxs78 } from "react/jsx-runtime";
|
|
7150
7237
|
function NavRail({ items, activeId, onNavigate, className, testID = "nav-rail" }) {
|
|
7151
|
-
const [hinted, setHinted] =
|
|
7238
|
+
const [hinted, setHinted] = React42.useState(null);
|
|
7152
7239
|
const renderItem = (item) => /* @__PURE__ */ jsxs78(View88, { className: "relative z-10", children: [
|
|
7153
|
-
/* @__PURE__ */
|
|
7240
|
+
/* @__PURE__ */ jsx127(
|
|
7154
7241
|
NavButton,
|
|
7155
7242
|
{
|
|
7156
7243
|
item,
|
|
@@ -7162,13 +7249,13 @@ function NavRail({ items, activeId, onNavigate, className, testID = "nav-rail" }
|
|
|
7162
7249
|
onBlur: () => setHinted((id) => id === item.id ? null : id)
|
|
7163
7250
|
}
|
|
7164
7251
|
),
|
|
7165
|
-
hinted === item.id && /* @__PURE__ */
|
|
7252
|
+
hinted === item.id && /* @__PURE__ */ jsx127(
|
|
7166
7253
|
View88,
|
|
7167
7254
|
{
|
|
7168
7255
|
testID: `nav-rail-label-${item.id}`,
|
|
7169
7256
|
pointerEvents: "none",
|
|
7170
7257
|
className: "absolute left-full top-2 z-50 ml-3 rounded-md border border-border bg-popover px-3 py-1.5 shadow-md",
|
|
7171
|
-
children: /* @__PURE__ */
|
|
7258
|
+
children: /* @__PURE__ */ jsx127(Text, { className: "text-sm text-popover-foreground", numberOfLines: 1, children: item.label })
|
|
7172
7259
|
}
|
|
7173
7260
|
)
|
|
7174
7261
|
] }, item.id);
|
|
@@ -7181,15 +7268,15 @@ function NavRail({ items, activeId, onNavigate, className, testID = "nav-rail" }
|
|
|
7181
7268
|
testID,
|
|
7182
7269
|
className: cn97("z-10 w-16 items-center border-r border-border bg-card py-2", className),
|
|
7183
7270
|
children: [
|
|
7184
|
-
/* @__PURE__ */
|
|
7185
|
-
bottom.length > 0 && /* @__PURE__ */
|
|
7271
|
+
/* @__PURE__ */ jsx127(View88, { className: "gap-2", children: top.map(renderItem) }),
|
|
7272
|
+
bottom.length > 0 && /* @__PURE__ */ jsx127(View88, { className: "mt-auto gap-2", children: bottom.map(renderItem) })
|
|
7186
7273
|
]
|
|
7187
7274
|
}
|
|
7188
7275
|
);
|
|
7189
7276
|
}
|
|
7190
7277
|
|
|
7191
7278
|
// src/shell/app-shell.tsx
|
|
7192
|
-
import { jsx as
|
|
7279
|
+
import { jsx as jsx128, jsxs as jsxs79 } from "react/jsx-runtime";
|
|
7193
7280
|
var WIDE_MIN_WIDTH2 = 768;
|
|
7194
7281
|
var WIDE_MIN_HEIGHT2 = 480;
|
|
7195
7282
|
function AppShell({
|
|
@@ -7203,18 +7290,18 @@ function AppShell({
|
|
|
7203
7290
|
}) {
|
|
7204
7291
|
const { width, height } = useWindowDimensions10();
|
|
7205
7292
|
const phone = width < WIDE_MIN_WIDTH2 || height < WIDE_MIN_HEIGHT2;
|
|
7206
|
-
const [menuOpen, setMenuOpen] =
|
|
7293
|
+
const [menuOpen, setMenuOpen] = React43.useState(false);
|
|
7207
7294
|
if (!phone && menuOpen) setMenuOpen(false);
|
|
7208
|
-
const openMenu =
|
|
7209
|
-
const shell =
|
|
7295
|
+
const openMenu = React43.useCallback(() => setMenuOpen(true), []);
|
|
7296
|
+
const shell = React43.useMemo(() => ({ phone, openMenu: phone ? openMenu : void 0 }), [phone, openMenu]);
|
|
7210
7297
|
const page = /* @__PURE__ */ jsxs79(View89, { className: "min-w-0 flex-1", children: [
|
|
7211
7298
|
registerBar,
|
|
7212
|
-
/* @__PURE__ */
|
|
7299
|
+
/* @__PURE__ */ jsx128(View89, { className: "flex-1", children })
|
|
7213
7300
|
] });
|
|
7214
|
-
return /* @__PURE__ */
|
|
7215
|
-
!phone && /* @__PURE__ */
|
|
7301
|
+
return /* @__PURE__ */ jsx128(ShellContext.Provider, { value: shell, children: /* @__PURE__ */ jsxs79(View89, { testID, className: cn98("flex-1 bg-background", !phone && "flex-row", className), children: [
|
|
7302
|
+
!phone && /* @__PURE__ */ jsx128(NavRail, { items: navItems, activeId, onNavigate }),
|
|
7216
7303
|
page,
|
|
7217
|
-
phone && /* @__PURE__ */
|
|
7304
|
+
phone && /* @__PURE__ */ jsx128(
|
|
7218
7305
|
NavDrawer,
|
|
7219
7306
|
{
|
|
7220
7307
|
open: menuOpen,
|
|
@@ -7234,7 +7321,7 @@ import { View as View93 } from "react-native";
|
|
|
7234
7321
|
import { Pressable as Pressable47, Text as Text54, View as View90 } from "react-native";
|
|
7235
7322
|
import { formatMoney as formatMoney24 } from "@tallyui/core";
|
|
7236
7323
|
import { cn as cn99 } from "@tallyui/theme";
|
|
7237
|
-
import { Fragment as Fragment14, jsx as
|
|
7324
|
+
import { Fragment as Fragment14, jsx as jsx129, jsxs as jsxs80 } from "react/jsx-runtime";
|
|
7238
7325
|
var SWATCHES = ["bg-primary", "bg-info", "bg-success", "bg-warning", "bg-destructive"];
|
|
7239
7326
|
var OTHER_SWATCH = "bg-muted-foreground";
|
|
7240
7327
|
var LEGEND_ROWS = 5;
|
|
@@ -7243,31 +7330,31 @@ var UNKNOWN = "\u2014";
|
|
|
7243
7330
|
var percent = (fraction) => `${(fraction * 100).toFixed(1)}%`;
|
|
7244
7331
|
function ReportCard({ id, name, figure, onOpen, children }) {
|
|
7245
7332
|
const head = /* @__PURE__ */ jsxs80(View90, { className: "flex-row items-baseline justify-between gap-2", children: [
|
|
7246
|
-
/* @__PURE__ */
|
|
7247
|
-
/* @__PURE__ */
|
|
7333
|
+
/* @__PURE__ */ jsx129(Text54, { className: "text-sm text-muted-foreground", children: name }),
|
|
7334
|
+
/* @__PURE__ */ jsx129(Text54, { testID: `card-${id}-figure`, className: "text-lg font-semibold text-foreground", children: figure })
|
|
7248
7335
|
] });
|
|
7249
7336
|
return /* @__PURE__ */ jsxs80(Card, { testID: `card-${id}`, className: "min-w-72 flex-1 gap-3 p-4", children: [
|
|
7250
|
-
onOpen ? /* @__PURE__ */
|
|
7337
|
+
onOpen ? /* @__PURE__ */ jsx129(Pressable47, { testID: `card-${id}-open`, accessibilityRole: "button", accessibilityLabel: name, onPress: () => onOpen(id), children: head }) : head,
|
|
7251
7338
|
children
|
|
7252
7339
|
] });
|
|
7253
7340
|
}
|
|
7254
|
-
var Empty = ({ testID, children }) => /* @__PURE__ */
|
|
7341
|
+
var Empty = ({ testID, children }) => /* @__PURE__ */ jsx129(Text54, { testID, className: "text-sm text-muted-foreground", children });
|
|
7255
7342
|
function StatGrid({ stats }) {
|
|
7256
|
-
return /* @__PURE__ */
|
|
7257
|
-
/* @__PURE__ */
|
|
7258
|
-
/* @__PURE__ */
|
|
7343
|
+
return /* @__PURE__ */ jsx129(View90, { className: "flex-row flex-wrap gap-y-2", children: stats.map((stat) => /* @__PURE__ */ jsxs80(View90, { className: "basis-1/3 gap-0.5", children: [
|
|
7344
|
+
/* @__PURE__ */ jsx129(Text54, { className: "text-xs text-muted-foreground", children: stat.label }),
|
|
7345
|
+
/* @__PURE__ */ jsx129(Text54, { testID: stat.testID, className: "text-sm font-medium text-foreground", children: stat.value })
|
|
7259
7346
|
] }, stat.label)) });
|
|
7260
7347
|
}
|
|
7261
7348
|
function ProportionalBar({ shares: shares2 }) {
|
|
7262
7349
|
const positive = shares2.filter((share) => share.value > 0);
|
|
7263
|
-
return /* @__PURE__ */
|
|
7350
|
+
return /* @__PURE__ */ jsx129(View90, { className: "h-2 flex-row gap-0.5 overflow-hidden rounded-md", children: positive.length ? positive.map((share, i) => /* @__PURE__ */ jsx129(View90, { className: share.swatch, style: { flex: share.value } }, i)) : /* @__PURE__ */ jsx129(View90, { className: "flex-1 bg-muted" }) });
|
|
7264
7351
|
}
|
|
7265
7352
|
function Legend({ shares: shares2 }) {
|
|
7266
|
-
return /* @__PURE__ */
|
|
7267
|
-
/* @__PURE__ */
|
|
7268
|
-
/* @__PURE__ */
|
|
7269
|
-
share.note && /* @__PURE__ */
|
|
7270
|
-
/* @__PURE__ */
|
|
7353
|
+
return /* @__PURE__ */ jsx129(View90, { className: "gap-1.5", children: shares2.map((share, i) => /* @__PURE__ */ jsxs80(View90, { className: "flex-row items-center gap-2", children: [
|
|
7354
|
+
/* @__PURE__ */ jsx129(View90, { className: cn99("h-2.5 w-2.5 rounded-sm", share.swatch) }),
|
|
7355
|
+
/* @__PURE__ */ jsx129(Text54, { className: "flex-1 text-sm text-foreground", numberOfLines: 1, children: share.label }),
|
|
7356
|
+
share.note && /* @__PURE__ */ jsx129(Text54, { className: "text-xs text-muted-foreground", children: share.note }),
|
|
7357
|
+
/* @__PURE__ */ jsx129(Text54, { className: "text-sm font-medium text-foreground", children: share.text })
|
|
7271
7358
|
] }, i)) });
|
|
7272
7359
|
}
|
|
7273
7360
|
function shares(rows, toShare, otherText) {
|
|
@@ -7302,45 +7389,45 @@ function SalesCards({ figures, currency, onOpenCard }) {
|
|
|
7302
7389
|
}), (rest) => money(rest.reduce((sum, row) => sum + row.taxMinor, 0)));
|
|
7303
7390
|
const card = { onOpen: onOpenCard };
|
|
7304
7391
|
return /* @__PURE__ */ jsxs80(View90, { testID: "sales-cards", className: "flex-row flex-wrap gap-4", children: [
|
|
7305
|
-
/* @__PURE__ */
|
|
7306
|
-
/* @__PURE__ */
|
|
7392
|
+
/* @__PURE__ */ jsx129(ReportCard, { id: "orders", name: "Orders", figure: String(totals.orderCount), ...card, children: totals.orderCount === 0 ? /* @__PURE__ */ jsx129(Empty, { testID: "card-orders-empty", children: "No orders in this period" }) : /* @__PURE__ */ jsxs80(View90, { className: "gap-2", children: [
|
|
7393
|
+
/* @__PURE__ */ jsx129(StatGrid, { stats: [
|
|
7307
7394
|
{ label: "Average order", value: money(totals.averageMinor) },
|
|
7308
7395
|
{ label: "Items Sold", value: String(totals.items) },
|
|
7309
7396
|
{ label: "Items per order", value: (totals.items / totals.orderCount).toFixed(1) },
|
|
7310
7397
|
{ label: "Discounts", value: money(totals.discountMinor) },
|
|
7311
7398
|
{ label: "Margin %", value: margin.marginPct === null ? UNKNOWN : percent(margin.marginPct), testID: "card-orders-margin" }
|
|
7312
7399
|
] }),
|
|
7313
|
-
margin.missingLines > 0 && /* @__PURE__ */
|
|
7400
|
+
margin.missingLines > 0 && /* @__PURE__ */ jsx129(Text54, { testID: "card-orders-cost-missing", className: "text-xs text-muted-foreground", children: `Cost missing on ${margin.missingQuantity} of ${totals.items} items` })
|
|
7314
7401
|
] }) }),
|
|
7315
|
-
/* @__PURE__ */
|
|
7316
|
-
/* @__PURE__ */
|
|
7317
|
-
/* @__PURE__ */
|
|
7402
|
+
/* @__PURE__ */ jsx129(ReportCard, { id: "payments", name: "Payments", figure: money(totals.grossMinor), ...card, children: payments.rows.length === 0 ? /* @__PURE__ */ jsx129(Empty, { testID: "card-payments-empty", children: "No payments in this period" }) : /* @__PURE__ */ jsxs80(Fragment14, { children: [
|
|
7403
|
+
/* @__PURE__ */ jsx129(ProportionalBar, { shares: paymentShares }),
|
|
7404
|
+
/* @__PURE__ */ jsx129(Legend, { shares: paymentShares })
|
|
7318
7405
|
] }) }),
|
|
7319
|
-
/* @__PURE__ */
|
|
7406
|
+
/* @__PURE__ */ jsx129(ReportCard, { id: "products", name: "Top products", figure: String(totals.items), ...card, children: products.length === 0 ? /* @__PURE__ */ jsx129(Empty, { testID: "card-products-empty", children: "No sales in this period" }) : /* @__PURE__ */ jsx129(View90, { className: "gap-2", children: products.slice(0, TOP_PRODUCTS).map((row) => {
|
|
7320
7407
|
const share = productNet > 0 ? Math.min(1, Math.max(0, row.netMinor / productNet)) : 0;
|
|
7321
7408
|
return /* @__PURE__ */ jsxs80(View90, { className: "gap-1", children: [
|
|
7322
7409
|
/* @__PURE__ */ jsxs80(View90, { className: "flex-row justify-between gap-2", children: [
|
|
7323
|
-
/* @__PURE__ */
|
|
7324
|
-
/* @__PURE__ */
|
|
7410
|
+
/* @__PURE__ */ jsx129(Text54, { className: "flex-1 text-sm text-foreground", numberOfLines: 1, children: row.name || "Unknown" }),
|
|
7411
|
+
/* @__PURE__ */ jsx129(Text54, { className: "text-sm font-medium text-foreground", children: money(row.netMinor) })
|
|
7325
7412
|
] }),
|
|
7326
|
-
/* @__PURE__ */
|
|
7327
|
-
/* @__PURE__ */
|
|
7413
|
+
/* @__PURE__ */ jsx129(View90, { className: "h-1.5 overflow-hidden rounded-md bg-muted", children: /* @__PURE__ */ jsx129(View90, { className: "h-full bg-primary", style: { width: `${share * 100}%` } }) }),
|
|
7414
|
+
/* @__PURE__ */ jsx129(Text54, { className: "text-xs text-muted-foreground", children: `${percent(share)} \xB7 ${row.quantity} sold` })
|
|
7328
7415
|
] }, row.key);
|
|
7329
7416
|
}) }) }),
|
|
7330
|
-
/* @__PURE__ */
|
|
7331
|
-
/* @__PURE__ */
|
|
7332
|
-
/* @__PURE__ */
|
|
7417
|
+
/* @__PURE__ */ jsx129(ReportCard, { id: "categories", name: "Categories", figure: money(categoryNet), ...card, children: categories.length === 0 ? /* @__PURE__ */ jsx129(Empty, { testID: "card-categories-empty", children: "No sales in this period" }) : /* @__PURE__ */ jsxs80(Fragment14, { children: [
|
|
7418
|
+
/* @__PURE__ */ jsx129(ProportionalBar, { shares: categoryShares }),
|
|
7419
|
+
/* @__PURE__ */ jsx129(Legend, { shares: categoryShares })
|
|
7333
7420
|
] }) }),
|
|
7334
|
-
/* @__PURE__ */
|
|
7335
|
-
/* @__PURE__ */
|
|
7336
|
-
/* @__PURE__ */
|
|
7337
|
-
/* @__PURE__ */
|
|
7421
|
+
/* @__PURE__ */ jsx129(ReportCard, { id: "taxes", name: "Taxes", figure: money(totals.taxMinor), ...card, children: taxes.length === 0 ? /* @__PURE__ */ jsx129(Empty, { testID: "card-taxes-empty", children: "None in this period" }) : /* @__PURE__ */ jsxs80(Fragment14, { children: [
|
|
7422
|
+
/* @__PURE__ */ jsx129(ProportionalBar, { shares: taxShares }),
|
|
7423
|
+
/* @__PURE__ */ jsx129(Legend, { shares: taxShares }),
|
|
7424
|
+
/* @__PURE__ */ jsx129(StatGrid, { stats: [
|
|
7338
7425
|
{ label: "Net", value: money(totals.netMinor) },
|
|
7339
7426
|
{ label: "Tax", value: money(totals.taxMinor) },
|
|
7340
7427
|
{ label: "Gross", value: money(totals.grossMinor) }
|
|
7341
7428
|
] })
|
|
7342
7429
|
] }) }),
|
|
7343
|
-
/* @__PURE__ */
|
|
7430
|
+
/* @__PURE__ */ jsx129(ReportCard, { id: "refunds", name: "Refunds", figure: money(refunds.amountMinor), ...card, children: refunds.count === 0 ? /* @__PURE__ */ jsx129(Empty, { testID: "card-refunds-none", children: "None in this period" }) : /* @__PURE__ */ jsx129(StatGrid, { stats: [
|
|
7344
7431
|
{ label: "Refunded", value: money(refunds.amountMinor) },
|
|
7345
7432
|
{ label: "Orders", value: `${refunds.orders} of ${totals.orderCount}` },
|
|
7346
7433
|
{
|
|
@@ -7353,11 +7440,11 @@ function SalesCards({ figures, currency, onOpenCard }) {
|
|
|
7353
7440
|
}
|
|
7354
7441
|
|
|
7355
7442
|
// src/reports/filters-bar.tsx
|
|
7356
|
-
import { useState as
|
|
7443
|
+
import { useState as useState37 } from "react";
|
|
7357
7444
|
import { Pressable as Pressable48, Text as Text55, View as View91 } from "react-native";
|
|
7358
7445
|
import { DATE_PRESETS, presetRange } from "@tallyui/pos";
|
|
7359
7446
|
import { cn as cn100 } from "@tallyui/theme";
|
|
7360
|
-
import { jsx as
|
|
7447
|
+
import { jsx as jsx130, jsxs as jsxs81 } from "react/jsx-runtime";
|
|
7361
7448
|
var PRESET_LABELS = {
|
|
7362
7449
|
today: "Today",
|
|
7363
7450
|
yesterday: "Yesterday",
|
|
@@ -7369,20 +7456,20 @@ var PRESET_LABELS = {
|
|
|
7369
7456
|
var ALL = "all";
|
|
7370
7457
|
var dayLabel = (day) => new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short", timeZone: "UTC" }).format(/* @__PURE__ */ new Date(`${day}T00:00:00Z`));
|
|
7371
7458
|
function ChoiceSelect({ id, value, options, onChange }) {
|
|
7372
|
-
const [open, setOpen] =
|
|
7459
|
+
const [open, setOpen] = useState37(false);
|
|
7373
7460
|
const chosen = options.find((option) => option.value === value);
|
|
7374
7461
|
return /* @__PURE__ */ jsxs81(View91, { className: "gap-1", children: [
|
|
7375
|
-
/* @__PURE__ */
|
|
7462
|
+
/* @__PURE__ */ jsx130(
|
|
7376
7463
|
Pressable48,
|
|
7377
7464
|
{
|
|
7378
7465
|
testID: id,
|
|
7379
7466
|
accessibilityRole: "button",
|
|
7380
7467
|
onPress: () => setOpen(!open),
|
|
7381
7468
|
className: "rounded-md border border-border bg-card px-3 py-2",
|
|
7382
|
-
children: /* @__PURE__ */
|
|
7469
|
+
children: /* @__PURE__ */ jsx130(Text55, { className: "text-sm text-foreground", children: chosen?.label ?? value })
|
|
7383
7470
|
}
|
|
7384
7471
|
),
|
|
7385
|
-
open && /* @__PURE__ */
|
|
7472
|
+
open && /* @__PURE__ */ jsx130(View91, { className: "rounded-md border border-border bg-card py-1", children: options.map((option) => /* @__PURE__ */ jsx130(
|
|
7386
7473
|
Pressable48,
|
|
7387
7474
|
{
|
|
7388
7475
|
testID: `${id}-option-${option.value}`,
|
|
@@ -7393,7 +7480,7 @@ function ChoiceSelect({ id, value, options, onChange }) {
|
|
|
7393
7480
|
onChange(option.value);
|
|
7394
7481
|
},
|
|
7395
7482
|
className: cn100("px-3 py-2", option.value === value && "bg-muted"),
|
|
7396
|
-
children: /* @__PURE__ */
|
|
7483
|
+
children: /* @__PURE__ */ jsx130(Text55, { className: "text-sm text-foreground", children: option.label })
|
|
7397
7484
|
},
|
|
7398
7485
|
option.value
|
|
7399
7486
|
)) })
|
|
@@ -7410,7 +7497,7 @@ function SalesFiltersBar({
|
|
|
7410
7497
|
}) {
|
|
7411
7498
|
const { range } = filters;
|
|
7412
7499
|
return /* @__PURE__ */ jsxs81(View91, { testID: "sales-filters", className: "flex-row flex-wrap items-start gap-2", children: [
|
|
7413
|
-
/* @__PURE__ */
|
|
7500
|
+
/* @__PURE__ */ jsx130(
|
|
7414
7501
|
ChoiceSelect,
|
|
7415
7502
|
{
|
|
7416
7503
|
id: "sales-filter-period",
|
|
@@ -7422,8 +7509,8 @@ function SalesFiltersBar({
|
|
|
7422
7509
|
}
|
|
7423
7510
|
}
|
|
7424
7511
|
),
|
|
7425
|
-
/* @__PURE__ */
|
|
7426
|
-
/* @__PURE__ */
|
|
7512
|
+
/* @__PURE__ */ jsx130(Text55, { testID: "sales-filter-dates", className: "py-2 text-sm text-muted-foreground", children: range.from === range.to ? dayLabel(range.from) : `${dayLabel(range.from)} \u2013 ${dayLabel(range.to)}` }),
|
|
7513
|
+
/* @__PURE__ */ jsx130(
|
|
7427
7514
|
ChoiceSelect,
|
|
7428
7515
|
{
|
|
7429
7516
|
id: "sales-filter-status",
|
|
@@ -7432,7 +7519,7 @@ function SalesFiltersBar({
|
|
|
7432
7519
|
onChange: (status) => onFiltersChange({ ...filters, status })
|
|
7433
7520
|
}
|
|
7434
7521
|
),
|
|
7435
|
-
/* @__PURE__ */
|
|
7522
|
+
/* @__PURE__ */ jsx130(
|
|
7436
7523
|
ChoiceSelect,
|
|
7437
7524
|
{
|
|
7438
7525
|
id: "sales-filter-cashier",
|
|
@@ -7441,7 +7528,7 @@ function SalesFiltersBar({
|
|
|
7441
7528
|
onChange: (value) => onFiltersChange({ ...filters, cashierId: value === ALL ? null : value })
|
|
7442
7529
|
}
|
|
7443
7530
|
),
|
|
7444
|
-
/* @__PURE__ */
|
|
7531
|
+
/* @__PURE__ */ jsx130(
|
|
7445
7532
|
ChoiceSelect,
|
|
7446
7533
|
{
|
|
7447
7534
|
id: "sales-filter-register",
|
|
@@ -7457,12 +7544,12 @@ function SalesFiltersBar({
|
|
|
7457
7544
|
import { Pressable as Pressable49, Text as Text56, View as View92 } from "react-native";
|
|
7458
7545
|
import { formatMoney as formatMoney25 } from "@tallyui/core";
|
|
7459
7546
|
import { cn as cn101 } from "@tallyui/theme";
|
|
7460
|
-
import { jsx as
|
|
7547
|
+
import { jsx as jsx131, jsxs as jsxs82 } from "react/jsx-runtime";
|
|
7461
7548
|
var NO_COMPARISON = "\u2014";
|
|
7462
7549
|
var signed = (diff, format) => diff === 0 ? "\xB10" : `${diff > 0 ? "+" : "\u2212"}${format(Math.abs(diff))}`;
|
|
7463
7550
|
function Difference({ testID, text, diff, suffix }) {
|
|
7464
7551
|
const tone = text === void 0 || diff === 0 ? "text-muted-foreground" : diff > 0 ? "text-success" : "text-destructive";
|
|
7465
|
-
return /* @__PURE__ */
|
|
7552
|
+
return /* @__PURE__ */ jsx131(Text56, { testID, className: cn101("text-sm", tone), accessibilityLabel: text === void 0 ? "No comparison" : void 0, children: text === void 0 ? NO_COMPARISON : suffix ? `${text} ${suffix}` : text });
|
|
7466
7553
|
}
|
|
7467
7554
|
function compareLabel(filters) {
|
|
7468
7555
|
if (filters.preset === "thisWeek" || filters.preset === "lastWeek") return "vs the week before";
|
|
@@ -7489,8 +7576,8 @@ function SalesHero({ figures, filters, onFiltersChange, currency }) {
|
|
|
7489
7576
|
const oneDay = filters.preset === "today" || filters.preset === "yesterday";
|
|
7490
7577
|
return /* @__PURE__ */ jsxs82(Card, { testID: "sales-hero", className: "gap-4 p-4", children: [
|
|
7491
7578
|
/* @__PURE__ */ jsxs82(View92, { className: "flex-row flex-wrap items-end gap-3", children: [
|
|
7492
|
-
/* @__PURE__ */
|
|
7493
|
-
/* @__PURE__ */
|
|
7579
|
+
/* @__PURE__ */ jsx131(Text56, { testID: "hero-total", className: "text-4xl font-bold text-foreground", children: money(totals.grossMinor) }),
|
|
7580
|
+
/* @__PURE__ */ jsx131(
|
|
7494
7581
|
Difference,
|
|
7495
7582
|
{
|
|
7496
7583
|
testID: "hero-delta",
|
|
@@ -7500,7 +7587,7 @@ function SalesHero({ figures, filters, onFiltersChange, currency }) {
|
|
|
7500
7587
|
}
|
|
7501
7588
|
)
|
|
7502
7589
|
] }),
|
|
7503
|
-
oneDay ? /* @__PURE__ */
|
|
7590
|
+
oneDay ? /* @__PURE__ */ jsx131(View92, { className: "flex-row gap-2", children: ["previous", "week"].map((compare) => /* @__PURE__ */ jsx131(
|
|
7504
7591
|
Pressable49,
|
|
7505
7592
|
{
|
|
7506
7593
|
testID: `hero-compare-${compare}`,
|
|
@@ -7508,14 +7595,14 @@ function SalesHero({ figures, filters, onFiltersChange, currency }) {
|
|
|
7508
7595
|
accessibilityState: { checked: filters.compare === compare },
|
|
7509
7596
|
onPress: () => onFiltersChange({ ...filters, compare }),
|
|
7510
7597
|
className: cn101("rounded-md border border-border px-3 py-1", filters.compare === compare && "bg-muted"),
|
|
7511
|
-
children: /* @__PURE__ */
|
|
7598
|
+
children: /* @__PURE__ */ jsx131(Text56, { className: "text-sm text-foreground", children: compareLabel({ ...filters, compare }) })
|
|
7512
7599
|
},
|
|
7513
7600
|
compare
|
|
7514
|
-
)) }) : /* @__PURE__ */
|
|
7515
|
-
/* @__PURE__ */
|
|
7516
|
-
/* @__PURE__ */
|
|
7517
|
-
/* @__PURE__ */
|
|
7518
|
-
/* @__PURE__ */
|
|
7601
|
+
)) }) : /* @__PURE__ */ jsx131(Text56, { testID: "hero-compare", className: "text-sm text-muted-foreground", children: label }),
|
|
7602
|
+
/* @__PURE__ */ jsx131(View92, { className: "flex-row flex-wrap gap-6", children: companions.map(({ id, name, value, prev, format }) => /* @__PURE__ */ jsxs82(View92, { className: "gap-0.5", children: [
|
|
7603
|
+
/* @__PURE__ */ jsx131(Text56, { className: "text-xs text-muted-foreground", children: name }),
|
|
7604
|
+
/* @__PURE__ */ jsx131(Text56, { testID: `hero-${id}`, className: "text-lg font-semibold text-foreground", children: format(value) }),
|
|
7605
|
+
/* @__PURE__ */ jsx131(
|
|
7519
7606
|
Difference,
|
|
7520
7607
|
{
|
|
7521
7608
|
testID: `hero-${id}-delta`,
|
|
@@ -7524,8 +7611,8 @@ function SalesHero({ figures, filters, onFiltersChange, currency }) {
|
|
|
7524
7611
|
}
|
|
7525
7612
|
)
|
|
7526
7613
|
] }, id)) }),
|
|
7527
|
-
/* @__PURE__ */
|
|
7528
|
-
compareSeries[i] && /* @__PURE__ */
|
|
7614
|
+
/* @__PURE__ */ jsx131(View92, { testID: "hero-chart", className: "h-40 flex-row items-end gap-1", children: series.map((point, i) => /* @__PURE__ */ jsxs82(View92, { className: "h-full flex-1 flex-row items-end gap-0.5", children: [
|
|
7615
|
+
compareSeries[i] && /* @__PURE__ */ jsx131(
|
|
7529
7616
|
View92,
|
|
7530
7617
|
{
|
|
7531
7618
|
testID: `hero-bar-compare-${i}`,
|
|
@@ -7533,22 +7620,22 @@ function SalesHero({ figures, filters, onFiltersChange, currency }) {
|
|
|
7533
7620
|
style: { height: height(compareSeries[i].grossMinor) }
|
|
7534
7621
|
}
|
|
7535
7622
|
),
|
|
7536
|
-
/* @__PURE__ */
|
|
7623
|
+
/* @__PURE__ */ jsx131(View92, { testID: `hero-bar-${i}`, className: "flex-1 rounded-sm bg-primary", style: { height: height(point.grossMinor) } })
|
|
7537
7624
|
] }, point.day)) }),
|
|
7538
7625
|
series.length > 0 && /* @__PURE__ */ jsxs82(View92, { className: "flex-row justify-between", children: [
|
|
7539
|
-
/* @__PURE__ */
|
|
7540
|
-
series.length > 1 && /* @__PURE__ */
|
|
7626
|
+
/* @__PURE__ */ jsx131(Text56, { className: "text-xs text-muted-foreground", children: dayLabel(series[0].day) }),
|
|
7627
|
+
series.length > 1 && /* @__PURE__ */ jsx131(Text56, { className: "text-xs text-muted-foreground", children: dayLabel(series[series.length - 1].day) })
|
|
7541
7628
|
] })
|
|
7542
7629
|
] });
|
|
7543
7630
|
}
|
|
7544
7631
|
|
|
7545
7632
|
// src/reports/sales-room.tsx
|
|
7546
|
-
import { jsx as
|
|
7633
|
+
import { jsx as jsx132, jsxs as jsxs83 } from "react/jsx-runtime";
|
|
7547
7634
|
function SalesRoom({ figures, filters, onFiltersChange, currency, onOpenCard, ...bar }) {
|
|
7548
7635
|
return /* @__PURE__ */ jsxs83(View93, { testID: "sales-room", className: "gap-4", children: [
|
|
7549
|
-
/* @__PURE__ */
|
|
7550
|
-
/* @__PURE__ */
|
|
7551
|
-
/* @__PURE__ */
|
|
7636
|
+
/* @__PURE__ */ jsx132(SalesFiltersBar, { filters, onFiltersChange, ...bar }),
|
|
7637
|
+
/* @__PURE__ */ jsx132(SalesHero, { figures, filters, onFiltersChange, currency }),
|
|
7638
|
+
/* @__PURE__ */ jsx132(SalesCards, { figures, currency, onOpenCard })
|
|
7552
7639
|
] });
|
|
7553
7640
|
}
|
|
7554
7641
|
export {
|
|
@@ -7665,6 +7752,7 @@ export {
|
|
|
7665
7752
|
HoverCard,
|
|
7666
7753
|
HoverCardContent,
|
|
7667
7754
|
HoverCardTrigger,
|
|
7755
|
+
I18nProvider,
|
|
7668
7756
|
Icon,
|
|
7669
7757
|
IconButton,
|
|
7670
7758
|
InCartBadge,
|
|
@@ -7805,5 +7893,6 @@ export {
|
|
|
7805
7893
|
useInputContext,
|
|
7806
7894
|
usePointer,
|
|
7807
7895
|
useScale,
|
|
7896
|
+
useT,
|
|
7808
7897
|
vstackVariants
|
|
7809
7898
|
};
|