@mercurjs/admin 2.2.0-canary.18 → 2.2.0-canary.19

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 (173) hide show
  1. package/dist/{add-campaign-promotions-4QP4LF7G.js → add-campaign-promotions-KK4JMLSK.js} +3 -3
  2. package/dist/{adjust-inventory-AHIKDW7M.js → adjust-inventory-F3OTF6O6.js} +5 -5
  3. package/dist/{api-key-management-detail-ZRLG6YRB.js → api-key-management-detail-JMWPGN6M.js} +6 -6
  4. package/dist/{attribute-create-NIYUQEHQ.js → attribute-create-TJRNP5SK.js} +7 -7
  5. package/dist/{attribute-detail-GA4FDSAG.js → attribute-detail-7I2SQCDK.js} +6 -6
  6. package/dist/{attribute-edit-KJL36HQ4.js → attribute-edit-UBG6SMUF.js} +2 -2
  7. package/dist/{attribute-edit-possible-value-LGOD3ZKQ.js → attribute-edit-possible-value-3BYEPC4X.js} +2 -2
  8. package/dist/{attribute-list-A3RFO32Z.js → attribute-list-EFU4DPB5.js} +5 -5
  9. package/dist/{campaign-detail-A7ZM4Q7M.js → campaign-detail-H32E6EDD.js} +9 -9
  10. package/dist/{categories-metadata-FCV4YK74.js → categories-metadata-V37DXTVZ.js} +5 -5
  11. package/dist/{category-detail-CIEHVR4M.js → category-detail-5MRHPG6T.js} +10 -10
  12. package/dist/{category-products-AB3YAGSW.js → category-products-3KYY662O.js} +9 -9
  13. package/dist/{chunk-WUGV75DM.js → chunk-3F6U44M6.js} +1 -1
  14. package/dist/{chunk-IBX52HBP.js → chunk-3N7QXAMO.js} +1 -1
  15. package/dist/{chunk-K2C42QAV.js → chunk-4DYSSDAA.js} +4 -4
  16. package/dist/{chunk-2PUBUYFG.js → chunk-5GXPXVVD.js} +2 -2
  17. package/dist/{chunk-CIKXWLWE.js → chunk-6AYGDFNE.js} +2 -2
  18. package/dist/{chunk-G5DQCCPL.js → chunk-6LG3VL3Q.js} +2 -2
  19. package/dist/{chunk-A2GVK4VZ.js → chunk-AXVZ56UD.js} +2 -2
  20. package/dist/{chunk-2LKMOTLX.js → chunk-B7HIZN4V.js} +2 -2
  21. package/dist/{chunk-EOLSQKPV.js → chunk-BJQ4UBK7.js} +529 -480
  22. package/dist/{chunk-OMBP3YSV.js → chunk-CFBEBAQS.js} +1 -1
  23. package/dist/{chunk-FJRNNDZS.js → chunk-EASE3NLF.js} +1 -1
  24. package/dist/chunk-EG45GIE3.js +368 -0
  25. package/dist/{chunk-TWCYZF6X.js → chunk-EM5TF7YZ.js} +1 -1
  26. package/dist/{chunk-MEXH366L.js → chunk-FCLS6CKW.js} +2 -2
  27. package/dist/{chunk-ENFXIYIH.js → chunk-FYKG35MR.js} +1 -1
  28. package/dist/{chunk-VZ7GNMGX.js → chunk-GA4ZFAOV.js} +1 -1
  29. package/dist/{chunk-RZ5SFALB.js → chunk-GFUCELIZ.js} +2 -2
  30. package/dist/{chunk-OFOKVLV3.js → chunk-GHGOOZEL.js} +2 -2
  31. package/dist/{chunk-CVZA23ES.js → chunk-GNWWL47L.js} +3 -3
  32. package/dist/{chunk-MR3MLNWV.js → chunk-HYQPZADS.js} +1 -1
  33. package/dist/{chunk-DELK6EWH.js → chunk-IHTQOPB6.js} +1 -1
  34. package/dist/chunk-JEJQKTZO.js +191 -0
  35. package/dist/{chunk-5BF5JDWT.js → chunk-JWE2IW4R.js} +5 -5
  36. package/dist/chunk-KZB7LCF2.js +82 -0
  37. package/dist/{chunk-N6YOACEW.js → chunk-L5Z4JGRD.js} +1 -1
  38. package/dist/{chunk-3VDLE5GA.js → chunk-LVCIAKJI.js} +1 -1
  39. package/dist/{chunk-PE6JFXWU.js → chunk-MFIT2RX5.js} +1 -1
  40. package/dist/{chunk-ZB4TESPP.js → chunk-O62SUNK2.js} +16 -7
  41. package/dist/{chunk-Q5WTOVZZ.js → chunk-O63MLTQV.js} +71 -0
  42. package/dist/{chunk-WPVDACTL.js → chunk-OA24YN34.js} +1 -1
  43. package/dist/{chunk-3DMUKRIX.js → chunk-OXONMLRP.js} +2 -2
  44. package/dist/{chunk-LJDGVBOQ.js → chunk-PJR6W35H.js} +1 -1
  45. package/dist/chunk-PN5C4AND.js +115 -0
  46. package/dist/chunk-QR3GYYX6.js +0 -0
  47. package/dist/{chunk-VT6QIVZW.js → chunk-RMAQKNBA.js} +10 -1
  48. package/dist/{chunk-IEPH6A2W.js → chunk-RV7DWZZB.js} +2 -2
  49. package/dist/chunk-RXRDZ47F.js +103 -0
  50. package/dist/{chunk-623TMW36.js → chunk-T53YX34K.js} +1 -1
  51. package/dist/{chunk-EYFWEKFJ.js → chunk-TLOJG7LK.js} +2 -2
  52. package/dist/{chunk-7Y6A7XK6.js → chunk-UCHVBAUB.js} +2 -2
  53. package/dist/{chunk-47W2JHOE.js → chunk-UT2O7IS7.js} +2 -2
  54. package/dist/{chunk-B4K7H6DH.js → chunk-UUTACMA5.js} +1 -1
  55. package/dist/{chunk-JSMUFZZN.js → chunk-WHIYSLYW.js} +1 -1
  56. package/dist/{chunk-SEQJOCTT.js → chunk-X4N7EMFO.js} +2 -2
  57. package/dist/{chunk-RUSMGNQ6.js → chunk-X7E65HM2.js} +1 -1
  58. package/dist/{chunk-RWRL4AXD.js → chunk-XKD67CD4.js} +2 -2
  59. package/dist/{chunk-UCYSCKZV.js → chunk-Y7FNFQCU.js} +1 -6
  60. package/dist/{chunk-HEGPAGJT.js → chunk-YI7I7JFX.js} +2 -2
  61. package/dist/{chunk-EB6ZFOTO.js → chunk-YLK2WZU3.js} +2 -2
  62. package/dist/{chunk-OCRKS4Z7.js → chunk-ZDJWTF64.js} +2 -2
  63. package/dist/{chunk-T4GL73RP.js → chunk-ZG6DNI7O.js} +1 -1
  64. package/dist/{chunk-OHOWEMHO.js → chunk-ZIFHQXP3.js} +31 -25
  65. package/dist/{collection-add-products-KTUW23TD.js → collection-add-products-4EZ6W4N6.js} +9 -9
  66. package/dist/{collection-detail-TR7TDQZG.js → collection-detail-X22ZIM5S.js} +10 -10
  67. package/dist/{collection-list-FOWSOTS7.js → collection-list-6CUEOLUU.js} +9 -9
  68. package/dist/{collection-metadata-DS32TGOK.js → collection-metadata-AWJYPZKR.js} +5 -5
  69. package/dist/commission-rule-commission-edit-TA3H3EEN.js +196 -0
  70. package/dist/commission-rule-create-O7Z25SC7.js +412 -0
  71. package/dist/commission-rule-detail-I7LVSNAM.js +45 -0
  72. package/dist/commission-rule-edit-YSHDTYZY.js +342 -0
  73. package/dist/{commission-rate-list-Y5XLEO67.js → commissions-list-OUGVPED6.js} +13 -4
  74. package/dist/{customer-detail-5XGZ2K3H.js → customer-detail-6MBW3FHO.js} +6 -6
  75. package/dist/{customer-group-detail-JX3BEYFG.js → customer-group-detail-G53RB6EA.js} +5 -5
  76. package/dist/{customer-group-list-F5TFLDVH.js → customer-group-list-XDNCZ4K6.js} +5 -5
  77. package/dist/{customer-group-metadata-CHOTUAS2.js → customer-group-metadata-FWLKUHIZ.js} +5 -5
  78. package/dist/{customer-metadata-LG6HA56I.js → customer-metadata-KU4YWD3R.js} +5 -5
  79. package/dist/{customers-add-customer-group-3YKZEZKJ.js → customers-add-customer-group-5Y5XPN7C.js} +5 -5
  80. package/dist/{edit-inventory-item-5EYVQ6CM.js → edit-inventory-item-MBLHBGBH.js} +5 -5
  81. package/dist/{edit-inventory-item-attributes-7QM4YHAQ.js → edit-inventory-item-attributes-GTTGNBO4.js} +5 -5
  82. package/dist/{edit-rules-2S5H7MC2.js → edit-rules-UFGKSAJV.js} +5 -5
  83. package/dist/global-commission-edit-LCD6JJUX.js +194 -0
  84. package/dist/index.js +158 -150
  85. package/dist/{inventory-create-RBMMOSC3.js → inventory-create-4O4L6NXK.js} +5 -5
  86. package/dist/{inventory-detail-LSAJ3ZB5.js → inventory-detail-ZWHSLLLI.js} +5 -5
  87. package/dist/{inventory-metadata-OZAKLWNY.js → inventory-metadata-GZYYWU3S.js} +5 -5
  88. package/dist/{inventory-stock-WUAIUFQS.js → inventory-stock-S5B6ZZQW.js} +5 -5
  89. package/dist/{location-detail-PBCP7BBV.js → location-detail-QS7HM2KG.js} +5 -5
  90. package/dist/{location-fulfillment-providers-D4EFIF3Z.js → location-fulfillment-providers-6RUGYQ3W.js} +7 -7
  91. package/dist/{location-list-DM4WU57J.js → location-list-7RTDLHGR.js} +5 -5
  92. package/dist/{location-service-zone-shipping-option-create-T4LT4E6M.js → location-service-zone-shipping-option-create-UKULBDGM.js} +5 -5
  93. package/dist/{login-LTASZXSR.js → login-SFGV4QGP.js} +5 -5
  94. package/dist/{marketplace-detail-GSPPUVR7.js → marketplace-detail-7VPTFUPB.js} +5 -5
  95. package/dist/{marketplace-metadata-PB7JEK2K.js → marketplace-metadata-E25VT5TH.js} +5 -5
  96. package/dist/{offers-D2QQQD2F.js → offers-WYAJB75N.js} +9 -9
  97. package/dist/{order-create-claim-HND7RODU.js → order-create-claim-3AQK3FH2.js} +3 -3
  98. package/dist/{order-create-edit-LIQGALQ2.js → order-create-edit-UFD26FE2.js} +2 -2
  99. package/dist/{order-create-exchange-QE2TJ36U.js → order-create-exchange-QCYD3DC4.js} +7 -7
  100. package/dist/{order-create-refund-37JJA6MM.js → order-create-refund-TR4XMHRY.js} +5 -5
  101. package/dist/{order-create-return-AVVT3OUO.js → order-create-return-Y7QS52UL.js} +2 -2
  102. package/dist/{order-detail-A2WC2OZU.js → order-detail-FZT74HMD.js} +10 -10
  103. package/dist/{order-edit-billing-address-IPWVSYR2.js → order-edit-billing-address-OJZICMBN.js} +6 -6
  104. package/dist/{order-edit-email-ZQZNTV4P.js → order-edit-email-TH26N5HK.js} +5 -5
  105. package/dist/{order-edit-shipping-address-YPYWT3YN.js → order-edit-shipping-address-GBOUGZPD.js} +5 -5
  106. package/dist/{order-list-QR3ZVI4U.js → order-list-C5YOR6B5.js} +2 -2
  107. package/dist/{order-metadata-E25YHGCC.js → order-metadata-RT3BVTYZ.js} +5 -5
  108. package/dist/{order-request-transfer-XDNXRB66.js → order-request-transfer-3HTFPYFD.js} +5 -5
  109. package/dist/pages/index.d.ts +5 -23
  110. package/dist/pages/index.js +79 -77
  111. package/dist/{price-list-create-GBUUE3NP.js → price-list-create-XQWV352E.js} +10 -10
  112. package/dist/{price-list-detail-77FAEXXO.js → price-list-detail-347UU3LU.js} +10 -10
  113. package/dist/{price-list-prices-add-2XS5TX5X.js → price-list-prices-add-R656I6QF.js} +10 -10
  114. package/dist/{price-list-prices-edit-C2C3I64A.js → price-list-prices-edit-BOKBTLEI.js} +5 -5
  115. package/dist/{product-add-existing-attributes-NFXKW6SW.js → product-add-existing-attributes-MNGWZFGD.js} +7 -7
  116. package/dist/{product-create-AG4AYDM3.js → product-create-LMYR36NA.js} +9 -9
  117. package/dist/{product-create-variant-7DVYYUDX.js → product-create-variant-XETT2WJC.js} +3 -3
  118. package/dist/{product-detail-CNVETME5.js → product-detail-WSL4PXKK.js} +7 -7
  119. package/dist/{product-edit-attribute-GXFMVPCQ.js → product-edit-attribute-XEYHQJ6D.js} +2 -2
  120. package/dist/{product-list-KM37QJ6F.js → product-list-7YPGRGHX.js} +10 -10
  121. package/dist/{product-media-H5DAWUYR.js → product-media-H6SYBNLI.js} +2 -2
  122. package/dist/{product-metadata-4ZLL42UF.js → product-metadata-MGLJJ7QG.js} +5 -5
  123. package/dist/{product-tag-create-KKRQQT3A.js → product-tag-create-JCYAG42N.js} +5 -5
  124. package/dist/{product-tag-detail-R6UFJDCW.js → product-tag-detail-AUNKJJLP.js} +12 -12
  125. package/dist/{product-tag-edit-TISDF4FQ.js → product-tag-edit-2FREKKVN.js} +5 -5
  126. package/dist/{product-tag-list-NFPQVVMO.js → product-tag-list-IKL46JZT.js} +12 -12
  127. package/dist/{product-tag-metadata-GJFYX5HU.js → product-tag-metadata-UV3TBPXS.js} +5 -5
  128. package/dist/{product-type-detail-XJPSQDL2.js → product-type-detail-DKHKFADI.js} +13 -13
  129. package/dist/{product-type-metadata-GKVLFBF6.js → product-type-metadata-22OACFMD.js} +8 -8
  130. package/dist/{product-variant-detail-VCMC4BZP.js → product-variant-detail-MNMJBYIP.js} +5 -5
  131. package/dist/{product-variant-edit-QLDFN6LI.js → product-variant-edit-THZLEOGL.js} +7 -7
  132. package/dist/{product-variant-metadata-VZZMPRRG.js → product-variant-metadata-7N7PL7WY.js} +5 -5
  133. package/dist/{promotion-create-POBB7B23.js → promotion-create-RB3AA5GE.js} +5 -5
  134. package/dist/{promotion-detail-NSOGXQAY.js → promotion-detail-PEDTLXZ4.js} +8 -8
  135. package/dist/{promotion-list-7C3SQCSO.js → promotion-list-MCYWN5TF.js} +4 -4
  136. package/dist/{refund-reason-create-HPLJOL6S.js → refund-reason-create-YWA5XP4J.js} +5 -5
  137. package/dist/{refund-reason-edit-JI4U4RWO.js → refund-reason-edit-MBG5WL43.js} +5 -5
  138. package/dist/{refund-reason-list-SWU4B2ED.js → refund-reason-list-GPDRI2QM.js} +10 -10
  139. package/dist/{region-metadata-LDWMTB7G.js → region-metadata-WDZ7DRGU.js} +5 -5
  140. package/dist/{reservation-detail-BLPISKPA.js → reservation-detail-WTYOR6IB.js} +5 -5
  141. package/dist/{reservation-metadata-AZ265HZI.js → reservation-metadata-PJVHEJRU.js} +5 -5
  142. package/dist/{reset-password-6CAYNSJ6.js → reset-password-2NVKH6QA.js} +1 -1
  143. package/dist/{return-reason-list-7HTIV7NK.js → return-reason-list-E6L7VJY7.js} +5 -5
  144. package/dist/{sales-channel-add-products-S47CQCJF.js → sales-channel-add-products-BKT3CFLY.js} +9 -9
  145. package/dist/{sales-channel-detail-6JPHP4FZ.js → sales-channel-detail-MUBMJGQV.js} +10 -10
  146. package/dist/{sales-channel-list-D673ONK2.js → sales-channel-list-O5SFOGMA.js} +5 -5
  147. package/dist/{sales-channel-metadata-OY47MCFI.js → sales-channel-metadata-67RGBA7X.js} +5 -5
  148. package/dist/{shipping-option-type-create-H2YRDETZ.js → shipping-option-type-create-OBF6GG5W.js} +5 -5
  149. package/dist/{shipping-option-type-detail-NVSXILP4.js → shipping-option-type-detail-TJC2GBUA.js} +7 -7
  150. package/dist/{shipping-option-type-edit-KBPDYAUJ.js → shipping-option-type-edit-INKLJRSH.js} +5 -5
  151. package/dist/{shipping-option-type-list-OUKJZJ6R.js → shipping-option-type-list-WKA64NYE.js} +7 -7
  152. package/dist/{shipping-profile-metadata-CQCDC45M.js → shipping-profile-metadata-RI6Y2N6V.js} +5 -5
  153. package/dist/{store-bulk-edit-DXWHZMGL.js → store-bulk-edit-WML2DUA4.js} +1 -1
  154. package/dist/{store-create-MVHUY3I3.js → store-create-AGF2LZWR.js} +5 -5
  155. package/dist/{store-details-V3NMV665.js → store-details-3HWOCRYI.js} +11 -11
  156. package/dist/{store-edit-6CC2GBFY.js → store-edit-5WWOOSHT.js} +3 -3
  157. package/dist/{store-list-WV6XHGLU.js → store-list-YEEKX2AV.js} +9 -9
  158. package/dist/{store-member-invite-7YIXFC56.js → store-member-invite-TULPI3N5.js} +1 -1
  159. package/dist/{tax-region-create-RGE5ZIBR.js → tax-region-create-X2LAHX27.js} +6 -6
  160. package/dist/{tax-region-detail-OKEK6WNJ.js → tax-region-detail-3X3TNFJA.js} +5 -5
  161. package/dist/{tax-region-edit-QQ3LB74P.js → tax-region-edit-7ECYGXEA.js} +5 -5
  162. package/dist/{tax-region-metadata-GPTD6KZB.js → tax-region-metadata-FQLEYY2R.js} +5 -5
  163. package/dist/{tax-region-province-detail-WHO3RLUX.js → tax-region-province-detail-DIV5AAFQ.js} +5 -5
  164. package/dist/{tax-region-tax-override-create-223MPYUG.js → tax-region-tax-override-create-BV4O3QCU.js} +14 -16
  165. package/dist/{tax-region-tax-override-edit-WFOXP6A7.js → tax-region-tax-override-edit-QUA77YTI.js} +16 -18
  166. package/dist/{user-metadata-A3JS6O4K.js → user-metadata-64LX64QI.js} +5 -5
  167. package/package.json +1 -1
  168. package/dist/chunk-AKTAFKIU.js +0 -228
  169. package/dist/chunk-HLJ24XVH.js +0 -390
  170. package/dist/chunk-SWL7ZCP3.js +0 -11
  171. package/dist/commission-rate-create-G42ZUJPH.js +0 -782
  172. package/dist/commission-rate-detail-VGYTGWLH.js +0 -85
  173. package/dist/commission-rate-edit-3CYWYOMS.js +0 -767
@@ -1,390 +0,0 @@
1
- import {
2
- SectionRow
3
- } from "./chunk-3XPXUIK3.js";
4
- import {
5
- SingleColumnPage
6
- } from "./chunk-H6MYB7GB.js";
7
- import {
8
- useProductTypes
9
- } from "./chunk-46M463BR.js";
10
- import {
11
- useCommissionRate,
12
- useDeleteCommissionRate,
13
- useUpdateCommissionRate
14
- } from "./chunk-OHOWEMHO.js";
15
- import {
16
- useShippingOptions
17
- } from "./chunk-5TRY5IMZ.js";
18
- import {
19
- ActionMenu
20
- } from "./chunk-BDGZ4EQO.js";
21
- import {
22
- SingleColumnPageSkeleton
23
- } from "./chunk-INNFZYX2.js";
24
- import {
25
- useProducts
26
- } from "./chunk-M2E3PKA4.js";
27
-
28
- // src/pages/commission-rates/commission-rate-detail/commission-rate-detail.tsx
29
- import { Children } from "react";
30
- import { useLoaderData, useParams } from "react-router-dom";
31
-
32
- // src/pages/commission-rates/commission-rate-detail/components/commission-rate-general-section/commission-rate-general-section.tsx
33
- import { PencilSquare, Trash, XCircle, CheckCircle } from "@medusajs/icons";
34
- import { Badge, Container, Heading, StatusBadge, toast, usePrompt } from "@medusajs/ui";
35
- import { useTranslation } from "react-i18next";
36
- import { useNavigate } from "react-router-dom";
37
- import { jsx, jsxs } from "react/jsx-runtime";
38
- var CommissionRateGeneralSection = ({
39
- commissionRate
40
- }) => {
41
- const { t } = useTranslation();
42
- const formatValue = () => {
43
- if (commissionRate.type === "percentage") {
44
- return `${commissionRate.value}%`;
45
- }
46
- return commissionRate.currency_code ? `${commissionRate.value} ${commissionRate.currency_code.toUpperCase()}` : `${commissionRate.value}`;
47
- };
48
- return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
49
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
50
- /* @__PURE__ */ jsx(Heading, { children: commissionRate.name }),
51
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
52
- /* @__PURE__ */ jsx(StatusBadge, { color: commissionRate.is_enabled ? "green" : "grey", children: commissionRate.is_enabled ? t("commissionRates.status.enabled") : t("commissionRates.status.disabled") }),
53
- /* @__PURE__ */ jsx(CommissionRateActions, { commissionRate })
54
- ] })
55
- ] }),
56
- /* @__PURE__ */ jsx(
57
- SectionRow,
58
- {
59
- title: t("commissionRates.fields.code"),
60
- value: /* @__PURE__ */ jsx(Badge, { size: "2xsmall", className: "uppercase", children: commissionRate.code })
61
- }
62
- ),
63
- /* @__PURE__ */ jsx(
64
- SectionRow,
65
- {
66
- title: t("commissionRates.fields.type.label"),
67
- value: /* @__PURE__ */ jsx(
68
- Badge,
69
- {
70
- size: "2xsmall",
71
- color: commissionRate.type === "percentage" ? "blue" : "grey",
72
- children: commissionRate.type === "percentage" ? t("commissionRates.fields.type.percentage") : t("commissionRates.fields.type.fixed")
73
- }
74
- )
75
- }
76
- ),
77
- /* @__PURE__ */ jsx(SectionRow, { title: t("fields.value"), value: formatValue() }),
78
- /* @__PURE__ */ jsx(
79
- SectionRow,
80
- {
81
- title: t("commissionRates.fields.target.label"),
82
- value: commissionRate.target === "item" ? t("commissionRates.fields.target.item") : t("commissionRates.fields.target.shipping")
83
- }
84
- ),
85
- /* @__PURE__ */ jsx(
86
- SectionRow,
87
- {
88
- title: t("commissionRates.fields.includeTax"),
89
- value: commissionRate.include_tax ? t("general.yes") : t("general.no")
90
- }
91
- ),
92
- /* @__PURE__ */ jsx(
93
- SectionRow,
94
- {
95
- title: t("commissionRates.fields.priority"),
96
- value: String(commissionRate.priority)
97
- }
98
- ),
99
- commissionRate.min_amount != null && /* @__PURE__ */ jsx(
100
- SectionRow,
101
- {
102
- title: t("commissionRates.fields.minAmount"),
103
- value: commissionRate.currency_code ? `${commissionRate.min_amount} ${commissionRate.currency_code.toUpperCase()}` : String(commissionRate.min_amount)
104
- }
105
- )
106
- ] });
107
- };
108
- var CommissionRateActions = ({
109
- commissionRate
110
- }) => {
111
- const navigate = useNavigate();
112
- const { t } = useTranslation();
113
- const { mutateAsync } = useDeleteCommissionRate(commissionRate.id);
114
- const { mutateAsync: updateCommissionRate } = useUpdateCommissionRate(commissionRate.id);
115
- const prompt = usePrompt();
116
- const handleToggleEnabled = async () => {
117
- const newEnabled = !commissionRate.is_enabled;
118
- await updateCommissionRate(
119
- { is_enabled: newEnabled },
120
- {
121
- onSuccess: () => {
122
- toast.success(
123
- newEnabled ? t("commissionRates.toggle.enabledToast") : t("commissionRates.toggle.disabledToast")
124
- );
125
- },
126
- onError: (e) => {
127
- toast.error(e.message);
128
- }
129
- }
130
- );
131
- };
132
- const handleDelete = async () => {
133
- const res = await prompt({
134
- title: t("general.areYouSure"),
135
- description: t("commissionRates.delete.description", {
136
- name: commissionRate.name
137
- }),
138
- confirmText: t("actions.delete"),
139
- cancelText: t("actions.cancel")
140
- });
141
- if (!res) {
142
- return;
143
- }
144
- await mutateAsync(void 0, {
145
- onSuccess: () => {
146
- toast.success(t("commissionRates.delete.successToast"));
147
- navigate("/settings/commission-rates", { replace: true });
148
- },
149
- onError: (e) => {
150
- toast.error(e.message);
151
- }
152
- });
153
- };
154
- return /* @__PURE__ */ jsx(
155
- ActionMenu,
156
- {
157
- groups: [
158
- {
159
- actions: [
160
- {
161
- icon: /* @__PURE__ */ jsx(PencilSquare, {}),
162
- label: t("actions.edit"),
163
- to: `/settings/commission-rates/${commissionRate.id}/edit`
164
- },
165
- {
166
- icon: commissionRate.is_enabled ? /* @__PURE__ */ jsx(XCircle, {}) : /* @__PURE__ */ jsx(CheckCircle, {}),
167
- label: commissionRate.is_enabled ? t("actions.disable") : t("actions.enable"),
168
- onClick: handleToggleEnabled
169
- }
170
- ]
171
- },
172
- {
173
- actions: [
174
- {
175
- icon: /* @__PURE__ */ jsx(Trash, {}),
176
- label: t("actions.delete"),
177
- onClick: handleDelete
178
- }
179
- ]
180
- }
181
- ]
182
- }
183
- );
184
- };
185
-
186
- // src/pages/commission-rates/commission-rate-detail/components/commission-rate-rules-section/commission-rate-rules-section.tsx
187
- import { ArrowDownRightMini } from "@medusajs/icons";
188
- import {
189
- Badge as Badge2,
190
- Container as Container2,
191
- Heading as Heading2,
192
- Text,
193
- Tooltip
194
- } from "@medusajs/ui";
195
- import { useTranslation as useTranslation2 } from "react-i18next";
196
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
197
- var CommissionRateRulesSection = ({
198
- commissionRate
199
- }) => {
200
- const { t } = useTranslation2();
201
- const rules = commissionRate.rules || [];
202
- const groupedRules = rules.reduce(
203
- (acc, rule) => {
204
- if (!acc[rule.reference]) {
205
- acc[rule.reference] = [];
206
- }
207
- acc[rule.reference].push(rule.reference_id);
208
- return acc;
209
- },
210
- {}
211
- );
212
- const entries = Object.entries(groupedRules);
213
- return /* @__PURE__ */ jsxs2(Container2, { className: "divide-y p-0", children: [
214
- /* @__PURE__ */ jsx2("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsx2(Heading2, { level: "h2", children: t("taxRegions.fields.targets.label") }) }),
215
- entries.length === 0 ? /* @__PURE__ */ jsx2("div", { className: "flex items-center justify-center px-6 py-8", children: /* @__PURE__ */ jsx2(Text, { size: "small", className: "text-ui-fg-subtle", children: t("commissionRates.rules.empty") }) }) : /* @__PURE__ */ jsx2("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-3", children: [
216
- /* @__PURE__ */ jsx2("div", { className: "text-ui-fg-muted flex size-5 items-center justify-center", children: /* @__PURE__ */ jsx2(ArrowDownRightMini, {}) }),
217
- /* @__PURE__ */ jsxs2("div", { className: "flex flex-wrap items-center gap-x-1.5 gap-y-2", children: [
218
- /* @__PURE__ */ jsx2(
219
- Text,
220
- {
221
- size: "small",
222
- leading: "compact",
223
- className: "text-ui-fg-subtle",
224
- children: t("taxRegions.fields.targets.operators.on")
225
- }
226
- ),
227
- entries.map(([reference, ids], index) => {
228
- return /* @__PURE__ */ jsxs2(
229
- "div",
230
- {
231
- className: "flex items-center gap-x-1.5",
232
- children: [
233
- /* @__PURE__ */ jsx2(
234
- Reference,
235
- {
236
- reference,
237
- ids
238
- }
239
- ),
240
- index < entries.length - 1 && /* @__PURE__ */ jsx2(
241
- Text,
242
- {
243
- size: "small",
244
- leading: "compact",
245
- className: "text-ui-fg-subtle",
246
- children: t("taxRegions.fields.targets.operators.and")
247
- }
248
- )
249
- ]
250
- },
251
- reference
252
- );
253
- })
254
- ] })
255
- ] }) })
256
- ] });
257
- };
258
- var Reference = ({
259
- reference,
260
- ids
261
- }) => {
262
- return /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-1.5", children: [
263
- /* @__PURE__ */ jsx2(ReferenceBadge, { reference }),
264
- /* @__PURE__ */ jsx2(ReferenceValues, { type: reference, ids })
265
- ] });
266
- };
267
- var ReferenceBadge = ({
268
- reference
269
- }) => {
270
- const { t } = useTranslation2();
271
- let label = null;
272
- switch (reference) {
273
- case "product" /* PRODUCT */:
274
- label = t("taxRegions.fields.targets.tags.product");
275
- break;
276
- case "product_type" /* PRODUCT_TYPE */:
277
- label = t("taxRegions.fields.targets.tags.productType");
278
- break;
279
- case "shipping_option" /* SHIPPING_OPTION */:
280
- label = t("taxRegions.fields.targets.tags.shippingOption");
281
- break;
282
- }
283
- if (!label) {
284
- return null;
285
- }
286
- return /* @__PURE__ */ jsx2(Badge2, { size: "2xsmall", children: label });
287
- };
288
- var ReferenceValues = ({
289
- type,
290
- ids
291
- }) => {
292
- const { t } = useTranslation2();
293
- const { isPending, additional, labels, isError, error } = useReferenceValues(
294
- type,
295
- ids
296
- );
297
- if (isError) {
298
- throw error;
299
- }
300
- if (isPending) {
301
- return /* @__PURE__ */ jsx2("div", { className: "bg-ui-tag-neutral-bg border-ui-tag-neutral-border h-5 w-14 animate-pulse rounded-md" });
302
- }
303
- return /* @__PURE__ */ jsx2(
304
- Tooltip,
305
- {
306
- content: /* @__PURE__ */ jsxs2("ul", { children: [
307
- labels?.map((label, index) => /* @__PURE__ */ jsx2("li", { children: label }, index)),
308
- additional > 0 && /* @__PURE__ */ jsx2("li", { children: t("taxRegions.fields.targets.additionalValues", {
309
- count: additional
310
- }) })
311
- ] }),
312
- children: /* @__PURE__ */ jsx2(Badge2, { size: "2xsmall", children: t("taxRegions.fields.targets.values", {
313
- count: ids.length
314
- }) })
315
- }
316
- );
317
- };
318
- var useReferenceValues = (type, ids) => {
319
- const products = useProducts(
320
- { id: ids, limit: 10 },
321
- { enabled: !!ids.length && type === "product" /* PRODUCT */ }
322
- );
323
- const productTypes = useProductTypes(
324
- { id: ids, limit: 10 },
325
- { enabled: !!ids.length && type === "product_type" /* PRODUCT_TYPE */ }
326
- );
327
- const shippingOptions = useShippingOptions(
328
- { id: ids, limit: 10 },
329
- {
330
- enabled: !!ids.length && type === "shipping_option" /* SHIPPING_OPTION */
331
- }
332
- );
333
- switch (type) {
334
- case "product" /* PRODUCT */:
335
- return {
336
- labels: products.products?.map((product) => product.title),
337
- isPending: products.isPending,
338
- additional: products.products && products.count ? products.count - products.products.length : 0,
339
- isError: products.isError,
340
- error: products.error
341
- };
342
- case "product_type" /* PRODUCT_TYPE */:
343
- return {
344
- labels: productTypes.product_types?.map((type2) => type2.value),
345
- isPending: productTypes.isPending,
346
- additional: productTypes.product_types && productTypes.count ? productTypes.count - productTypes.product_types.length : 0,
347
- isError: productTypes.isError,
348
- error: productTypes.error
349
- };
350
- case "shipping_option" /* SHIPPING_OPTION */:
351
- return {
352
- labels: shippingOptions.shipping_options?.map((option) => option.name),
353
- isPending: shippingOptions.isPending,
354
- additional: shippingOptions.count ? shippingOptions.count - (shippingOptions.shipping_options?.length || 0) : 0,
355
- isError: shippingOptions.isError,
356
- error: shippingOptions.error
357
- };
358
- }
359
- };
360
-
361
- // src/pages/commission-rates/commission-rate-detail/commission-rate-detail.tsx
362
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
363
- var Root = ({ children }) => {
364
- const initialData = useLoaderData();
365
- const { id } = useParams();
366
- const {
367
- commission_rate,
368
- isPending: isLoading,
369
- isError,
370
- error
371
- } = useCommissionRate(id, { fields: "*rules" }, { initialData });
372
- if (isLoading || !commission_rate) {
373
- return /* @__PURE__ */ jsx3(SingleColumnPageSkeleton, { sections: 2, showJSON: true, showMetadata: true });
374
- }
375
- if (isError) {
376
- throw error;
377
- }
378
- return Children.count(children) > 0 ? /* @__PURE__ */ jsx3(SingleColumnPage, { data: commission_rate, showJSON: true, showMetadata: true, children }) : /* @__PURE__ */ jsxs3(SingleColumnPage, { data: commission_rate, showJSON: true, showMetadata: true, children: [
379
- /* @__PURE__ */ jsx3(CommissionRateGeneralSection, { commissionRate: commission_rate }),
380
- /* @__PURE__ */ jsx3(CommissionRateRulesSection, { commissionRate: commission_rate })
381
- ] });
382
- };
383
- var CommissionRateDetailPage = Object.assign(Root, {
384
- GeneralSection: CommissionRateGeneralSection,
385
- RulesSection: CommissionRateRulesSection
386
- });
387
-
388
- export {
389
- CommissionRateDetailPage
390
- };
@@ -1,11 +0,0 @@
1
- // src/pages/tax-regions/common/utils.ts
2
- var createTaxRulePayload = (target) => {
3
- return target.references.map((reference) => ({
4
- reference: target.reference_type,
5
- reference_id: reference.value
6
- }));
7
- };
8
-
9
- export {
10
- createTaxRulePayload
11
- };