@aglyn/plugins-commerce 1.30.0 → 1.32.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/README.md +4 -0
- package/package.json +13 -13
- package/src/lib/components/cart.js +46 -20
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/commerce-console-page.js +6 -0
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/console/currencies-card.component.d.ts +21 -0
- package/src/lib/components/console/currencies-card.component.js +408 -0
- package/src/lib/components/console/currencies-card.component.js.map +1 -0
- package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
- package/src/lib/components/console/product-add-ons-fields.component.js +74 -2
- package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
- package/src/lib/components/console/product-editor-dialog.component.js +47 -1
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-fixed-prices-fields.component.d.ts +25 -0
- package/src/lib/components/console/product-fixed-prices-fields.component.js +112 -0
- package/src/lib/components/console/product-fixed-prices-fields.component.js.map +1 -0
- package/src/lib/components/console/product-traffic-card.component.d.ts +24 -0
- package/src/lib/components/console/product-traffic-card.component.js +172 -0
- package/src/lib/components/console/product-traffic-card.component.js.map +1 -0
- package/src/lib/components/console/products-hub-card.component.js +181 -59
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/reservations-card.component.js +32 -15
- package/src/lib/components/console/reservations-card.component.js.map +1 -1
- package/src/lib/components/console/shipping-settings-card.component.js +131 -10
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/store-settings-card.component.js +1 -1
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/use-currency-setup.d.ts +20 -0
- package/src/lib/components/console/use-currency-setup.js +61 -0
- package/src/lib/components/console/use-currency-setup.js.map +1 -0
- package/src/lib/components/currency-selector.d.ts +36 -0
- package/src/lib/components/currency-selector.js +157 -0
- package/src/lib/components/currency-selector.js.map +1 -0
- package/src/lib/components/product-add-ons.d.ts +9 -1
- package/src/lib/components/product-add-ons.js +8 -4
- package/src/lib/components/product-add-ons.js.map +1 -1
- package/src/lib/components/product-choice-cards.d.ts +13 -1
- package/src/lib/components/product-choice-cards.js +5 -4
- package/src/lib/components/product-choice-cards.js.map +1 -1
- package/src/lib/components/product-detail.d.ts +8 -0
- package/src/lib/components/product-detail.js +38 -11
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.d.ts +2 -0
- package/src/lib/components/product-grid.js +22 -9
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/related-products.js +6 -2
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/components/shopper-currency.d.ts +108 -0
- package/src/lib/components/shopper-currency.js +262 -0
- package/src/lib/components/shopper-currency.js.map +1 -0
- package/src/lib/components/wishlist.js +7 -1
- package/src/lib/components/wishlist.js.map +1 -1
- package/src/lib/declarations.server.js +39 -0
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/commerce-currency-setup.d.ts +79 -0
- package/src/lib/model/commerce-currency-setup.js +124 -0
- package/src/lib/model/commerce-currency-setup.js.map +1 -0
- package/src/lib/model/commerce-currency.d.ts +215 -0
- package/src/lib/model/commerce-currency.js +511 -0
- package/src/lib/model/commerce-currency.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +17 -0
- package/src/lib/model/commerce-orders.js +10 -5
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-record-routes.js +56 -0
- package/src/lib/model/commerce-record-routes.js.map +1 -1
- package/src/lib/model/commerce-reservations.d.ts +6 -0
- package/src/lib/model/commerce-reservations.js.map +1 -1
- package/src/lib/model/commerce-shipping.d.ts +61 -17
- package/src/lib/model/commerce-shipping.js +346 -32
- package/src/lib/model/commerce-shipping.js.map +1 -1
- package/src/lib/model/commerce.d.ts +6 -0
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +2 -0
- package/src/lib/model/index.js +2 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/order-figures.js +9 -2
- package/src/lib/model/order-figures.js.map +1 -1
- package/src/lib/model/product-modifiers.d.ts +5 -0
- package/src/lib/model/product-modifiers.js.map +1 -1
- package/src/lib/model/product-write.d.ts +10 -1
- package/src/lib/model/product-write.js +13 -2
- package/src/lib/model/product-write.js.map +1 -1
- package/src/lib/server/billing-webhook.js +37 -24
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/carrier-shipping.js +3 -2
- package/src/lib/server/carrier-shipping.js.map +1 -1
- package/src/lib/server/cart-checkout.js +77 -15
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/cart.d.ts +12 -0
- package/src/lib/server/cart.js +52 -6
- package/src/lib/server/cart.js.map +1 -1
- package/src/lib/server/catalog.d.ts +5 -0
- package/src/lib/server/catalog.js +7 -0
- package/src/lib/server/catalog.js.map +1 -1
- package/src/lib/server/checkout.js +54 -16
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/currency.d.ts +93 -0
- package/src/lib/server/currency.js +182 -0
- package/src/lib/server/currency.js.map +1 -0
- package/src/lib/server/draft-order.js +3 -3
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/order-notifications.js +4 -2
- package/src/lib/server/order-notifications.js.map +1 -1
- package/src/lib/server/product.d.ts +9 -0
- package/src/lib/server/product.js +12 -0
- package/src/lib/server/product.js.map +1 -1
- package/src/lib/server/products-write.js +10 -2
- package/src/lib/server/products-write.js.map +1 -1
- package/src/lib/server/refund.js +3 -3
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/site-chat-tools.d.ts +22 -0
- package/src/lib/server/site-chat-tools.js +369 -0
- package/src/lib/server/site-chat-tools.js.map +1 -0
- package/src/lib/server/site-chat-visitor.d.ts +24 -0
- package/src/lib/server/site-chat-visitor.js +39 -0
- package/src/lib/server/site-chat-visitor.js.map +1 -0
- package/src/lib/server/site-offers.d.ts +31 -0
- package/src/lib/server/site-offers.js +91 -0
- package/src/lib/server/site-offers.js.map +1 -0
- package/src/lib/server/stays-site-search.d.ts +20 -0
- package/src/lib/server/stays-site-search.js +78 -0
- package/src/lib/server/stays-site-search.js.map +1 -0
- package/src/lib/server.js +20 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/site-chat-tool-definitions.d.ts +26 -0
- package/src/lib/site-chat-tool-definitions.js +141 -0
- package/src/lib/site-chat-tool-definitions.js.map +1 -0
- package/src/lib/site.js +8 -0
- package/src/lib/site.js.map +1 -1
- package/src/lib/subprocessors.js +7 -0
- package/src/lib/subprocessors.js.map +1 -1
|
@@ -25,7 +25,10 @@ import { CardDisplay, useConfirmationContext } from "@aglyn/shared-ui-jsx";
|
|
|
25
25
|
import ListFilterChips from "@aglyn/shared-ui-jsx/components/list-filter-chips.component";
|
|
26
26
|
import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.component";
|
|
27
27
|
import { ListQueryNotices, listQueryRefusals } from "@aglyn/shared-ui-jsx/components/list-query-notices.component";
|
|
28
|
-
import { ListTable, listActionsColumn } from "@aglyn/shared-ui-jsx/components/list-table.component";
|
|
28
|
+
import { ListRowActions, ListTable, listActionsColumn } from "@aglyn/shared-ui-jsx/components/list-table.component";
|
|
29
|
+
import { MdiIcon } from "@aglyn/shared-ui-jsx/components/mdi-icon/mdi-icon";
|
|
30
|
+
import { mdiArchiveArrowUpOutline, mdiArchiveOutline, mdiBarcode, mdiCheckCircleOutline, mdiContentCopy, mdiDeleteOutline, mdiEyeOutline, mdiFileDocumentEditOutline, mdiKeyOutline, mdiPackageVariant, mdiPencilOutline } from "@aglyn/shared-data-mdi";
|
|
31
|
+
import { siteLiveUrlForSlug } from "@aglyn/aglyn/app-utils/site-live-url";
|
|
29
32
|
import QuotaReadoutComponent from "@aglyn/shared-ui-jsx/components/quota-readout.component";
|
|
30
33
|
import { hiddenFilterVisibility } from "@aglyn/shared-ui-jsx/const/list-filter";
|
|
31
34
|
import { listFilterGridColumns } from "@aglyn/shared-ui-jsx/const/list-grid-filter";
|
|
@@ -34,7 +37,7 @@ import { useListGridFilter } from "@aglyn/shared-ui-jsx/hooks/use-list-grid-filt
|
|
|
34
37
|
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
35
38
|
import { Timestamp } from "@aglyn/shared-util-timestamp";
|
|
36
39
|
import { Alert, Box, Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, Stack, TextField, Tooltip, Typography } from "@mui/material";
|
|
37
|
-
import { addDoc, collection, doc, documentId, getDocFromServer, limit, orderBy, query, updateDoc, where } from "firebase/firestore";
|
|
40
|
+
import { addDoc, arrayUnion, collection, doc, documentId, getDoc, getDocFromServer, getDocs, limit, orderBy, query, updateDoc, where } from "firebase/firestore";
|
|
38
41
|
import { getLiveCountFromServer } from "@aglyn/aglyn/app-utils/live-document-count.client";
|
|
39
42
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
40
43
|
import { useSearchParams } from "next/navigation";
|
|
@@ -74,6 +77,20 @@ const PRODUCT_PAGE_SORT_HEADERS = {
|
|
|
74
77
|
stock: 'Stock',
|
|
75
78
|
variants: 'Variants'
|
|
76
79
|
};
|
|
80
|
+
/** What a status change from a row's menu says when it has been written. */ const PRODUCT_STATUS_DONE = {
|
|
81
|
+
active: 'Product is active',
|
|
82
|
+
draft: 'Product set to draft',
|
|
83
|
+
archived: 'Product archived'
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* The address one product's editor opens at, on the Catalog this list is
|
|
87
|
+
* on: what a cmd-click or middle-click on a row opens in a new tab.
|
|
88
|
+
*/ function productEditorHref(productId) {
|
|
89
|
+
const path = typeof window === 'undefined' ? '' : window.location.pathname;
|
|
90
|
+
return `${path}?${new URLSearchParams({
|
|
91
|
+
[PRODUCTS_PRODUCT_PARAM]: productId
|
|
92
|
+
}).toString()}`;
|
|
93
|
+
}
|
|
77
94
|
const STATUS_COLOR = {
|
|
78
95
|
active: 'success',
|
|
79
96
|
draft: 'warning',
|
|
@@ -209,6 +226,28 @@ const STATUS_COLOR = {
|
|
|
209
226
|
idField: '$id'
|
|
210
227
|
});
|
|
211
228
|
/*
|
|
229
|
+
* The site's address, for a row's "View on site" (its subdomain and custom
|
|
230
|
+
* domain). Read once: a site's address does not move under an open list.
|
|
231
|
+
*/ const [siteAddress, setSiteAddress] = useState(null);
|
|
232
|
+
useEffect(()=>{
|
|
233
|
+
let active = true;
|
|
234
|
+
void Promise.resolve().then(()=>getDoc(doc(firestore, 'hosts', hostId))).then((snapshot)=>{
|
|
235
|
+
var _snapshot_get, _snapshot_get1;
|
|
236
|
+
var _snapshot_exists;
|
|
237
|
+
if (!active || !(snapshot == null ? void 0 : (_snapshot_exists = snapshot.exists) == null ? void 0 : _snapshot_exists.call(snapshot))) return;
|
|
238
|
+
setSiteAddress({
|
|
239
|
+
subdomain: (_snapshot_get = snapshot.get('subdomain')) != null ? _snapshot_get : null,
|
|
240
|
+
cname: (_snapshot_get1 = snapshot.get('cname')) != null ? _snapshot_get1 : null
|
|
241
|
+
});
|
|
242
|
+
}).catch(()=>undefined);
|
|
243
|
+
return ()=>{
|
|
244
|
+
active = false;
|
|
245
|
+
};
|
|
246
|
+
}, [
|
|
247
|
+
firestore,
|
|
248
|
+
hostId
|
|
249
|
+
]);
|
|
250
|
+
/*
|
|
212
251
|
* The PAGE on screen, lifted from legacy shapes. It is what the table
|
|
213
252
|
* draws, the reserved-stock clock watches and the zone hands its widgets,
|
|
214
253
|
* and nothing narrows it: the query already answered every filter, and
|
|
@@ -396,13 +435,29 @@ const STATUS_COLOR = {
|
|
|
396
435
|
// The source's SKU and barcode keys are not copied: the copy's own
|
|
397
436
|
// are derived (`productDuplicateFields`), and a copy of a product
|
|
398
437
|
// with none must have none.
|
|
399
|
-
await createHostResource({
|
|
438
|
+
const { id: copyId } = await createHostResource({
|
|
400
439
|
hostId,
|
|
401
440
|
resource: 'product',
|
|
402
441
|
data: _extends({}, CommerceModel.productDuplicateFields(product, slug, Date.now()), await productCollectionFields(firestore, hostId, _extends({}, product, {
|
|
403
442
|
name: CommerceModel.productDuplicateName(product.name)
|
|
404
443
|
})))
|
|
405
444
|
});
|
|
445
|
+
/*
|
|
446
|
+
* The MANUAL collections the source is in hold it by id in their own
|
|
447
|
+
* `productIds`, which nothing on the product carries, so the copy
|
|
448
|
+
* joins each of them here. A draft is on no storefront until it is
|
|
449
|
+
* made active, so this changes nothing a visitor sees.
|
|
450
|
+
*/ try {
|
|
451
|
+
const manual = await getDocs(query(collection(firestore, 'hosts', hostId, 'collections'), where('productIds', 'array-contains', product.$id)));
|
|
452
|
+
await Promise.all(manual.docs.map((collectionDoc)=>updateDoc(collectionDoc.ref, {
|
|
453
|
+
productIds: arrayUnion(copyId)
|
|
454
|
+
})));
|
|
455
|
+
} catch (unused) {
|
|
456
|
+
enqueueSnackbar('Product duplicated, but it could not be added to the source’s collections: add it in Collections.', {
|
|
457
|
+
variant: 'warning',
|
|
458
|
+
persist: false
|
|
459
|
+
});
|
|
460
|
+
}
|
|
406
461
|
// A create moves the count and the aggregate is a one-shot — the
|
|
407
462
|
// listener refreshes the ROWS for free, the count has to be asked
|
|
408
463
|
// again or the cap drifts stale for the rest of the session.
|
|
@@ -445,6 +500,10 @@ const STATUS_COLOR = {
|
|
|
445
500
|
updatedAt: Timestamp.now()
|
|
446
501
|
})
|
|
447
502
|
});
|
|
503
|
+
enqueueSnackbar(PRODUCT_STATUS_DONE[status], {
|
|
504
|
+
variant: 'success',
|
|
505
|
+
persist: false
|
|
506
|
+
});
|
|
448
507
|
}, [
|
|
449
508
|
firestore,
|
|
450
509
|
hostId,
|
|
@@ -625,6 +684,114 @@ const STATUS_COLOR = {
|
|
|
625
684
|
const held = CommerceModel.heldProductUnits(product, nowMs);
|
|
626
685
|
return held > 0 ? ` (${held} reserved)` : '';
|
|
627
686
|
};
|
|
687
|
+
const icon = (path)=>/*#__PURE__*/ _jsx(MdiIcon, {
|
|
688
|
+
path: path,
|
|
689
|
+
size: 0.8
|
|
690
|
+
});
|
|
691
|
+
/**
|
|
692
|
+
* Every action a product row offers, in its ⋮ menu. An action that does
|
|
693
|
+
* not apply to this product is left out (labels are for physical goods,
|
|
694
|
+
* keys for digital ones, stock for tracked inventory); one that applies
|
|
695
|
+
* but cannot run now is shown disabled with the reason.
|
|
696
|
+
*/ const productRowActions = (product)=>{
|
|
697
|
+
const items = [
|
|
698
|
+
{
|
|
699
|
+
key: 'edit',
|
|
700
|
+
label: 'Edit',
|
|
701
|
+
icon: icon(mdiPencilOutline.path),
|
|
702
|
+
onClick: ()=>setEditing(product)
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
key: 'duplicate',
|
|
706
|
+
label: 'Duplicate',
|
|
707
|
+
icon: icon(mdiContentCopy.path),
|
|
708
|
+
description: 'Copies it as a draft',
|
|
709
|
+
disabled: !productQuota,
|
|
710
|
+
disabledReason: productQuota ? undefined : 'Checking your plan…',
|
|
711
|
+
onClick: ()=>void handleDuplicate(product)()
|
|
712
|
+
}
|
|
713
|
+
];
|
|
714
|
+
const liveUrl = product.slug && siteAddress ? siteLiveUrlForSlug(siteAddress, `/products/${product.slug}`) : undefined;
|
|
715
|
+
const offline = product.status !== 'active' ? 'Only active products are on the site' : !CommerceModel.productSellsOnline(product) ? 'Sold in person only, so it has no page on the site' : !liveUrl ? 'This site has no address yet' : undefined;
|
|
716
|
+
items.push({
|
|
717
|
+
key: 'view',
|
|
718
|
+
label: 'View on site',
|
|
719
|
+
icon: icon(mdiEyeOutline.path),
|
|
720
|
+
href: offline ? undefined : liveUrl,
|
|
721
|
+
external: true,
|
|
722
|
+
disabled: Boolean(offline),
|
|
723
|
+
disabledReason: offline
|
|
724
|
+
});
|
|
725
|
+
if (CommerceModel.productInventory(product) != null) {
|
|
726
|
+
items.push({
|
|
727
|
+
key: 'stock',
|
|
728
|
+
label: 'Adjust stock',
|
|
729
|
+
icon: icon(mdiPackageVariant.path),
|
|
730
|
+
onClick: ()=>{
|
|
731
|
+
var _ref, _ref1, _ref2;
|
|
732
|
+
var _product_variants_find, _find, _;
|
|
733
|
+
return setAdjusting({
|
|
734
|
+
product,
|
|
735
|
+
variantId: (_ref = (_product_variants_find = product.variants.find((variant)=>variant.inventory != null)) == null ? void 0 : _product_variants_find.id) != null ? _ref : product.variants[0].id,
|
|
736
|
+
delta: '',
|
|
737
|
+
reason: 'restock',
|
|
738
|
+
locationId: (_ref1 = (_ref2 = (_find = (locationDocs != null ? locationDocs : []).find((location)=>location.isDefault)) == null ? void 0 : _find.$id) != null ? _ref2 : (_ = (locationDocs != null ? locationDocs : [])[0]) == null ? void 0 : _.$id) != null ? _ref1 : ''
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
if (product.type === 'physical') {
|
|
744
|
+
items.push({
|
|
745
|
+
key: 'labels',
|
|
746
|
+
label: 'Print labels',
|
|
747
|
+
icon: icon(mdiBarcode.path),
|
|
748
|
+
onClick: ()=>setLabelsFor(product)
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
if (product.type === 'digital') {
|
|
752
|
+
items.push({
|
|
753
|
+
key: 'keys',
|
|
754
|
+
label: 'License keys',
|
|
755
|
+
icon: icon(mdiKeyOutline.path),
|
|
756
|
+
onClick: ()=>setKeysFor(product)
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
if (product.status !== 'active') {
|
|
760
|
+
items.push({
|
|
761
|
+
key: 'activate',
|
|
762
|
+
label: 'Set active',
|
|
763
|
+
icon: icon(mdiCheckCircleOutline.path),
|
|
764
|
+
onClick: ()=>void handleStatus(product, 'active')()
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
if (product.status === 'active') {
|
|
768
|
+
items.push({
|
|
769
|
+
key: 'draft',
|
|
770
|
+
label: 'Set to draft',
|
|
771
|
+
icon: icon(mdiFileDocumentEditOutline.path),
|
|
772
|
+
description: 'Takes it off the site',
|
|
773
|
+
onClick: ()=>void handleStatus(product, 'draft')()
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
items.push(product.status === 'archived' ? {
|
|
777
|
+
key: 'unarchive',
|
|
778
|
+
label: 'Unarchive as draft',
|
|
779
|
+
icon: icon(mdiArchiveArrowUpOutline.path),
|
|
780
|
+
onClick: ()=>void handleStatus(product, 'draft')()
|
|
781
|
+
} : {
|
|
782
|
+
key: 'archive',
|
|
783
|
+
label: 'Archive',
|
|
784
|
+
icon: icon(mdiArchiveOutline.path),
|
|
785
|
+
onClick: ()=>void handleStatus(product, 'archived')()
|
|
786
|
+
}, {
|
|
787
|
+
key: 'delete',
|
|
788
|
+
label: 'Delete',
|
|
789
|
+
icon: icon(mdiDeleteOutline.path),
|
|
790
|
+
destructive: true,
|
|
791
|
+
onClick: ()=>void handleDelete(product)()
|
|
792
|
+
});
|
|
793
|
+
return items;
|
|
794
|
+
};
|
|
628
795
|
const productColumns = listFilterGridColumns([
|
|
629
796
|
{
|
|
630
797
|
field: 'name',
|
|
@@ -726,63 +893,14 @@ const STATUS_COLOR = {
|
|
|
726
893
|
width: 100,
|
|
727
894
|
valueGetter: (_value, row)=>row.variants.length
|
|
728
895
|
},
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
},
|
|
736
|
-
children: [
|
|
737
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
738
|
-
size: "small",
|
|
739
|
-
onClick: ()=>setEditing(product),
|
|
740
|
-
children: 'Edit'
|
|
741
|
-
}),
|
|
742
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
743
|
-
size: "small",
|
|
744
|
-
onClick: handleDuplicate(product),
|
|
745
|
-
children: 'Duplicate'
|
|
746
|
-
}),
|
|
747
|
-
product.type === 'physical' ? /*#__PURE__*/ _jsx(Button, {
|
|
748
|
-
size: "small",
|
|
749
|
-
onClick: ()=>setLabelsFor(product),
|
|
750
|
-
children: 'Labels'
|
|
751
|
-
}) : null,
|
|
752
|
-
product.type === 'digital' ? /*#__PURE__*/ _jsx(Button, {
|
|
753
|
-
size: "small",
|
|
754
|
-
onClick: ()=>setKeysFor(product),
|
|
755
|
-
children: 'Keys'
|
|
756
|
-
}) : null,
|
|
757
|
-
CommerceModel.productInventory(product) != null ? /*#__PURE__*/ _jsx(Button, {
|
|
758
|
-
size: "small",
|
|
759
|
-
onClick: ()=>{
|
|
760
|
-
var _ref, _ref1, _ref2;
|
|
761
|
-
var _product_variants_find, _find, _;
|
|
762
|
-
return setAdjusting({
|
|
763
|
-
product,
|
|
764
|
-
variantId: (_ref = (_product_variants_find = product.variants.find((variant)=>variant.inventory != null)) == null ? void 0 : _product_variants_find.id) != null ? _ref : product.variants[0].id,
|
|
765
|
-
delta: '',
|
|
766
|
-
reason: 'restock',
|
|
767
|
-
locationId: (_ref1 = (_ref2 = (_find = (locationDocs != null ? locationDocs : []).find((location)=>location.isDefault)) == null ? void 0 : _find.$id) != null ? _ref2 : (_ = (locationDocs != null ? locationDocs : [])[0]) == null ? void 0 : _.$id) != null ? _ref1 : ''
|
|
768
|
-
});
|
|
769
|
-
},
|
|
770
|
-
children: 'Stock'
|
|
771
|
-
}) : null,
|
|
772
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
773
|
-
size: "small",
|
|
774
|
-
onClick: handleStatus(product, product.status === 'archived' ? 'active' : 'archived'),
|
|
775
|
-
children: product.status === 'archived' ? 'Activate' : 'Archive'
|
|
776
|
-
}),
|
|
777
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
778
|
-
size: "small",
|
|
779
|
-
color: "error",
|
|
780
|
-
onClick: handleDelete(product),
|
|
781
|
-
children: 'Delete'
|
|
782
|
-
})
|
|
783
|
-
]
|
|
896
|
+
// ONE menu per row, the same on every row (Zach, 2026-11-25): the
|
|
897
|
+
// inline buttons were wider than the column, so the table clipped
|
|
898
|
+
// them and a row showed whichever ones happened to fit.
|
|
899
|
+
listActionsColumn((product)=>/*#__PURE__*/ _jsx(ListRowActions, {
|
|
900
|
+
label: product.name,
|
|
901
|
+
items: productRowActions(product)
|
|
784
902
|
}), {
|
|
785
|
-
width:
|
|
903
|
+
width: 64
|
|
786
904
|
})
|
|
787
905
|
], PRODUCT_LIST_FIELDS, PRODUCT_LIST_OPTIONS, PRODUCT_LIST_HEADERS);
|
|
788
906
|
/** Add product: the quota first, then the create drawer. */ const startAddProduct = ()=>{
|
|
@@ -924,6 +1042,10 @@ const STATUS_COLOR = {
|
|
|
924
1042
|
}),
|
|
925
1043
|
/*#__PURE__*/ _jsx(ListTable, {
|
|
926
1044
|
"aria-label": "Products",
|
|
1045
|
+
// A row opens its product in the editor; cmd-, ctrl-, shift- or
|
|
1046
|
+
// middle-click opens the editor in a new tab.
|
|
1047
|
+
onOpen: (_id, row)=>setEditing(row),
|
|
1048
|
+
openHref: (id)=>productEditorHref(id),
|
|
927
1049
|
rows: columnSort.rows,
|
|
928
1050
|
columns: productColumns,
|
|
929
1051
|
loading: productsStatus === 'loading',
|