@mercurjs/admin 2.4.2-canary.0 → 2.4.2-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-campaign-promotions-I2RE2TFI.js → add-campaign-promotions-RK4N7E4J.js} +3 -3
- package/dist/{campaign-detail-CQLFD5TR.js → campaign-detail-SIUHKEBE.js} +4 -4
- package/dist/category-detail-XYXPRDG6.js +1 -1
- package/dist/{chunk-AHXURBQK.js → chunk-6FWR6IXZ.js} +1 -1
- package/dist/{chunk-FKQAVXJB.js → chunk-7XATJLO3.js} +1 -1
- package/dist/{chunk-RJ62M6VM.js → chunk-B7MV2IBN.js} +1 -1
- package/dist/{chunk-GTWQFFLT.js → chunk-BHAZEG34.js} +1 -1
- package/dist/{chunk-2JJKODRU.js → chunk-JQKWHQYV.js} +1 -1
- package/dist/{chunk-2LSMPTXI.js → chunk-MZMJTKII.js} +1 -1
- package/dist/{chunk-VOIYFZUD.js → chunk-O65UQTKL.js} +1 -1
- package/dist/{chunk-Z5JATDR6.js → chunk-POICNIRJ.js} +1 -1
- package/dist/{chunk-LHSJXV22.js → chunk-QBKQ5PAI.js} +11 -6
- package/dist/{chunk-65UMNTRR.js → chunk-VGIRBDBL.js} +1 -1
- package/dist/{chunk-4HKO3FVW.js → chunk-VGWI5VD4.js} +4 -4
- package/dist/collection-detail-SA3GXCYV.js +1 -1
- package/dist/extension-targets.d.ts +3 -3
- package/dist/{home-ZMWPB7Z4.js → home-4ZLUQ2LL.js} +1 -1
- package/dist/index.js +27 -27
- package/dist/{inventory-list-DPV4VMBB.js → inventory-list-SUFVDLEJ.js} +1 -1
- package/dist/{inventory-stock-2KPY45VX.js → inventory-stock-LTLXVUHQ.js} +118 -30
- package/dist/offer-condition-list-F2UTHYW5.js +1 -1
- package/dist/{order-create-edit-ZOXREL6X.js → order-create-edit-AC2YWTP7.js} +84 -56
- package/dist/{order-edit-billing-address-L7OB7DT4.js → order-edit-billing-address-SM2VDTND.js} +1 -1
- package/dist/pages/index.js +10 -10
- package/dist/{product-create-W3RUAYN2.js → product-create-CEUBLSNB.js} +3 -3
- package/dist/product-list-UTRXPARK.js +1 -1
- package/dist/{product-media-W3QHRCXX.js → product-media-DB74GMWE.js} +2 -2
- package/dist/{product-organization-BPTXZPF2.js → product-organization-J4WAKRIN.js} +1 -1
- package/dist/{product-inbox-BBAXGADC.js → product-requests-SV5NHQ4L.js} +49 -49
- package/dist/product-tag-detail-PWYCRCC3.js +1 -1
- package/dist/product-tag-list-LNKN323U.js +1 -1
- package/dist/product-type-detail-7P2M7JIS.js +1 -1
- package/dist/{promotion-detail-QYNXRGMO.js → promotion-detail-FNO3QDGZ.js} +3 -3
- package/dist/{promotion-list-DTEMWIUT.js → promotion-list-JNUPZ3PP.js} +4 -4
- package/dist/refund-reason-list-YJN3YBCX.js +1 -1
- package/dist/{reset-password-CRA4KXXZ.js → reset-password-ITQ3O4O7.js} +1 -1
- package/dist/return-reason-list-2GUYWZLY.js +1 -1
- package/dist/sales-channel-detail-WUA6WCD3.js +1 -1
- package/dist/{settings-SQMRZHLN.js → settings-2XM6WY63.js} +2 -2
- package/dist/store-details-CTXOMJ4F.js +1 -1
- package/dist/{store-edit-6G62NLNK.js → store-edit-LELCWFLY.js} +2 -2
- package/dist/{tax-region-create-27DNVEWH.js → tax-region-create-7NCIY2IB.js} +1 -1
- package/dist/tax-region-tax-override-create-MGQYCSLB.js +1 -1
- package/dist/tax-region-tax-override-edit-PWH2ZJVM.js +1 -1
- package/package.json +6 -6
- package/dist/{category-products-AE44IYFB.js → category-products-YTOLFNN3.js} +1 -1
- package/dist/{collection-add-products-YGSJTBLG.js → collection-add-products-X5ALICTT.js} +1 -1
- package/dist/{sales-channel-add-products-XSGA433D.js → sales-channel-add-products-EIVCMYH6.js} +1 -1
|
@@ -70,7 +70,7 @@ import "./chunk-NBMM2TZK.js";
|
|
|
70
70
|
|
|
71
71
|
// src/pages/inventory/inventory-stock/inventory-stock.tsx
|
|
72
72
|
import { SectionNoAccess, isForbidden, useCan } from "@mercurjs/dashboard-shared";
|
|
73
|
-
import { useTranslation as
|
|
73
|
+
import { useTranslation as useTranslation4 } from "react-i18next";
|
|
74
74
|
import { useSearchParams } from "react-router-dom";
|
|
75
75
|
|
|
76
76
|
// src/pages/inventory/inventory-stock/components/inventory-stock-form/inventory-stock-form.tsx
|
|
@@ -78,11 +78,12 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|
|
78
78
|
import { Button, toast, usePrompt } from "@medusajs/ui";
|
|
79
79
|
import { useRef as useRef2 } from "react";
|
|
80
80
|
import { useForm } from "react-hook-form";
|
|
81
|
-
import { useTranslation as
|
|
81
|
+
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
82
82
|
|
|
83
83
|
// src/pages/inventory/inventory-stock/hooks/use-inventory-stock-columns.tsx
|
|
84
|
+
import { Buildings } from "@medusajs/icons";
|
|
84
85
|
import { useMemo } from "react";
|
|
85
|
-
import { useTranslation } from "react-i18next";
|
|
86
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
86
87
|
|
|
87
88
|
// src/components/data-grid/components/data-grid-toggleable-number-cell.tsx
|
|
88
89
|
import { Switch } from "@medusajs/ui";
|
|
@@ -241,11 +242,71 @@ var Inner = ({
|
|
|
241
242
|
) });
|
|
242
243
|
};
|
|
243
244
|
|
|
245
|
+
// src/pages/inventory/inventory-stock/components/foreign-location-cell/foreign-location-cell.tsx
|
|
246
|
+
import { Switch as Switch2, Tooltip } from "@medusajs/ui";
|
|
247
|
+
import { useTranslation } from "react-i18next";
|
|
248
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
249
|
+
var ForeignLocationCell = ({
|
|
250
|
+
context
|
|
251
|
+
}) => {
|
|
252
|
+
const { t } = useTranslation();
|
|
253
|
+
return /* @__PURE__ */ jsx2(DataGridReadonlyCell, { context, color: "normal", children: /* @__PURE__ */ jsx2(Tooltip, { content: t("inventory.stock.foreignStoreTooltip"), children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-x-2", children: [
|
|
254
|
+
/* @__PURE__ */ jsx2(
|
|
255
|
+
Switch2,
|
|
256
|
+
{
|
|
257
|
+
dir: "ltr",
|
|
258
|
+
size: "small",
|
|
259
|
+
className: "shrink-0 rtl:rotate-180",
|
|
260
|
+
checked: false,
|
|
261
|
+
disabled: true
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
/* @__PURE__ */ jsx2("span", { className: "text-ui-fg-muted", children: t("inventory.stock.placeholder") })
|
|
265
|
+
] }) }) });
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// src/pages/inventory/inventory-stock/utils.ts
|
|
269
|
+
var getItemSellerIds = (item) => {
|
|
270
|
+
const ids = /* @__PURE__ */ new Set();
|
|
271
|
+
if (item.seller?.id) {
|
|
272
|
+
ids.add(item.seller.id);
|
|
273
|
+
}
|
|
274
|
+
for (const offer of item.offers ?? []) {
|
|
275
|
+
if (offer.seller_id) {
|
|
276
|
+
ids.add(offer.seller_id);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return ids;
|
|
280
|
+
};
|
|
281
|
+
var getOfferTitle = (item) => item.offers?.[0]?.product_variant?.product?.title ?? void 0;
|
|
282
|
+
var isForeignLocation = (item, location) => {
|
|
283
|
+
const locationSellerId = location.seller?.id;
|
|
284
|
+
if (!locationSellerId) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
const itemSellerIds = getItemSellerIds(item);
|
|
288
|
+
if (itemSellerIds.size === 0) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
return !itemSellerIds.has(locationSellerId);
|
|
292
|
+
};
|
|
293
|
+
var scopeLocationsToItems = (items, locations) => {
|
|
294
|
+
const sellerIds = /* @__PURE__ */ new Set();
|
|
295
|
+
for (const item of items) {
|
|
296
|
+
for (const id of getItemSellerIds(item)) {
|
|
297
|
+
sellerIds.add(id);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return locations.filter(
|
|
301
|
+
(location) => !!location.seller?.id && sellerIds.has(location.seller.id)
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
|
|
244
305
|
// src/pages/inventory/inventory-stock/hooks/use-inventory-stock-columns.tsx
|
|
245
|
-
import { jsx as
|
|
306
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
246
307
|
var helper = createDataGridHelper();
|
|
247
308
|
var useInventoryStockColumns = (locations = []) => {
|
|
248
|
-
const { t } =
|
|
309
|
+
const { t } = useTranslation2();
|
|
249
310
|
return useMemo(
|
|
250
311
|
() => [
|
|
251
312
|
helper.column({
|
|
@@ -254,7 +315,7 @@ var useInventoryStockColumns = (locations = []) => {
|
|
|
254
315
|
header: t("fields.title"),
|
|
255
316
|
cell: (context) => {
|
|
256
317
|
const item = context.row.original;
|
|
257
|
-
return /* @__PURE__ */
|
|
318
|
+
return /* @__PURE__ */ jsx3(DataGridReadonlyCell, { context, color: "normal", children: /* @__PURE__ */ jsx3("span", { title: item.title || void 0, children: item.title || "-" }) });
|
|
258
319
|
},
|
|
259
320
|
disableHiding: true
|
|
260
321
|
}),
|
|
@@ -264,7 +325,17 @@ var useInventoryStockColumns = (locations = []) => {
|
|
|
264
325
|
header: t("fields.sku"),
|
|
265
326
|
cell: (context) => {
|
|
266
327
|
const item = context.row.original;
|
|
267
|
-
return /* @__PURE__ */
|
|
328
|
+
return /* @__PURE__ */ jsx3(DataGridReadonlyCell, { context, color: "normal", children: /* @__PURE__ */ jsx3("span", { title: item.sku || void 0, children: item.sku || "-" }) });
|
|
329
|
+
},
|
|
330
|
+
disableHiding: true
|
|
331
|
+
}),
|
|
332
|
+
helper.column({
|
|
333
|
+
id: "offer",
|
|
334
|
+
name: t("fields.offer"),
|
|
335
|
+
header: t("fields.offer"),
|
|
336
|
+
cell: (context) => {
|
|
337
|
+
const offerTitle = getOfferTitle(context.row.original);
|
|
338
|
+
return /* @__PURE__ */ jsx3(DataGridReadonlyCell, { context, color: "normal", children: /* @__PURE__ */ jsx3("span", { title: offerTitle, children: offerTitle || "-" }) });
|
|
268
339
|
},
|
|
269
340
|
disableHiding: true
|
|
270
341
|
}),
|
|
@@ -272,17 +343,24 @@ var useInventoryStockColumns = (locations = []) => {
|
|
|
272
343
|
(location) => helper.column({
|
|
273
344
|
id: `location_${location.id}`,
|
|
274
345
|
name: location.name,
|
|
275
|
-
header:
|
|
346
|
+
header: () => /* @__PURE__ */ jsxs2("div", { className: "flex w-full items-center justify-between gap-x-2", children: [
|
|
347
|
+
/* @__PURE__ */ jsx3("span", { className: "truncate", children: location.name }),
|
|
348
|
+
/* @__PURE__ */ jsx3(Buildings, { className: "text-ui-fg-subtle shrink-0" })
|
|
349
|
+
] }),
|
|
276
350
|
field: (context) => {
|
|
277
351
|
const item = context.row.original;
|
|
278
352
|
return `inventory_items.${item.id}.locations.${location.id}`;
|
|
279
353
|
},
|
|
280
354
|
type: "togglable-number",
|
|
281
355
|
cell: (context) => {
|
|
282
|
-
|
|
356
|
+
if (isForeignLocation(context.row.original, location)) {
|
|
357
|
+
return /* @__PURE__ */ jsx3(ForeignLocationCell, { context });
|
|
358
|
+
}
|
|
359
|
+
return /* @__PURE__ */ jsx3(
|
|
283
360
|
DataGridTogglableNumberCell,
|
|
284
361
|
{
|
|
285
362
|
context,
|
|
363
|
+
placeholder: t("inventory.stock.placeholder"),
|
|
286
364
|
disabledToggleTooltip: t(
|
|
287
365
|
"inventory.stock.disabledToggleTooltip"
|
|
288
366
|
)
|
|
@@ -313,12 +391,12 @@ var InventoryStockSchema = z.object({
|
|
|
313
391
|
});
|
|
314
392
|
|
|
315
393
|
// src/pages/inventory/inventory-stock/components/inventory-stock-form/inventory-stock-form.tsx
|
|
316
|
-
import { jsx as
|
|
394
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
317
395
|
var InventoryStockForm = ({
|
|
318
396
|
items,
|
|
319
397
|
locations
|
|
320
398
|
}) => {
|
|
321
|
-
const { t } =
|
|
399
|
+
const { t } = useTranslation3();
|
|
322
400
|
const { setCloseOnEscape, handleSuccess } = useRouteModal();
|
|
323
401
|
const prompt = usePrompt();
|
|
324
402
|
const initialValues = useRef2(getDefaultValues(items, locations));
|
|
@@ -335,10 +413,19 @@ var InventoryStockForm = ({
|
|
|
335
413
|
delete: [],
|
|
336
414
|
force: true
|
|
337
415
|
};
|
|
416
|
+
const itemsById = new Map(items.map((item) => [item.id, item]));
|
|
417
|
+
const locationsById = new Map(
|
|
418
|
+
locations.map((location) => [location.id, location])
|
|
419
|
+
);
|
|
338
420
|
for (const [inventory_item_id, item] of Object.entries(
|
|
339
421
|
data.inventory_items
|
|
340
422
|
)) {
|
|
341
423
|
for (const [location_id, level] of Object.entries(item.locations)) {
|
|
424
|
+
const gridItem = itemsById.get(inventory_item_id);
|
|
425
|
+
const gridLocation = locationsById.get(location_id);
|
|
426
|
+
if (!gridItem || !gridLocation || isForeignLocation(gridItem, gridLocation)) {
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
342
429
|
if (level.id) {
|
|
343
430
|
const wasChecked = initialValues.current?.inventory_items?.[inventory_item_id]?.locations?.[location_id]?.checked;
|
|
344
431
|
if (wasChecked && !level.checked) {
|
|
@@ -384,9 +471,9 @@ var InventoryStockForm = ({
|
|
|
384
471
|
}
|
|
385
472
|
});
|
|
386
473
|
});
|
|
387
|
-
return /* @__PURE__ */
|
|
388
|
-
/* @__PURE__ */
|
|
389
|
-
/* @__PURE__ */
|
|
474
|
+
return /* @__PURE__ */ jsx4(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs3(KeyboundForm, { onSubmit, className: "flex size-full flex-col", children: [
|
|
475
|
+
/* @__PURE__ */ jsx4(RouteFocusModal.Header, {}),
|
|
476
|
+
/* @__PURE__ */ jsx4(RouteFocusModal.Body, { className: "size-full flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx4(
|
|
390
477
|
DataGrid,
|
|
391
478
|
{
|
|
392
479
|
columns,
|
|
@@ -397,9 +484,9 @@ var InventoryStockForm = ({
|
|
|
397
484
|
}
|
|
398
485
|
}
|
|
399
486
|
) }),
|
|
400
|
-
/* @__PURE__ */
|
|
401
|
-
/* @__PURE__ */
|
|
402
|
-
/* @__PURE__ */
|
|
487
|
+
/* @__PURE__ */ jsx4(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-2", children: [
|
|
488
|
+
/* @__PURE__ */ jsx4(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx4(Button, { variant: "secondary", size: "small", type: "button", children: t("actions.cancel") }) }),
|
|
489
|
+
/* @__PURE__ */ jsx4(Button, { type: "submit", size: "small", isLoading: isPending, children: t("actions.save") })
|
|
403
490
|
] }) })
|
|
404
491
|
] }) });
|
|
405
492
|
};
|
|
@@ -425,15 +512,15 @@ function getDefaultValues(items, locations) {
|
|
|
425
512
|
}
|
|
426
513
|
|
|
427
514
|
// src/pages/inventory/inventory-stock/inventory-stock.tsx
|
|
428
|
-
import { Fragment, jsx as
|
|
515
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
429
516
|
var InventoryStock = () => {
|
|
430
|
-
const { t } =
|
|
517
|
+
const { t } = useTranslation4();
|
|
431
518
|
const canViewLocations = useCan("stock_locations");
|
|
432
519
|
const [searchParams] = useSearchParams();
|
|
433
520
|
const inventoryItemIds = searchParams.get(INVENTORY_ITEM_IDS_KEY)?.split(",") || void 0;
|
|
434
521
|
const { inventory_items, isPending, isError, error } = useInventoryItems({
|
|
435
522
|
id: inventoryItemIds,
|
|
436
|
-
fields: "id,sku,title,*location_levels,offers.seller_id"
|
|
523
|
+
fields: "id,sku,title,*location_levels,seller.id,offers.seller_id,offers.product_variant.product.title"
|
|
437
524
|
});
|
|
438
525
|
const {
|
|
439
526
|
stock_locations,
|
|
@@ -455,18 +542,19 @@ var InventoryStock = () => {
|
|
|
455
542
|
if (isErrorStockLocations && !noAccess) {
|
|
456
543
|
throw errorStockLocations;
|
|
457
544
|
}
|
|
458
|
-
const
|
|
459
|
-
|
|
545
|
+
const items = inventory_items ?? [];
|
|
546
|
+
const scopedLocations = scopeLocationsToItems(
|
|
547
|
+
items,
|
|
548
|
+
stock_locations ?? []
|
|
460
549
|
);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
/* @__PURE__ */
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
/* @__PURE__ */
|
|
467
|
-
/* @__PURE__ */ jsx4(RouteFocusModal.Body, { children: /* @__PURE__ */ jsx4(SectionNoAccess, {}) })
|
|
550
|
+
return /* @__PURE__ */ jsxs4(RouteFocusModal, { children: [
|
|
551
|
+
/* @__PURE__ */ jsx5(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx5("span", { className: "sr-only", children: t("inventory.stock.title") }) }),
|
|
552
|
+
/* @__PURE__ */ jsx5(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx5("span", { className: "sr-only", children: t("inventory.stock.description") }) }),
|
|
553
|
+
noAccess && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
554
|
+
/* @__PURE__ */ jsx5(RouteFocusModal.Header, {}),
|
|
555
|
+
/* @__PURE__ */ jsx5(RouteFocusModal.Body, { children: /* @__PURE__ */ jsx5(SectionNoAccess, {}) })
|
|
468
556
|
] }),
|
|
469
|
-
ready && /* @__PURE__ */
|
|
557
|
+
ready && /* @__PURE__ */ jsx5(InventoryStockForm, { items, locations: scopedLocations })
|
|
470
558
|
] });
|
|
471
559
|
};
|
|
472
560
|
export {
|
|
@@ -35,8 +35,8 @@ import "./chunk-MDABSESI.js";
|
|
|
35
35
|
import "./chunk-JRTZWK77.js";
|
|
36
36
|
import "./chunk-F3XPA5ID.js";
|
|
37
37
|
import "./chunk-QNH2UAGS.js";
|
|
38
|
-
import "./chunk-XSACPXD4.js";
|
|
39
38
|
import "./chunk-S4IDR46L.js";
|
|
39
|
+
import "./chunk-XSACPXD4.js";
|
|
40
40
|
import "./chunk-N72547NA.js";
|
|
41
41
|
import "./chunk-SANVDYAL.js";
|
|
42
42
|
import "./chunk-DB6ANJBO.js";
|
|
@@ -19,6 +19,9 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
DEFAULT_FIELDS
|
|
21
21
|
} from "./chunk-JHBNG7OD.js";
|
|
22
|
+
import {
|
|
23
|
+
CategoryCell
|
|
24
|
+
} from "./chunk-XSACPXD4.js";
|
|
22
25
|
import {
|
|
23
26
|
PlaceholderCell
|
|
24
27
|
} from "./chunk-PHOCVOZ5.js";
|
|
@@ -88,16 +91,22 @@ import { useTranslation as useTranslation5 } from "react-i18next";
|
|
|
88
91
|
|
|
89
92
|
// src/pages/orders/order-create-edit/components/add-order-edit-items-table/add-order-edit-items-table.tsx
|
|
90
93
|
import { SectionNoAccess, useCan } from "@mercurjs/dashboard-shared";
|
|
91
|
-
import { useMemo as useMemo2, useState } from "react";
|
|
94
|
+
import { useMemo as useMemo2, useRef, useState } from "react";
|
|
92
95
|
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
93
96
|
|
|
94
97
|
// src/pages/orders/order-create-edit/components/add-order-edit-items-table/use-order-edit-item-table-columns.tsx
|
|
95
|
-
import { Checkbox, Text } from "@medusajs/ui";
|
|
98
|
+
import { Checkbox, Text, Tooltip } from "@medusajs/ui";
|
|
96
99
|
import { createColumnHelper } from "@tanstack/react-table";
|
|
97
100
|
import { useMemo } from "react";
|
|
98
101
|
import { useTranslation } from "react-i18next";
|
|
99
102
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
100
103
|
var columnHelper = createColumnHelper();
|
|
104
|
+
var TextCell = ({ value }) => {
|
|
105
|
+
if (!value) {
|
|
106
|
+
return /* @__PURE__ */ jsx(PlaceholderCell, {});
|
|
107
|
+
}
|
|
108
|
+
return /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "truncate", title: value, children: value });
|
|
109
|
+
};
|
|
101
110
|
var useOrderEditItemsTableColumns = () => {
|
|
102
111
|
const { t } = useTranslation();
|
|
103
112
|
return useMemo(
|
|
@@ -112,11 +121,10 @@ var useOrderEditItemsTableColumns = () => {
|
|
|
112
121
|
}
|
|
113
122
|
),
|
|
114
123
|
cell: ({ row }) => {
|
|
115
|
-
const
|
|
116
|
-
return /* @__PURE__ */ jsx(
|
|
124
|
+
const checkbox = /* @__PURE__ */ jsx(
|
|
117
125
|
Checkbox,
|
|
118
126
|
{
|
|
119
|
-
disabled: !
|
|
127
|
+
disabled: !row.getCanSelect(),
|
|
120
128
|
checked: row.getIsSelected(),
|
|
121
129
|
onCheckedChange: (value) => row.toggleSelected(!!value),
|
|
122
130
|
onClick: (e) => {
|
|
@@ -124,48 +132,54 @@ var useOrderEditItemsTableColumns = () => {
|
|
|
124
132
|
}
|
|
125
133
|
}
|
|
126
134
|
);
|
|
135
|
+
if (!row.original.unavailable_reason) {
|
|
136
|
+
return checkbox;
|
|
137
|
+
}
|
|
138
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: row.original.unavailable_reason, side: "right", children: checkbox });
|
|
127
139
|
}
|
|
128
140
|
}),
|
|
129
141
|
columnHelper.display({
|
|
130
|
-
id: "
|
|
131
|
-
header: t("fields.
|
|
142
|
+
id: "offer",
|
|
143
|
+
header: t("fields.offer"),
|
|
132
144
|
cell: ({ row }) => {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
if (!productTitle) {
|
|
145
|
+
const product = row.original.product_variant?.product;
|
|
146
|
+
if (!product?.title) {
|
|
136
147
|
return /* @__PURE__ */ jsx(PlaceholderCell, {});
|
|
137
148
|
}
|
|
138
149
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full max-w-[300px] items-center gap-x-3 overflow-hidden", children: [
|
|
139
|
-
/* @__PURE__ */ jsx(Thumbnail, { src:
|
|
140
|
-
/* @__PURE__ */ jsx(
|
|
141
|
-
Text,
|
|
142
|
-
{
|
|
143
|
-
size: "small",
|
|
144
|
-
leading: "compact",
|
|
145
|
-
className: "truncate",
|
|
146
|
-
title: productTitle,
|
|
147
|
-
children: productTitle
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
+
/* @__PURE__ */ jsx(Thumbnail, { src: product.thumbnail }),
|
|
151
|
+
/* @__PURE__ */ jsx(TextCell, { value: product.title })
|
|
150
152
|
] });
|
|
151
153
|
}
|
|
152
154
|
}),
|
|
155
|
+
columnHelper.display({
|
|
156
|
+
id: "variant_title",
|
|
157
|
+
header: t("fields.variantTitle"),
|
|
158
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(TextCell, { value: row.original.product_variant?.title })
|
|
159
|
+
}),
|
|
153
160
|
columnHelper.accessor("sku", {
|
|
154
161
|
header: t("fields.sku"),
|
|
155
|
-
cell: ({ getValue }) => {
|
|
156
|
-
const sku = getValue();
|
|
157
|
-
if (!sku) return /* @__PURE__ */ jsx(PlaceholderCell, {});
|
|
158
|
-
return /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "truncate", children: sku });
|
|
159
|
-
}
|
|
162
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx(TextCell, { value: getValue() })
|
|
160
163
|
}),
|
|
161
164
|
columnHelper.display({
|
|
162
|
-
id: "
|
|
163
|
-
header: t("fields.
|
|
164
|
-
cell: ({ row }) =>
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
id: "category",
|
|
166
|
+
header: t("fields.category"),
|
|
167
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(
|
|
168
|
+
CategoryCell,
|
|
169
|
+
{
|
|
170
|
+
categories: row.original.product_variant?.product?.categories
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
}),
|
|
174
|
+
columnHelper.display({
|
|
175
|
+
id: "collection",
|
|
176
|
+
header: t("fields.collection"),
|
|
177
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(
|
|
178
|
+
TextCell,
|
|
179
|
+
{
|
|
180
|
+
value: row.original.product_variant?.product?.collection?.title
|
|
181
|
+
}
|
|
182
|
+
)
|
|
169
183
|
})
|
|
170
184
|
],
|
|
171
185
|
[t]
|
|
@@ -227,6 +241,9 @@ var OFFER_PICKER_FIELDS = [
|
|
|
227
241
|
"product_variant.product.id",
|
|
228
242
|
"product_variant.product.title",
|
|
229
243
|
"product_variant.product.thumbnail",
|
|
244
|
+
"product_variant.product.categories.id",
|
|
245
|
+
"product_variant.product.categories.name",
|
|
246
|
+
"product_variant.product.collection.title",
|
|
230
247
|
"product_variant.manage_inventory",
|
|
231
248
|
"product_variant.inventory_quantity",
|
|
232
249
|
"product_variant.inventory_items.required_quantity",
|
|
@@ -251,6 +268,7 @@ var offerHasInventory = (offer) => {
|
|
|
251
268
|
};
|
|
252
269
|
var AddOrderEditItemsTable = ({
|
|
253
270
|
currencyCode,
|
|
271
|
+
sellerId,
|
|
254
272
|
onSelectionChange
|
|
255
273
|
}) => {
|
|
256
274
|
const { t } = useTranslation3();
|
|
@@ -263,40 +281,47 @@ var AddOrderEditItemsTable = ({
|
|
|
263
281
|
const offersResponse = useOffers(
|
|
264
282
|
{
|
|
265
283
|
...searchParams,
|
|
284
|
+
seller_id: sellerId,
|
|
266
285
|
fields: OFFER_PICKER_FIELDS
|
|
267
286
|
},
|
|
268
|
-
{ enabled: canViewOffers }
|
|
287
|
+
{ enabled: canViewOffers && !!sellerId }
|
|
269
288
|
);
|
|
270
|
-
const
|
|
289
|
+
const count = offersResponse.count ?? 0;
|
|
271
290
|
const offers = useMemo2(() => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
291
|
+
return (offersResponse.offers ?? []).map((offer) => {
|
|
292
|
+
const hasPrice = !currencyCode || (offer.prices ?? []).some((p) => p.currency_code === currencyCode);
|
|
293
|
+
if (!hasPrice) {
|
|
294
|
+
return {
|
|
295
|
+
...offer,
|
|
296
|
+
unavailable_reason: t("orders.edits.offerNoPriceTooltip", {
|
|
297
|
+
currency: currencyCode?.toUpperCase()
|
|
298
|
+
})
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
if (!offerHasInventory(offer)) {
|
|
302
|
+
return {
|
|
303
|
+
...offer,
|
|
304
|
+
unavailable_reason: t("orders.edits.offerOutOfStockTooltip")
|
|
305
|
+
};
|
|
279
306
|
}
|
|
280
|
-
return
|
|
307
|
+
return offer;
|
|
281
308
|
});
|
|
282
|
-
}, [offersResponse.offers, currencyCode]);
|
|
283
|
-
const count = offers.length;
|
|
284
|
-
void rawCount;
|
|
309
|
+
}, [offersResponse.offers, currencyCode, t]);
|
|
285
310
|
const columns = useOrderEditItemsTableColumns();
|
|
286
311
|
const filters = useOrderEditItemTableFilters();
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
map.set(offer.id, { variantId: offer.variant_id, offerId: offer.id });
|
|
292
|
-
}
|
|
312
|
+
const variantIdByOfferId = useRef(/* @__PURE__ */ new Map());
|
|
313
|
+
for (const offer of offers) {
|
|
314
|
+
if (offer.id && offer.variant_id) {
|
|
315
|
+
variantIdByOfferId.current.set(offer.id, offer.variant_id);
|
|
293
316
|
}
|
|
294
|
-
|
|
295
|
-
}, [offers]);
|
|
317
|
+
}
|
|
296
318
|
const updater = (fn) => {
|
|
297
319
|
const newState = typeof fn === "function" ? fn(rowSelection) : fn;
|
|
298
320
|
setRowSelection(newState);
|
|
299
|
-
const pairs = Object.keys(newState).
|
|
321
|
+
const pairs = Object.keys(newState).flatMap((offerId) => {
|
|
322
|
+
const variantId = variantIdByOfferId.current.get(offerId);
|
|
323
|
+
return variantId ? [{ variantId, offerId }] : [];
|
|
324
|
+
});
|
|
300
325
|
onSelectionChange(pairs);
|
|
301
326
|
};
|
|
302
327
|
const { table } = useDataTable({
|
|
@@ -310,7 +335,8 @@ var AddOrderEditItemsTable = ({
|
|
|
310
335
|
// admin override route can apply the offer's price + reservation math.
|
|
311
336
|
getRowId: (row) => row.id ?? row.variant_id,
|
|
312
337
|
pageSize: PAGE_SIZE,
|
|
313
|
-
|
|
338
|
+
prefix: PREFIX,
|
|
339
|
+
enableRowSelection: (row) => !row.original.unavailable_reason,
|
|
314
340
|
rowSelection: {
|
|
315
341
|
state: rowSelection,
|
|
316
342
|
updater
|
|
@@ -546,6 +572,7 @@ var OrderEditItemsSection = ({
|
|
|
546
572
|
const { setIsOpen } = useStackedModal();
|
|
547
573
|
const [filterTerm, setFilterTerm] = useState2("");
|
|
548
574
|
const { mutateAsync: addItems, isPending } = useAddOrderEditItems(order.id);
|
|
575
|
+
const sellerId = order.seller?.id;
|
|
549
576
|
const onItemsSelected = async () => {
|
|
550
577
|
await addItems(
|
|
551
578
|
{
|
|
@@ -602,6 +629,7 @@ var OrderEditItemsSection = ({
|
|
|
602
629
|
AddOrderEditItemsTable,
|
|
603
630
|
{
|
|
604
631
|
currencyCode: order.currency_code,
|
|
632
|
+
sellerId,
|
|
605
633
|
onSelectionChange: (finalSelection) => {
|
|
606
634
|
addedSelections = finalSelection;
|
|
607
635
|
}
|
package/dist/pages/index.js
CHANGED
|
@@ -111,7 +111,7 @@ import {
|
|
|
111
111
|
} from "../chunk-US4ODTG4.js";
|
|
112
112
|
import {
|
|
113
113
|
InventoryListPage
|
|
114
|
-
} from "../chunk-
|
|
114
|
+
} from "../chunk-B7MV2IBN.js";
|
|
115
115
|
import "../chunk-EOZUAYQL.js";
|
|
116
116
|
import {
|
|
117
117
|
ReservationListPage
|
|
@@ -205,12 +205,12 @@ import {
|
|
|
205
205
|
import "../chunk-RSBKZYJ7.js";
|
|
206
206
|
import {
|
|
207
207
|
CampaignDetailPage
|
|
208
|
-
} from "../chunk-
|
|
208
|
+
} from "../chunk-VGIRBDBL.js";
|
|
209
209
|
import "../chunk-WP3B4NEU.js";
|
|
210
210
|
import {
|
|
211
211
|
PromotionListPage
|
|
212
|
-
} from "../chunk-
|
|
213
|
-
import "../chunk-
|
|
212
|
+
} from "../chunk-O65UQTKL.js";
|
|
213
|
+
import "../chunk-POICNIRJ.js";
|
|
214
214
|
import "../chunk-ZREELPMV.js";
|
|
215
215
|
import {
|
|
216
216
|
CreatePromotionSchema,
|
|
@@ -223,10 +223,10 @@ import "../chunk-GJCMUX7T.js";
|
|
|
223
223
|
import "../chunk-54TMLQH3.js";
|
|
224
224
|
import {
|
|
225
225
|
PromotionDetailPage
|
|
226
|
-
} from "../chunk-
|
|
226
|
+
} from "../chunk-JQKWHQYV.js";
|
|
227
227
|
import "../chunk-QLOJNFUE.js";
|
|
228
228
|
import "../chunk-O7324VFF.js";
|
|
229
|
-
import "../chunk-
|
|
229
|
+
import "../chunk-BHAZEG34.js";
|
|
230
230
|
import "../chunk-MAEP2UCK.js";
|
|
231
231
|
import "../chunk-GY7HAFTG.js";
|
|
232
232
|
import {
|
|
@@ -313,9 +313,9 @@ import {
|
|
|
313
313
|
ProductListPage
|
|
314
314
|
} from "../chunk-N3MOQFE2.js";
|
|
315
315
|
import "../chunk-QNH2UAGS.js";
|
|
316
|
-
import "../chunk-XSACPXD4.js";
|
|
317
316
|
import "../chunk-7F6ILJAJ.js";
|
|
318
317
|
import "../chunk-S4IDR46L.js";
|
|
318
|
+
import "../chunk-XSACPXD4.js";
|
|
319
319
|
import "../chunk-N72547NA.js";
|
|
320
320
|
import "../chunk-SANVDYAL.js";
|
|
321
321
|
import "../chunk-DB6ANJBO.js";
|
|
@@ -325,7 +325,7 @@ import "../chunk-H6MYB7GB.js";
|
|
|
325
325
|
import "../chunk-U3I6S3RO.js";
|
|
326
326
|
import {
|
|
327
327
|
ProductCreatePage
|
|
328
|
-
} from "../chunk-
|
|
328
|
+
} from "../chunk-6FWR6IXZ.js";
|
|
329
329
|
import "../chunk-IIFQ7KYL.js";
|
|
330
330
|
import "../chunk-HJ56YXBU.js";
|
|
331
331
|
import "../chunk-W2WJU2F7.js";
|
|
@@ -334,14 +334,14 @@ import "../chunk-PYDRHQTY.js";
|
|
|
334
334
|
import "../chunk-32URSQ4F.js";
|
|
335
335
|
import {
|
|
336
336
|
ProductCreateSchema
|
|
337
|
-
} from "../chunk-
|
|
337
|
+
} from "../chunk-7XATJLO3.js";
|
|
338
338
|
import "../chunk-5EOI66G4.js";
|
|
339
339
|
import "../chunk-AJLGY3LQ.js";
|
|
340
340
|
import "../chunk-SMQT3ZNO.js";
|
|
341
341
|
import "../chunk-RT6L7JXU.js";
|
|
342
342
|
import "../chunk-4YWKKCTT.js";
|
|
343
343
|
import "../chunk-SR3DYN52.js";
|
|
344
|
-
import "../chunk-
|
|
344
|
+
import "../chunk-QBKQ5PAI.js";
|
|
345
345
|
import "../chunk-FREUYHMS.js";
|
|
346
346
|
import "../chunk-VSLHL2AZ.js";
|
|
347
347
|
import "../chunk-2EME4AWX.js";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProductCreate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6FWR6IXZ.js";
|
|
4
4
|
import "./chunk-IIFQ7KYL.js";
|
|
5
5
|
import "./chunk-HJ56YXBU.js";
|
|
6
6
|
import "./chunk-W2WJU2F7.js";
|
|
7
7
|
import "./chunk-5KGMGL4N.js";
|
|
8
8
|
import "./chunk-PYDRHQTY.js";
|
|
9
9
|
import "./chunk-32URSQ4F.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-7XATJLO3.js";
|
|
11
11
|
import "./chunk-5EOI66G4.js";
|
|
12
12
|
import "./chunk-AJLGY3LQ.js";
|
|
13
13
|
import "./chunk-SMQT3ZNO.js";
|
|
14
14
|
import "./chunk-RT6L7JXU.js";
|
|
15
15
|
import "./chunk-4YWKKCTT.js";
|
|
16
16
|
import "./chunk-SR3DYN52.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-QBKQ5PAI.js";
|
|
18
18
|
import "./chunk-FREUYHMS.js";
|
|
19
19
|
import "./chunk-VSLHL2AZ.js";
|
|
20
20
|
import "./chunk-2EME4AWX.js";
|
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
ProductListPage
|
|
3
3
|
} from "./chunk-N3MOQFE2.js";
|
|
4
4
|
import "./chunk-QNH2UAGS.js";
|
|
5
|
-
import "./chunk-XSACPXD4.js";
|
|
6
5
|
import "./chunk-7F6ILJAJ.js";
|
|
7
6
|
import "./chunk-S4IDR46L.js";
|
|
7
|
+
import "./chunk-XSACPXD4.js";
|
|
8
8
|
import "./chunk-N72547NA.js";
|
|
9
9
|
import "./chunk-SANVDYAL.js";
|
|
10
10
|
import "./chunk-DB6ANJBO.js";
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-32URSQ4F.js";
|
|
7
7
|
import {
|
|
8
8
|
EditProductMediaSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7XATJLO3.js";
|
|
10
10
|
import "./chunk-AJLGY3LQ.js";
|
|
11
11
|
import "./chunk-SMQT3ZNO.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-QBKQ5PAI.js";
|
|
13
13
|
import "./chunk-VSLHL2AZ.js";
|
|
14
14
|
import "./chunk-732GOB5M.js";
|
|
15
15
|
import "./chunk-TKGWSUEI.js";
|