@pisell/private-materials 6.12.169 → 6.12.170
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +10 -10
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +10 -10
- package/es/components/HDLKiosk/components/common/HDLKioskSkuOptionsSelection/index.less +1 -1
- package/es/components/HDLKiosk/components/overlays/HDLKioskModal/index.less +1 -1
- package/es/components/HDLKiosk/components/shell/HDLKioskBottomBarHost/index.js +4 -1
- package/es/components/HDLKiosk/docs/02-Host/351/200/202/351/205/215/344/270/216/344/270/232/345/212/241/346/225/260/346/215/256.md +20 -19
- package/es/components/HDLKiosk/index.js +10 -2
- package/es/components/HDLKiosk/index.less +7 -2
- package/es/components/HDLKiosk/slices/identity/Screen/index.less +1 -1
- package/es/components/HDLKiosk/slices/payment/Screen/index.less +1 -1
- package/es/components/HDLKiosk/ui/HDLKioskWorkflowView.js +26 -1
- package/es/components/HDLKiosk/ui/collaborationStatus.js +11 -0
- package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +0 -1
- package/es/components/bigSale/components/TimeBar/index.js +0 -1
- package/es/components/bigSale/dialog.js +0 -1
- package/es/components/bigSale/hooks/useBigSaleContext.js +0 -1
- package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +0 -1
- package/es/components/bigSale/index.js +0 -1
- package/es/components/bigSale/templates/HDLKiosk/README.md +43 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/createHost.js +7 -7
- package/es/components/bigSale/templates/HDLKiosk/adapter/{devices.js → devices/devicePort.js} +10 -38
- package/es/components/bigSale/templates/HDLKiosk/adapter/{capabilities.js → host/capabilities.js} +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/{fulfillment.js → host/fulfillmentWriter.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/{projection.js → host/projection.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/{telemetry.js → host/telemetry.js} +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +187 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.js +160 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/{customizationProduct.js → sales/customizationProduct.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/fulfillment.js +31 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/identity.js +57 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +18 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/payment.js +123 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +71 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/weightedOperations.js +124 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/{weightedProduct.js → sales/weightedProduct.js} +2 -2
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskAdapter.js +41 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +7 -7
- package/es/components/bigSale/templates/HDLKiosk/cart/useBigSaleHDLKioskCart.js +122 -0
- package/es/components/bigSale/templates/HDLKiosk/{adapter → hooks}/useHDLKioskEntryPreparationToast.js +2 -1
- package/es/components/bigSale/templates/HDLKiosk/index.js +40 -146
- package/es/components/bigSale/templates/HDLKiosk/{adapter/scaleTrigger.js → runtime/BigSaleScaleRuntimeOwner.js} +15 -59
- package/es/components/bigSale/templates/HDLKiosk/{adapter → runtime}/HDLKioskPaymentRuntime.js +2 -2
- package/es/components/bigSale/templates/HDLKiosk/runtime/scaleBridge.js +44 -0
- package/es/components/bigSale/templates/Kiosk/index.js +0 -1
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +0 -1
- package/es/index.js +0 -2
- package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
- package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
- package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
- package/es/plus/saleDetail/Base.js +0 -1
- package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +0 -1
- package/es/plus/saleDetail/components/DetailActions/index.js +0 -1
- package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +0 -1
- package/es/plus/saleDetail/index.js +0 -1
- package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +0 -1
- package/es/plus/saleDetail/tmpl/B/index.js +0 -1
- package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
- package/es/plus/salesSdk/utils/bookingDate.js +1 -1
- package/es/plus/salesSdk/utils/customerAuthGate.js +1 -1
- package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
- package/es/private-materials/lowcode/authmodal/meta.d.ts +1 -0
- package/es/pro/Login2.0/AuthModal.d.ts +1 -1
- package/es/pro/Login2.0/index.d.ts +1 -2
- package/es/pro/Login2.0/shared/types.d.ts +1 -1
- package/lib/components/HDLKiosk/components/common/HDLKioskSkuOptionsSelection/index.less +1 -1
- package/lib/components/HDLKiosk/components/overlays/HDLKioskModal/index.less +1 -1
- package/lib/components/HDLKiosk/components/shell/HDLKioskBottomBarHost/index.js +4 -1
- package/lib/components/HDLKiosk/docs/02-Host/351/200/202/351/205/215/344/270/216/344/270/232/345/212/241/346/225/260/346/215/256.md +20 -19
- package/lib/components/HDLKiosk/index.js +10 -2
- package/lib/components/HDLKiosk/index.less +7 -2
- package/lib/components/HDLKiosk/slices/identity/Screen/index.less +1 -1
- package/lib/components/HDLKiosk/slices/payment/Screen/index.less +1 -1
- package/lib/components/HDLKiosk/ui/HDLKioskWorkflowView.js +26 -1
- package/lib/components/HDLKiosk/ui/collaborationStatus.js +11 -0
- package/lib/components/bigSale/templates/HDLKiosk/README.md +43 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/createHost.js +9 -9
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{devices.js → devices/devicePort.js} +10 -38
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{capabilities.js → host/capabilities.js} +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{fulfillment.js → host/fulfillmentWriter.js} +3 -3
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{projection.js → host/projection.js} +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{telemetry.js → host/telemetry.js} +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +189 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.js +162 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{customizationProduct.js → sales/customizationProduct.js} +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/fulfillment.js +31 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/identity.js +57 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +18 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/payment.js +123 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +71 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/weightedOperations.js +126 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{weightedProduct.js → sales/weightedProduct.js} +3 -3
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskAdapter.js +42 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +7 -7
- package/lib/components/bigSale/templates/HDLKiosk/cart/useBigSaleHDLKioskCart.js +124 -0
- package/lib/components/bigSale/templates/HDLKiosk/{adapter → hooks}/useHDLKioskEntryPreparationToast.js +2 -1
- package/lib/components/bigSale/templates/HDLKiosk/index.js +41 -147
- package/lib/components/bigSale/templates/HDLKiosk/{adapter/scaleTrigger.js → runtime/BigSaleScaleRuntimeOwner.js} +14 -59
- package/lib/components/bigSale/templates/HDLKiosk/{adapter → runtime}/HDLKioskPaymentRuntime.js +2 -2
- package/lib/components/bigSale/templates/HDLKiosk/runtime/scaleBridge.js +44 -0
- package/package.json +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales.js +0 -710
- package/es/plus/pisellReservation/index.js +0 -17
- package/es/plus/salesSdk/index.js +0 -52
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales.js +0 -712
|
@@ -1,710 +0,0 @@
|
|
|
1
|
-
import { _objectSpread2 } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
-
import { _asyncToGenerator } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
3
|
-
import { resolveProductPricePresentation } from "../../../../../plus/productSelect/pricing/pricePresentation.js";
|
|
4
|
-
import { buildProductSkuPatch, resolvePatchProductOptions } from "../../../../../plus/salesSdk/utils/productSkuOptions.js";
|
|
5
|
-
import { pickIdentity } from "../../../../../plus/salesSdk/utils/identity.js";
|
|
6
|
-
import { buildProductLineUpdates } from "../../../../../plus/salesSdk/utils/buildProductLineUpdates.js";
|
|
7
|
-
import { resolveHDLWeightedProduct } from "../../../../HDLKiosk/product.js";
|
|
8
|
-
import { projectBigSaleCartLine, resolveBigSaleLineId, resolveBigSaleLiveTempOrder } from "./projection.js";
|
|
9
|
-
import { failed, isRecord, partialFailure, readPath, unknown } from "./normalize.js";
|
|
10
|
-
import { createHDLPrimaryWeightedPreparedProduct } from "./customizationProduct.js";
|
|
11
|
-
import Decimal from "decimal.js";
|
|
12
|
-
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales.ts
|
|
13
|
-
/**
|
|
14
|
-
* 文件角色:实现 HDLSalesPort 到 BigSale/SalesSDK 的全部命令和商品查询映射。
|
|
15
|
-
* 运行机制:对接 queryProducts、OS add flow、购物车、客户、Summary、Checkout、
|
|
16
|
-
* reset,并把 writer 返回投影成最小 receipt 供 Core 写后验证。
|
|
17
|
-
* 边界:复杂 OS 对象止于本文件;模糊 callback、缺 writer 或不可表达商品必须 fail closed。
|
|
18
|
-
*/
|
|
19
|
-
function cancelled(reason) {
|
|
20
|
-
return {
|
|
21
|
-
status: "cancelled",
|
|
22
|
-
reason
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
const PAYMENT_WRITE_FROZEN_STATUSES = new Set(["payment_pending", "processing"]);
|
|
26
|
-
function readPaymentStatus(order) {
|
|
27
|
-
var _order$payment_status;
|
|
28
|
-
return String((_order$payment_status = order === null || order === void 0 ? void 0 : order.payment_status) !== null && _order$payment_status !== void 0 ? _order$payment_status : "").trim().toLowerCase();
|
|
29
|
-
}
|
|
30
|
-
function hasCommittedOrderIdentity(order) {
|
|
31
|
-
const orderId = order === null || order === void 0 ? void 0 : order.order_id;
|
|
32
|
-
return orderId !== null && orderId !== void 0 && String(orderId).trim() !== "";
|
|
33
|
-
}
|
|
34
|
-
function isCommittedPaidOrder(order) {
|
|
35
|
-
return readPaymentStatus(order) === "paid" && hasCommittedOrderIdentity(order);
|
|
36
|
-
}
|
|
37
|
-
function findCartLine(context, lineId) {
|
|
38
|
-
var _context$cart$display;
|
|
39
|
-
return ((_context$cart$display = context.cart.displayLines) !== null && _context$cart$display !== void 0 ? _context$cart$display : context.cart.items).find((line) => resolveBigSaleLineId(line) === lineId);
|
|
40
|
-
}
|
|
41
|
-
function resolveCartProduct(line) {
|
|
42
|
-
var _line$_extend;
|
|
43
|
-
return "product_id" in line ? line : (_line$_extend = line._extend) === null || _line$_extend === void 0 ? void 0 : _line$_extend.product;
|
|
44
|
-
}
|
|
45
|
-
function hasRequestedWeight(product, requestedWeightKg) {
|
|
46
|
-
var _product$product_sku$, _product$product_sku;
|
|
47
|
-
const actual = new Decimal((_product$product_sku$ = (_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.net_weight) !== null && _product$product_sku$ !== void 0 ? _product$product_sku$ : NaN);
|
|
48
|
-
const expected = new Decimal(requestedWeightKg || NaN);
|
|
49
|
-
return actual.isFinite() && expected.isFinite() && actual.equals(expected);
|
|
50
|
-
}
|
|
51
|
-
function findConfirmedMutationLine(products, productId, requestedWeightKg, uniqueId) {
|
|
52
|
-
return [...products].reverse().find((candidate) => {
|
|
53
|
-
var _candidate$product_id, _candidate$metadata$u, _candidate$metadata;
|
|
54
|
-
if (String((_candidate$product_id = candidate.product_id) !== null && _candidate$product_id !== void 0 ? _candidate$product_id : "") !== productId) return false;
|
|
55
|
-
if (!hasRequestedWeight(candidate, requestedWeightKg)) return false;
|
|
56
|
-
if (uniqueId == null || uniqueId === "") return true;
|
|
57
|
-
return String((_candidate$metadata$u = (_candidate$metadata = candidate.metadata) === null || _candidate$metadata === void 0 ? void 0 : _candidate$metadata.unique_identification_number) !== null && _candidate$metadata$u !== void 0 ? _candidate$metadata$u : "") === String(uniqueId);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
function projectConfirmedMutationLine(product) {
|
|
61
|
-
var _projectBigSaleCartLi;
|
|
62
|
-
return product ? (_projectBigSaleCartLi = projectBigSaleCartLine(product)) !== null && _projectBigSaleCartLi !== void 0 ? _projectBigSaleCartLi : void 0 : void 0;
|
|
63
|
-
}
|
|
64
|
-
function projectConfirmedCartLineById(products, lineId) {
|
|
65
|
-
return projectConfirmedMutationLine(products.find((candidate) => resolveBigSaleLineId(candidate) === lineId));
|
|
66
|
-
}
|
|
67
|
-
function projectConfirmedCustomer(customer) {
|
|
68
|
-
var _customer$id;
|
|
69
|
-
if (!customer || [
|
|
70
|
-
"0",
|
|
71
|
-
"1",
|
|
72
|
-
""
|
|
73
|
-
].includes(String((_customer$id = customer.id) !== null && _customer$id !== void 0 ? _customer$id : ""))) return;
|
|
74
|
-
return Object.freeze(_objectSpread2(_objectSpread2({
|
|
75
|
-
customerId: String(customer.id),
|
|
76
|
-
displayName: typeof customer.name === "string" ? customer.name : void 0
|
|
77
|
-
}, typeof customer.avatar === "string" && customer.avatar.trim() ? { avatarUrl: customer.avatar.trim() } : {}), {}, { member: true }));
|
|
78
|
-
}
|
|
79
|
-
function findOrderProduct(context, product) {
|
|
80
|
-
var _product$_identity, _context$sales$tempOr, _products$find;
|
|
81
|
-
const uniqueId = ((_product$_identity = product._identity) !== null && _product$_identity !== void 0 ? _product$_identity : pickIdentity(product)).unique_identification_number;
|
|
82
|
-
return (_products$find = (((_context$sales$tempOr = context.sales.tempOrder) === null || _context$sales$tempOr === void 0 ? void 0 : _context$sales$tempOr.products) || []).find((candidate) => {
|
|
83
|
-
var _candidate$metadata$u2, _candidate$metadata2;
|
|
84
|
-
return uniqueId != null && String((_candidate$metadata$u2 = (_candidate$metadata2 = candidate.metadata) === null || _candidate$metadata2 === void 0 ? void 0 : _candidate$metadata2.unique_identification_number) !== null && _candidate$metadata$u2 !== void 0 ? _candidate$metadata$u2 : "") === String(uniqueId);
|
|
85
|
-
})) !== null && _products$find !== void 0 ? _products$find : product;
|
|
86
|
-
}
|
|
87
|
-
function findCatalogProduct(context, productId) {
|
|
88
|
-
return context.products.products.find((product) => String(product.id) === productId);
|
|
89
|
-
}
|
|
90
|
-
function resolveProductQuery(context) {
|
|
91
|
-
var _bookingTicket$store;
|
|
92
|
-
if (typeof context.products.queryProducts === "function") return function() {
|
|
93
|
-
var _ref = _asyncToGenerator(function* (params) {
|
|
94
|
-
return (yield context.products.queryProducts.call(context.products, params)) || [];
|
|
95
|
-
});
|
|
96
|
-
return function(_x) {
|
|
97
|
-
return _ref.apply(this, arguments);
|
|
98
|
-
};
|
|
99
|
-
}();
|
|
100
|
-
const bookingTicket = context.sales.bookingTicket;
|
|
101
|
-
if (typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.queryProducts) === "function") return function() {
|
|
102
|
-
var _ref2 = _asyncToGenerator(function* (params) {
|
|
103
|
-
return (yield bookingTicket.queryProducts(params)) || [];
|
|
104
|
-
});
|
|
105
|
-
return function(_x2) {
|
|
106
|
-
return _ref2.apply(this, arguments);
|
|
107
|
-
};
|
|
108
|
-
}();
|
|
109
|
-
const productListStore = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$store = bookingTicket.store) === null || _bookingTicket$store === void 0 ? void 0 : _bookingTicket$store.products;
|
|
110
|
-
if (typeof (productListStore === null || productListStore === void 0 ? void 0 : productListStore.queryProducts) === "function") return function() {
|
|
111
|
-
var _ref3 = _asyncToGenerator(function* (params) {
|
|
112
|
-
return (yield productListStore.queryProducts.call(productListStore, params)) || [];
|
|
113
|
-
});
|
|
114
|
-
return function(_x3) {
|
|
115
|
-
return _ref3.apply(this, arguments);
|
|
116
|
-
};
|
|
117
|
-
}();
|
|
118
|
-
}
|
|
119
|
-
function queryPrimaryProduct(_x4, _x5, _x6) {
|
|
120
|
-
return _queryPrimaryProduct.apply(this, arguments);
|
|
121
|
-
}
|
|
122
|
-
function _queryPrimaryProduct() {
|
|
123
|
-
_queryPrimaryProduct = _asyncToGenerator(function* (context, productId, signal) {
|
|
124
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
125
|
-
const queryProducts = resolveProductQuery(context);
|
|
126
|
-
if (typeof queryProducts !== "function") return failed("primaryProductQueryUnavailable", "staff");
|
|
127
|
-
try {
|
|
128
|
-
let products = yield queryProducts({ includeIds: [productId] });
|
|
129
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
130
|
-
let product = products.find((candidate) => String(candidate.id) === productId);
|
|
131
|
-
const numericProductId = Number(productId);
|
|
132
|
-
if (!product && Number.isSafeInteger(numericProductId) && numericProductId > 0 && typeof context.products.findByIds === "function") {
|
|
133
|
-
yield context.products.findByIds([numericProductId], {
|
|
134
|
-
loadMissing: true,
|
|
135
|
-
refreshCatalog: false
|
|
136
|
-
});
|
|
137
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
138
|
-
products = yield queryProducts({ includeIds: [productId] });
|
|
139
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
140
|
-
product = products.find((candidate) => String(candidate.id) === productId);
|
|
141
|
-
}
|
|
142
|
-
return product ? {
|
|
143
|
-
status: "succeeded",
|
|
144
|
-
data: product
|
|
145
|
-
} : failed("primaryProductNotFound", "staff");
|
|
146
|
-
} catch (error) {
|
|
147
|
-
return partialFailure("primaryProductQueryFailed", error);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
return _queryPrimaryProduct.apply(this, arguments);
|
|
151
|
-
}
|
|
152
|
-
function readProductName(product) {
|
|
153
|
-
const rawName = product.title;
|
|
154
|
-
if (typeof rawName === "string") return rawName || void 0;
|
|
155
|
-
if (!rawName || typeof rawName !== "object") return void 0;
|
|
156
|
-
return Object.values(rawName).find((value) => typeof value === "string" && value.length > 0);
|
|
157
|
-
}
|
|
158
|
-
function readLocalizedText(value) {
|
|
159
|
-
if (typeof value === "string") return value || void 0;
|
|
160
|
-
if (!value || typeof value !== "object") return void 0;
|
|
161
|
-
return Object.values(value).find((item) => typeof item === "string" && item.length > 0);
|
|
162
|
-
}
|
|
163
|
-
function projectProductCategories(product) {
|
|
164
|
-
const directCategories = Array.isArray(product.category) ? product.category : [];
|
|
165
|
-
const categories = /* @__PURE__ */ new Map();
|
|
166
|
-
const visit = (category, direct) => {
|
|
167
|
-
var _category$name, _ref4, _category$parent_id;
|
|
168
|
-
if (!category || category.id === void 0 || category.id === null) return;
|
|
169
|
-
const parent = category.parent_category;
|
|
170
|
-
visit(parent, false);
|
|
171
|
-
const categoryId = String(category.id);
|
|
172
|
-
const name = readLocalizedText((_category$name = category.name) !== null && _category$name !== void 0 ? _category$name : category.title);
|
|
173
|
-
if (!name) return;
|
|
174
|
-
const parentId = (_ref4 = (_category$parent_id = category.parent_id) !== null && _category$parent_id !== void 0 ? _category$parent_id : parent === null || parent === void 0 ? void 0 : parent.id) !== null && _ref4 !== void 0 ? _ref4 : void 0;
|
|
175
|
-
const previous = categories.get(categoryId);
|
|
176
|
-
categories.set(categoryId, Object.freeze({
|
|
177
|
-
categoryId,
|
|
178
|
-
name,
|
|
179
|
-
parentId: parentId === void 0 || parentId === null || parentId === 0 ? void 0 : String(parentId),
|
|
180
|
-
sort: Number.isFinite(Number(category.sort)) ? Number(category.sort) : void 0,
|
|
181
|
-
direct: direct || (previous === null || previous === void 0 ? void 0 : previous.direct) === true
|
|
182
|
-
}));
|
|
183
|
-
};
|
|
184
|
-
directCategories.forEach((category) => visit(category, true));
|
|
185
|
-
return Object.freeze(Array.from(categories.values()));
|
|
186
|
-
}
|
|
187
|
-
function projectCatalogProduct(product, currency, currencySymbol) {
|
|
188
|
-
var _ref5, _ref6, _product$price, _product$variants, _product$variants2;
|
|
189
|
-
const name = readProductName(product);
|
|
190
|
-
if (!name) return void 0;
|
|
191
|
-
const rawPrice = (_ref5 = (_ref6 = (_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : product.selling_price) !== null && _ref6 !== void 0 ? _ref6 : (_product$variants = product.variants) === null || _product$variants === void 0 || (_product$variants = _product$variants[0]) === null || _product$variants === void 0 ? void 0 : _product$variants.selling_price) !== null && _ref5 !== void 0 ? _ref5 : (_product$variants2 = product.variants) === null || _product$variants2 === void 0 || (_product$variants2 = _product$variants2[0]) === null || _product$variants2 === void 0 ? void 0 : _product$variants2.price;
|
|
192
|
-
const pricePresentation = resolveProductPricePresentation(product, rawPrice === void 0 || rawPrice === null ? void 0 : { price: rawPrice });
|
|
193
|
-
const categories = projectProductCategories(product);
|
|
194
|
-
return Object.freeze(_objectSpread2({
|
|
195
|
-
productId: String(product.id),
|
|
196
|
-
name,
|
|
197
|
-
imageUrl: product.cover || void 0,
|
|
198
|
-
currency: currency || void 0,
|
|
199
|
-
currencySymbol: currencySymbol || void 0,
|
|
200
|
-
pricePresentation: pricePresentation ? Object.freeze({
|
|
201
|
-
amount: String(pricePresentation.amount),
|
|
202
|
-
originalAmount: pricePresentation.originalAmount === void 0 ? void 0 : String(pricePresentation.originalAmount),
|
|
203
|
-
qualifier: pricePresentation.qualifier,
|
|
204
|
-
unit: pricePresentation.unit,
|
|
205
|
-
precision: pricePresentation.precision
|
|
206
|
-
}) : void 0,
|
|
207
|
-
available: product.status !== "disabled" && product.status !== "sold_out" && product.is_sold_out !== true
|
|
208
|
-
}, categories.length ? { categories } : {}));
|
|
209
|
-
}
|
|
210
|
-
function normalizeCheckoutResult(result, snapshot) {
|
|
211
|
-
var _readPath;
|
|
212
|
-
const status = isRecord(result) ? result.status : void 0;
|
|
213
|
-
const reason = isRecord(result) ? result.reason : void 0;
|
|
214
|
-
const type = isRecord(result) ? result.type : void 0;
|
|
215
|
-
if (status === "cancelled" || reason === "back" || reason === "cancel") return {
|
|
216
|
-
status: "cancelled",
|
|
217
|
-
reason: String(reason !== null && reason !== void 0 ? reason : "cancelled")
|
|
218
|
-
};
|
|
219
|
-
const paymentStatus = (_readPath = readPath(result, [
|
|
220
|
-
"payload",
|
|
221
|
-
"paymentResult",
|
|
222
|
-
"paymentResultViewModel",
|
|
223
|
-
"status"
|
|
224
|
-
])) !== null && _readPath !== void 0 ? _readPath : readPath(result, [
|
|
225
|
-
"data",
|
|
226
|
-
"paymentResult",
|
|
227
|
-
"paymentResultViewModel",
|
|
228
|
-
"status"
|
|
229
|
-
]);
|
|
230
|
-
if (paymentStatus === "failed" || paymentStatus === "wallet-pass-failed") return failed("checkoutFailed", "retry");
|
|
231
|
-
if (type === "error" || status === "failed") return failed("checkoutFailed", "retry");
|
|
232
|
-
if (paymentStatus === "success" || paymentStatus === "paid" || paymentStatus === "deposit-paid" || status === "success" || status === "paid") {
|
|
233
|
-
var _result$orderId, _snapshot$orderId, _snapshot$customer;
|
|
234
|
-
const resultOrderId = isRecord(result) && ((_result$orderId = result.orderId) !== null && _result$orderId !== void 0 ? _result$orderId : result.order_id) || readPath(result, ["payload", "order_id"]) || readPath(result, ["payload", "orderId"]);
|
|
235
|
-
const orderId = (_snapshot$orderId = snapshot.orderId) !== null && _snapshot$orderId !== void 0 ? _snapshot$orderId : resultOrderId;
|
|
236
|
-
if (!orderId || snapshot.summary.status !== "ready") return unknown("checkoutSuccessMissingOrderFacts");
|
|
237
|
-
return {
|
|
238
|
-
status: "succeeded",
|
|
239
|
-
data: {
|
|
240
|
-
orderId: String(orderId),
|
|
241
|
-
amount: snapshot.summary.due,
|
|
242
|
-
member: ((_snapshot$customer = snapshot.customer) === null || _snapshot$customer === void 0 ? void 0 : _snapshot$customer.member) === true
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
return unknown("checkoutResultAmbiguous");
|
|
247
|
-
}
|
|
248
|
-
function refreshCheckoutOrderProjection(_x7, _x8, _x9) {
|
|
249
|
-
return _refreshCheckoutOrderProjection.apply(this, arguments);
|
|
250
|
-
}
|
|
251
|
-
function _refreshCheckoutOrderProjection() {
|
|
252
|
-
_refreshCheckoutOrderProjection = _asyncToGenerator(function* (getContext, getSnapshot, result) {
|
|
253
|
-
if (result.status !== "succeeded" || getSnapshot().pickupNumber) return;
|
|
254
|
-
const loadDetail = getContext().sales.loadDetail;
|
|
255
|
-
if (typeof loadDetail !== "function") return;
|
|
256
|
-
try {
|
|
257
|
-
yield loadDetail({
|
|
258
|
-
orderId: result.data.orderId,
|
|
259
|
-
forceRemote: true
|
|
260
|
-
});
|
|
261
|
-
} catch (_unused) {}
|
|
262
|
-
});
|
|
263
|
-
return _refreshCheckoutOrderProjection.apply(this, arguments);
|
|
264
|
-
}
|
|
265
|
-
function createBigSaleSalesPort({ getContext, getSnapshot, executeScan, writeFulfillment, getWriteFulfillment, getAuthenticatedCustomer, allowSimulatedFulfillment = false, onSimulatedFulfillment, subscribeProjection, getPaymentController }) {
|
|
266
|
-
return {
|
|
267
|
-
getObservedSnapshot: getSnapshot,
|
|
268
|
-
getCatalogSnapshot: () => {
|
|
269
|
-
var _context$sales$tempOr2, _context$sales$tempOr3, _context$sales$tempOr4, _context$sales$tempOr5;
|
|
270
|
-
const context = getContext();
|
|
271
|
-
const currency = String((_context$sales$tempOr2 = (_context$sales$tempOr3 = context.sales.tempOrder) === null || _context$sales$tempOr3 === void 0 ? void 0 : _context$sales$tempOr3.currency_code) !== null && _context$sales$tempOr2 !== void 0 ? _context$sales$tempOr2 : "");
|
|
272
|
-
const currencySymbol = String((_context$sales$tempOr4 = (_context$sales$tempOr5 = context.sales.tempOrder) === null || _context$sales$tempOr5 === void 0 ? void 0 : _context$sales$tempOr5.currency_symbol) !== null && _context$sales$tempOr4 !== void 0 ? _context$sales$tempOr4 : "");
|
|
273
|
-
const products = context.products.products.map((product) => projectCatalogProduct(product, currency, currencySymbol)).filter((product) => product !== void 0);
|
|
274
|
-
return Object.freeze({
|
|
275
|
-
status: context.products.error ? "error" : context.products.loading || context.sales.catalogState === "pending" ? "loading" : "ready",
|
|
276
|
-
products: Object.freeze(products)
|
|
277
|
-
});
|
|
278
|
-
},
|
|
279
|
-
subscribe: (listener) => {
|
|
280
|
-
var _subscribeProjection;
|
|
281
|
-
return (_subscribeProjection = subscribeProjection === null || subscribeProjection === void 0 ? void 0 : subscribeProjection(listener)) !== null && _subscribeProjection !== void 0 ? _subscribeProjection : (() => void 0);
|
|
282
|
-
},
|
|
283
|
-
ensureSession: function() {
|
|
284
|
-
var _ref7 = _asyncToGenerator(function* (signal) {
|
|
285
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
286
|
-
const context = getContext();
|
|
287
|
-
const currentOrder = resolveBigSaleLiveTempOrder(context);
|
|
288
|
-
const currentPaymentStatus = readPaymentStatus(currentOrder);
|
|
289
|
-
if (PAYMENT_WRITE_FROZEN_STATUSES.has(currentPaymentStatus)) return unknown("ensureSessionPaymentInProgress");
|
|
290
|
-
if (currentOrder && !isCommittedPaidOrder(currentOrder)) return {
|
|
291
|
-
status: "succeeded",
|
|
292
|
-
data: void 0
|
|
293
|
-
};
|
|
294
|
-
try {
|
|
295
|
-
const createdOrder = isCommittedPaidOrder(currentOrder) ? yield context.sales.clearCartAndReset() : yield context.sales.createNew();
|
|
296
|
-
if (signal.aborted) return unknown("ensureSessionAbortedAfterDispatch");
|
|
297
|
-
const liveCreatedOrder = resolveBigSaleLiveTempOrder(getContext());
|
|
298
|
-
const createdPaymentStatus = readPaymentStatus(liveCreatedOrder !== null && liveCreatedOrder !== void 0 ? liveCreatedOrder : createdOrder);
|
|
299
|
-
if (isCommittedPaidOrder(liveCreatedOrder !== null && liveCreatedOrder !== void 0 ? liveCreatedOrder : createdOrder) || PAYMENT_WRITE_FROZEN_STATUSES.has(createdPaymentStatus)) return unknown("ensureSessionNotWritable");
|
|
300
|
-
return {
|
|
301
|
-
status: "succeeded",
|
|
302
|
-
data: void 0
|
|
303
|
-
};
|
|
304
|
-
} catch (error) {
|
|
305
|
-
return partialFailure("ensureSessionFailed", error);
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
return function ensureSession(_x10) {
|
|
309
|
-
return _ref7.apply(this, arguments);
|
|
310
|
-
};
|
|
311
|
-
}(),
|
|
312
|
-
loadPrimaryProduct: function() {
|
|
313
|
-
var _ref8 = _asyncToGenerator(function* (rawProductId, signal) {
|
|
314
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
315
|
-
const productId = Number(rawProductId);
|
|
316
|
-
if (!Number.isFinite(productId)) return failed("primaryProductIdInvalid", "staff");
|
|
317
|
-
try {
|
|
318
|
-
const productResult = yield queryPrimaryProduct(getContext(), String(productId), signal);
|
|
319
|
-
if (productResult.status !== "succeeded") return productResult;
|
|
320
|
-
return {
|
|
321
|
-
status: "succeeded",
|
|
322
|
-
data: productResult.data
|
|
323
|
-
};
|
|
324
|
-
} catch (error) {
|
|
325
|
-
return partialFailure("primaryProductLoadFailed", error);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
return function loadPrimaryProduct(_x11, _x12) {
|
|
329
|
-
return _ref8.apply(this, arguments);
|
|
330
|
-
};
|
|
331
|
-
}(),
|
|
332
|
-
selectIdentity: function() {
|
|
333
|
-
var _ref9 = _asyncToGenerator(function* (input, signal) {
|
|
334
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
335
|
-
try {
|
|
336
|
-
var _input$customerId, _currentCustomer$id, _selected$id;
|
|
337
|
-
const context = getContext();
|
|
338
|
-
const customerId = (_input$customerId = input.customerId) === null || _input$customerId === void 0 ? void 0 : _input$customerId.trim();
|
|
339
|
-
if (!customerId) {
|
|
340
|
-
context.customer.select(null);
|
|
341
|
-
if (signal.aborted) return unknown("identityAbortedAfterDispatch");
|
|
342
|
-
return {
|
|
343
|
-
status: "succeeded",
|
|
344
|
-
data: {}
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
const authenticatedCustomer = getAuthenticatedCustomer === null || getAuthenticatedCustomer === void 0 ? void 0 : getAuthenticatedCustomer(customerId);
|
|
348
|
-
const currentCustomer = context.customer.selected;
|
|
349
|
-
const selected = authenticatedCustomer !== null && authenticatedCustomer !== void 0 ? authenticatedCustomer : String((_currentCustomer$id = currentCustomer === null || currentCustomer === void 0 ? void 0 : currentCustomer.id) !== null && _currentCustomer$id !== void 0 ? _currentCustomer$id : "") === customerId ? currentCustomer : void 0;
|
|
350
|
-
if (!selected || String(selected.id) !== customerId || [
|
|
351
|
-
"0",
|
|
352
|
-
"1",
|
|
353
|
-
""
|
|
354
|
-
].includes(String((_selected$id = selected.id) !== null && _selected$id !== void 0 ? _selected$id : ""))) return failed("authenticatedCustomerUnavailable", "back");
|
|
355
|
-
context.customer.select(selected);
|
|
356
|
-
if (signal.aborted) return unknown("identityAbortedAfterDispatch");
|
|
357
|
-
return {
|
|
358
|
-
status: "succeeded",
|
|
359
|
-
data: { customer: projectConfirmedCustomer(selected) }
|
|
360
|
-
};
|
|
361
|
-
} catch (error) {
|
|
362
|
-
return partialFailure("identitySelectionFailed", error);
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
return function selectIdentity(_x13, _x14) {
|
|
366
|
-
return _ref9.apply(this, arguments);
|
|
367
|
-
};
|
|
368
|
-
}(),
|
|
369
|
-
setFulfillment: function() {
|
|
370
|
-
var _ref10 = _asyncToGenerator(function* (input, signal) {
|
|
371
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
372
|
-
const currentWriteFulfillment = getWriteFulfillment ? getWriteFulfillment() : writeFulfillment;
|
|
373
|
-
if (!currentWriteFulfillment) {
|
|
374
|
-
if (allowSimulatedFulfillment) {
|
|
375
|
-
onSimulatedFulfillment === null || onSimulatedFulfillment === void 0 || onSimulatedFulfillment(input);
|
|
376
|
-
return {
|
|
377
|
-
status: "succeeded",
|
|
378
|
-
data: void 0
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
return failed("fulfillmentHostWriterUnavailable", "staff");
|
|
382
|
-
}
|
|
383
|
-
try {
|
|
384
|
-
return yield currentWriteFulfillment(input, signal);
|
|
385
|
-
} catch (error) {
|
|
386
|
-
return partialFailure("fulfillmentWriteFailed", error);
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
return function setFulfillment(_x15, _x16) {
|
|
390
|
-
return _ref10.apply(this, arguments);
|
|
391
|
-
};
|
|
392
|
-
}(),
|
|
393
|
-
syncPrimaryWeightedProduct: function() {
|
|
394
|
-
var _ref12 = _asyncToGenerator(function* (input, signal) {
|
|
395
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
396
|
-
const productId = Number(input.productId);
|
|
397
|
-
if (!Number.isFinite(productId)) return failed("primaryWeightedProductInputInvalid", "staff");
|
|
398
|
-
try {
|
|
399
|
-
const context = getContext();
|
|
400
|
-
const productResult = yield queryPrimaryProduct(context, String(productId), signal);
|
|
401
|
-
if (productResult.status !== "succeeded") return productResult;
|
|
402
|
-
const product = productResult.data;
|
|
403
|
-
const resolved = resolveHDLWeightedProduct(product);
|
|
404
|
-
if (!resolved) return failed("primaryWeightedProductConfigInvalid", "staff");
|
|
405
|
-
const prepared = createHDLPrimaryWeightedPreparedProduct(resolved, input);
|
|
406
|
-
if (!prepared) return failed("primaryWeightedProductSelectionInvalid", "retry");
|
|
407
|
-
if (input.existingLineId) {
|
|
408
|
-
var _cartProduct$_identit, _identity$product_var, _ref11, _productPatch$product;
|
|
409
|
-
const displayLine = findCartLine(context, input.existingLineId);
|
|
410
|
-
const cartProduct = displayLine ? resolveCartProduct(displayLine) : void 0;
|
|
411
|
-
const bookingTicket = context.sales.bookingTicket;
|
|
412
|
-
if (!cartProduct) return failed("primaryWeightedProductLineNotFound", "back");
|
|
413
|
-
if (typeof context.cart.updateItem !== "function" || typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.transformDetailToProductAndBooking) !== "function") return failed("primaryWeightedProductUpdateUnavailable", "staff");
|
|
414
|
-
const orderLine = findOrderProduct(context, cartProduct);
|
|
415
|
-
const identity = (_cartProduct$_identit = cartProduct._identity) !== null && _cartProduct$_identit !== void 0 ? _cartProduct$_identit : pickIdentity(orderLine);
|
|
416
|
-
const preparedForUpdate = _objectSpread2(_objectSpread2({}, prepared), {}, { _extend: _objectSpread2(_objectSpread2({}, prepared._extend || {}), identity.unique_identification_number != null ? { unique_identification_number: identity.unique_identification_number } : {}) });
|
|
417
|
-
const transformed = bookingTicket.transformDetailToProductAndBooking({
|
|
418
|
-
item: resolved.product,
|
|
419
|
-
cacheItem: preparedForUpdate
|
|
420
|
-
});
|
|
421
|
-
const productPatch = transformed === null || transformed === void 0 ? void 0 : transformed.product;
|
|
422
|
-
if (!productPatch) return failed("primaryWeightedProductUpdateInvalid", "retry");
|
|
423
|
-
const patchVariantId = Number(productPatch.product_variant_id);
|
|
424
|
-
const nextVariantId = Number.isFinite(patchVariantId) && patchVariantId > 0 ? patchVariantId : Number((_identity$product_var = identity.product_variant_id) !== null && _identity$product_var !== void 0 ? _identity$product_var : 0);
|
|
425
|
-
const nextOptions = resolvePatchProductOptions(orderLine, productPatch);
|
|
426
|
-
const lineUpdates = buildProductLineUpdates(orderLine, productPatch);
|
|
427
|
-
lineUpdates.metadata = _objectSpread2(_objectSpread2({}, lineUpdates.metadata || {}), identity.unique_identification_number != null ? { unique_identification_number: identity.unique_identification_number } : {});
|
|
428
|
-
const updatedProducts = yield context.cart.updateItem({
|
|
429
|
-
product_id: identity.product_id,
|
|
430
|
-
product_variant_id: nextVariantId,
|
|
431
|
-
unique_identification_number: identity.unique_identification_number,
|
|
432
|
-
identity_key: identity.identity_key,
|
|
433
|
-
product_sku: buildProductSkuPatch(orderLine, nextOptions, productPatch.product_sku),
|
|
434
|
-
product_option_item: nextOptions,
|
|
435
|
-
product_bundle: (_ref11 = (_productPatch$product = productPatch.product_bundle) !== null && _productPatch$product !== void 0 ? _productPatch$product : identity.product_bundle) !== null && _ref11 !== void 0 ? _ref11 : [],
|
|
436
|
-
updates: lineUpdates
|
|
437
|
-
});
|
|
438
|
-
if (signal.aborted) return unknown("primaryProductUpdateAbortedAfterDispatch");
|
|
439
|
-
const confirmedLine = projectConfirmedMutationLine(findConfirmedMutationLine(updatedProducts, input.productId, input.measurement.netWeightKg, identity.unique_identification_number));
|
|
440
|
-
return {
|
|
441
|
-
status: "succeeded",
|
|
442
|
-
data: _objectSpread2({ affectedLineId: input.existingLineId }, confirmedLine ? { confirmedLine } : {})
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
const result = yield context.cart.addProductWithFlow(product, {
|
|
446
|
-
quantity: 1,
|
|
447
|
-
debounceMs: 0,
|
|
448
|
-
notShowToast: true,
|
|
449
|
-
preparedCacheItem: prepared
|
|
450
|
-
});
|
|
451
|
-
if (signal.aborted) return unknown("primaryProductAddAbortedAfterDispatch");
|
|
452
|
-
if (result.status === "cancelled") return cancelled("userCancelled");
|
|
453
|
-
if (result.status !== "added") return unknown("primaryProductAddAmbiguous");
|
|
454
|
-
const confirmedLine = projectConfirmedMutationLine(findConfirmedMutationLine(result.products, input.productId, input.measurement.netWeightKg));
|
|
455
|
-
return {
|
|
456
|
-
status: "succeeded",
|
|
457
|
-
data: confirmedLine ? {
|
|
458
|
-
affectedLineId: confirmedLine.lineId,
|
|
459
|
-
confirmedLine
|
|
460
|
-
} : {}
|
|
461
|
-
};
|
|
462
|
-
} catch (error) {
|
|
463
|
-
return partialFailure("primaryWeightedProductSyncFailed", error);
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
return function syncPrimaryWeightedProduct(_x17, _x18) {
|
|
467
|
-
return _ref12.apply(this, arguments);
|
|
468
|
-
};
|
|
469
|
-
}(),
|
|
470
|
-
consumeBarcode: function() {
|
|
471
|
-
var _ref13 = _asyncToGenerator(function* (code, signal) {
|
|
472
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
473
|
-
if (!code.trim()) return failed("barcodeEmpty", "back");
|
|
474
|
-
try {
|
|
475
|
-
var _scanResult$meta$coun, _scanResult$meta;
|
|
476
|
-
const execution = yield executeScan(code);
|
|
477
|
-
if (signal.aborted) return unknown("barcodeAbortedAfterDispatch");
|
|
478
|
-
const scanResult = execution.scanResult;
|
|
479
|
-
if (!scanResult) return failed("barcodeUnavailable", "staff");
|
|
480
|
-
if (scanResult.status === "cancelled") return {
|
|
481
|
-
status: "cancelled",
|
|
482
|
-
reason: scanResult.reason
|
|
483
|
-
};
|
|
484
|
-
if (scanResult.status === "failed") return failed("barcodeNotResolved", "retry");
|
|
485
|
-
return {
|
|
486
|
-
status: "succeeded",
|
|
487
|
-
data: {
|
|
488
|
-
code: scanResult.status === "pending" ? "requiresSelection" : "added",
|
|
489
|
-
cartChangeConfirmed: scanResult.status === "success" && Number((_scanResult$meta$coun = (_scanResult$meta = scanResult.meta) === null || _scanResult$meta === void 0 ? void 0 : _scanResult$meta.count) !== null && _scanResult$meta$coun !== void 0 ? _scanResult$meta$coun : 0) > 0
|
|
490
|
-
}
|
|
491
|
-
};
|
|
492
|
-
} catch (error) {
|
|
493
|
-
return partialFailure("barcodeDispatchFailed", error);
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
return function consumeBarcode(_x19, _x20) {
|
|
497
|
-
return _ref13.apply(this, arguments);
|
|
498
|
-
};
|
|
499
|
-
}(),
|
|
500
|
-
addProduct: function() {
|
|
501
|
-
var _ref14 = _asyncToGenerator(function* (input, signal) {
|
|
502
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
503
|
-
const productId = Number(input.productId);
|
|
504
|
-
const quantity = Number(input.quantity);
|
|
505
|
-
if (!Number.isFinite(productId) || !Number.isFinite(quantity) || quantity <= 0) return failed("productInputInvalid", "back");
|
|
506
|
-
try {
|
|
507
|
-
const context = getContext();
|
|
508
|
-
const product = findCatalogProduct(context, String(productId));
|
|
509
|
-
if (!product) return failed("productNotFound", "back");
|
|
510
|
-
const result = yield context.cart.addProductWithFlow(product, {
|
|
511
|
-
quantity,
|
|
512
|
-
notShowToast: true
|
|
513
|
-
});
|
|
514
|
-
if (signal.aborted) return unknown("addProductAbortedAfterDispatch");
|
|
515
|
-
if (result.status === "cancelled") return cancelled("userCancelled");
|
|
516
|
-
if (result.status !== "added") return failed("productRequiresUnsupportedSelection", "back");
|
|
517
|
-
const confirmedLine = projectConfirmedMutationLine([...Array.isArray(result.products) ? result.products : []].reverse().find((candidate) => {
|
|
518
|
-
var _candidate$product_id2;
|
|
519
|
-
return String((_candidate$product_id2 = candidate.product_id) !== null && _candidate$product_id2 !== void 0 ? _candidate$product_id2 : "") === input.productId;
|
|
520
|
-
}));
|
|
521
|
-
return {
|
|
522
|
-
status: "succeeded",
|
|
523
|
-
data: confirmedLine ? {
|
|
524
|
-
affectedLineId: confirmedLine.lineId,
|
|
525
|
-
confirmedLine
|
|
526
|
-
} : {}
|
|
527
|
-
};
|
|
528
|
-
} catch (error) {
|
|
529
|
-
return partialFailure("addProductFailed", error);
|
|
530
|
-
}
|
|
531
|
-
});
|
|
532
|
-
return function addProduct(_x21, _x22) {
|
|
533
|
-
return _ref14.apply(this, arguments);
|
|
534
|
-
};
|
|
535
|
-
}(),
|
|
536
|
-
updateQuantity: function() {
|
|
537
|
-
var _ref15 = _asyncToGenerator(function* (input, signal) {
|
|
538
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
539
|
-
const quantity = Number(input.quantity);
|
|
540
|
-
if (!Number.isFinite(quantity) || quantity <= 0) return failed("quantityInvalid", "back");
|
|
541
|
-
const context = getContext();
|
|
542
|
-
const line = findCartLine(context, input.lineId);
|
|
543
|
-
if (!line) return failed("cartLineNotFound", "back");
|
|
544
|
-
try {
|
|
545
|
-
const updatedProducts = yield context.cart.updateItemQuantity(line, quantity);
|
|
546
|
-
if (signal.aborted) return unknown("updateQuantityAbortedAfterDispatch");
|
|
547
|
-
const confirmedLine = projectConfirmedCartLineById(Array.isArray(updatedProducts) ? updatedProducts : [], input.lineId);
|
|
548
|
-
return {
|
|
549
|
-
status: "succeeded",
|
|
550
|
-
data: _objectSpread2({ affectedLineId: input.lineId }, confirmedLine ? { confirmedLine } : {})
|
|
551
|
-
};
|
|
552
|
-
} catch (error) {
|
|
553
|
-
return partialFailure("updateQuantityFailed", error);
|
|
554
|
-
}
|
|
555
|
-
});
|
|
556
|
-
return function updateQuantity(_x23, _x24) {
|
|
557
|
-
return _ref15.apply(this, arguments);
|
|
558
|
-
};
|
|
559
|
-
}(),
|
|
560
|
-
removeLine: function() {
|
|
561
|
-
var _ref16 = _asyncToGenerator(function* (input, signal) {
|
|
562
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
563
|
-
const context = getContext();
|
|
564
|
-
const line = findCartLine(context, input.lineId);
|
|
565
|
-
if (!line) return failed("cartLineNotFound", "back");
|
|
566
|
-
try {
|
|
567
|
-
const remainingProducts = yield context.cart.removeItem(line);
|
|
568
|
-
if (signal.aborted) return unknown("removeLineAbortedAfterDispatch");
|
|
569
|
-
return {
|
|
570
|
-
status: "succeeded",
|
|
571
|
-
data: _objectSpread2({ affectedLineId: input.lineId }, Array.isArray(remainingProducts) && !remainingProducts.some((candidate) => resolveBigSaleLineId(candidate) === input.lineId) ? { removedLineId: input.lineId } : {})
|
|
572
|
-
};
|
|
573
|
-
} catch (error) {
|
|
574
|
-
return partialFailure("removeLineFailed", error);
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
return function removeLine(_x25, _x26) {
|
|
578
|
-
return _ref16.apply(this, arguments);
|
|
579
|
-
};
|
|
580
|
-
}(),
|
|
581
|
-
waitForCartConsistency: function() {
|
|
582
|
-
var _ref17 = _asyncToGenerator(function* (signal) {
|
|
583
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
584
|
-
try {
|
|
585
|
-
yield getContext().cart.waitForCartConsistency();
|
|
586
|
-
if (signal.aborted) return unknown("consistencyAbortedAfterWait");
|
|
587
|
-
return {
|
|
588
|
-
status: "succeeded",
|
|
589
|
-
data: { observationId: getSnapshot().observationId }
|
|
590
|
-
};
|
|
591
|
-
} catch (error) {
|
|
592
|
-
return failed("cartConsistencyFailed", "retry", error);
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
return function waitForCartConsistency(_x27) {
|
|
596
|
-
return _ref17.apply(this, arguments);
|
|
597
|
-
};
|
|
598
|
-
}(),
|
|
599
|
-
recalculateSummary: function() {
|
|
600
|
-
var _ref18 = _asyncToGenerator(function* (signal) {
|
|
601
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
602
|
-
try {
|
|
603
|
-
var _getContext$sales$tem, _getContext$sales$tem2, _getContext$sales$tem3, _getContext$sales$tem4;
|
|
604
|
-
const summary = yield getContext().cart.recalcSummary();
|
|
605
|
-
if (signal.aborted) return unknown("summaryAbortedAfterDispatch");
|
|
606
|
-
if (!summary) return failed("summaryMissing", "retry");
|
|
607
|
-
return {
|
|
608
|
-
status: "succeeded",
|
|
609
|
-
data: {
|
|
610
|
-
observationId: getSnapshot().observationId,
|
|
611
|
-
confirmedSummary: {
|
|
612
|
-
status: "ready",
|
|
613
|
-
currency: String((_getContext$sales$tem = (_getContext$sales$tem2 = getContext().sales.tempOrder) === null || _getContext$sales$tem2 === void 0 ? void 0 : _getContext$sales$tem2.currency_code) !== null && _getContext$sales$tem !== void 0 ? _getContext$sales$tem : ""),
|
|
614
|
-
currencySymbol: String((_getContext$sales$tem3 = (_getContext$sales$tem4 = getContext().sales.tempOrder) === null || _getContext$sales$tem4 === void 0 ? void 0 : _getContext$sales$tem4.currency_symbol) !== null && _getContext$sales$tem3 !== void 0 ? _getContext$sales$tem3 : ""),
|
|
615
|
-
total: String(summary.total_amount),
|
|
616
|
-
due: String(summary.expect_amount)
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
} catch (error) {
|
|
621
|
-
return failed("summaryRecalculationFailed", "retry", error);
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
return function recalculateSummary(_x28) {
|
|
625
|
-
return _ref18.apply(this, arguments);
|
|
626
|
-
};
|
|
627
|
-
}(),
|
|
628
|
-
loadPaymentMethods: function() {
|
|
629
|
-
var _ref19 = _asyncToGenerator(function* (signal) {
|
|
630
|
-
if (signal.aborted) return cancelled("paymentMethodsAborted");
|
|
631
|
-
const controller = getPaymentController === null || getPaymentController === void 0 ? void 0 : getPaymentController();
|
|
632
|
-
if (!controller) return failed("paymentRuntimeUnavailable", "staff");
|
|
633
|
-
return controller.loadPaymentMethods();
|
|
634
|
-
});
|
|
635
|
-
return function loadPaymentMethods(_x29) {
|
|
636
|
-
return _ref19.apply(this, arguments);
|
|
637
|
-
};
|
|
638
|
-
}(),
|
|
639
|
-
payEftpos: function() {
|
|
640
|
-
var _ref20 = _asyncToGenerator(function* (input, signal) {
|
|
641
|
-
if (signal.aborted) return cancelled("eftposAborted");
|
|
642
|
-
const controller = getPaymentController === null || getPaymentController === void 0 ? void 0 : getPaymentController();
|
|
643
|
-
if (!controller) return failed("paymentRuntimeUnavailable", "staff");
|
|
644
|
-
return controller.payEftpos(input);
|
|
645
|
-
});
|
|
646
|
-
return function payEftpos(_x30, _x31) {
|
|
647
|
-
return _ref20.apply(this, arguments);
|
|
648
|
-
};
|
|
649
|
-
}(),
|
|
650
|
-
requestStaffPaymentApproval: function() {
|
|
651
|
-
var _ref21 = _asyncToGenerator(function* (input, signal) {
|
|
652
|
-
if (signal.aborted) return cancelled("staffPaymentApprovalAborted");
|
|
653
|
-
const controller = getPaymentController === null || getPaymentController === void 0 ? void 0 : getPaymentController();
|
|
654
|
-
if (!controller) return failed("paymentRuntimeUnavailable", "staff");
|
|
655
|
-
return controller.requestStaffPaymentApproval(input);
|
|
656
|
-
});
|
|
657
|
-
return function requestStaffPaymentApproval(_x32, _x33) {
|
|
658
|
-
return _ref21.apply(this, arguments);
|
|
659
|
-
};
|
|
660
|
-
}(),
|
|
661
|
-
subscribeStaffPaymentAuthorizationResult: (listener) => {
|
|
662
|
-
var _controller$subscribe;
|
|
663
|
-
const controller = getPaymentController === null || getPaymentController === void 0 ? void 0 : getPaymentController();
|
|
664
|
-
return (_controller$subscribe = controller === null || controller === void 0 ? void 0 : controller.subscribeStaffPaymentAuthorizationResult(listener)) !== null && _controller$subscribe !== void 0 ? _controller$subscribe : (() => void 0);
|
|
665
|
-
},
|
|
666
|
-
openCheckout: function() {
|
|
667
|
-
var _ref22 = _asyncToGenerator(function* (signal) {
|
|
668
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
669
|
-
try {
|
|
670
|
-
const snapshotBeforeCheckout = getSnapshot();
|
|
671
|
-
const result = yield getContext().sales.openCheckout({
|
|
672
|
-
paymentResultDisplayMode: "page",
|
|
673
|
-
walletPassMode: "shared"
|
|
674
|
-
});
|
|
675
|
-
if (signal.aborted) return unknown("checkoutAbortedAfterDispatch");
|
|
676
|
-
const checkoutResult = normalizeCheckoutResult(result, snapshotBeforeCheckout);
|
|
677
|
-
yield refreshCheckoutOrderProjection(getContext, getSnapshot, checkoutResult);
|
|
678
|
-
return checkoutResult;
|
|
679
|
-
} catch (error) {
|
|
680
|
-
return unknown("checkoutInvocationFailed", error);
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
return function openCheckout(_x34) {
|
|
684
|
-
return _ref22.apply(this, arguments);
|
|
685
|
-
};
|
|
686
|
-
}(),
|
|
687
|
-
clearAndReset: function() {
|
|
688
|
-
var _ref23 = _asyncToGenerator(function* (signal) {
|
|
689
|
-
if (signal.aborted) return { status: "cancelled" };
|
|
690
|
-
try {
|
|
691
|
-
var _resetOrder$products$, _resetOrder$products, _resetOrder$bookings$, _resetOrder$bookings;
|
|
692
|
-
const resetOrder = yield getContext().sales.clearCartAndReset();
|
|
693
|
-
if (signal.aborted) return unknown("resetAbortedAfterDispatch");
|
|
694
|
-
if (!(((_resetOrder$products$ = (_resetOrder$products = resetOrder.products) === null || _resetOrder$products === void 0 ? void 0 : _resetOrder$products.length) !== null && _resetOrder$products$ !== void 0 ? _resetOrder$products$ : 0) === 0 && ((_resetOrder$bookings$ = (_resetOrder$bookings = resetOrder.bookings) === null || _resetOrder$bookings === void 0 ? void 0 : _resetOrder$bookings.length) !== null && _resetOrder$bookings$ !== void 0 ? _resetOrder$bookings$ : 0) === 0)) return unknown("resetHostResultNotEmpty");
|
|
695
|
-
return {
|
|
696
|
-
status: "succeeded",
|
|
697
|
-
data: { cartEmpty: true }
|
|
698
|
-
};
|
|
699
|
-
} catch (error) {
|
|
700
|
-
return partialFailure("resetFailed", error);
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
return function clearAndReset(_x35) {
|
|
704
|
-
return _ref23.apply(this, arguments);
|
|
705
|
-
};
|
|
706
|
-
}()
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
//#endregion
|
|
710
|
-
export { createBigSaleSalesPort };
|