@mercurjs/vendor 2.2.0-canary.12 → 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]-Q4HX3TQU.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]-WDBUNEJB.js → [id]-PEUI67SP.js} +2 -2
- package/dist/{[id]-T5ECVBPF.js → [id]-RFEYRBLI.js} +4 -5
- package/dist/{[id]-OWENEUQB.js → [id]-US6IULL2.js} +147 -441
- 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-DH5CD5AT.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-23LX6FBE.js → chunk-5YCDZ4AU.js} +1 -1
- package/dist/{chunk-N77NE6O7.js → chunk-A6QH53CS.js} +8 -2
- package/dist/{chunk-TM76WRG2.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-CBRAKSMA.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-55OUOPNF.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-2UXFGPKI.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-7DBAV3KH.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-XEQZ6CLI.js → create-QZBCYHHQ.js} +8 -9
- package/dist/{create-A7B3MLJX.js → create-SLJ2BMH7.js} +5 -6
- package/dist/{create-GGACODDN.js → create-WQ5TM5IZ.js} +1 -1
- package/dist/{edit-2AAEQJEM.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 -3
- package/dist/index.js +138 -102
- 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-LVQQTWOJ.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/{products-6XWNKRLZ.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-ACIFBWUH.js → promotions-MFAFFHF3.js} +4 -4
- package/dist/{register-4AQP5DC3.js → register-3A6G6QNI.js} +5 -6
- package/dist/{reset-password-VSAY3YQX.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-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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PriceListPricesEditForm
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZBSFGCWY.js";
|
|
4
4
|
import {
|
|
5
5
|
usePriceListCurrencyData
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YPTJETJQ.js";
|
|
7
7
|
import "./chunk-XRNDVICA.js";
|
|
8
8
|
import "./chunk-6IJMSVC6.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-DNEPOMOX.js";
|
|
10
10
|
import "./chunk-IQPN4PZJ.js";
|
|
11
11
|
import "./chunk-SMQT3ZNO.js";
|
|
12
12
|
import "./chunk-TKGWSUEI.js";
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import "./chunk-3QSRE5LS.js";
|
|
18
18
|
import "./chunk-WIYFXWRI.js";
|
|
19
19
|
import "./chunk-INNFZYX2.js";
|
|
20
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-R5QZO3QY.js";
|
|
21
21
|
import "./chunk-F4OJN2F2.js";
|
|
22
22
|
import "./chunk-LRARA622.js";
|
|
23
23
|
import "./chunk-M6N4ISXL.js";
|
|
@@ -27,10 +27,9 @@ import {
|
|
|
27
27
|
usePriceList
|
|
28
28
|
} from "./chunk-BXRNZS5K.js";
|
|
29
29
|
import "./chunk-BOZJOOGW.js";
|
|
30
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-IQWK723D.js";
|
|
31
31
|
import "./chunk-4S6XGIC6.js";
|
|
32
32
|
import "./chunk-S23FD6FA.js";
|
|
33
|
-
import "./chunk-IQWK723D.js";
|
|
34
33
|
import "./chunk-DDJQRV6E.js";
|
|
35
34
|
import "./chunk-LWJF63JW.js";
|
|
36
35
|
import "./chunk-VXWN37PT.js";
|
|
@@ -38,7 +37,7 @@ import "./chunk-5QI3NDJG.js";
|
|
|
38
37
|
import "./chunk-VZUA5SRD.js";
|
|
39
38
|
import "./chunk-VXMOPVRH.js";
|
|
40
39
|
import "./chunk-NBPMNUKZ.js";
|
|
41
|
-
import "./chunk-
|
|
40
|
+
import "./chunk-SIEEMXNZ.js";
|
|
42
41
|
import "./chunk-Y2MQ5EMD.js";
|
|
43
42
|
import "./chunk-3B34B2M2.js";
|
|
44
43
|
import "./chunk-LAVHRER2.js";
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OFFER_PRODUCT_DETAIL_FIELDS
|
|
3
|
+
} from "./chunk-XQUF3WIS.js";
|
|
4
|
+
import {
|
|
5
|
+
DataGrid,
|
|
6
|
+
createDataGridHelper,
|
|
7
|
+
createDataGridPriceColumns
|
|
8
|
+
} from "./chunk-DNEPOMOX.js";
|
|
9
|
+
import "./chunk-IQPN4PZJ.js";
|
|
10
|
+
import "./chunk-TKGWSUEI.js";
|
|
11
|
+
import {
|
|
12
|
+
KeyboundForm
|
|
13
|
+
} from "./chunk-U2ZFCAPX.js";
|
|
14
|
+
import {
|
|
15
|
+
RouteFocusModal,
|
|
16
|
+
useRouteModal
|
|
17
|
+
} from "./chunk-GDWBOQI5.js";
|
|
18
|
+
import "./chunk-3QSRE5LS.js";
|
|
19
|
+
import {
|
|
20
|
+
Thumbnail
|
|
21
|
+
} from "./chunk-WIYFXWRI.js";
|
|
22
|
+
import "./chunk-INNFZYX2.js";
|
|
23
|
+
import {
|
|
24
|
+
usePricePreferences
|
|
25
|
+
} from "./chunk-4S6XGIC6.js";
|
|
26
|
+
import {
|
|
27
|
+
useCurrentSeller
|
|
28
|
+
} from "./chunk-S23FD6FA.js";
|
|
29
|
+
import {
|
|
30
|
+
offerQueryKeys
|
|
31
|
+
} from "./chunk-SIEEMXNZ.js";
|
|
32
|
+
import "./chunk-LAVHRER2.js";
|
|
33
|
+
import "./chunk-Y7QKP6QU.js";
|
|
34
|
+
import {
|
|
35
|
+
productsQueryKeys,
|
|
36
|
+
useProduct
|
|
37
|
+
} from "./chunk-JAUZ73XE.js";
|
|
38
|
+
import "./chunk-A5DJIOHN.js";
|
|
39
|
+
import {
|
|
40
|
+
queryClient
|
|
41
|
+
} from "./chunk-RHKRREUU.js";
|
|
42
|
+
import "./chunk-ZA2KFUFR.js";
|
|
43
|
+
import {
|
|
44
|
+
sdk
|
|
45
|
+
} from "./chunk-RIN4CBRB.js";
|
|
46
|
+
import "./chunk-NBMM2TZK.js";
|
|
47
|
+
|
|
48
|
+
// src/pages/offers/[id]/edit-price/index.tsx
|
|
49
|
+
import { Button, toast } from "@medusajs/ui";
|
|
50
|
+
import { useMemo } from "react";
|
|
51
|
+
import { useForm } from "react-hook-form";
|
|
52
|
+
import { useTranslation } from "react-i18next";
|
|
53
|
+
import { useParams } from "react-router-dom";
|
|
54
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
55
|
+
var numericOrZero = (v) => v === "" || v === null || v === void 0 ? 0 : Number(v) || 0;
|
|
56
|
+
var buildRows = (product, currencies) => (product.variants ?? []).flatMap(
|
|
57
|
+
(variant) => (variant.offers ?? []).map((offer) => {
|
|
58
|
+
const prices = {};
|
|
59
|
+
for (const code of currencies) {
|
|
60
|
+
const match = (offer.prices ?? []).find(
|
|
61
|
+
(p) => p.currency_code === code
|
|
62
|
+
);
|
|
63
|
+
prices[code] = match?.amount ?? "";
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
offer_id: offer.id,
|
|
67
|
+
variant_title: variant.title ?? "",
|
|
68
|
+
product_thumbnail: product.thumbnail ?? null,
|
|
69
|
+
prices
|
|
70
|
+
};
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
var columnHelper = createDataGridHelper();
|
|
74
|
+
var useColumns = ({
|
|
75
|
+
currencies,
|
|
76
|
+
pricePreferences
|
|
77
|
+
}) => {
|
|
78
|
+
const { t } = useTranslation();
|
|
79
|
+
return useMemo(
|
|
80
|
+
() => [
|
|
81
|
+
columnHelper.column({
|
|
82
|
+
id: "title",
|
|
83
|
+
header: t("fields.title"),
|
|
84
|
+
cell: (context) => {
|
|
85
|
+
const entity = context.row.original;
|
|
86
|
+
return /* @__PURE__ */ jsx(DataGrid.ReadonlyCell, { context, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full items-center gap-x-2 overflow-hidden", children: [
|
|
87
|
+
/* @__PURE__ */ jsx(Thumbnail, { src: entity.product_thumbnail ?? null }),
|
|
88
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", title: entity.variant_title, children: entity.variant_title })
|
|
89
|
+
] }) });
|
|
90
|
+
},
|
|
91
|
+
disableHiding: true
|
|
92
|
+
}),
|
|
93
|
+
...createDataGridPriceColumns({
|
|
94
|
+
currencies,
|
|
95
|
+
pricePreferences: pricePreferences ?? [],
|
|
96
|
+
getFieldName: (context, value) => {
|
|
97
|
+
if (context.column.id?.startsWith("currency_prices")) {
|
|
98
|
+
return `rows.${context.row.index}.prices.${value}`;
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
},
|
|
102
|
+
t
|
|
103
|
+
})
|
|
104
|
+
],
|
|
105
|
+
[t, currencies, pricePreferences]
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
var EditPriceGrid = ({
|
|
109
|
+
product,
|
|
110
|
+
productId
|
|
111
|
+
}) => {
|
|
112
|
+
const { t } = useTranslation();
|
|
113
|
+
const { handleSuccess, setCloseOnEscape } = useRouteModal();
|
|
114
|
+
const { currency_code } = useCurrentSeller();
|
|
115
|
+
const { price_preferences: pricePreferences } = usePricePreferences({});
|
|
116
|
+
const currencies = useMemo(
|
|
117
|
+
() => currency_code ? [currency_code] : [],
|
|
118
|
+
[currency_code]
|
|
119
|
+
);
|
|
120
|
+
const rows = useMemo(
|
|
121
|
+
() => buildRows(product, currencies),
|
|
122
|
+
[product, currencies]
|
|
123
|
+
);
|
|
124
|
+
const form = useForm({ defaultValues: { rows } });
|
|
125
|
+
const columns = useColumns({ currencies, pricePreferences });
|
|
126
|
+
const handleSubmit = form.handleSubmit(async (values) => {
|
|
127
|
+
try {
|
|
128
|
+
await Promise.all(
|
|
129
|
+
values.rows.map((row) => {
|
|
130
|
+
const prices = currencies.map((code) => ({
|
|
131
|
+
amount: numericOrZero(row.prices?.[code]),
|
|
132
|
+
currency_code: code
|
|
133
|
+
}));
|
|
134
|
+
return sdk.vendor.offers.$id.mutate({ $id: row.offer_id, prices });
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
await queryClient.invalidateQueries({ queryKey: offerQueryKeys.lists() });
|
|
138
|
+
await queryClient.invalidateQueries({
|
|
139
|
+
queryKey: productsQueryKeys.detail(productId)
|
|
140
|
+
});
|
|
141
|
+
toast.success(t("offers.pricing.successToast"));
|
|
142
|
+
handleSuccess();
|
|
143
|
+
} catch (error) {
|
|
144
|
+
toast.error(error.message);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
148
|
+
KeyboundForm,
|
|
149
|
+
{
|
|
150
|
+
onSubmit: handleSubmit,
|
|
151
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
152
|
+
"data-testid": "offer-edit-price-form",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden p-0", children: /* @__PURE__ */ jsx(
|
|
155
|
+
DataGrid,
|
|
156
|
+
{
|
|
157
|
+
columns,
|
|
158
|
+
data: rows,
|
|
159
|
+
state: form,
|
|
160
|
+
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
161
|
+
}
|
|
162
|
+
) }),
|
|
163
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
164
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
Button,
|
|
167
|
+
{
|
|
168
|
+
size: "small",
|
|
169
|
+
type: "submit",
|
|
170
|
+
isLoading: form.formState.isSubmitting,
|
|
171
|
+
children: t("actions.save")
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
] }) })
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
) });
|
|
178
|
+
};
|
|
179
|
+
var OfferEditPricePage = () => {
|
|
180
|
+
const { id } = useParams();
|
|
181
|
+
const { t } = useTranslation();
|
|
182
|
+
const { product, isPending, isError, error } = useProduct(id, {
|
|
183
|
+
fields: OFFER_PRODUCT_DETAIL_FIELDS
|
|
184
|
+
});
|
|
185
|
+
if (isError) throw error;
|
|
186
|
+
return /* @__PURE__ */ jsxs(RouteFocusModal, { children: [
|
|
187
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("offers.pricing.header") }) }),
|
|
188
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("offers.pricing.description") }) }),
|
|
189
|
+
!isPending && product && /* @__PURE__ */ jsx(EditPriceGrid, { product, productId: id })
|
|
190
|
+
] });
|
|
191
|
+
};
|
|
192
|
+
var Component = OfferEditPricePage;
|
|
193
|
+
export {
|
|
194
|
+
Component,
|
|
195
|
+
OfferEditPricePage
|
|
196
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OFFER_PRODUCT_DETAIL_FIELDS
|
|
3
|
+
} from "./chunk-XQUF3WIS.js";
|
|
4
|
+
import {
|
|
5
|
+
DataGrid,
|
|
6
|
+
createDataGridHelper,
|
|
7
|
+
createDataGridLocationStockColumns
|
|
8
|
+
} from "./chunk-DNEPOMOX.js";
|
|
9
|
+
import "./chunk-IQPN4PZJ.js";
|
|
10
|
+
import "./chunk-TKGWSUEI.js";
|
|
11
|
+
import {
|
|
12
|
+
KeyboundForm
|
|
13
|
+
} from "./chunk-U2ZFCAPX.js";
|
|
14
|
+
import {
|
|
15
|
+
RouteFocusModal,
|
|
16
|
+
useRouteModal
|
|
17
|
+
} from "./chunk-GDWBOQI5.js";
|
|
18
|
+
import "./chunk-3QSRE5LS.js";
|
|
19
|
+
import {
|
|
20
|
+
Thumbnail
|
|
21
|
+
} from "./chunk-WIYFXWRI.js";
|
|
22
|
+
import "./chunk-INNFZYX2.js";
|
|
23
|
+
import {
|
|
24
|
+
useStockLocations
|
|
25
|
+
} from "./chunk-NBPMNUKZ.js";
|
|
26
|
+
import {
|
|
27
|
+
offerQueryKeys
|
|
28
|
+
} from "./chunk-SIEEMXNZ.js";
|
|
29
|
+
import "./chunk-LAVHRER2.js";
|
|
30
|
+
import "./chunk-Y7QKP6QU.js";
|
|
31
|
+
import {
|
|
32
|
+
productsQueryKeys,
|
|
33
|
+
useBatchInventoryItemsLocationLevels,
|
|
34
|
+
useProduct
|
|
35
|
+
} from "./chunk-JAUZ73XE.js";
|
|
36
|
+
import "./chunk-A5DJIOHN.js";
|
|
37
|
+
import {
|
|
38
|
+
queryClient
|
|
39
|
+
} from "./chunk-RHKRREUU.js";
|
|
40
|
+
import "./chunk-ZA2KFUFR.js";
|
|
41
|
+
import "./chunk-RIN4CBRB.js";
|
|
42
|
+
import "./chunk-NBMM2TZK.js";
|
|
43
|
+
|
|
44
|
+
// src/pages/offers/[id]/edit-stock/index.tsx
|
|
45
|
+
import { Button, toast } from "@medusajs/ui";
|
|
46
|
+
import { useMemo, useRef } from "react";
|
|
47
|
+
import { useForm } from "react-hook-form";
|
|
48
|
+
import { useTranslation } from "react-i18next";
|
|
49
|
+
import { useParams } from "react-router-dom";
|
|
50
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
51
|
+
var castNumber = (v) => v === "" || v === null || v === void 0 ? 0 : Number(v) || 0;
|
|
52
|
+
var buildRows = (product, locations) => (product.variants ?? []).flatMap(
|
|
53
|
+
(variant) => (variant.offers ?? []).map((offer) => {
|
|
54
|
+
const link = offer.inventory_item_link?.[0];
|
|
55
|
+
const levels = link?.inventory_item?.location_levels ?? [];
|
|
56
|
+
const inventory = {};
|
|
57
|
+
for (const loc of locations) {
|
|
58
|
+
const level = levels.find((l) => l.location_id === loc.id);
|
|
59
|
+
inventory[loc.id] = level ? {
|
|
60
|
+
checked: true,
|
|
61
|
+
quantity: level.stocked_quantity ?? 0,
|
|
62
|
+
id: level.id ?? void 0
|
|
63
|
+
} : { checked: false, quantity: "" };
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
offer_id: offer.id,
|
|
67
|
+
inventory_item_id: link?.inventory_item_id ?? null,
|
|
68
|
+
variant_title: variant.title ?? "",
|
|
69
|
+
product_thumbnail: product.thumbnail ?? null,
|
|
70
|
+
sku: offer.sku ?? variant.sku ?? null,
|
|
71
|
+
inventory
|
|
72
|
+
};
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
var columnHelper = createDataGridHelper();
|
|
76
|
+
var useColumns = ({
|
|
77
|
+
stockLocations
|
|
78
|
+
}) => {
|
|
79
|
+
const { t } = useTranslation();
|
|
80
|
+
return useMemo(
|
|
81
|
+
() => [
|
|
82
|
+
columnHelper.column({
|
|
83
|
+
id: "title",
|
|
84
|
+
header: t("fields.title"),
|
|
85
|
+
cell: (context) => {
|
|
86
|
+
const entity = context.row.original;
|
|
87
|
+
return /* @__PURE__ */ jsx(DataGrid.ReadonlyCell, { context, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full items-center gap-x-2 overflow-hidden", children: [
|
|
88
|
+
/* @__PURE__ */ jsx(Thumbnail, { src: entity.product_thumbnail ?? null }),
|
|
89
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", title: entity.variant_title, children: entity.variant_title })
|
|
90
|
+
] }) });
|
|
91
|
+
},
|
|
92
|
+
disableHiding: true
|
|
93
|
+
}),
|
|
94
|
+
columnHelper.column({
|
|
95
|
+
id: "sku",
|
|
96
|
+
name: t("fields.sku"),
|
|
97
|
+
header: t("fields.sku"),
|
|
98
|
+
cell: (context) => /* @__PURE__ */ jsx(DataGrid.ReadonlyCell, { context, children: /* @__PURE__ */ jsx("span", { className: "truncate", children: context.row.original.sku ?? "-" }) })
|
|
99
|
+
}),
|
|
100
|
+
...createDataGridLocationStockColumns({
|
|
101
|
+
stockLocations,
|
|
102
|
+
getFieldName: (context, index) => {
|
|
103
|
+
const location = stockLocations[index];
|
|
104
|
+
if (!location) return null;
|
|
105
|
+
return `rows.${context.row.index}.inventory.${location.id}`;
|
|
106
|
+
},
|
|
107
|
+
t
|
|
108
|
+
})
|
|
109
|
+
],
|
|
110
|
+
[t, stockLocations]
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
var EditStockGrid = ({
|
|
114
|
+
product,
|
|
115
|
+
productId,
|
|
116
|
+
locations
|
|
117
|
+
}) => {
|
|
118
|
+
const { t } = useTranslation();
|
|
119
|
+
const { handleSuccess, setCloseOnEscape } = useRouteModal();
|
|
120
|
+
const { mutateAsync, isPending } = useBatchInventoryItemsLocationLevels();
|
|
121
|
+
const rows = useMemo(
|
|
122
|
+
() => buildRows(product, locations),
|
|
123
|
+
[product, locations]
|
|
124
|
+
);
|
|
125
|
+
const initial = useRef(rows);
|
|
126
|
+
const form = useForm({ defaultValues: { rows } });
|
|
127
|
+
const columns = useColumns({ stockLocations: locations });
|
|
128
|
+
const handleSubmit = form.handleSubmit(async (values) => {
|
|
129
|
+
const payload = {
|
|
130
|
+
create: [],
|
|
131
|
+
update: [],
|
|
132
|
+
delete: [],
|
|
133
|
+
force: true
|
|
134
|
+
};
|
|
135
|
+
values.rows.forEach((row, index) => {
|
|
136
|
+
const itemId = row.inventory_item_id;
|
|
137
|
+
if (!itemId) return;
|
|
138
|
+
const initialRow = initial.current[index];
|
|
139
|
+
for (const [locationId, level] of Object.entries(row.inventory)) {
|
|
140
|
+
const prior = initialRow?.inventory?.[locationId];
|
|
141
|
+
if (level.id) {
|
|
142
|
+
if (prior?.checked && !level.checked) {
|
|
143
|
+
payload.delete.push(level.id);
|
|
144
|
+
} else {
|
|
145
|
+
const next = castNumber(level.quantity);
|
|
146
|
+
if (next !== castNumber(prior?.quantity)) {
|
|
147
|
+
payload.update.push({
|
|
148
|
+
inventory_item_id: itemId,
|
|
149
|
+
location_id: locationId,
|
|
150
|
+
stocked_quantity: next
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
} else if (level.checked && level.quantity !== "") {
|
|
155
|
+
payload.create.push({
|
|
156
|
+
inventory_item_id: itemId,
|
|
157
|
+
location_id: locationId,
|
|
158
|
+
stocked_quantity: castNumber(level.quantity)
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
await mutateAsync(payload, {
|
|
164
|
+
onSuccess: async () => {
|
|
165
|
+
await queryClient.invalidateQueries({
|
|
166
|
+
queryKey: offerQueryKeys.lists()
|
|
167
|
+
});
|
|
168
|
+
await queryClient.invalidateQueries({
|
|
169
|
+
queryKey: productsQueryKeys.detail(productId)
|
|
170
|
+
});
|
|
171
|
+
toast.success(t("offers.inventory.successToast"));
|
|
172
|
+
handleSuccess();
|
|
173
|
+
},
|
|
174
|
+
onError: (error) => toast.error(error.message)
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
178
|
+
KeyboundForm,
|
|
179
|
+
{
|
|
180
|
+
onSubmit: handleSubmit,
|
|
181
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
182
|
+
"data-testid": "offer-edit-stock-form",
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden p-0", children: /* @__PURE__ */ jsx(
|
|
185
|
+
DataGrid,
|
|
186
|
+
{
|
|
187
|
+
columns,
|
|
188
|
+
data: rows,
|
|
189
|
+
state: form,
|
|
190
|
+
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
191
|
+
}
|
|
192
|
+
) }),
|
|
193
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
194
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
|
|
195
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: t("actions.save") })
|
|
196
|
+
] }) })
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
) });
|
|
200
|
+
};
|
|
201
|
+
var OfferEditStockPage = () => {
|
|
202
|
+
const { id } = useParams();
|
|
203
|
+
const { t } = useTranslation();
|
|
204
|
+
const { product, isPending, isError, error } = useProduct(id, {
|
|
205
|
+
fields: OFFER_PRODUCT_DETAIL_FIELDS
|
|
206
|
+
});
|
|
207
|
+
const { stock_locations, isPending: isLocationsPending } = useStockLocations({
|
|
208
|
+
limit: 100
|
|
209
|
+
});
|
|
210
|
+
if (isError) throw error;
|
|
211
|
+
const ready = !isPending && !!product && !isLocationsPending && !!stock_locations;
|
|
212
|
+
return /* @__PURE__ */ jsxs(RouteFocusModal, { children: [
|
|
213
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("offers.inventory.header") }) }),
|
|
214
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("offers.inventory.description") }) }),
|
|
215
|
+
ready && /* @__PURE__ */ jsx(
|
|
216
|
+
EditStockGrid,
|
|
217
|
+
{
|
|
218
|
+
product,
|
|
219
|
+
productId: id,
|
|
220
|
+
locations: stock_locations
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
] });
|
|
224
|
+
};
|
|
225
|
+
var Component = OfferEditStockPage;
|
|
226
|
+
export {
|
|
227
|
+
Component,
|
|
228
|
+
OfferEditStockPage
|
|
229
|
+
};
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
Thumbnail
|
|
21
21
|
} from "./chunk-WIYFXWRI.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-R5QZO3QY.js";
|
|
23
23
|
import "./chunk-F4OJN2F2.js";
|
|
24
24
|
import "./chunk-LRARA622.js";
|
|
25
25
|
import "./chunk-M6N4ISXL.js";
|
|
@@ -27,10 +27,9 @@ import "./chunk-S7EKBD2C.js";
|
|
|
27
27
|
import "./chunk-VV6IKGCN.js";
|
|
28
28
|
import "./chunk-BXRNZS5K.js";
|
|
29
29
|
import "./chunk-BOZJOOGW.js";
|
|
30
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-IQWK723D.js";
|
|
31
31
|
import "./chunk-4S6XGIC6.js";
|
|
32
32
|
import "./chunk-S23FD6FA.js";
|
|
33
|
-
import "./chunk-IQWK723D.js";
|
|
34
33
|
import "./chunk-DDJQRV6E.js";
|
|
35
34
|
import "./chunk-LWJF63JW.js";
|
|
36
35
|
import "./chunk-VXWN37PT.js";
|
|
@@ -42,7 +41,7 @@ import {
|
|
|
42
41
|
import {
|
|
43
42
|
useStockLocations
|
|
44
43
|
} from "./chunk-NBPMNUKZ.js";
|
|
45
|
-
import "./chunk-
|
|
44
|
+
import "./chunk-SIEEMXNZ.js";
|
|
46
45
|
import {
|
|
47
46
|
useCreateOrderFulfillment,
|
|
48
47
|
useOrder
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
formatProvider
|
|
17
17
|
} from "./chunk-VW56KWO2.js";
|
|
18
18
|
import "./chunk-FQERBIVS.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-DEJIBIQZ.js";
|
|
20
20
|
import "./chunk-PHOCVOZ5.js";
|
|
21
21
|
import {
|
|
22
22
|
_DataTable,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
import "./chunk-LRD242C7.js";
|
|
41
41
|
import "./chunk-UCYSCKZV.js";
|
|
42
42
|
import "./chunk-INNFZYX2.js";
|
|
43
|
-
import "./chunk-
|
|
43
|
+
import "./chunk-R5QZO3QY.js";
|
|
44
44
|
import "./chunk-F4OJN2F2.js";
|
|
45
45
|
import "./chunk-LRARA622.js";
|
|
46
46
|
import "./chunk-M6N4ISXL.js";
|
|
@@ -48,10 +48,9 @@ import "./chunk-S7EKBD2C.js";
|
|
|
48
48
|
import "./chunk-VV6IKGCN.js";
|
|
49
49
|
import "./chunk-BXRNZS5K.js";
|
|
50
50
|
import "./chunk-BOZJOOGW.js";
|
|
51
|
-
import "./chunk-
|
|
51
|
+
import "./chunk-IQWK723D.js";
|
|
52
52
|
import "./chunk-4S6XGIC6.js";
|
|
53
53
|
import "./chunk-S23FD6FA.js";
|
|
54
|
-
import "./chunk-IQWK723D.js";
|
|
55
54
|
import "./chunk-DDJQRV6E.js";
|
|
56
55
|
import "./chunk-LWJF63JW.js";
|
|
57
56
|
import "./chunk-VXWN37PT.js";
|
|
@@ -63,7 +62,7 @@ import {
|
|
|
63
62
|
useStockLocation,
|
|
64
63
|
useUpdateStockLocationFulfillmentProviders
|
|
65
64
|
} from "./chunk-NBPMNUKZ.js";
|
|
66
|
-
import "./chunk-
|
|
65
|
+
import "./chunk-SIEEMXNZ.js";
|
|
67
66
|
import "./chunk-Y2MQ5EMD.js";
|
|
68
67
|
import "./chunk-3B34B2M2.js";
|
|
69
68
|
import "./chunk-LAVHRER2.js";
|
package/dist/index.css
CHANGED
|
@@ -1656,6 +1656,9 @@ video {
|
|
|
1656
1656
|
.h-4 {
|
|
1657
1657
|
height: 1rem;
|
|
1658
1658
|
}
|
|
1659
|
+
.h-40 {
|
|
1660
|
+
height: 10rem;
|
|
1661
|
+
}
|
|
1659
1662
|
.h-5 {
|
|
1660
1663
|
height: 1.25rem;
|
|
1661
1664
|
}
|
|
@@ -2099,9 +2102,6 @@ video {
|
|
|
2099
2102
|
.max-w-\[304px\] {
|
|
2100
2103
|
max-width: 304px;
|
|
2101
2104
|
}
|
|
2102
|
-
.max-w-\[320px\] {
|
|
2103
|
-
max-width: 320px;
|
|
2104
|
-
}
|
|
2105
2105
|
.max-w-\[400px\] {
|
|
2106
2106
|
max-width: 400px;
|
|
2107
2107
|
}
|
|
@@ -2631,6 +2631,9 @@ video {
|
|
|
2631
2631
|
.border-l {
|
|
2632
2632
|
border-left-width: 1px;
|
|
2633
2633
|
}
|
|
2634
|
+
.border-l-2 {
|
|
2635
|
+
border-left-width: 2px;
|
|
2636
|
+
}
|
|
2634
2637
|
.border-l-4 {
|
|
2635
2638
|
border-left-width: 4px;
|
|
2636
2639
|
}
|