@aglyn/plugins-commerce 1.20.3 → 1.22.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/package.json +16 -16
- package/src/lib/components/cart-fulfillment.js +19 -8
- package/src/lib/components/cart-fulfillment.js.map +1 -1
- package/src/lib/components/cart.js +106 -9
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/console/catalog-organization-card.component.js +102 -32
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/discounts-card.component.js +39 -5
- package/src/lib/components/console/discounts-card.component.js.map +1 -1
- package/src/lib/components/console/local-delivery-settings-card.component.js +34 -9
- package/src/lib/components/console/local-delivery-settings-card.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +72 -46
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +43 -6
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/quote-settings-card.component.js +31 -8
- package/src/lib/components/console/quote-settings-card.component.js.map +1 -1
- package/src/lib/components/console/reservations-card.component.js +39 -4
- package/src/lib/components/console/reservations-card.component.js.map +1 -1
- package/src/lib/components/console/return-settings-card.component.js +39 -17
- package/src/lib/components/console/return-settings-card.component.js.map +1 -1
- package/src/lib/components/console/shipping-settings-card.component.js +34 -10
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/store-settings-card.component.js +38 -13
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/suppliers-card.component.js +49 -15
- package/src/lib/components/console/suppliers-card.component.js.map +1 -1
- package/src/lib/components/console/tax-settings-card.component.js +36 -12
- package/src/lib/components/console/tax-settings-card.component.js.map +1 -1
- package/src/lib/model/commerce-pos-offline.d.ts +21 -3
- package/src/lib/model/commerce-pos-offline.js +17 -5
- package/src/lib/model/commerce-pos-offline.js.map +1 -1
- package/src/lib/server/cart.js +57 -0
- package/src/lib/server/cart.js.map +1 -1
- package/src/lib/server/pos-offline-card-order.d.ts +2 -0
- package/src/lib/server/pos-offline-card-order.js +6 -2
- package/src/lib/server/pos-offline-card-order.js.map +1 -1
- package/src/lib/server/pos-offline-card-reconcile.d.ts +5 -1
- package/src/lib/server/pos-offline-card-reconcile.js +42 -10
- package/src/lib/server/pos-offline-card-reconcile.js.map +1 -1
- package/src/lib/server/pos-offline-sync.d.ts +48 -6
- package/src/lib/server/pos-offline-sync.js +142 -31
- package/src/lib/server/pos-offline-sync.js.map +1 -1
- package/src/lib/server/pos-stripe.d.ts +11 -0
- package/src/lib/server/pos-stripe.js +14 -0
- package/src/lib/server/pos-stripe.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +21 -1
- package/src/lib/server/pos-terminal.js +41 -7
- package/src/lib/server/pos-terminal.js.map +1 -1
- package/src/lib/transfer/product-transfer.js +15 -1
- package/src/lib/transfer/product-transfer.js.map +1 -1
|
@@ -26,9 +26,11 @@ import { Alert, Autocomplete, Box, Button, Dialog, DialogActions, DialogContent,
|
|
|
26
26
|
import { collection, doc, getDoc } from "firebase/firestore";
|
|
27
27
|
import { ScanAdornment } from "../../barcode/scan-button.component.js";
|
|
28
28
|
import { productCollectionFields } from "./smart-collections.js";
|
|
29
|
-
import { lazy, memo, Suspense, useCallback, useMemo,
|
|
29
|
+
import { lazy, memo, Suspense, useCallback, useMemo, useState } from "react";
|
|
30
30
|
import { ceilingedWindow, collectionCeiling, useFirestore, useFirestoreCollection, useHostResourceApi, writeGuardedBySeed, useUser } from "@aglyn/tenant-feature-instance";
|
|
31
31
|
import { writeSiteWideChange } from "@aglyn/tenant-feature-instance/hooks/helpers/site-wide-change";
|
|
32
|
+
import { heldSaveLabel, isSeedChecking, seedCheckingText, useHeldSave, useSeedEdits } from "@aglyn/tenant-feature-instance/hooks/use-seed-edits";
|
|
33
|
+
import { seedEditsBetween } from "@aglyn/tenant-feature-instance/hooks/use-seed-draft";
|
|
32
34
|
import { useMediaPicker } from "@aglyn/aglyn";
|
|
33
35
|
import { useConsoleWidgetSlot } from "@aglyn/aglyn/app-utils/console-widget-slot-context";
|
|
34
36
|
import { seoListingFieldCount, seoListingFieldTooLong } from "@aglyn/aglyn/app-utils/seo-listing-fields";
|
|
@@ -1106,7 +1108,7 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1106
1108
|
* first variant so the legacy Product block + checkout API (AGL-90) keep
|
|
1107
1109
|
* charging correctly without reading the variants array.
|
|
1108
1110
|
*/ export function ProductEditorDialog(props) {
|
|
1109
|
-
var _ref,
|
|
1111
|
+
var _ref, _current_description, _current_tags, _current_categoryIds, _current_options, _current_mediaUrls, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _current_description1, _ref14, _ref15, _current_description2, _current_tags1, _current_mediaUrls1, _current_options1, _subs_planLabel, _gifts_planLabel, _subs_planLabel1, _gifts_planLabel1, _current_oversellPolicy, _current_modifierGroups, _current_options2, _current_digitalFiles, _current_gatedVideos, _ref16;
|
|
1110
1112
|
var _current_seo, _current_seo1, _current_shipping, _current_shipping1, _current_shipping2, _current_shipping3, _current_shipping4, _current_channel, _current_channel1, _current_channel2, _current_channel3, _current_channel4, _current_seo2, _current_seo3, _current_gatedVideos1, _current_seo4, _current_seo5, _current_seo6, _current_seo7;
|
|
1111
1113
|
const { hostId, product, seedFromCache, seedUnreadable, seedListen, open, onClose } = props;
|
|
1112
1114
|
/**
|
|
@@ -1176,7 +1178,6 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1176
1178
|
const lifted = useMemo(()=>product ? CommerceModel.liftLegacyProduct(product) : null, [
|
|
1177
1179
|
product
|
|
1178
1180
|
]);
|
|
1179
|
-
const [draft, setDraft] = useState(null);
|
|
1180
1181
|
const [slugTouched, setSlugTouched] = useState(false);
|
|
1181
1182
|
// The console media browser is provided by the shell (AGL-395); opening it
|
|
1182
1183
|
// resolves with the chosen asset (or null if cancelled).
|
|
@@ -1187,19 +1188,34 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1187
1188
|
}, [
|
|
1188
1189
|
pickMedia
|
|
1189
1190
|
]);
|
|
1190
|
-
|
|
1191
|
-
|
|
1191
|
+
/*
|
|
1192
|
+
* What was typed, kept as EDITS over the product (AGL-4047). The hub hands
|
|
1193
|
+
* the row as its list has it now, so the server's copy arriving after the
|
|
1194
|
+
* dialog opened on the cache's replaces it under every field nobody
|
|
1195
|
+
* touched, and Save is held until it has (`checking`). Lazy-init per open;
|
|
1196
|
+
* the parent remounts via `key` on product change.
|
|
1197
|
+
*/ const seed = useMemo(()=>lifted != null ? lifted : blankProduct(), [
|
|
1198
|
+
lifted
|
|
1199
|
+
]);
|
|
1200
|
+
const form = useSeedEdits(seed);
|
|
1201
|
+
const current = form.values;
|
|
1202
|
+
const { edit } = form;
|
|
1203
|
+
const checking = Boolean(product) && isSeedChecking({
|
|
1204
|
+
fromCache: seedFromCache,
|
|
1205
|
+
unreadable: seedUnreadable
|
|
1206
|
+
});
|
|
1192
1207
|
/*
|
|
1193
1208
|
* The two writes every field goes through, each keeping its identity for
|
|
1194
1209
|
* the life of the dialog so a memoized section redraws only when its own
|
|
1195
|
-
* slice of the draft does (AGL-3423). Both write from the draft as
|
|
1196
|
-
*
|
|
1197
|
-
* patch that is a function is handed it, so no field holds a
|
|
1198
|
-
* product to spread. A write that lands after a picker closes
|
|
1199
|
-
* draft as it is then.
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1210
|
+
* slice of the draft does (AGL-3423). Both write from the draft as it is
|
|
1211
|
+
* when the write lands, which `edit` hands them: `update` spreads a patch
|
|
1212
|
+
* over it, and a patch that is a function is handed it, so no field holds a
|
|
1213
|
+
* copy of the product to spread. A write that lands after a picker closes
|
|
1214
|
+
* lands on the draft as it is then. Only the keys a write moved are kept as
|
|
1215
|
+
* edits (`seedEditsBetween`), so every other key follows the seed.
|
|
1216
|
+
*/ const replaceDraft = useCallback((build)=>edit((values)=>seedEditsBetween(values, build(values))), [
|
|
1217
|
+
edit
|
|
1218
|
+
]);
|
|
1203
1219
|
const update = useCallback((patch)=>replaceDraft((at)=>_extends({}, at, typeof patch === 'function' ? patch(at) : patch)), [
|
|
1204
1220
|
replaceDraft
|
|
1205
1221
|
]);
|
|
@@ -1313,15 +1329,11 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1313
1329
|
if (typeof value === 'string') staged[field] = value;
|
|
1314
1330
|
}
|
|
1315
1331
|
if (!Object.keys(staged).length) return;
|
|
1316
|
-
|
|
1317
|
-
var _ref;
|
|
1318
|
-
const base = (_ref = prior != null ? prior : lifted) != null ? _ref : blankProduct();
|
|
1319
|
-
return _extends({}, base, {
|
|
1332
|
+
edit((base)=>({
|
|
1320
1333
|
seo: _extends({}, base.seo, staged)
|
|
1321
|
-
});
|
|
1322
|
-
});
|
|
1334
|
+
}));
|
|
1323
1335
|
}, [
|
|
1324
|
-
|
|
1336
|
+
edit
|
|
1325
1337
|
]);
|
|
1326
1338
|
/**
|
|
1327
1339
|
* The product zone's proposal (AGL-2916): copy staged into the draft like
|
|
@@ -1329,13 +1341,9 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1329
1341
|
* go through `renameProductOptions`, so every variant keeps its price, SKU
|
|
1330
1342
|
* and stock.
|
|
1331
1343
|
*/ const proposeProductValues = useCallback((values)=>{
|
|
1332
|
-
|
|
1333
|
-
var _ref;
|
|
1334
|
-
const base = (_ref = prior != null ? prior : lifted) != null ? _ref : blankProduct();
|
|
1335
|
-
return _extends({}, base, CommerceModel.productCopyPatch(base, values));
|
|
1336
|
-
});
|
|
1344
|
+
edit((base)=>CommerceModel.productCopyPatch(base, values));
|
|
1337
1345
|
}, [
|
|
1338
|
-
|
|
1346
|
+
edit
|
|
1339
1347
|
]);
|
|
1340
1348
|
const zoneCategories = useMemo(()=>categories.rows.map((category)=>{
|
|
1341
1349
|
var _category_name;
|
|
@@ -1350,7 +1358,7 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1350
1358
|
* What the two zones are handed, held by content: a keystroke in a field
|
|
1351
1359
|
* neither zone reads (a SKU, a price) leaves both as they were.
|
|
1352
1360
|
*/ const zoneProduct = useContentStable({
|
|
1353
|
-
id: (
|
|
1361
|
+
id: (_ref = product == null ? void 0 : product.$id) != null ? _ref : null,
|
|
1354
1362
|
name: current.name,
|
|
1355
1363
|
type: current.type,
|
|
1356
1364
|
description: String((_current_description = current.description) != null ? _current_description : ''),
|
|
@@ -1361,32 +1369,32 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1361
1369
|
values: option.values
|
|
1362
1370
|
})),
|
|
1363
1371
|
mediaUrls: (_current_mediaUrls = current.mediaUrls) != null ? _current_mediaUrls : [],
|
|
1364
|
-
seoTitle: (
|
|
1365
|
-
seoDescription: (
|
|
1372
|
+
seoTitle: (_ref1 = (_current_seo = current.seo) == null ? void 0 : _current_seo.title) != null ? _ref1 : '',
|
|
1373
|
+
seoDescription: (_ref2 = (_current_seo1 = current.seo) == null ? void 0 : _current_seo1.description) != null ? _ref2 : '',
|
|
1366
1374
|
shipping: {
|
|
1367
|
-
lengthCm: (
|
|
1368
|
-
widthCm: (
|
|
1369
|
-
heightCm: (
|
|
1370
|
-
hsCode: (
|
|
1371
|
-
originCountry: (
|
|
1375
|
+
lengthCm: (_ref3 = (_current_shipping = current.shipping) == null ? void 0 : _current_shipping.lengthCm) != null ? _ref3 : null,
|
|
1376
|
+
widthCm: (_ref4 = (_current_shipping1 = current.shipping) == null ? void 0 : _current_shipping1.widthCm) != null ? _ref4 : null,
|
|
1377
|
+
heightCm: (_ref5 = (_current_shipping2 = current.shipping) == null ? void 0 : _current_shipping2.heightCm) != null ? _ref5 : null,
|
|
1378
|
+
hsCode: (_ref6 = (_current_shipping3 = current.shipping) == null ? void 0 : _current_shipping3.hsCode) != null ? _ref6 : '',
|
|
1379
|
+
originCountry: (_ref7 = (_current_shipping4 = current.shipping) == null ? void 0 : _current_shipping4.originCountry) != null ? _ref7 : ''
|
|
1372
1380
|
},
|
|
1373
1381
|
channel: {
|
|
1374
|
-
brand: (
|
|
1375
|
-
gtin: (
|
|
1376
|
-
mpn: (
|
|
1377
|
-
condition: (
|
|
1378
|
-
googleProductCategory: (
|
|
1382
|
+
brand: (_ref8 = (_current_channel = current.channel) == null ? void 0 : _current_channel.brand) != null ? _ref8 : '',
|
|
1383
|
+
gtin: (_ref9 = (_current_channel1 = current.channel) == null ? void 0 : _current_channel1.gtin) != null ? _ref9 : '',
|
|
1384
|
+
mpn: (_ref10 = (_current_channel2 = current.channel) == null ? void 0 : _current_channel2.mpn) != null ? _ref10 : '',
|
|
1385
|
+
condition: (_ref11 = (_current_channel3 = current.channel) == null ? void 0 : _current_channel3.condition) != null ? _ref11 : '',
|
|
1386
|
+
googleProductCategory: (_ref12 = (_current_channel4 = current.channel) == null ? void 0 : _current_channel4.googleProductCategory) != null ? _ref12 : ''
|
|
1379
1387
|
}
|
|
1380
1388
|
});
|
|
1381
1389
|
const seoSubject = useContentStable({
|
|
1382
1390
|
kind: 'product',
|
|
1383
|
-
id: (
|
|
1391
|
+
id: (_ref13 = product == null ? void 0 : product.$id) != null ? _ref13 : null,
|
|
1384
1392
|
name: current.name,
|
|
1385
1393
|
description: String((_current_description1 = current.description) != null ? _current_description1 : '')
|
|
1386
1394
|
});
|
|
1387
1395
|
const seoValues = useContentStable({
|
|
1388
|
-
title: (
|
|
1389
|
-
description: (
|
|
1396
|
+
title: (_ref14 = (_current_seo2 = current.seo) == null ? void 0 : _current_seo2.title) != null ? _ref14 : '',
|
|
1397
|
+
description: (_ref15 = (_current_seo3 = current.seo) == null ? void 0 : _current_seo3.description) != null ? _ref15 : ''
|
|
1390
1398
|
});
|
|
1391
1399
|
/**
|
|
1392
1400
|
* More combinations than a product holds (AGL-4100): said with the count
|
|
@@ -1657,6 +1665,15 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1657
1665
|
onClose,
|
|
1658
1666
|
enqueueSnackbar
|
|
1659
1667
|
]);
|
|
1668
|
+
// A press while Save is held is kept, and saves once confirmed (AGL-4047).
|
|
1669
|
+
const held = useHeldSave(handleSave, {
|
|
1670
|
+
checking,
|
|
1671
|
+
subject: 'product',
|
|
1672
|
+
onRefused: (message)=>enqueueSnackbar(message, {
|
|
1673
|
+
variant: 'warning',
|
|
1674
|
+
persist: false
|
|
1675
|
+
})
|
|
1676
|
+
});
|
|
1660
1677
|
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
1661
1678
|
open: open,
|
|
1662
1679
|
onClose: onClose,
|
|
@@ -1852,7 +1869,7 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1852
1869
|
gatedVideos: (_current_gatedVideos = current.gatedVideos) != null ? _current_gatedVideos : NO_VIDEOS,
|
|
1853
1870
|
update: update
|
|
1854
1871
|
}) : null,
|
|
1855
|
-
current.type === 'digital' && (((
|
|
1872
|
+
current.type === 'digital' && (((_ref16 = (_current_gatedVideos1 = current.gatedVideos) == null ? void 0 : _current_gatedVideos1.length) != null ? _ref16 : 0) > 0 || pickedVideoAccess.length > 0) ? /*#__PURE__*/ _jsx(ProductChipsField, {
|
|
1856
1873
|
label: "Members videos are also open to buyers of",
|
|
1857
1874
|
helperText: "Their buyers and active subscribers can watch this product's members videos too. Use it to share one video library across several plans.",
|
|
1858
1875
|
options: relatedOptions,
|
|
@@ -1902,6 +1919,15 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1902
1919
|
}),
|
|
1903
1920
|
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
1904
1921
|
children: [
|
|
1922
|
+
checking ? /*#__PURE__*/ _jsx(Typography, {
|
|
1923
|
+
variant: "body2",
|
|
1924
|
+
color: "text.secondary",
|
|
1925
|
+
role: "status",
|
|
1926
|
+
sx: {
|
|
1927
|
+
mr: 'auto'
|
|
1928
|
+
},
|
|
1929
|
+
children: seedCheckingText('product')
|
|
1930
|
+
}) : null,
|
|
1905
1931
|
/*#__PURE__*/ _jsx(Button, {
|
|
1906
1932
|
onClick: onClose,
|
|
1907
1933
|
children: 'Cancel'
|
|
@@ -1909,9 +1935,9 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
|
|
|
1909
1935
|
/*#__PURE__*/ _jsx(Button, {
|
|
1910
1936
|
variant: "contained",
|
|
1911
1937
|
color: "primary",
|
|
1912
|
-
disabled: !current.name.trim() || Boolean(error),
|
|
1913
|
-
onClick:
|
|
1914
|
-
children: 'Save product'
|
|
1938
|
+
disabled: !current.name.trim() || Boolean(error) || held.saving,
|
|
1939
|
+
onClick: held.press,
|
|
1940
|
+
children: heldSaveLabel(held, 'Save product')
|
|
1915
1941
|
})
|
|
1916
1942
|
]
|
|
1917
1943
|
})
|