@mercurjs/vendor 2.2.0-canary.11 → 2.2.0-canary.13
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/{[id]-EKLRGVBA.js → [id]-ET35KT2M.js} +3 -3
- package/dist/{[id]-A55T2ORL.js → [id]-FALIOGXK.js} +3 -4
- package/dist/{[id]-GC3ZYPK4.js → [id]-GY5R652O.js} +5 -6
- package/dist/{[id]-GBT6VB4S.js → [id]-IGQTT3AM.js} +4 -5
- package/dist/{[id]-SHAJTJNZ.js → [id]-IW2AZE77.js} +5 -6
- package/dist/{[id]-FE5GYYVZ.js → [id]-OTK2NOXT.js} +3 -4
- package/dist/{[id]-U5KZEQDR.js → [id]-PEUI67SP.js} +2 -2
- package/dist/{[id]-T5ECVBPF.js → [id]-RFEYRBLI.js} +4 -5
- package/dist/{[id]-B4YZTANM.js → [id]-US6IULL2.js} +205 -484
- package/dist/{[id]-QOEO3JOV.js → [id]-YZSVSJWU.js} +3 -4
- package/dist/{[id]-QQU5HVFU.js → [id]-ZMLS73X5.js} +4 -5
- package/dist/{[province_id]-6GUA4PV5.js → [province_id]-J3OB2LZ4.js} +5 -6
- package/dist/{add-NTRYWOJF.js → add-XEUXK63F.js} +6 -7
- package/dist/{add-customer-groups-U5RZWW4B.js → add-customer-groups-HZNWWRVG.js} +3 -4
- package/dist/{add-products-Q4MMDQKT.js → add-products-E5GULF6B.js} +4 -5
- package/dist/{add-promotions-3AYXQXTP.js → add-promotions-KW5YZHLS.js} +3 -3
- package/dist/{address-77Y3AOQ3.js → address-6T4H6P7O.js} +3 -4
- package/dist/{breadcrumb-EVZIOB2G.js → breadcrumb-5HYIEPCL.js} +3 -4
- package/dist/{breadcrumb-TNJSGX4T.js → breadcrumb-HL7NKNX4.js} +3 -4
- package/dist/{breadcrumb-THJ2HPRB.js → breadcrumb-L3MFH4I2.js} +9 -8
- package/dist/{breadcrumb-5NP23D6X.js → breadcrumb-LKLWHB63.js} +4 -5
- package/dist/breadcrumb-ZMACILH3.js +28 -0
- package/dist/chunk-4WCPN4OA.js +315 -0
- package/dist/{chunk-LDZCCWJB.js → chunk-5YCDZ4AU.js} +1 -1
- package/dist/{chunk-OYKUQXJX.js → chunk-A6QH53CS.js} +21 -10
- package/dist/{chunk-GN6KB75Z.js → chunk-AQTEEQWX.js} +1 -1
- package/dist/{chunk-K6LOZ4S3.js → chunk-DEJIBIQZ.js} +1 -1
- package/dist/{chunk-4LVP635F.js → chunk-DNEPOMOX.js} +125 -125
- package/dist/{chunk-25E4KME5.js → chunk-J7ZU2HZZ.js} +1 -1
- package/dist/{chunk-OZ44ATGE.js → chunk-KJWVLGXG.js} +2 -2
- package/dist/{chunk-LKUW5SV4.js → chunk-LDX23XPT.js} +1 -1
- package/dist/{chunk-XP23ZVQT.js → chunk-MVYAN2RR.js} +4 -4
- package/dist/{chunk-TBYCZRZ7.js → chunk-R5QZO3QY.js} +14 -5
- package/dist/{chunk-UORPTGV2.js → chunk-SIEEMXNZ.js} +10 -14
- package/dist/chunk-SJT6A4AV.js +354 -0
- package/dist/{chunk-FWS4YJ4B.js → chunk-STWHJLVV.js} +1 -1
- package/dist/{chunk-TYESCFYW.js → chunk-UDOBGAP7.js} +1 -1
- package/dist/{chunk-6K6EQOJF.js → chunk-VAOJVT7R.js} +1 -1
- package/dist/{chunk-VCOQ7WQ2.js → chunk-VMFC2UDJ.js} +1 -1
- package/dist/chunk-XQUF3WIS.js +159 -0
- package/dist/{chunk-7IPCLQ5V.js → chunk-YPTJETJQ.js} +2 -2
- package/dist/{chunk-X4GWB6AT.js → chunk-ZBSFGCWY.js} +2 -2
- package/dist/{chunk-YGJCJBPM.js → chunk-ZPH3WXJ6.js} +1 -1
- package/dist/{collections-URH2TCWJ.js → collections-HO2F62RN.js} +4 -5
- package/dist/{create-FKRYB7ZS.js → create-7EVR4N6N.js} +1 -1
- package/dist/{create-JF2OUZQA.js → create-DB4EYPJ5.js} +3 -4
- package/dist/{create-JGYG5SBM.js → create-EFMCNOR5.js} +6 -7
- package/dist/{create-MS6KKFSV.js → create-FBPPNBLQ.js} +3 -4
- package/dist/{create-ODOFJF5N.js → create-J5OLH7OJ.js} +7 -8
- package/dist/{create-O35JRZEF.js → create-QAEOARJO.js} +4 -5
- package/dist/{create-HVZYJ3YC.js → create-QZBCYHHQ.js} +8 -9
- package/dist/{create-A7B3MLJX.js → create-SLJ2BMH7.js} +5 -6
- package/dist/{create-7R6CZU53.js → create-WBZJFMA7.js} +12 -3
- package/dist/{create-GGACODDN.js → create-WQ5TM5IZ.js} +1 -1
- package/dist/{edit-4G5D7TES.js → edit-3O6WVIMM.js} +5 -6
- package/dist/{edit-VVLITC2E.js → edit-G57GESSR.js} +1 -1
- package/dist/edit-PUZ23M7V.js +102 -0
- package/dist/{edit-G2E5SNGU.js → edit-PVJ3S4TW.js} +3 -4
- package/dist/{edit-2R5QCPTB.js → edit-RJE7L3PH.js} +3 -4
- package/dist/{edit-HTLLYECP.js → edit-TIRMXOLT.js} +6 -7
- package/dist/{edit-5CROKEJE.js → edit-W6WKYNOG.js} +5 -6
- package/dist/{edit-OKU6FMHJ.js → edit-WPX2ANVI.js} +3 -4
- package/dist/{edit-3E4ZO7HT.js → edit-YW4RBDPH.js} +6 -7
- package/dist/edit-price-5ICQPJ42.js +196 -0
- package/dist/edit-stock-KS2NFC2Z.js +229 -0
- package/dist/{fulfillment-76IVZ266.js → fulfillment-ZV2R43N2.js} +3 -4
- package/dist/{fulfillment-providers-G2L6LEVO.js → fulfillment-providers-KKCL25KA.js} +4 -5
- package/dist/index.css +6 -6
- package/dist/index.js +142 -106
- package/dist/{offer-inventory-batch-page-BD6PMDLW.js → inventory-5UNDKYDL.js} +12 -12
- package/dist/{invite-2673PU4I.js → invite-KKIJNMER.js} +6 -7
- package/dist/{invite-HRXZ5YBP.js → invite-P7I5BGOJ.js} +3 -4
- package/dist/loader-UZTTBKYF.js +33 -0
- package/dist/loader-WEJZTX5Q.js +34 -0
- package/dist/{login-TWUBU6I6.js → login-A65IAXSI.js} +4 -5
- package/dist/{media-Z4N5MKFG.js → media-EM3K4AWO.js} +6 -7
- package/dist/{metadata-Q74OJWUD.js → metadata-A5XZKPL4.js} +4 -5
- package/dist/{metadata-D6M66NQK.js → metadata-JFLFWXOS.js} +3 -4
- package/dist/{metadata-YVHJPDLD.js → metadata-SFO3J5O5.js} +3 -4
- package/dist/{metadata-NIDIBXJT.js → metadata-USXOQUIX.js} +3 -4
- package/dist/{metadata-REQIFWWH.js → metadata-WJ4CNB6I.js} +3 -4
- package/dist/{offer-create-page-E4FLSDJQ.js → offer-create-page-3PIJXHWZ.js} +169 -173
- package/dist/offer-detail-page-SPHP3XKC.js +580 -0
- package/dist/{offer-detail-page-6SIBQTLP.js → offer-variant-detail-page-KTHKV6WW.js} +144 -215
- package/dist/offers-GWMIEPCM.js +54 -0
- package/dist/{onboarding-MK2RIFD4.js → onboarding-JOGRNDPI.js} +3 -4
- package/dist/{orders-TVQDR4OJ.js → orders-Q2IKEJIM.js} +4 -5
- package/dist/{organization-XO3T2K2X.js → organization-HRYDC66D.js} +3 -4
- package/dist/pages/index.js +25 -27
- package/dist/{payment-details-CFTX3QDL.js → payment-details-YLPIR52N.js} +3 -4
- package/dist/{pricing-ECXV6K7G.js → pricing-ECJH4VXZ.js} +5 -6
- package/dist/{offer-pricing-edit-page-4TINK42V.js → pricing-EPNQ63NT.js} +15 -13
- package/dist/{product-tags-5O7ZG6SA.js → product-tags-WMC7G3C4.js} +5 -6
- package/dist/{product-variant-detail-PUWOMVHQ.js → product-variant-detail-BQL2NGVE.js} +3 -4
- package/dist/{product-variant-edit-WZNO4CQX.js → product-variant-edit-GACQHD46.js} +9 -20
- package/dist/{products-CPTRYL2Z.js → products-LGQMESEZ.js} +10 -11
- package/dist/{products-BM3IIH5P.js → products-PQ3FG5KC.js} +4 -5
- package/dist/{professional-details-ED4HNYXY.js → professional-details-AASVGTUO.js} +3 -4
- package/dist/{profile-6TGCNNUU.js → profile-ZNQEDSDM.js} +3 -4
- package/dist/{promotions-4336KI7E.js → promotions-MFAFFHF3.js} +4 -4
- package/dist/{register-OZ5CRANZ.js → register-3A6G6QNI.js} +5 -6
- package/dist/{reset-password-5UHZU4D3.js → reset-password-FV5762CA.js} +1 -1
- package/dist/{settings-2GCQQTO6.js → settings-OKNGWUKL.js} +12 -13
- package/dist/{shipment-HWQHMX2L.js → shipment-ZF7IRKKS.js} +3 -4
- package/dist/shipping-HWJPX34K.js +113 -0
- package/dist/{shipping-profile-ZP7M6VSS.js → shipping-profile-3QKTQI6L.js} +2 -6
- package/dist/{shipping-profiles-C5WBXWZ2.js → shipping-profiles-FZCKGCBU.js} +3 -4
- package/dist/{stock-MQA7PRO6.js → stock-FI5WXVWN.js} +4 -5
- package/dist/{store-5ZHZR4JI.js → store-VFRKJYMD.js} +3 -4
- package/dist/{store-closure-H5WHV3LA.js → store-closure-WZIWGESD.js} +3 -4
- package/dist/{store-select-PZS556FB.js → store-select-GKRDFGEY.js} +4 -5
- package/dist/{team-CLKJCZNH.js → team-CXEAYN7O.js} +3 -4
- package/package.json +1 -1
- package/dist/chunk-27KRIXMQ.js +0 -71
- package/dist/chunk-CFRWIQIZ.js +0 -43
- package/dist/chunk-RXV7INUV.js +0 -426
- package/dist/chunk-T6LHVNWO.js +0 -27
- package/dist/loader-VDYPD3RI.js +0 -31
- package/dist/offer-edit-page-3MO566RP.js +0 -151
- package/dist/offers-GVN5LCK6.js +0 -32
- package/dist/{chunk-SPOHNK4X.js → chunk-BPVMJN2D.js} +3 -3
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OFFER_PRODUCT_DETAIL_FIELDS
|
|
3
|
+
} from "./chunk-XQUF3WIS.js";
|
|
4
|
+
import {
|
|
5
|
+
ProductMediaSection,
|
|
6
|
+
productStatusColor
|
|
7
|
+
} from "./chunk-4WCPN4OA.js";
|
|
8
|
+
import {
|
|
9
|
+
SectionRow
|
|
10
|
+
} from "./chunk-4TLP3TAA.js";
|
|
11
|
+
import {
|
|
12
|
+
TwoColumnPage
|
|
13
|
+
} from "./chunk-YV6MK4PZ.js";
|
|
14
|
+
import {
|
|
15
|
+
useDataTableDateFilters
|
|
16
|
+
} from "./chunk-HFRHHT36.js";
|
|
17
|
+
import {
|
|
18
|
+
DataTable
|
|
19
|
+
} from "./chunk-5T6UWTRU.js";
|
|
20
|
+
import {
|
|
21
|
+
useQueryParams
|
|
22
|
+
} from "./chunk-THHRRYRS.js";
|
|
23
|
+
import {
|
|
24
|
+
useDate
|
|
25
|
+
} from "./chunk-LRD242C7.js";
|
|
26
|
+
import {
|
|
27
|
+
Thumbnail
|
|
28
|
+
} from "./chunk-WIYFXWRI.js";
|
|
29
|
+
import {
|
|
30
|
+
TwoColumnPageSkeleton
|
|
31
|
+
} from "./chunk-INNFZYX2.js";
|
|
32
|
+
import {
|
|
33
|
+
useBulkDeleteOffers
|
|
34
|
+
} from "./chunk-SIEEMXNZ.js";
|
|
35
|
+
import {
|
|
36
|
+
ActionMenu
|
|
37
|
+
} from "./chunk-BDGZ4EQO.js";
|
|
38
|
+
import "./chunk-LAVHRER2.js";
|
|
39
|
+
import "./chunk-QHQWEERJ.js";
|
|
40
|
+
import "./chunk-Y7QKP6QU.js";
|
|
41
|
+
import {
|
|
42
|
+
useProduct
|
|
43
|
+
} from "./chunk-JAUZ73XE.js";
|
|
44
|
+
import "./chunk-A5DJIOHN.js";
|
|
45
|
+
import "./chunk-RHKRREUU.js";
|
|
46
|
+
import "./chunk-ZA2KFUFR.js";
|
|
47
|
+
import "./chunk-RIN4CBRB.js";
|
|
48
|
+
import "./chunk-NBMM2TZK.js";
|
|
49
|
+
|
|
50
|
+
// src/pages/offers/[id]/offer-detail-page.tsx
|
|
51
|
+
import { Children } from "react";
|
|
52
|
+
import { useLoaderData, useParams } from "react-router-dom";
|
|
53
|
+
|
|
54
|
+
// src/pages/offers/[id]/_components/offer-detail-general-section.tsx
|
|
55
|
+
import { Trash } from "@medusajs/icons";
|
|
56
|
+
import { Container, Heading, StatusBadge, toast, usePrompt } from "@medusajs/ui";
|
|
57
|
+
import { useTranslation } from "react-i18next";
|
|
58
|
+
import { useNavigate } from "react-router-dom";
|
|
59
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
60
|
+
var OfferDetailGeneralSection = ({
|
|
61
|
+
product
|
|
62
|
+
}) => {
|
|
63
|
+
const { t } = useTranslation();
|
|
64
|
+
const prompt = usePrompt();
|
|
65
|
+
const navigate = useNavigate();
|
|
66
|
+
const { mutateAsync: bulkDelete } = useBulkDeleteOffers();
|
|
67
|
+
const offerIds = (product.variants ?? []).flatMap(
|
|
68
|
+
(v) => (v.offers ?? []).map((o) => o.id)
|
|
69
|
+
);
|
|
70
|
+
const handleDelete = async () => {
|
|
71
|
+
if (!offerIds.length) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const confirmed = await prompt({
|
|
75
|
+
title: t("general.areYouSure"),
|
|
76
|
+
// The product listing is one offer to the seller, regardless of how
|
|
77
|
+
// many of its variants are offered under the hood.
|
|
78
|
+
description: t("offers.bulkDelete.description", { count: 1 }),
|
|
79
|
+
confirmText: t("actions.delete"),
|
|
80
|
+
cancelText: t("actions.cancel"),
|
|
81
|
+
variant: "danger"
|
|
82
|
+
});
|
|
83
|
+
if (!confirmed) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const result = await bulkDelete(offerIds);
|
|
87
|
+
if (result.failed.length === 0) {
|
|
88
|
+
toast.success(t("offers.bulkDelete.successToast", { count: 1 }));
|
|
89
|
+
navigate("/offers");
|
|
90
|
+
} else {
|
|
91
|
+
toast.warning(
|
|
92
|
+
t("offers.bulkDelete.partialToast", {
|
|
93
|
+
succeeded: result.succeeded.length,
|
|
94
|
+
total: offerIds.length,
|
|
95
|
+
failed: result.failed.length
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
101
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
102
|
+
/* @__PURE__ */ jsx(Heading, { children: product.title }),
|
|
103
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
|
|
104
|
+
product.status && /* @__PURE__ */ jsx(StatusBadge, { color: productStatusColor(product.status), children: t(`products.productStatus.${product.status}`) }),
|
|
105
|
+
/* @__PURE__ */ jsx(
|
|
106
|
+
ActionMenu,
|
|
107
|
+
{
|
|
108
|
+
groups: [
|
|
109
|
+
{
|
|
110
|
+
actions: [
|
|
111
|
+
{
|
|
112
|
+
label: t("actions.delete"),
|
|
113
|
+
onClick: handleDelete,
|
|
114
|
+
icon: /* @__PURE__ */ jsx(Trash, {}),
|
|
115
|
+
disabled: offerIds.length === 0
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] })
|
|
123
|
+
] }),
|
|
124
|
+
/* @__PURE__ */ jsx(
|
|
125
|
+
SectionRow,
|
|
126
|
+
{
|
|
127
|
+
title: t("fields.description"),
|
|
128
|
+
value: product.description || "-"
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsx(SectionRow, { title: t("fields.subtitle"), value: product.subtitle || "-" }),
|
|
132
|
+
/* @__PURE__ */ jsx(
|
|
133
|
+
SectionRow,
|
|
134
|
+
{
|
|
135
|
+
title: t("fields.handle"),
|
|
136
|
+
value: product.handle ? `/${product.handle}` : "-"
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ jsx(
|
|
140
|
+
SectionRow,
|
|
141
|
+
{
|
|
142
|
+
title: t("fields.discountable"),
|
|
143
|
+
value: product.discountable ? t("general.true") : t("general.false")
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
] });
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/pages/offers/[id]/_components/offer-variants-section.tsx
|
|
150
|
+
import {
|
|
151
|
+
Buildings,
|
|
152
|
+
Component,
|
|
153
|
+
CurrencyDollar,
|
|
154
|
+
PencilSquare,
|
|
155
|
+
Trash as Trash2
|
|
156
|
+
} from "@medusajs/icons";
|
|
157
|
+
import {
|
|
158
|
+
Badge,
|
|
159
|
+
clx,
|
|
160
|
+
Container as Container2,
|
|
161
|
+
createDataTableColumnHelper,
|
|
162
|
+
Heading as Heading2,
|
|
163
|
+
toast as toast2,
|
|
164
|
+
Tooltip,
|
|
165
|
+
usePrompt as usePrompt2
|
|
166
|
+
} from "@medusajs/ui";
|
|
167
|
+
import { useCallback, useMemo } from "react";
|
|
168
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
169
|
+
import { useNavigate as useNavigate2 } from "react-router-dom";
|
|
170
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
171
|
+
var PAGE_SIZE = 10;
|
|
172
|
+
var PREFIX = "ov";
|
|
173
|
+
var skuOf = (row) => row.offer.sku ?? row.variant.sku ?? "";
|
|
174
|
+
var inventoryOf = (offer) => {
|
|
175
|
+
const links = offer.inventory_item_link ?? [];
|
|
176
|
+
let available = 0;
|
|
177
|
+
const locations = /* @__PURE__ */ new Set();
|
|
178
|
+
for (const link of links) {
|
|
179
|
+
for (const level of link.inventory_item?.location_levels ?? []) {
|
|
180
|
+
available += level.stocked_quantity ?? 0;
|
|
181
|
+
if (level.location_id) {
|
|
182
|
+
locations.add(level.location_id);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
hasItems: links.length > 0,
|
|
188
|
+
// More than one backing inventory item ⇒ the offer is an inventory
|
|
189
|
+
// kit; the table marks it with a Component glyph (Figma `40016500:749885`).
|
|
190
|
+
isKit: links.length > 1,
|
|
191
|
+
available,
|
|
192
|
+
locationCount: locations.size
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
var matchesDateFilter = (value, filter) => {
|
|
196
|
+
if (!value) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
const time = new Date(value).getTime();
|
|
200
|
+
if (Number.isNaN(time)) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
if (filter.$gte && time < new Date(filter.$gte).getTime()) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
if (filter.$lte && time > new Date(filter.$lte).getTime()) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
return true;
|
|
210
|
+
};
|
|
211
|
+
var columnHelper = createDataTableColumnHelper();
|
|
212
|
+
var useColumns = ({
|
|
213
|
+
optionTitles,
|
|
214
|
+
thumbnail,
|
|
215
|
+
getActions
|
|
216
|
+
}) => {
|
|
217
|
+
const { t } = useTranslation2();
|
|
218
|
+
const { getFullDate } = useDate();
|
|
219
|
+
return useMemo(
|
|
220
|
+
() => [
|
|
221
|
+
columnHelper.display({
|
|
222
|
+
id: "thumbnail",
|
|
223
|
+
header: "",
|
|
224
|
+
// Variant-level images aren't carried by the `withOffers` wrap, so
|
|
225
|
+
// every row falls back to the product thumbnail (Figma shows a
|
|
226
|
+
// thumbnail in the Title cell, `40016500:747487`).
|
|
227
|
+
cell: () => /* @__PURE__ */ jsx2("div", { className: "flex items-center", children: /* @__PURE__ */ jsx2(Thumbnail, { src: thumbnail ?? null }) })
|
|
228
|
+
}),
|
|
229
|
+
columnHelper.accessor((row) => row.variant.title ?? "", {
|
|
230
|
+
id: "title",
|
|
231
|
+
header: t("fields.title"),
|
|
232
|
+
enableSorting: true,
|
|
233
|
+
sortAscLabel: t("filters.sorting.alphabeticallyAsc"),
|
|
234
|
+
sortDescLabel: t("filters.sorting.alphabeticallyDesc"),
|
|
235
|
+
cell: ({ getValue }) => getValue() || /* @__PURE__ */ jsx2("span", { className: "text-ui-fg-muted", children: "-" })
|
|
236
|
+
}),
|
|
237
|
+
columnHelper.accessor((row) => skuOf(row), {
|
|
238
|
+
id: "sku",
|
|
239
|
+
header: t("fields.sku"),
|
|
240
|
+
enableSorting: true,
|
|
241
|
+
sortAscLabel: t("filters.sorting.alphabeticallyAsc"),
|
|
242
|
+
sortDescLabel: t("filters.sorting.alphabeticallyDesc"),
|
|
243
|
+
cell: ({ getValue }) => getValue() || /* @__PURE__ */ jsx2("span", { className: "text-ui-fg-muted", children: "-" })
|
|
244
|
+
}),
|
|
245
|
+
...optionTitles.map(
|
|
246
|
+
(title) => columnHelper.display({
|
|
247
|
+
id: `option-${title}`,
|
|
248
|
+
header: title,
|
|
249
|
+
cell: ({ row }) => {
|
|
250
|
+
const opt = row.original.variant.options?.find(
|
|
251
|
+
(o) => o.option?.title === title
|
|
252
|
+
);
|
|
253
|
+
return opt?.value ? /* @__PURE__ */ jsx2(Badge, { size: "2xsmall", children: opt.value }) : /* @__PURE__ */ jsx2("span", { className: "text-ui-fg-muted", children: "-" });
|
|
254
|
+
}
|
|
255
|
+
})
|
|
256
|
+
),
|
|
257
|
+
columnHelper.display({
|
|
258
|
+
id: "inventory",
|
|
259
|
+
header: t("fields.inventory"),
|
|
260
|
+
cell: ({ row }) => {
|
|
261
|
+
const { hasItems, isKit, available, locationCount } = inventoryOf(
|
|
262
|
+
row.original.offer
|
|
263
|
+
);
|
|
264
|
+
if (!hasItems) {
|
|
265
|
+
return /* @__PURE__ */ jsx2("span", { className: "text-ui-fg-muted", children: "-" });
|
|
266
|
+
}
|
|
267
|
+
const text = t("products.variant.tableItem", {
|
|
268
|
+
availableCount: available,
|
|
269
|
+
locationCount,
|
|
270
|
+
count: locationCount
|
|
271
|
+
});
|
|
272
|
+
return /* @__PURE__ */ jsx2(Tooltip, { content: text, children: /* @__PURE__ */ jsxs2("div", { className: "flex h-full w-full items-center gap-2 overflow-hidden", children: [
|
|
273
|
+
isKit && /* @__PURE__ */ jsx2(Component, { className: "text-ui-fg-subtle" }),
|
|
274
|
+
/* @__PURE__ */ jsx2(
|
|
275
|
+
"span",
|
|
276
|
+
{
|
|
277
|
+
className: clx("truncate", {
|
|
278
|
+
"text-ui-fg-error": available === 0
|
|
279
|
+
}),
|
|
280
|
+
children: text
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
] }) });
|
|
284
|
+
}
|
|
285
|
+
}),
|
|
286
|
+
columnHelper.accessor((row) => row.offer.created_at, {
|
|
287
|
+
id: "created_at",
|
|
288
|
+
header: t("fields.createdAt"),
|
|
289
|
+
enableSorting: true,
|
|
290
|
+
sortAscLabel: t("filters.sorting.dateAsc"),
|
|
291
|
+
sortDescLabel: t("filters.sorting.dateDesc"),
|
|
292
|
+
cell: ({ getValue }) => {
|
|
293
|
+
const date = getValue();
|
|
294
|
+
if (!date) {
|
|
295
|
+
return /* @__PURE__ */ jsx2("span", { className: "text-ui-fg-muted", children: "-" });
|
|
296
|
+
}
|
|
297
|
+
return /* @__PURE__ */ jsx2(Tooltip, { content: getFullDate({ date, includeTime: true }), children: /* @__PURE__ */ jsx2("span", { children: getFullDate({ date }) }) });
|
|
298
|
+
}
|
|
299
|
+
}),
|
|
300
|
+
columnHelper.accessor((row) => row.offer.updated_at, {
|
|
301
|
+
id: "updated_at",
|
|
302
|
+
header: t("fields.updatedAt"),
|
|
303
|
+
enableSorting: true,
|
|
304
|
+
sortAscLabel: t("filters.sorting.dateAsc"),
|
|
305
|
+
sortDescLabel: t("filters.sorting.dateDesc"),
|
|
306
|
+
cell: ({ getValue }) => {
|
|
307
|
+
const date = getValue();
|
|
308
|
+
if (!date) {
|
|
309
|
+
return /* @__PURE__ */ jsx2("span", { className: "text-ui-fg-muted", children: "-" });
|
|
310
|
+
}
|
|
311
|
+
return /* @__PURE__ */ jsx2(Tooltip, { content: getFullDate({ date, includeTime: true }), children: /* @__PURE__ */ jsx2("span", { children: getFullDate({ date }) }) });
|
|
312
|
+
}
|
|
313
|
+
}),
|
|
314
|
+
columnHelper.action({ actions: getActions })
|
|
315
|
+
],
|
|
316
|
+
[t, optionTitles, thumbnail, getActions, getFullDate]
|
|
317
|
+
);
|
|
318
|
+
};
|
|
319
|
+
var OfferVariantsSection = ({
|
|
320
|
+
variants,
|
|
321
|
+
thumbnail
|
|
322
|
+
}) => {
|
|
323
|
+
const { t } = useTranslation2();
|
|
324
|
+
const navigate = useNavigate2();
|
|
325
|
+
const prompt = usePrompt2();
|
|
326
|
+
const { mutateAsync: bulkDelete } = useBulkDeleteOffers();
|
|
327
|
+
const { q, order, offset, created_at, updated_at } = useQueryParams(
|
|
328
|
+
["q", "order", "offset", "created_at", "updated_at"],
|
|
329
|
+
PREFIX
|
|
330
|
+
);
|
|
331
|
+
const allRows = useMemo(
|
|
332
|
+
() => (variants ?? []).flatMap(
|
|
333
|
+
(variant) => (variant.offers ?? []).map((offer) => ({
|
|
334
|
+
id: offer.id,
|
|
335
|
+
variant,
|
|
336
|
+
offer
|
|
337
|
+
}))
|
|
338
|
+
),
|
|
339
|
+
[variants]
|
|
340
|
+
);
|
|
341
|
+
const optionTitles = useMemo(() => {
|
|
342
|
+
const set = /* @__PURE__ */ new Set();
|
|
343
|
+
for (const variant of variants ?? []) {
|
|
344
|
+
for (const opt of variant.options ?? []) {
|
|
345
|
+
if (opt.option?.title) {
|
|
346
|
+
set.add(opt.option.title);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return Array.from(set);
|
|
351
|
+
}, [variants]);
|
|
352
|
+
const filteredRows = useMemo(() => {
|
|
353
|
+
let rows = allRows;
|
|
354
|
+
const search = q?.trim().toLowerCase();
|
|
355
|
+
if (search) {
|
|
356
|
+
rows = rows.filter((row) => {
|
|
357
|
+
const title = (row.variant.title ?? "").toLowerCase();
|
|
358
|
+
return title.includes(search) || skuOf(row).toLowerCase().includes(search);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
const createdFilter = created_at ? JSON.parse(created_at) : null;
|
|
362
|
+
if (createdFilter) {
|
|
363
|
+
rows = rows.filter(
|
|
364
|
+
(row) => matchesDateFilter(row.offer.created_at, createdFilter)
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
const updatedFilter = updated_at ? JSON.parse(updated_at) : null;
|
|
368
|
+
if (updatedFilter) {
|
|
369
|
+
rows = rows.filter(
|
|
370
|
+
(row) => matchesDateFilter(row.offer.updated_at, updatedFilter)
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
return rows;
|
|
374
|
+
}, [allRows, q, created_at, updated_at]);
|
|
375
|
+
const sortedRows = useMemo(() => {
|
|
376
|
+
if (!order) {
|
|
377
|
+
return filteredRows;
|
|
378
|
+
}
|
|
379
|
+
const desc = order.startsWith("-");
|
|
380
|
+
const key = desc ? order.slice(1) : order;
|
|
381
|
+
const valueOf = (row) => {
|
|
382
|
+
switch (key) {
|
|
383
|
+
case "title":
|
|
384
|
+
return row.variant.title ?? "";
|
|
385
|
+
case "sku":
|
|
386
|
+
return skuOf(row);
|
|
387
|
+
case "created_at":
|
|
388
|
+
return row.offer.created_at ? new Date(row.offer.created_at).toISOString() : "";
|
|
389
|
+
case "updated_at":
|
|
390
|
+
return row.offer.updated_at ? new Date(row.offer.updated_at).toISOString() : "";
|
|
391
|
+
default:
|
|
392
|
+
return "";
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const sorted = [...filteredRows].sort(
|
|
396
|
+
(a, b) => valueOf(a).localeCompare(valueOf(b))
|
|
397
|
+
);
|
|
398
|
+
return desc ? sorted.reverse() : sorted;
|
|
399
|
+
}, [filteredRows, order]);
|
|
400
|
+
const pageIndex = offset ? Math.floor(parseInt(offset) / PAGE_SIZE) : 0;
|
|
401
|
+
const pageRows = useMemo(
|
|
402
|
+
() => sortedRows.slice(pageIndex * PAGE_SIZE, (pageIndex + 1) * PAGE_SIZE),
|
|
403
|
+
[sortedRows, pageIndex]
|
|
404
|
+
);
|
|
405
|
+
const handleDelete = useCallback(
|
|
406
|
+
async (offerId, sku) => {
|
|
407
|
+
const confirmed = await prompt({
|
|
408
|
+
title: t("general.areYouSure"),
|
|
409
|
+
description: t("offers.delete.description", { sku: sku || "-" }),
|
|
410
|
+
confirmText: t("actions.delete"),
|
|
411
|
+
cancelText: t("actions.cancel"),
|
|
412
|
+
variant: "danger"
|
|
413
|
+
});
|
|
414
|
+
if (!confirmed) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const result = await bulkDelete([offerId]);
|
|
418
|
+
if (result.failed.length === 0) {
|
|
419
|
+
toast2.success(t("offers.delete.successToast"));
|
|
420
|
+
} else {
|
|
421
|
+
toast2.error(result.failed[0]?.error.message);
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
[prompt, bulkDelete, t]
|
|
425
|
+
);
|
|
426
|
+
const getActions = useCallback(
|
|
427
|
+
(ctx) => {
|
|
428
|
+
const row = ctx.row.original;
|
|
429
|
+
return [
|
|
430
|
+
[
|
|
431
|
+
{
|
|
432
|
+
icon: /* @__PURE__ */ jsx2(PencilSquare, {}),
|
|
433
|
+
label: t("actions.edit"),
|
|
434
|
+
onClick: () => navigate(`variants/${row.id}/edit`)
|
|
435
|
+
}
|
|
436
|
+
],
|
|
437
|
+
[
|
|
438
|
+
{
|
|
439
|
+
icon: /* @__PURE__ */ jsx2(Trash2, {}),
|
|
440
|
+
label: t("actions.delete"),
|
|
441
|
+
onClick: () => handleDelete(row.offer.id, skuOf(row))
|
|
442
|
+
}
|
|
443
|
+
]
|
|
444
|
+
];
|
|
445
|
+
},
|
|
446
|
+
[navigate, handleDelete, t]
|
|
447
|
+
);
|
|
448
|
+
const columns = useColumns({ optionTitles, thumbnail, getActions });
|
|
449
|
+
const filters = useDataTableDateFilters();
|
|
450
|
+
return /* @__PURE__ */ jsxs2(Container2, { className: "p-0", "data-testid": "offer-variants-section", children: [
|
|
451
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
452
|
+
/* @__PURE__ */ jsx2(Heading2, { level: "h2", children: t("offers.fields.variants") }),
|
|
453
|
+
/* @__PURE__ */ jsx2("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsx2(
|
|
454
|
+
ActionMenu,
|
|
455
|
+
{
|
|
456
|
+
groups: [
|
|
457
|
+
{
|
|
458
|
+
actions: [
|
|
459
|
+
{
|
|
460
|
+
label: t("offers.actions.edit_prices"),
|
|
461
|
+
icon: /* @__PURE__ */ jsx2(CurrencyDollar, {}),
|
|
462
|
+
to: "edit-price"
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
label: t("offers.actions.edit_stock_levels"),
|
|
466
|
+
icon: /* @__PURE__ */ jsx2(Buildings, {}),
|
|
467
|
+
to: "edit-stock"
|
|
468
|
+
}
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
]
|
|
472
|
+
}
|
|
473
|
+
) })
|
|
474
|
+
] }),
|
|
475
|
+
/* @__PURE__ */ jsx2(
|
|
476
|
+
DataTable,
|
|
477
|
+
{
|
|
478
|
+
data: pageRows,
|
|
479
|
+
columns,
|
|
480
|
+
filters,
|
|
481
|
+
getRowId: (row) => row.id,
|
|
482
|
+
rowHref: (row) => `variants/${row.id}`,
|
|
483
|
+
rowCount: sortedRows.length,
|
|
484
|
+
pageSize: PAGE_SIZE,
|
|
485
|
+
prefix: PREFIX,
|
|
486
|
+
compact: true,
|
|
487
|
+
emptyState: {
|
|
488
|
+
empty: {
|
|
489
|
+
heading: t("offers.empty.heading"),
|
|
490
|
+
description: t("offers.empty.description")
|
|
491
|
+
},
|
|
492
|
+
filtered: {
|
|
493
|
+
heading: t("offers.filtered.heading"),
|
|
494
|
+
description: t("offers.filtered.description")
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
)
|
|
499
|
+
] });
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
// src/pages/offers/[id]/_components/offer-associated-product-section.tsx
|
|
503
|
+
import { TriangleRightMini } from "@medusajs/icons";
|
|
504
|
+
import { Container as Container3, Heading as Heading3 } from "@medusajs/ui";
|
|
505
|
+
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
506
|
+
import { Link } from "react-router-dom";
|
|
507
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
508
|
+
var OfferAssociatedProductSection = ({
|
|
509
|
+
product
|
|
510
|
+
}) => {
|
|
511
|
+
const { t } = useTranslation3();
|
|
512
|
+
return /* @__PURE__ */ jsxs3(Container3, { className: "p-0", "data-testid": "offer-associated-product-section", children: [
|
|
513
|
+
/* @__PURE__ */ jsx3("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsx3(Heading3, { level: "h2", children: t("offers.detail.associatedProduct") }) }),
|
|
514
|
+
/* @__PURE__ */ jsx3("div", { className: "txt-small flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx3(
|
|
515
|
+
Link,
|
|
516
|
+
{
|
|
517
|
+
to: `/products/${product.id}`,
|
|
518
|
+
className: "outline-none focus-within:shadow-borders-interactive-with-focus rounded-md [&:hover>div]:bg-ui-bg-component-hover",
|
|
519
|
+
"data-testid": "offer-associated-product-link",
|
|
520
|
+
children: /* @__PURE__ */ jsx3("div", { className: "shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-2 transition-colors", children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
|
|
521
|
+
/* @__PURE__ */ jsx3("div", { className: "shadow-elevation-card-rest rounded-md", children: /* @__PURE__ */ jsx3(Thumbnail, { src: product.thumbnail ?? null }) }),
|
|
522
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
523
|
+
/* @__PURE__ */ jsx3("span", { className: "text-ui-fg-base truncate font-medium", children: product.title }),
|
|
524
|
+
product.handle && /* @__PURE__ */ jsxs3("span", { className: "text-ui-fg-subtle truncate", children: [
|
|
525
|
+
"/",
|
|
526
|
+
product.handle
|
|
527
|
+
] })
|
|
528
|
+
] }),
|
|
529
|
+
/* @__PURE__ */ jsx3("div", { className: "size-7 flex items-center justify-center", children: /* @__PURE__ */ jsx3(TriangleRightMini, { className: "text-ui-fg-muted rtl:rotate-180" }) })
|
|
530
|
+
] }) })
|
|
531
|
+
}
|
|
532
|
+
) })
|
|
533
|
+
] });
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
// src/pages/offers/[id]/offer-detail-page.tsx
|
|
537
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
538
|
+
var Root = ({ children }) => {
|
|
539
|
+
const { id } = useParams();
|
|
540
|
+
const initialData = useLoaderData();
|
|
541
|
+
const { product, isLoading, isError, error } = useProduct(
|
|
542
|
+
id,
|
|
543
|
+
{ fields: OFFER_PRODUCT_DETAIL_FIELDS },
|
|
544
|
+
{ initialData }
|
|
545
|
+
);
|
|
546
|
+
if (isError) {
|
|
547
|
+
throw error;
|
|
548
|
+
}
|
|
549
|
+
if (isLoading || !product) {
|
|
550
|
+
return /* @__PURE__ */ jsx4(TwoColumnPageSkeleton, { mainSections: 3, sidebarSections: 1 });
|
|
551
|
+
}
|
|
552
|
+
const typed = product;
|
|
553
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs4(TwoColumnPage, { data: typed, hasOutlet: true, children: [
|
|
554
|
+
/* @__PURE__ */ jsxs4(TwoColumnPage.Main, { children: [
|
|
555
|
+
/* @__PURE__ */ jsx4(OfferDetailGeneralSection, { product: typed }),
|
|
556
|
+
/* @__PURE__ */ jsx4(ProductMediaSection, { product: typed, readOnly: true }),
|
|
557
|
+
/* @__PURE__ */ jsx4(
|
|
558
|
+
OfferVariantsSection,
|
|
559
|
+
{
|
|
560
|
+
variants: typed.variants,
|
|
561
|
+
thumbnail: typed.thumbnail
|
|
562
|
+
}
|
|
563
|
+
)
|
|
564
|
+
] }),
|
|
565
|
+
/* @__PURE__ */ jsx4(TwoColumnPage.Sidebar, { children: /* @__PURE__ */ jsx4(OfferAssociatedProductSection, { product: typed }) })
|
|
566
|
+
] }) });
|
|
567
|
+
};
|
|
568
|
+
var OfferDetailPage = Object.assign(Root, {
|
|
569
|
+
Main: TwoColumnPage.Main,
|
|
570
|
+
Sidebar: TwoColumnPage.Sidebar,
|
|
571
|
+
General: OfferDetailGeneralSection,
|
|
572
|
+
Media: ProductMediaSection,
|
|
573
|
+
Variants: OfferVariantsSection,
|
|
574
|
+
AssociatedProduct: OfferAssociatedProductSection
|
|
575
|
+
});
|
|
576
|
+
var Component2 = Root;
|
|
577
|
+
export {
|
|
578
|
+
Component2 as Component,
|
|
579
|
+
OfferDetailPage
|
|
580
|
+
};
|