@mercurjs/vendor 2.2.1 → 2.3.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/dist/{[id]-47SUX5X3.js → [id]-3IFUEMOA.js} +12 -9
  2. package/dist/{[id]-PIB2DEVI.js → [id]-3NM7G2QP.js} +11 -8
  3. package/dist/[id]-3TCOLUQH.js +197 -0
  4. package/dist/{[id]-SKU5SFBG.js → [id]-4IWSF6TW.js} +137 -204
  5. package/dist/{[id]-BPQNQFVE.js → [id]-AMZFAAJ3.js} +75 -124
  6. package/dist/[id]-C3TB6V2O.js +286 -0
  7. package/dist/{[id]-NGRV5I2A.js → [id]-HEDNHQ5Z.js} +8 -6
  8. package/dist/[id]-KFACDZAI.js +949 -0
  9. package/dist/{[id]-BHU5BSQT.js → [id]-KFRGBNLH.js} +19 -16
  10. package/dist/{[id]-OE5TUWNF.js → [id]-OVWD6DNG.js} +8 -6
  11. package/dist/{[id]-RJRAZN3T.js → [id]-PJ2K4O3C.js} +7 -5
  12. package/dist/{[id]-ZD5HBP2R.js → [id]-ROMWNPJA.js} +13 -10
  13. package/dist/[id]-UPNI3OCU.js +697 -0
  14. package/dist/{[id]-YB3DBBXT.js → [id]-YFLQXZGC.js} +12 -9
  15. package/dist/{[province_id]-CUWKNPBW.js → [province_id]-IM22PLJP.js} +8 -6
  16. package/dist/{add-YEUSE5QA.js → add-AUSWWCA3.js} +9 -7
  17. package/dist/{add-MYV5IOGP.js → add-MBCWT6XT.js} +157 -227
  18. package/dist/{add-customer-groups-Q3F357F2.js → add-customer-groups-3FD754Z2.js} +7 -5
  19. package/dist/{add-products-WVNYODC6.js → add-products-IS22SHHN.js} +12 -9
  20. package/dist/{add-promotions-F62YE3BE.js → add-promotions-VDD5PKMN.js} +27 -9
  21. package/dist/{add-to-campaign-WBSCTSKW.js → add-to-campaign-B3PGGNFA.js} +3 -2
  22. package/dist/{address-ZMZ4ST5T.js → address-7HSQSXUS.js} +6 -4
  23. package/dist/{adjust-inventory-QUGKDXOC.js → adjust-inventory-2OKDFVLK.js} +2 -3
  24. package/dist/{allocate-items-7NSBGXSF.js → allocate-items-QAYROQMK.js} +4 -2
  25. package/dist/{areas-EJCZBY2E.js → areas-WQ44GWQO.js} +2 -2
  26. package/dist/{breadcrumb-M657ZCG6.js → breadcrumb-4I7MU2QY.js} +1 -1
  27. package/dist/{breadcrumb-KNBZ3JNR.js → breadcrumb-7ZFC43R4.js} +1 -1
  28. package/dist/{breadcrumb-C7M5PG2Q.js → breadcrumb-IDLCUHX3.js} +6 -4
  29. package/dist/{breadcrumb-MXYWEBK6.js → breadcrumb-OXRGEOVL.js} +6 -4
  30. package/dist/{breadcrumb-JWFTKHLE.js → breadcrumb-RQ52GELM.js} +2 -1
  31. package/dist/{breadcrumb-QPV566YX.js → breadcrumb-UDSK4EUS.js} +7 -5
  32. package/dist/breadcrumb-XCPUUZUO.js +26 -0
  33. package/dist/{campaigns-BPLAE6QQ.js → campaigns-LIPKZKI7.js} +5 -4
  34. package/dist/{categories-H2XAJCGC.js → categories-D2U6VLH5.js} +2 -2
  35. package/dist/{chunk-4RVWITM2.js → chunk-3JWHERV7.js} +76 -23
  36. package/dist/{chunk-BCXREBMV.js → chunk-4ATO577Q.js} +1 -1
  37. package/dist/{chunk-VHFKJLDH.js → chunk-4JVORTN4.js} +1 -1
  38. package/dist/{chunk-HHD2VUED.js → chunk-4UKAKFKL.js} +1 -1
  39. package/dist/{chunk-3L7WHWKB.js → chunk-5DRYAIOY.js} +3 -3
  40. package/dist/{chunk-7TIZP4YG.js → chunk-5RWK4U4V.js} +26 -0
  41. package/dist/{chunk-UEKRQS5Q.js → chunk-6ECHPZS3.js} +2 -2
  42. package/dist/{chunk-IWAL74YU.js → chunk-6GQLSWOO.js} +1 -1
  43. package/dist/{chunk-HCUIYIIY.js → chunk-6OZQTHCR.js} +1 -1
  44. package/dist/chunk-6XMUN2BZ.js +0 -0
  45. package/dist/{chunk-RLRWDHME.js → chunk-6YQR2AWM.js} +3 -20
  46. package/dist/{chunk-26OOAKQ6.js → chunk-7H6NMQ6U.js} +8 -1
  47. package/dist/{chunk-SVYBMLVN.js → chunk-7J2QRH4V.js} +1 -1
  48. package/dist/chunk-7LIENHWP.js +26 -0
  49. package/dist/{chunk-EPSRO7C5.js → chunk-7LIT4GXO.js} +2 -2
  50. package/dist/chunk-7POOMBIN.js +108 -0
  51. package/dist/{chunk-SDFZUBS3.js → chunk-CDZALZ5E.js} +1 -1
  52. package/dist/{chunk-72HQFLZI.js → chunk-CSEB2RNO.js} +1 -1
  53. package/dist/{chunk-X6ZQMFCT.js → chunk-DAOSTHVB.js} +44 -25
  54. package/dist/chunk-FKKI62AC.js +282 -0
  55. package/dist/{chunk-VBKW4GWP.js → chunk-FPBXQIFJ.js} +1 -1
  56. package/dist/{chunk-SI55QRZ4.js → chunk-G5NNOOHR.js} +59 -6
  57. package/dist/chunk-G6J5ZKM3.js +31 -0
  58. package/dist/{chunk-U5V6HNVW.js → chunk-GL3XVUAY.js} +1 -1
  59. package/dist/{chunk-RJE4MAYB.js → chunk-GYLRZXWS.js} +1 -1
  60. package/dist/{chunk-3XW55FZY.js → chunk-IYQHEISY.js} +6 -6
  61. package/dist/chunk-IZI2PKL7.js +27 -0
  62. package/dist/chunk-JN6MHI6V.js +334 -0
  63. package/dist/{chunk-YUQA6TUA.js → chunk-JOCO7JOB.js} +3 -3
  64. package/dist/{chunk-OGUTFP6B.js → chunk-JYUHDM23.js} +13 -51
  65. package/dist/{chunk-QB7BI4B7.js → chunk-K2DXXPNA.js} +153 -86
  66. package/dist/{chunk-XG76XXM2.js → chunk-KKMA6VPG.js} +1 -1
  67. package/dist/chunk-KVAD5JGS.js +11 -0
  68. package/dist/{chunk-YRZ53SAN.js → chunk-L26J5MO2.js} +2 -2
  69. package/dist/{chunk-FEVCBT24.js → chunk-LOSVZJXS.js} +2 -2
  70. package/dist/{chunk-63XYNXUL.js → chunk-LYP7XK5O.js} +1 -1
  71. package/dist/chunk-MVVFD2JT.js +51 -0
  72. package/dist/{chunk-RVFPWOR2.js → chunk-MY5H7C3A.js} +2 -2
  73. package/dist/{chunk-GTNCNKTC.js → chunk-NP5TISFX.js} +1 -1
  74. package/dist/{chunk-3GSR455R.js → chunk-NQMHP2LC.js} +1 -1
  75. package/dist/{chunk-2S2WK2OG.js → chunk-NV2RZAHW.js} +1 -10
  76. package/dist/{chunk-4IIATKG7.js → chunk-O7OWHKWA.js} +6 -6
  77. package/dist/{chunk-GIKVFOQL.js → chunk-OJCMHDZI.js} +2 -2
  78. package/dist/chunk-QLOJNFUE.js +53 -0
  79. package/dist/{chunk-OKJHUQBY.js → chunk-QSS7ATY3.js} +15 -27
  80. package/dist/{chunk-XVBONKRV.js → chunk-RCMKDW6O.js} +1 -1
  81. package/dist/{chunk-WJF24CGA.js → chunk-RDLVH6CM.js} +33 -5
  82. package/dist/chunk-SF5N2HX4.js +268 -0
  83. package/dist/{chunk-MQR26KYT.js → chunk-SYHA2RVL.js} +1 -1
  84. package/dist/{chunk-ZXDMPIXN.js → chunk-U3OEGBHH.js} +2 -2
  85. package/dist/{chunk-EJBOBB4B.js → chunk-V3N2Y4OL.js} +46 -46
  86. package/dist/{chunk-UUBGLS7U.js → chunk-V43BEBDT.js} +187 -35
  87. package/dist/{chunk-VBRTC2VU.js → chunk-VAFGNDAP.js} +4 -3
  88. package/dist/{chunk-4UQMRTSC.js → chunk-VH3TGSWE.js} +46 -2
  89. package/dist/{chunk-ZEKV7LGF.js → chunk-VV2K3EBF.js} +1 -1
  90. package/dist/{chunk-S2VYK3YC.js → chunk-WI2ZAFZF.js} +1 -1
  91. package/dist/chunk-WP3B4NEU.js +32 -0
  92. package/dist/{chunk-DY3XQPHC.js → chunk-WW2XYOHJ.js} +5 -3
  93. package/dist/{chunk-IVYIMGQC.js → chunk-X44P463Q.js} +45 -10
  94. package/dist/{chunk-R5KN6IFB.js → chunk-XHWBTV72.js} +2 -2
  95. package/dist/{chunk-OVHIUZ3K.js → chunk-XQ47NZJC.js} +1 -1
  96. package/dist/{chunk-LN7XHEPJ.js → chunk-YT4RAUWM.js} +2 -2
  97. package/dist/{chunk-6VKJM537.js → chunk-ZK4DIDXG.js} +1 -1
  98. package/dist/{collections-52DJLHWW.js → collections-3MEKABDT.js} +13 -12
  99. package/dist/{configuration-UMRBE5RQ.js → configuration-QK2FW2CV.js} +2 -2
  100. package/dist/{configuration-QEDVL2WF.js → configuration-RYH3VUBV.js} +15 -48
  101. package/dist/{create-ALUKAFJS.js → create-5M66YUYY.js} +2 -2
  102. package/dist/{create-ABRPUMHQ.js → create-75C65ZIS.js} +6 -5
  103. package/dist/{create-6IRD2CVC.js → create-A3CQXIRQ.js} +11 -9
  104. package/dist/{create-LYNWCP2N.js → create-GYNDVCY2.js} +5 -4
  105. package/dist/create-ICCAEOSA.js +343 -0
  106. package/dist/{create-5RQ32XPT.js → create-KBDT33O2.js} +287 -287
  107. package/dist/{create-GEYXN6SW.js → create-L5HMOVY5.js} +6 -4
  108. package/dist/{create-MFGMTZ5A.js → create-M2W5N6QV.js} +7 -5
  109. package/dist/{create-NTZH45DW.js → create-NSJGRO4L.js} +13 -11
  110. package/dist/{create-H77ZUZG5.js → create-O4K6TO4G.js} +9 -7
  111. package/dist/{create-S7VYYTUD.js → create-PW5L3MJI.js} +9 -7
  112. package/dist/{create-7SJ5DSQK.js → create-UQ26QTPQ.js} +19 -16
  113. package/dist/{create-2I3GAX4C.js → create-WIGBFSRH.js} +15 -6
  114. package/dist/{create-7FT7N2NH.js → create-WPN3OUJU.js} +3 -2
  115. package/dist/{create-G76MVCJU.js → create-ZVGYET6W.js} +5 -4
  116. package/dist/customer-availability-VAOKKCTK.js +164 -0
  117. package/dist/{customer-group-add-customers-T7OYWJCB.js → customer-group-add-customers-BSMUKWVO.js} +1 -1
  118. package/dist/{customer-group-detail-E7HRZ3LE.js → customer-group-detail-QCPC2YWK.js} +2 -2
  119. package/dist/{customer-groups-26HJ55MF.js → customer-groups-6WGUNFHG.js} +2 -2
  120. package/dist/{customers-EXFRZX5F.js → customers-7OGYQSGA.js} +2 -2
  121. package/dist/edit-2BKYNGYL.js +262 -0
  122. package/dist/{edit-M4AP65HO.js → edit-32ZGQUWZ.js} +7 -5
  123. package/dist/{edit-MPOTIGUY.js → edit-3OXHBHY4.js} +22 -38
  124. package/dist/{edit-2RN3OT27.js → edit-7T2JMZG3.js} +7 -56
  125. package/dist/{edit-6VJWRZHQ.js → edit-AFWQY3BZ.js} +6 -4
  126. package/dist/{edit-NB5VN2E4.js → edit-EDXF3T7F.js} +4 -3
  127. package/dist/edit-GJCXPD5A.js +81 -0
  128. package/dist/{edit-WHGYNDEB.js → edit-KOLDPZ4H.js} +19 -16
  129. package/dist/{edit-TIBQEQVV.js → edit-LZFD3RSY.js} +9 -7
  130. package/dist/{edit-QBUYHSE7.js → edit-QVK3BEPA.js} +7 -5
  131. package/dist/{edit-EGBVEWXS.js → edit-ZLZR7F33.js} +8 -6
  132. package/dist/{edit-H5FJ45ZT.js → edit-ZM7NJVRE.js} +1 -1
  133. package/dist/{edit-budget-PYPHUJPW.js → edit-budget-MOZETGZV.js} +1 -1
  134. package/dist/{edit-inventory-item-BCVECCLT.js → edit-inventory-item-HFGHS732.js} +17 -14
  135. package/dist/{edit-inventory-item-attributes-GWEMP67O.js → edit-inventory-item-attributes-5ORZJF4I.js} +18 -1
  136. package/dist/edit-reservation-LSYQUDYQ.js +294 -0
  137. package/dist/extension-targets.d.ts +6 -3
  138. package/dist/{fulfillment-HDU7GATG.js → fulfillment-TVRF5TID.js} +6 -4
  139. package/dist/{fulfillment-providers-6RZNNT7U.js → fulfillment-providers-TEV23LGB.js} +11 -10
  140. package/dist/index.css +14 -14
  141. package/dist/index.js +252 -146
  142. package/dist/{inventory-XJ2E6DPC.js → inventory-CMIRAJJY.js} +2 -2
  143. package/dist/{invite-755AJC3M.js → invite-K3R2GRYF.js} +6 -4
  144. package/dist/{invite-FD2TXZTW.js → invite-ZMIYLOWJ.js} +9 -7
  145. package/dist/{login-UGKYRKMD.js → login-LG3XH6B2.js} +8 -6
  146. package/dist/{manage-locations-PRQI5TI4.js → manage-locations-5B4HP6NQ.js} +24 -5
  147. package/dist/{media-TGFAHFBV.js → media-DY2XDZYT.js} +7 -5
  148. package/dist/{media-2KEHXPRU.js → media-OGO6M3CP.js} +10 -8
  149. package/dist/{metadata-BQQFHVKF.js → metadata-AW5Y72BI.js} +6 -4
  150. package/dist/metadata-HS6CLO4Z.js +69 -0
  151. package/dist/{metadata-5TVRCKWX.js → metadata-HXXVD3VP.js} +6 -4
  152. package/dist/{metadata-7JWZ4VFM.js → metadata-TXNUZBPX.js} +6 -4
  153. package/dist/{metadata-G73TILNE.js → metadata-UVOHT2VF.js} +6 -4
  154. package/dist/{metadata-4ZZ4ZIWJ.js → metadata-ZBSZL74N.js} +6 -4
  155. package/dist/{offer-create-page-PPXRYET4.js → offer-create-page-53P65U2V.js} +11 -8
  156. package/dist/{offer-detail-page-BFGKAS4L.js → offer-detail-page-BGFLDXO7.js} +1 -1
  157. package/dist/{offer-variant-detail-page-BLHRF4MK.js → offer-variant-detail-page-DCTRZUTM.js} +1 -1
  158. package/dist/{offers-7I67VSHI.js → offers-5776XUH5.js} +13 -9
  159. package/dist/{onboarding-7MURQYXX.js → onboarding-ROLIHG3L.js} +6 -4
  160. package/dist/{orders-D7NZNDUS.js → orders-VA3HNJAY.js} +12 -11
  161. package/dist/{organization-T6ZTYMMW.js → organization-UH4IUA62.js} +8 -6
  162. package/dist/pages/index.d.ts +9 -1
  163. package/dist/pages/index.js +53 -44
  164. package/dist/{payment-details-UQ65D5AY.js → payment-details-CD4GZEUL.js} +6 -4
  165. package/dist/{payouts-A336D2HG.js → payouts-26ZOYDRP.js} +2 -2
  166. package/dist/{price-lists-3WRT4TR2.js → price-lists-U5ASDHMI.js} +5 -8
  167. package/dist/{pricing-CPPIL627.js → pricing-SWUZSQL3.js} +8 -6
  168. package/dist/{product-tags-7DTA73YT.js → product-tags-4V65LOJJ.js} +19 -16
  169. package/dist/{product-types-OB26NF2D.js → product-types-CMI33S32.js} +3 -4
  170. package/dist/{product-variant-detail-4DDE6RJ5.js → product-variant-detail-NW3LQZE7.js} +6 -4
  171. package/dist/{product-variant-edit-SAZUI4E3.js → product-variant-edit-MNYFEZND.js} +9 -7
  172. package/dist/{products-RYXTZFGT.js → products-L2H6HOL2.js} +18 -15
  173. package/dist/{products-GJ2KTGBZ.js → products-YIF6FPBO.js} +12 -9
  174. package/dist/{professional-details-UN5B4YDJ.js → professional-details-QO5BWMRD.js} +6 -4
  175. package/dist/{profile-6MIDTK52.js → profile-2KKBVKAL.js} +6 -4
  176. package/dist/{promotions-SQ47TCZL.js → promotions-C5YWXVP5.js} +5 -5
  177. package/dist/{receive-ZG6FFN7H.js → receive-RRZK3FP2.js} +4 -3
  178. package/dist/{refund-KJX74N6T.js → refund-FLCZAMPR.js} +3 -2
  179. package/dist/{register-RDSK4E4D.js → register-SZ2T6QQA.js} +8 -6
  180. package/dist/reservations-C326XEVA.js +350 -0
  181. package/dist/{reset-password-C462PDN2.js → reset-password-H66R27K4.js} +1 -1
  182. package/dist/respond-IPRDCH57.js +132 -0
  183. package/dist/{return-reasons-MY63HNF6.js → return-reasons-2BUKIQBO.js} +9 -7
  184. package/dist/reviews-LBLCFBRQ.js +14 -0
  185. package/dist/{settings-TJ6HPHMK.js → settings-THSRJ5WS.js} +26 -23
  186. package/dist/{shipment-6CTA2GHU.js → shipment-X2WWJ3AE.js} +6 -4
  187. package/dist/{shipping-profile-CFISOMTE.js → shipping-profile-7P3RPEIJ.js} +1 -1
  188. package/dist/{shipping-profiles-5UAZNYKJ.js → shipping-profiles-JPBRRMPD.js} +8 -6
  189. package/dist/{stock-465GEUY3.js → stock-UMESDWV5.js} +21 -7
  190. package/dist/{store-2PQB2XWE.js → store-5YMOSKVT.js} +7 -5
  191. package/dist/{store-closure-DYW54VHB.js → store-closure-EPGDOV7U.js} +6 -4
  192. package/dist/{store-select-6A5YR7WH.js → store-select-JEEV4V57.js} +7 -5
  193. package/dist/{team-GXEBC57M.js → team-R6ARMF73.js} +9 -7
  194. package/package.json +12 -9
  195. package/dist/[id]-HEVGSOAV.js +0 -598
  196. package/dist/[id]-MU7A6SZO.js +0 -526
  197. package/dist/chunk-2ZFELO2L.js +0 -13
  198. package/dist/chunk-6IJMSVC6.js +0 -16
  199. package/dist/chunk-BNOKKKUU.js +0 -88
  200. package/dist/chunk-BX3JE7IE.js +0 -247
  201. package/dist/edit-4B364HGZ.js +0 -222
  202. package/dist/edit-SQU5UOGE.js +0 -105
  203. package/dist/{[location_id]-OXNC5E4F.js → [location_id]-IGPM7LDR.js} +1 -1
  204. package/dist/{chunk-CYE7HVAV.js → chunk-SCJBJQCL.js} +3 -3
@@ -1,247 +0,0 @@
1
- import {
2
- PriceListUpdateProductsSchema,
3
- usePriceListGridColumns
4
- } from "./chunk-X6ZQMFCT.js";
5
- import {
6
- isProductRow
7
- } from "./chunk-BNOKKKUU.js";
8
- import {
9
- DataGrid
10
- } from "./chunk-5FBQOAXU.js";
11
- import {
12
- castNumber
13
- } from "./chunk-SMQT3ZNO.js";
14
- import {
15
- KeyboundForm
16
- } from "./chunk-SITRHMZZ.js";
17
- import {
18
- RouteFocusModal,
19
- useRouteModal
20
- } from "./chunk-GDWBOQI5.js";
21
- import {
22
- useBatchPriceListPrices
23
- } from "./chunk-2S2WK2OG.js";
24
-
25
- // src/pages/price-lists/[id]/products/[variant_id]/edit/price-list-prices-edit-form/price-list-prices-edit-form.tsx
26
- import { zodResolver } from "@hookform/resolvers/zod";
27
- import { Button, toast } from "@medusajs/ui";
28
- import { useRef } from "react";
29
- import { useForm } from "react-hook-form";
30
- import { useTranslation } from "react-i18next";
31
- import { z } from "zod";
32
- import { jsx, jsxs } from "react/jsx-runtime";
33
- var PricingProductPricesSchema = z.object({
34
- products: PriceListUpdateProductsSchema
35
- });
36
- var PriceListPricesEditForm = ({
37
- priceList,
38
- products,
39
- regions,
40
- currencies,
41
- pricePreferences
42
- }) => {
43
- const { t } = useTranslation();
44
- const { handleSuccess, setCloseOnEscape } = useRouteModal();
45
- const initialValue = useRef(initRecord(priceList, products));
46
- const form = useForm({
47
- defaultValues: {
48
- products: initialValue.current
49
- },
50
- resolver: zodResolver(PricingProductPricesSchema)
51
- });
52
- const { mutateAsync, isPending } = useBatchPriceListPrices(priceList.id);
53
- const handleSubmit = form.handleSubmit(async (values) => {
54
- const { products: products2 } = values;
55
- const { pricesToDelete, pricesToCreate, pricesToUpdate } = sortPrices(
56
- products2,
57
- initialValue.current,
58
- regions
59
- );
60
- mutateAsync(
61
- {
62
- delete: pricesToDelete,
63
- update: pricesToUpdate,
64
- create: pricesToCreate
65
- },
66
- {
67
- onSuccess: () => {
68
- toast.success(t("priceLists.products.edit.successToast"));
69
- handleSuccess();
70
- },
71
- onError: (error) => {
72
- toast.error(error.message);
73
- }
74
- }
75
- );
76
- });
77
- const columns = usePriceListGridColumns({
78
- currencies,
79
- regions,
80
- pricePreferences
81
- });
82
- return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { onSubmit: handleSubmit, className: "flex size-full flex-col", children: [
83
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
84
- /* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-col overflow-hidden", children: /* @__PURE__ */ jsx(
85
- DataGrid,
86
- {
87
- columns,
88
- data: products,
89
- getSubRows: (row) => {
90
- if (isProductRow(row) && row.variants) {
91
- return row.variants;
92
- }
93
- },
94
- state: form,
95
- onEditingChange: (editing) => setCloseOnEscape(!editing)
96
- }
97
- ) }),
98
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
99
- /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
100
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: t("actions.save") })
101
- ] }) })
102
- ] }) });
103
- };
104
- function initRecord(priceList, products) {
105
- const record = {};
106
- const variantPrices = priceList.prices?.reduce((variants, price) => {
107
- const variantObject = variants[price.variant_id] || {};
108
- const isRegionPrice = !!price.rules?.region_id;
109
- if (isRegionPrice) {
110
- const regionId = price.rules.region_id;
111
- variantObject.region_prices = {
112
- ...variantObject.region_prices,
113
- [regionId]: {
114
- amount: price.amount.toString(),
115
- id: price.id
116
- }
117
- };
118
- } else {
119
- variantObject.currency_prices = {
120
- ...variantObject.currency_prices,
121
- [price.currency_code]: {
122
- amount: price.amount.toString(),
123
- id: price.id
124
- }
125
- };
126
- }
127
- variants[price.variant_id] = variantObject;
128
- return variants;
129
- }, {});
130
- for (const product of products) {
131
- record[product.id] = {
132
- variants: product.variants?.reduce((variants, variant) => {
133
- const prices = variantPrices[variant.id] || {};
134
- variants[variant.id] = prices;
135
- return variants;
136
- }, {}) || {}
137
- };
138
- }
139
- return record;
140
- }
141
- function convertToPriceArray(data, regions) {
142
- const prices = [];
143
- const regionCurrencyMap = regions.reduce(
144
- (map, region) => {
145
- map[region.id] = region.currency_code;
146
- return map;
147
- },
148
- {}
149
- );
150
- for (const [_productId, product] of Object.entries(data || {})) {
151
- const { variants } = product || {};
152
- for (const [variantId, variant] of Object.entries(variants || {})) {
153
- const { currency_prices: currencyPrices, region_prices: regionPrices } = variant || {};
154
- for (const [currencyCode, currencyPrice] of Object.entries(
155
- currencyPrices || {}
156
- )) {
157
- if (currencyPrice?.amount !== "" && typeof currencyPrice?.amount !== "undefined") {
158
- prices.push({
159
- variantId,
160
- currencyCode,
161
- amount: castNumber(currencyPrice.amount),
162
- id: currencyPrice.id
163
- });
164
- }
165
- }
166
- for (const [regionId, regionPrice] of Object.entries(
167
- regionPrices || {}
168
- )) {
169
- if (regionPrice?.amount !== "" && typeof regionPrice?.amount !== "undefined") {
170
- prices.push({
171
- variantId,
172
- regionId,
173
- currencyCode: regionCurrencyMap[regionId],
174
- amount: castNumber(regionPrice.amount),
175
- id: regionPrice.id
176
- });
177
- }
178
- }
179
- }
180
- }
181
- return prices;
182
- }
183
- function createMapKey(obj) {
184
- return `${obj.variantId}-${obj.currencyCode}-${obj.regionId || "none"}-${obj.id || "none"}`;
185
- }
186
- function comparePrices(initialPrices, newPrices) {
187
- const pricesToUpdate = [];
188
- const pricesToCreate = [];
189
- const pricesToDelete = [];
190
- const initialPriceMap = initialPrices.reduce(
191
- (map, price) => {
192
- map[createMapKey(price)] = price;
193
- return map;
194
- },
195
- {}
196
- );
197
- const newPriceMap = newPrices.reduce(
198
- (map, price) => {
199
- map[createMapKey(price)] = price;
200
- return map;
201
- },
202
- {}
203
- );
204
- const keys = /* @__PURE__ */ new Set([
205
- ...Object.keys(initialPriceMap),
206
- ...Object.keys(newPriceMap)
207
- ]);
208
- for (const key of keys) {
209
- const initialPrice = initialPriceMap[key];
210
- const newPrice = newPriceMap[key];
211
- if (initialPrice && newPrice) {
212
- if (isNaN(newPrice.amount) && newPrice.id) {
213
- pricesToDelete.push(newPrice.id);
214
- }
215
- if (initialPrice.amount !== newPrice.amount && newPrice.id) {
216
- pricesToUpdate.push({
217
- id: newPrice.id,
218
- variant_id: newPrice.variantId,
219
- currency_code: newPrice.currencyCode,
220
- rules: newPrice.regionId ? { region_id: newPrice.regionId } : void 0,
221
- amount: newPrice.amount
222
- });
223
- }
224
- }
225
- if (!initialPrice && newPrice) {
226
- pricesToCreate.push({
227
- variant_id: newPrice.variantId,
228
- currency_code: newPrice.currencyCode,
229
- rules: newPrice.regionId ? { region_id: newPrice.regionId } : void 0,
230
- amount: newPrice.amount
231
- });
232
- }
233
- if (initialPrice && !newPrice && initialPrice.id) {
234
- pricesToDelete.push(initialPrice.id);
235
- }
236
- }
237
- return { pricesToDelete, pricesToCreate, pricesToUpdate };
238
- }
239
- function sortPrices(data, initialValue, regions) {
240
- const initialPrices = convertToPriceArray(initialValue, regions);
241
- const newPrices = convertToPriceArray(data, regions);
242
- return comparePrices(initialPrices, newPrices);
243
- }
244
-
245
- export {
246
- PriceListPricesEditForm
247
- };
@@ -1,222 +0,0 @@
1
- import {
2
- PriceListStatus,
3
- PriceListType
4
- } from "./chunk-6IJMSVC6.js";
5
- import "./chunk-TKGWSUEI.js";
6
- import {
7
- KeyboundForm
8
- } from "./chunk-SITRHMZZ.js";
9
- import {
10
- RouteDrawer,
11
- useRouteModal
12
- } from "./chunk-GDWBOQI5.js";
13
- import {
14
- Form
15
- } from "./chunk-3QSRE5LS.js";
16
- import {
17
- usePriceList,
18
- useUpdatePriceList
19
- } from "./chunk-2S2WK2OG.js";
20
- import "./chunk-II3CLUXA.js";
21
- import "./chunk-EMUCGKHP.js";
22
- import "./chunk-A5DJIOHN.js";
23
- import "./chunk-RHKRREUU.js";
24
- import "./chunk-ZA2KFUFR.js";
25
- import "./chunk-DTGEFKK4.js";
26
- import "./chunk-NBMM2TZK.js";
27
-
28
- // src/pages/price-lists/[id]/edit/index.tsx
29
- import { Heading } from "@medusajs/ui";
30
- import { useTranslation as useTranslation2 } from "react-i18next";
31
- import { useParams } from "react-router-dom";
32
- import { useLinkQuery } from "@mercurjs/dashboard-shared";
33
-
34
- // src/pages/price-lists/[id]/edit/price-list-edit-form/edit-price-list-form.tsx
35
- import {
36
- Button,
37
- Input,
38
- RadioGroup,
39
- Select,
40
- Textarea,
41
- toast
42
- } from "@medusajs/ui";
43
- import { useTranslation } from "react-i18next";
44
- import { z } from "zod";
45
- import {
46
- FormExtensionZone,
47
- useExtendableForm
48
- } from "@mercurjs/dashboard-shared";
49
- import { jsx, jsxs } from "react/jsx-runtime";
50
- var PriceListEditSchema = z.object({
51
- status: z.nativeEnum(PriceListStatus),
52
- type: z.nativeEnum(PriceListType),
53
- title: z.string().min(1),
54
- description: z.string().min(1)
55
- });
56
- var PriceListEditForm = ({ priceList }) => {
57
- const { t } = useTranslation();
58
- const { handleSuccess } = useRouteModal();
59
- const form = useExtendableForm({
60
- schema: PriceListEditSchema,
61
- model: "price_list",
62
- zone: "edit",
63
- data: priceList,
64
- defaultValues: {
65
- type: priceList.type,
66
- title: priceList.title,
67
- description: priceList.description,
68
- status: priceList.status
69
- }
70
- });
71
- const { mutateAsync, isPending } = useUpdatePriceList(priceList.id);
72
- const handleSubmit = form.handleSubmit(async (values) => {
73
- const { status, type, title, description } = values;
74
- await mutateAsync({ status, type, title, description }, {
75
- onSuccess: ({ price_list }) => {
76
- toast.success(
77
- t("priceLists.edit.successToast", {
78
- title: price_list.title
79
- })
80
- );
81
- handleSuccess();
82
- },
83
- onError: (error) => {
84
- toast.error(error.message);
85
- }
86
- });
87
- });
88
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
89
- KeyboundForm,
90
- {
91
- className: "flex flex-1 flex-col overflow-hidden",
92
- onSubmit: handleSubmit,
93
- children: [
94
- /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-6 overflow-auto", children: [
95
- /* @__PURE__ */ jsx(
96
- Form.Field,
97
- {
98
- control: form.control,
99
- name: "type",
100
- render: ({ field: { onChange, ...field } }) => {
101
- return /* @__PURE__ */ jsxs(Form.Item, { children: [
102
- /* @__PURE__ */ jsxs("div", { children: [
103
- /* @__PURE__ */ jsx(Form.Label, { children: t("priceLists.fields.type.label") }),
104
- /* @__PURE__ */ jsx(Form.Hint, { children: t("priceLists.fields.type.hint") })
105
- ] }),
106
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(RadioGroup, { ...field, onValueChange: onChange, children: [
107
- /* @__PURE__ */ jsx(
108
- RadioGroup.ChoiceBox,
109
- {
110
- value: "sale" /* SALE */,
111
- label: t("priceLists.fields.type.options.sale.label"),
112
- description: t(
113
- "priceLists.fields.type.options.sale.description"
114
- )
115
- }
116
- ),
117
- /* @__PURE__ */ jsx(
118
- RadioGroup.ChoiceBox,
119
- {
120
- value: "override" /* OVERRIDE */,
121
- label: t(
122
- "priceLists.fields.type.options.override.label"
123
- ),
124
- description: t(
125
- "priceLists.fields.type.options.override.description"
126
- )
127
- }
128
- )
129
- ] }) }),
130
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
131
- ] });
132
- }
133
- }
134
- ),
135
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
136
- /* @__PURE__ */ jsx(
137
- Form.Field,
138
- {
139
- control: form.control,
140
- name: "title",
141
- render: ({ field }) => {
142
- return /* @__PURE__ */ jsxs(Form.Item, { children: [
143
- /* @__PURE__ */ jsx(Form.Label, { children: t("fields.title") }),
144
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
145
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
146
- ] });
147
- }
148
- }
149
- ),
150
- /* @__PURE__ */ jsx(
151
- Form.Field,
152
- {
153
- control: form.control,
154
- name: "status",
155
- render: ({ field: { onChange, ref, ...field } }) => {
156
- return /* @__PURE__ */ jsxs(Form.Item, { children: [
157
- /* @__PURE__ */ jsx(Form.Label, { children: t("priceLists.fields.status.label") }),
158
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
159
- /* @__PURE__ */ jsx(Select.Trigger, { ref, children: /* @__PURE__ */ jsx(Select.Value, {}) }),
160
- /* @__PURE__ */ jsxs(Select.Content, { children: [
161
- /* @__PURE__ */ jsx(Select.Item, { value: "active" /* ACTIVE */, children: t("priceLists.fields.status.options.active") }),
162
- /* @__PURE__ */ jsx(Select.Item, { value: "draft" /* DRAFT */, children: t("priceLists.fields.status.options.draft") })
163
- ] })
164
- ] }) }),
165
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
166
- ] });
167
- }
168
- }
169
- ),
170
- /* @__PURE__ */ jsx(
171
- Form.Field,
172
- {
173
- control: form.control,
174
- name: "description",
175
- render: ({ field }) => {
176
- return /* @__PURE__ */ jsxs(Form.Item, { children: [
177
- /* @__PURE__ */ jsx(Form.Label, { children: t("fields.description") }),
178
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
179
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
180
- ] });
181
- }
182
- }
183
- )
184
- ] }),
185
- /* @__PURE__ */ jsx(
186
- FormExtensionZone,
187
- {
188
- model: "price_list",
189
- zone: "edit",
190
- control: form.control,
191
- data: priceList
192
- }
193
- )
194
- ] }),
195
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { className: "shrink-0", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
196
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
197
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: t("actions.save") })
198
- ] }) })
199
- ]
200
- }
201
- ) });
202
- };
203
-
204
- // src/pages/price-lists/[id]/edit/index.tsx
205
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
206
- var Component = () => {
207
- const { t } = useTranslation2();
208
- const { id } = useParams();
209
- const linkQuery = useLinkQuery("price_list");
210
- const { price_list, isLoading, isError, error } = usePriceList(id, linkQuery);
211
- const ready = !isLoading && price_list;
212
- if (isError) {
213
- throw error;
214
- }
215
- return /* @__PURE__ */ jsxs2(RouteDrawer, { children: [
216
- /* @__PURE__ */ jsx2(RouteDrawer.Header, { children: /* @__PURE__ */ jsx2(Heading, { children: t("priceLists.edit.header") }) }),
217
- ready && /* @__PURE__ */ jsx2(PriceListEditForm, { priceList: price_list })
218
- ] });
219
- };
220
- export {
221
- Component
222
- };
@@ -1,105 +0,0 @@
1
- import {
2
- PriceListPricesEditForm
3
- } from "./chunk-BX3JE7IE.js";
4
- import {
5
- usePriceListCurrencyData
6
- } from "./chunk-X6ZQMFCT.js";
7
- import "./chunk-BNOKKKUU.js";
8
- import "./chunk-6IJMSVC6.js";
9
- import "./chunk-5FBQOAXU.js";
10
- import "./chunk-IQPN4PZJ.js";
11
- import "./chunk-SMQT3ZNO.js";
12
- import "./chunk-TKGWSUEI.js";
13
- import "./chunk-SITRHMZZ.js";
14
- import {
15
- RouteFocusModal
16
- } from "./chunk-GDWBOQI5.js";
17
- import "./chunk-3QSRE5LS.js";
18
- import "./chunk-WIYFXWRI.js";
19
- import "./chunk-INNFZYX2.js";
20
- import "./chunk-LAVHRER2.js";
21
- import "./chunk-Y7QKP6QU.js";
22
- import "./chunk-RLRWDHME.js";
23
- import "./chunk-K5324KIX.js";
24
- import "./chunk-FV76G2D7.js";
25
- import "./chunk-GHDLST2P.js";
26
- import "./chunk-YVYYOBAE.js";
27
- import "./chunk-L2NJPDUD.js";
28
- import {
29
- usePriceList
30
- } from "./chunk-2S2WK2OG.js";
31
- import "./chunk-MR6REQKT.js";
32
- import "./chunk-EPSDO2MJ.js";
33
- import "./chunk-BHEU34FL.js";
34
- import "./chunk-W34KDYZA.js";
35
- import "./chunk-II3CLUXA.js";
36
- import "./chunk-OCYVN77Z.js";
37
- import "./chunk-J2XUEO2E.js";
38
- import "./chunk-DETQ6IBQ.js";
39
- import "./chunk-VWPNMEOE.js";
40
- import "./chunk-O72AIZUN.js";
41
- import "./chunk-U5V6HNVW.js";
42
- import "./chunk-PF7R7LMW.js";
43
- import "./chunk-OGUTFP6B.js";
44
- import "./chunk-4U2BLH45.js";
45
- import {
46
- useProducts
47
- } from "./chunk-EMUCGKHP.js";
48
- import "./chunk-A5DJIOHN.js";
49
- import "./chunk-RHKRREUU.js";
50
- import "./chunk-ZA2KFUFR.js";
51
- import "./chunk-DTGEFKK4.js";
52
- import "./chunk-NBMM2TZK.js";
53
-
54
- // src/pages/price-lists/[id]/products/edit/index.tsx
55
- import { useTranslation } from "react-i18next";
56
- import { useParams, useSearchParams } from "react-router-dom";
57
- import { jsx, jsxs } from "react/jsx-runtime";
58
- var Component = () => {
59
- const { t } = useTranslation();
60
- const { id } = useParams();
61
- const [searchParams] = useSearchParams();
62
- const ids = searchParams.get("ids[]");
63
- const { price_list, isLoading, isError, error } = usePriceList(id, {
64
- fields: "*prices,prices.price_set.variant.id,prices.price_rules.attribute,prices.price_rules.value"
65
- });
66
- const productIds = ids?.split(",");
67
- const {
68
- products,
69
- isLoading: isProductsLoading,
70
- isError: isProductsError,
71
- error: productError
72
- } = useProducts({
73
- id: productIds,
74
- limit: productIds?.length || 9999,
75
- // Temporary until we support lazy loading in the DataGrid
76
- price_list_id: [id],
77
- // TODO: Remove exclusion once we avoid including unnecessary relations by default in the query config
78
- fields: "title,thumbnail,*variants,-type,-collection,-options,-tags,-images,-sales_channels"
79
- });
80
- const { isReady, regions, currencies, pricePreferences } = usePriceListCurrencyData();
81
- const ready = !isLoading && !!price_list && !isProductsLoading && !!products && isReady;
82
- if (isError) {
83
- throw error;
84
- }
85
- if (isProductsError) {
86
- throw productError;
87
- }
88
- return /* @__PURE__ */ jsxs(RouteFocusModal, { children: [
89
- /* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("priceLists.products.edit.title", { title: price_list?.title }) }) }),
90
- /* @__PURE__ */ jsx(RouteFocusModal.Description, { className: "sr-only", children: t("priceLists.products.edit.description") }),
91
- ready && /* @__PURE__ */ jsx(
92
- PriceListPricesEditForm,
93
- {
94
- priceList: price_list,
95
- products,
96
- regions,
97
- currencies,
98
- pricePreferences
99
- }
100
- )
101
- ] });
102
- };
103
- export {
104
- Component
105
- };
@@ -12,10 +12,10 @@ import {
12
12
  import {
13
13
  LinkButton
14
14
  } from "./chunk-7AV5EJJ5.js";
15
+ import "./chunk-BCU3FKP2.js";
15
16
  import {
16
17
  formatProvider
17
18
  } from "./chunk-VW56KWO2.js";
18
- import "./chunk-BCU3FKP2.js";
19
19
  import {
20
20
  getFormattedAddress
21
21
  } from "./chunk-W6Y3PPU5.js";
@@ -1,10 +1,10 @@
1
- import {
2
- TaxRateRuleReferenceType
3
- } from "./chunk-Q4UVXS46.js";
4
1
  import {
5
2
  LocalizedTablePagination,
6
3
  useDeleteTaxRateAction
7
4
  } from "./chunk-PEXMLTJX.js";
5
+ import {
6
+ TaxRateRuleReferenceType
7
+ } from "./chunk-Q4UVXS46.js";
8
8
  import {
9
9
  formatPercentage
10
10
  } from "./chunk-QDPLZDMX.js";