@mercurjs/admin 2.0.0-canary.29 → 2.0.0-canary.31

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 (129) hide show
  1. package/dist/{add-campaign-promotions-TXOODRHB.js → add-campaign-promotions-UVEH25GZ.js} +3 -3
  2. package/dist/{adjust-inventory-6RA7MJEM.js → adjust-inventory-6Q53EEFB.js} +6 -4
  3. package/dist/{api-key-management-detail-24BNBQNS.js → api-key-management-detail-RQW5RC5F.js} +6 -4
  4. package/dist/{campaign-detail-FBUQQL2W.js → campaign-detail-4DO3S5UZ.js} +9 -7
  5. package/dist/{categories-metadata-7NJ5AUE7.js → categories-metadata-G7JDGW6O.js} +6 -4
  6. package/dist/{category-detail-IQ4PUZG7.js → category-detail-2U65E3CX.js} +8 -6
  7. package/dist/{category-products-FSVFQAE4.js → category-products-FH4RIZKA.js} +8 -6
  8. package/dist/{chunk-AAW22JWF.js → chunk-2BE77FVK.js} +1 -1
  9. package/dist/chunk-A4X5VP3G.js +102 -0
  10. package/dist/{chunk-BRUOBAPY.js → chunk-BFCAJKRG.js} +36 -68
  11. package/dist/{chunk-TO7KBKHJ.js → chunk-F5PEK3DA.js} +5 -2
  12. package/dist/{chunk-PASXA3UX.js → chunk-FBUH5OLD.js} +22 -1
  13. package/dist/{chunk-6KI3GDYH.js → chunk-FMOQNZFZ.js} +39 -3
  14. package/dist/{chunk-6NNBZIM7.js → chunk-GFZ7GOEU.js} +4 -1
  15. package/dist/{chunk-RILFAVKM.js → chunk-HOZHWCST.js} +1 -1
  16. package/dist/{chunk-NWQRHWE5.js → chunk-K6FXWZ2M.js} +1300 -1300
  17. package/dist/chunk-M3I52H3M.js +32 -0
  18. package/dist/chunk-RW35OPIA.js +45 -0
  19. package/dist/chunk-SWL7ZCP3.js +11 -0
  20. package/dist/{chunk-ZGQV4I7U.js → chunk-SXC5ZMLI.js} +3 -3
  21. package/dist/{chunk-4XHMNG3H.js → chunk-UZVYM65V.js} +8 -17
  22. package/dist/{chunk-KW56S7WF.js → chunk-VVWB3GIK.js} +5 -2
  23. package/dist/chunk-VZEMURY7.js +35 -0
  24. package/dist/{chunk-SJKPESDA.js → chunk-XE6KSRKQ.js} +1 -1
  25. package/dist/{chunk-QM2TMBP3.js → chunk-XM6GCWNF.js} +7 -31
  26. package/dist/{chunk-NKLW7RD6.js → chunk-XXXE6VUX.js} +1 -1
  27. package/dist/{collection-add-products-4HTDHYXO.js → collection-add-products-RLTEE27D.js} +8 -6
  28. package/dist/{collection-detail-CWGP5ICA.js → collection-detail-Y4GGSHXX.js} +8 -6
  29. package/dist/{collection-list-6DZKMCB5.js → collection-list-WUPG6AU2.js} +14 -12
  30. package/dist/{collection-metadata-7BON4MGI.js → collection-metadata-CQWEZ4EQ.js} +6 -4
  31. package/dist/commission-rate-create-YK6GCP2R.js +779 -0
  32. package/dist/commission-rate-detail-ANI37QHI.js +441 -0
  33. package/dist/commission-rate-edit-5MPI53CE.js +762 -0
  34. package/dist/commission-rate-list-FCQ3HXC7.js +196 -0
  35. package/dist/{customer-detail-46UYP6GW.js → customer-detail-YS265DZS.js} +12 -9
  36. package/dist/{customer-group-detail-3RD6DT7U.js → customer-group-detail-CPONLZRF.js} +6 -4
  37. package/dist/{customer-group-list-TFM2WJ4X.js → customer-group-list-V2CGT3FT.js} +6 -4
  38. package/dist/{customer-group-metadata-P7QANREG.js → customer-group-metadata-BITZXXFX.js} +6 -4
  39. package/dist/{customer-metadata-MBI3NDAU.js → customer-metadata-6DDHIGDD.js} +6 -4
  40. package/dist/{customers-add-customer-group-IHI2A5OO.js → customers-add-customer-group-SD3KK6JE.js} +6 -4
  41. package/dist/{edit-inventory-item-EULGCSM4.js → edit-inventory-item-5PZZ3IAH.js} +6 -4
  42. package/dist/{edit-inventory-item-attributes-56QN6GHF.js → edit-inventory-item-attributes-7PJQCUXL.js} +6 -4
  43. package/dist/{edit-rules-3WAX7GEP.js → edit-rules-E2564ZQB.js} +6 -4
  44. package/dist/index.js +204 -121
  45. package/dist/{inventory-create-WCI6KWDJ.js → inventory-create-LYXHQR7Y.js} +6 -4
  46. package/dist/{inventory-detail-WDI5KD2U.js → inventory-detail-42GK24BA.js} +6 -4
  47. package/dist/{inventory-metadata-S34DYKIW.js → inventory-metadata-OLR5ZMMN.js} +6 -4
  48. package/dist/{inventory-stock-ITSFGRAG.js → inventory-stock-ZOM2ANKJ.js} +6 -4
  49. package/dist/{location-detail-DIAY4ZPW.js → location-detail-XO4RRCAU.js} +11 -9
  50. package/dist/{location-fulfillment-providers-EBFA6G7P.js → location-fulfillment-providers-6T27UNF7.js} +8 -6
  51. package/dist/{location-list-ZWDA6NC3.js → location-list-KVFFPEIV.js} +7 -5
  52. package/dist/{location-service-zone-shipping-option-create-LNLXDZYF.js → location-service-zone-shipping-option-create-PSPX634E.js} +6 -4
  53. package/dist/{login-FXV4BRJ2.js → login-U5WERLJC.js} +6 -4
  54. package/dist/{marketplace-detail-GOA4HYOL.js → marketplace-detail-OVWHCK5W.js} +6 -4
  55. package/dist/{marketplace-metadata-GCD7VD34.js → marketplace-metadata-GIYATM54.js} +6 -4
  56. package/dist/{order-create-claim-OT3YIYG7.js → order-create-claim-UWNZUBL7.js} +9 -7
  57. package/dist/{order-create-edit-KF5V64D7.js → order-create-edit-JD4UZ5GW.js} +9 -7
  58. package/dist/{order-create-exchange-5PH2DDPB.js → order-create-exchange-OTIDP47E.js} +9 -7
  59. package/dist/{order-create-fulfillment-MIJWDDL2.js → order-create-fulfillment-7OP64TNJ.js} +6 -4
  60. package/dist/{order-create-refund-56LLPYLA.js → order-create-refund-U4UK5IZB.js} +9 -7
  61. package/dist/{order-create-shipment-TCGKO67Z.js → order-create-shipment-URYCUNU6.js} +6 -4
  62. package/dist/{order-detail-ZDPCS42E.js → order-detail-V2O5C4CX.js} +12 -9
  63. package/dist/{order-edit-billing-address-C7YX7626.js → order-edit-billing-address-XRUEKX33.js} +7 -5
  64. package/dist/{order-edit-email-7NMGVKNJ.js → order-edit-email-CJ3MEZB6.js} +6 -4
  65. package/dist/{order-edit-shipping-address-BSWGO3G3.js → order-edit-shipping-address-SV4UVNBQ.js} +6 -4
  66. package/dist/order-list-P75CDQ2O.js +308 -0
  67. package/dist/{order-metadata-XXEPKUFM.js → order-metadata-HIOSALZT.js} +6 -4
  68. package/dist/{order-receive-return-JFIMIGGV.js → order-receive-return-4SRRRBW6.js} +6 -4
  69. package/dist/{order-request-transfer-TXC2FK4A.js → order-request-transfer-5AGKGFVY.js} +6 -4
  70. package/dist/{price-list-create-L5KWHQIJ.js → price-list-create-3NNWUS6L.js} +9 -7
  71. package/dist/{price-list-detail-E3F63UB6.js → price-list-detail-324FZRK5.js} +11 -9
  72. package/dist/{price-list-prices-add-OHMQZH73.js → price-list-prices-add-IBSLTMNK.js} +8 -6
  73. package/dist/{price-list-prices-edit-ORJ3VWX2.js → price-list-prices-edit-AAVPX34P.js} +6 -4
  74. package/dist/{product-create-FWHZORNL.js → product-create-C4GHUEM5.js} +39 -6
  75. package/dist/{product-create-variant-ZMSJOFSJ.js → product-create-variant-5MVBT5ST.js} +6 -4
  76. package/dist/{product-detail-V24PBFTX.js → product-detail-3UWUMNHC.js} +11 -5
  77. package/dist/{product-export-H5Z6JVW7.js → product-export-XTS7P5AD.js} +14 -12
  78. package/dist/{product-import-HYPRL63J.js → product-import-ZEZE2JE6.js} +6 -4
  79. package/dist/{product-list-XWJ5JFO2.js → product-list-7WK2AWI2.js} +16 -6
  80. package/dist/{product-media-TGVTQNDO.js → product-media-Z2DCRZSU.js} +2 -2
  81. package/dist/{product-metadata-LP6ZZFCV.js → product-metadata-NBB5SRDN.js} +6 -4
  82. package/dist/{product-stock-S6XIQVMO.js → product-stock-ZXNZZBJI.js} +6 -4
  83. package/dist/{product-tag-create-WIROVJ3M.js → product-tag-create-LL35OFZM.js} +6 -4
  84. package/dist/{product-tag-detail-F27ML7MQ.js → product-tag-detail-E7VYBISE.js} +19 -16
  85. package/dist/{product-tag-edit-7A2H7OW2.js → product-tag-edit-6XBZCCED.js} +6 -4
  86. package/dist/{product-tag-list-KMVTIS7O.js → product-tag-list-I6M6TAYM.js} +19 -16
  87. package/dist/{product-tag-metadata-AZUT3RGE.js → product-tag-metadata-UGO4RUFU.js} +6 -4
  88. package/dist/{product-type-detail-LHNEJ5V3.js → product-type-detail-JI4DF7WR.js} +8 -6
  89. package/dist/{product-type-metadata-SB7Z6X6E.js → product-type-metadata-ZKOZNZE3.js} +6 -4
  90. package/dist/{product-variant-detail-VA7DHMCF.js → product-variant-detail-DXTUM4R7.js} +17 -5
  91. package/dist/{product-variant-edit-FCOJQ4E7.js → product-variant-edit-KGLW5GXD.js} +6 -4
  92. package/dist/{product-variant-metadata-TH6U2EQW.js → product-variant-metadata-H7J7SZNU.js} +6 -4
  93. package/dist/{promotion-create-7L5LWMEM.js → promotion-create-P2WR5RPH.js} +6 -4
  94. package/dist/{promotion-detail-NGOQNJER.js → promotion-detail-IO7V5CXR.js} +8 -6
  95. package/dist/{promotion-list-CV35S2NN.js → promotion-list-SJYMXQXT.js} +3 -3
  96. package/dist/{refund-reason-create-V2VJFJQ2.js → refund-reason-create-PTHFUT2D.js} +6 -4
  97. package/dist/{refund-reason-edit-ZTSUQ7IF.js → refund-reason-edit-WEEQQGYO.js} +6 -4
  98. package/dist/{refund-reason-list-FYROEGE3.js → refund-reason-list-ECQKWA2M.js} +12 -9
  99. package/dist/{region-metadata-R4EIHSPF.js → region-metadata-IYIHJCTK.js} +6 -4
  100. package/dist/{reservation-detail-MKH3WGNU.js → reservation-detail-J4M2EXRY.js} +6 -4
  101. package/dist/{reservation-metadata-W3BBPRGI.js → reservation-metadata-MMHE4TPO.js} +6 -4
  102. package/dist/{reset-password-EEDB3CUC.js → reset-password-WNANNJDX.js} +1 -1
  103. package/dist/{return-reason-list-B32WYMI2.js → return-reason-list-MRYG7ZK7.js} +11 -10
  104. package/dist/{sales-channel-add-products-LHMQAZUR.js → sales-channel-add-products-GP7TMMKB.js} +8 -6
  105. package/dist/{sales-channel-detail-MYCYNGWP.js → sales-channel-detail-RMU5QW3N.js} +8 -6
  106. package/dist/{sales-channel-list-UK62MLV6.js → sales-channel-list-2ZUNUM2T.js} +6 -4
  107. package/dist/{sales-channel-metadata-YQG6HIJA.js → sales-channel-metadata-QF5KEN7C.js} +6 -4
  108. package/dist/seller-address-edit-ZD3CYNHQ.js +223 -0
  109. package/dist/{seller-details-MSDVT5IO.js → seller-details-EUCYPH4Z.js} +171 -228
  110. package/dist/{seller-edit-RUYGO7CB.js → seller-edit-DL7IFKVU.js} +5 -212
  111. package/dist/{seller-list-B45KDWT7.js → seller-list-W76S2T27.js} +44 -3
  112. package/dist/{shipping-option-type-create-MPIM2Y2U.js → shipping-option-type-create-KBQMPNIW.js} +6 -4
  113. package/dist/{shipping-option-type-detail-FTLW2VVA.js → shipping-option-type-detail-CFGKF7NV.js} +7 -5
  114. package/dist/{shipping-option-type-edit-AAKLLV23.js → shipping-option-type-edit-S3R6JBFV.js} +6 -4
  115. package/dist/{shipping-option-type-list-UDGLHQWB.js → shipping-option-type-list-4A7FT4P5.js} +7 -5
  116. package/dist/{shipping-profile-metadata-D74JJSCX.js → shipping-profile-metadata-BJFUYS5L.js} +6 -4
  117. package/dist/{tax-region-create-JNOTV4L4.js → tax-region-create-KTFZNQCZ.js} +7 -5
  118. package/dist/{tax-region-detail-EKF3UNHB.js → tax-region-detail-L3EB6JSF.js} +38 -20
  119. package/dist/{tax-region-edit-4RUDAWE6.js → tax-region-edit-H2ORQVEW.js} +6 -4
  120. package/dist/{tax-region-metadata-7DE72RDE.js → tax-region-metadata-2PYZ5ECB.js} +6 -4
  121. package/dist/{tax-region-province-detail-ENOLU5SV.js → tax-region-province-detail-PB7RFWJ4.js} +8 -6
  122. package/dist/{tax-region-tax-override-create-EAUDM7RZ.js → tax-region-tax-override-create-IDGG732M.js} +28 -23
  123. package/dist/{tax-region-tax-override-edit-H5I3E3AJ.js → tax-region-tax-override-edit-NSBZBBZA.js} +28 -23
  124. package/dist/{user-metadata-4EBEIV3V.js → user-metadata-QFVK2VJX.js} +6 -4
  125. package/package.json +6 -6
  126. package/dist/order-list-Y3CNRMSU.js +0 -235
  127. package/dist/{chunk-O4E3MAKS.js → chunk-BGDOVLJF.js} +3 -3
  128. package/dist/{location-service-zone-shipping-option-edit-TBJ3NSBP.js → location-service-zone-shipping-option-edit-SSMGORBF.js} +3 -3
  129. package/dist/{order-create-return-63NO5ODU.js → order-create-return-LH4LW5BZ.js} +3 -3
@@ -0,0 +1,762 @@
1
+ import {
2
+ TargetForm,
3
+ TargetItem,
4
+ TaxRateRuleReferenceSchema
5
+ } from "./chunk-UZVYM65V.js";
6
+ import "./chunk-5A4JNOK3.js";
7
+ import "./chunk-O5VKW5FL.js";
8
+ import "./chunk-LTBX54CI.js";
9
+ import "./chunk-2PZGY332.js";
10
+ import "./chunk-AFQS6E4N.js";
11
+ import "./chunk-QG6PLWNH.js";
12
+ import "./chunk-BFCAJKRG.js";
13
+ import "./chunk-4F5GP7J7.js";
14
+ import "./chunk-54EPH67T.js";
15
+ import "./chunk-JQV7CXEC.js";
16
+ import {
17
+ PercentageInput
18
+ } from "./chunk-MAEP2UCK.js";
19
+ import "./chunk-HINXQTCW.js";
20
+ import "./chunk-VW56KWO2.js";
21
+ import "./chunk-HC25LNX7.js";
22
+ import "./chunk-2Y3WMGN6.js";
23
+ import "./chunk-RW35OPIA.js";
24
+ import "./chunk-25LYVP3C.js";
25
+ import "./chunk-LQSLDDPT.js";
26
+ import "./chunk-JHIMVLB2.js";
27
+ import "./chunk-PXYDR7WQ.js";
28
+ import "./chunk-3CKTAFTR.js";
29
+ import "./chunk-G5OVX555.js";
30
+ import "./chunk-FWPGOIFA.js";
31
+ import "./chunk-DB6ANJBO.js";
32
+ import "./chunk-FQERBIVS.js";
33
+ import "./chunk-PHOCVOZ5.js";
34
+ import "./chunk-FLCYR7E5.js";
35
+ import "./chunk-YBZWO4ZV.js";
36
+ import "./chunk-KAZ5BYTQ.js";
37
+ import "./chunk-3EF54XFY.js";
38
+ import "./chunk-WIYFXWRI.js";
39
+ import {
40
+ currencies,
41
+ getCurrencySymbol
42
+ } from "./chunk-IQPN4PZJ.js";
43
+ import "./chunk-TKGWSUEI.js";
44
+ import {
45
+ KeyboundForm
46
+ } from "./chunk-U2ZFCAPX.js";
47
+ import "./chunk-FMOQNZFZ.js";
48
+ import "./chunk-2ZFELO2L.js";
49
+ import "./chunk-26OOAKQ6.js";
50
+ import "./chunk-ZQZHFMD7.js";
51
+ import "./chunk-K3GJ266Z.js";
52
+ import "./chunk-GEVYE225.js";
53
+ import "./chunk-CMHI2RPL.js";
54
+ import "./chunk-S2WEYEQR.js";
55
+ import "./chunk-SXC5ZMLI.js";
56
+ import "./chunk-MG4GKUJW.js";
57
+ import "./chunk-AYVH6Q5O.js";
58
+ import "./chunk-VOHEQ7B5.js";
59
+ import "./chunk-N5IUYCUZ.js";
60
+ import "./chunk-7SVLKK6Q.js";
61
+ import "./chunk-GR6JUIRU.js";
62
+ import "./chunk-PVZBDWLK.js";
63
+ import "./chunk-O5HZRJPB.js";
64
+ import "./chunk-VKOE5J66.js";
65
+ import "./chunk-DY3XQPHC.js";
66
+ import "./chunk-FBUH5OLD.js";
67
+ import "./chunk-VVWB3GIK.js";
68
+ import "./chunk-KBYZLKI4.js";
69
+ import "./chunk-YWWUOGJA.js";
70
+ import {
71
+ RouteDrawer,
72
+ StackedDrawer,
73
+ useRouteModal,
74
+ useStackedModal
75
+ } from "./chunk-MWOKFNRO.js";
76
+ import {
77
+ Form
78
+ } from "./chunk-3QSRE5LS.js";
79
+ import "./chunk-JRTZWK77.js";
80
+ import "./chunk-INNFZYX2.js";
81
+ import "./chunk-LAVHRER2.js";
82
+ import {
83
+ useDocumentDirection
84
+ } from "./chunk-Y7QKP6QU.js";
85
+ import "./chunk-THHRRYRS.js";
86
+ import "./chunk-UZWFZMOX.js";
87
+ import "./chunk-XQNVC4Q7.js";
88
+ import "./chunk-XM6GCWNF.js";
89
+ import "./chunk-ODBDAABQ.js";
90
+ import "./chunk-CDQJKJMX.js";
91
+ import "./chunk-JLATVDLM.js";
92
+ import "./chunk-GPRBBA7S.js";
93
+ import "./chunk-E7ZBQO6E.js";
94
+ import "./chunk-XGHM75N2.js";
95
+ import "./chunk-U2GCSKW3.js";
96
+ import "./chunk-RTAIDSDS.js";
97
+ import "./chunk-LW3UWYZU.js";
98
+ import {
99
+ useBatchCommissionRules,
100
+ useCommissionRate,
101
+ useUpdateCommissionRate
102
+ } from "./chunk-A4X5VP3G.js";
103
+ import "./chunk-NNZP4PYP.js";
104
+ import "./chunk-GF4QHVX3.js";
105
+ import "./chunk-JOQ3RTF5.js";
106
+ import "./chunk-V534K7G4.js";
107
+ import "./chunk-A5XOYSDC.js";
108
+ import "./chunk-TQI3DOQ5.js";
109
+ import "./chunk-5PB7KCTF.js";
110
+ import "./chunk-YOIARITB.js";
111
+ import "./chunk-W7G64ULL.js";
112
+ import "./chunk-6C7TCU42.js";
113
+ import "./chunk-4YF3GAKE.js";
114
+ import "./chunk-M3I52H3M.js";
115
+ import "./chunk-LORVU5II.js";
116
+ import "./chunk-36ORDF7W.js";
117
+ import "./chunk-QSM56ZOP.js";
118
+ import {
119
+ useStore
120
+ } from "./chunk-MIHEJ6Y6.js";
121
+ import "./chunk-3VZV6SJQ.js";
122
+ import "./chunk-K357FGGP.js";
123
+ import "./chunk-RHKRREUU.js";
124
+ import "./chunk-ZA2KFUFR.js";
125
+ import "./chunk-ZYNBKBY3.js";
126
+ import "./chunk-NBMM2TZK.js";
127
+
128
+ // src/pages/commission-rates/commission-rate-edit/commission-rate-edit.tsx
129
+ import { Heading as Heading2 } from "@medusajs/ui";
130
+ import { useParams } from "react-router-dom";
131
+
132
+ // src/pages/commission-rates/commission-rate-edit/components/edit-commission-rate-form/edit-commission-rate-form.tsx
133
+ import { zodResolver } from "@hookform/resolvers/zod";
134
+ import { MagnifyingGlass } from "@medusajs/icons";
135
+ import {
136
+ Button,
137
+ clx,
138
+ CurrencyInput,
139
+ Divider,
140
+ Heading,
141
+ Hint,
142
+ Input,
143
+ Label,
144
+ Select,
145
+ Switch,
146
+ Text,
147
+ toast
148
+ } from "@medusajs/ui";
149
+ import { useFieldArray, useForm, useWatch } from "react-hook-form";
150
+ import { useTranslation } from "react-i18next";
151
+ import * as zod from "zod";
152
+ import { jsx, jsxs } from "react/jsx-runtime";
153
+ var STACKED_MODAL_ID = "cr";
154
+ var getStackedModalId = (type) => `${STACKED_MODAL_ID}-${type}`;
155
+ var EditCommissionRateSchema = zod.object({
156
+ name: zod.string().min(1),
157
+ code: zod.string().min(1),
158
+ type: zod.enum(["fixed", "percentage"]),
159
+ target: zod.enum(["item", "shipping"]),
160
+ value: zod.coerce.number().min(0),
161
+ currency_code: zod.string().optional(),
162
+ min_amount: zod.coerce.number().optional(),
163
+ include_tax: zod.boolean(),
164
+ priority: zod.coerce.number().int().min(0),
165
+ enabled_rules: zod.object({
166
+ product: zod.boolean(),
167
+ product_type: zod.boolean(),
168
+ shipping_option: zod.boolean()
169
+ }),
170
+ product: zod.array(TaxRateRuleReferenceSchema).optional(),
171
+ product_type: zod.array(TaxRateRuleReferenceSchema).optional(),
172
+ shipping_option: zod.array(TaxRateRuleReferenceSchema).optional()
173
+ });
174
+ var getRulesByType = (rules, type) => {
175
+ return (rules || []).filter((r) => r.reference === type).map((r) => ({ value: r.reference_id, label: "" }));
176
+ };
177
+ var EditCommissionRateForm = ({
178
+ commissionRate
179
+ }) => {
180
+ const { t } = useTranslation();
181
+ const { handleSuccess } = useRouteModal();
182
+ const { setIsOpen } = useStackedModal();
183
+ const direction = useDocumentDirection();
184
+ const initialProducts = getRulesByType(
185
+ commissionRate.rules,
186
+ "product" /* PRODUCT */
187
+ );
188
+ const initialProductTypes = getRulesByType(
189
+ commissionRate.rules,
190
+ "product_type" /* PRODUCT_TYPE */
191
+ );
192
+ const initialShippingOptions = getRulesByType(
193
+ commissionRate.rules,
194
+ "shipping_option" /* SHIPPING_OPTION */
195
+ );
196
+ const form = useForm({
197
+ defaultValues: {
198
+ name: commissionRate.name,
199
+ code: commissionRate.code,
200
+ type: commissionRate.type,
201
+ target: commissionRate.target,
202
+ value: commissionRate.value,
203
+ currency_code: commissionRate.currency_code ?? "",
204
+ min_amount: commissionRate.min_amount ?? void 0,
205
+ include_tax: commissionRate.include_tax,
206
+ priority: commissionRate.priority,
207
+ enabled_rules: {
208
+ product: initialProducts.length > 0,
209
+ product_type: initialProductTypes.length > 0,
210
+ shipping_option: initialShippingOptions.length > 0
211
+ },
212
+ product: initialProducts,
213
+ product_type: initialProductTypes,
214
+ shipping_option: initialShippingOptions
215
+ },
216
+ resolver: zodResolver(EditCommissionRateSchema)
217
+ });
218
+ const { store } = useStore();
219
+ const storeCurrencies = (store?.supported_currencies ?? []).map(
220
+ (c) => currencies[c.currency_code.toUpperCase()]
221
+ );
222
+ const { mutateAsync: updateCommissionRate, isPending: isUpdating } = useUpdateCommissionRate(commissionRate.id);
223
+ const { mutateAsync: batchRules, isPending: isBatching } = useBatchCommissionRules(commissionRate.id);
224
+ const handleSubmit = form.handleSubmit(async (values) => {
225
+ const newRules = [
226
+ ...(values.product || []).map((ref) => ({
227
+ reference: "product" /* PRODUCT */,
228
+ reference_id: ref.value
229
+ })),
230
+ ...(values.product_type || []).map((ref) => ({
231
+ reference: "product_type" /* PRODUCT_TYPE */,
232
+ reference_id: ref.value
233
+ })),
234
+ ...(values.shipping_option || []).map((ref) => ({
235
+ reference: "shipping_option" /* SHIPPING_OPTION */,
236
+ reference_id: ref.value
237
+ }))
238
+ ];
239
+ const existingRules = commissionRate.rules || [];
240
+ const toCreate = newRules.filter(
241
+ (nr) => !existingRules.some(
242
+ (er) => er.reference === nr.reference && er.reference_id === nr.reference_id
243
+ )
244
+ );
245
+ const toDelete = existingRules.filter(
246
+ (er) => !newRules.some(
247
+ (nr) => nr.reference === er.reference && nr.reference_id === er.reference_id
248
+ )
249
+ ).map((er) => er.id);
250
+ try {
251
+ await updateCommissionRate({
252
+ name: values.name,
253
+ code: values.code,
254
+ type: values.type,
255
+ target: values.target,
256
+ value: values.value,
257
+ currency_code: values.currency_code || null,
258
+ min_amount: values.min_amount ?? null,
259
+ include_tax: values.include_tax,
260
+ priority: values.priority
261
+ });
262
+ if (toCreate.length > 0 || toDelete.length > 0) {
263
+ await batchRules({
264
+ ...toCreate.length > 0 ? { create: toCreate } : {},
265
+ ...toDelete.length > 0 ? { delete: toDelete } : {}
266
+ });
267
+ }
268
+ toast.success("Commission rate updated successfully");
269
+ handleSuccess();
270
+ } catch (e) {
271
+ toast.error(e.message);
272
+ }
273
+ });
274
+ const watchType = form.watch("type");
275
+ const watchCurrency = form.watch("currency_code");
276
+ const products = useFieldArray({
277
+ control: form.control,
278
+ name: "product" /* PRODUCT */
279
+ });
280
+ const productTypes = useFieldArray({
281
+ control: form.control,
282
+ name: "product_type" /* PRODUCT_TYPE */
283
+ });
284
+ const shippingOptions = useFieldArray({
285
+ control: form.control,
286
+ name: "shipping_option" /* SHIPPING_OPTION */
287
+ });
288
+ const getControls = (type) => {
289
+ switch (type) {
290
+ case "product" /* PRODUCT */:
291
+ return products;
292
+ case "product_type" /* PRODUCT_TYPE */:
293
+ return productTypes;
294
+ case "shipping_option" /* SHIPPING_OPTION */:
295
+ return shippingOptions;
296
+ }
297
+ };
298
+ const referenceTypeOptions = [
299
+ {
300
+ value: "product" /* PRODUCT */,
301
+ label: t("taxRegions.fields.targets.options.product")
302
+ },
303
+ {
304
+ value: "product_type" /* PRODUCT_TYPE */,
305
+ label: t("taxRegions.fields.targets.options.productType")
306
+ },
307
+ {
308
+ value: "shipping_option" /* SHIPPING_OPTION */,
309
+ label: t("taxRegions.fields.targets.options.shippingOption")
310
+ }
311
+ ];
312
+ const searchPlaceholders = {
313
+ ["product" /* PRODUCT */]: t(
314
+ "taxRegions.fields.targets.placeholders.product"
315
+ ),
316
+ ["product_type" /* PRODUCT_TYPE */]: t(
317
+ "taxRegions.fields.targets.placeholders.productType"
318
+ ),
319
+ ["shipping_option" /* SHIPPING_OPTION */]: t(
320
+ "taxRegions.fields.targets.placeholders.shippingOption"
321
+ )
322
+ };
323
+ const getFieldHandler = (type) => {
324
+ const { fields, remove, prepend } = getControls(type);
325
+ const modalId = getStackedModalId(type);
326
+ return (references) => {
327
+ if (!references.length) {
328
+ form.setValue(type, [], { shouldDirty: true });
329
+ setIsOpen(modalId, false);
330
+ return;
331
+ }
332
+ const newIds = references.map((reference) => reference.value);
333
+ const fieldsToAdd = references.filter(
334
+ (reference) => !fields.some((field) => field.value === reference.value)
335
+ );
336
+ for (const field of fields) {
337
+ if (!newIds.includes(field.value)) {
338
+ remove(fields.indexOf(field));
339
+ }
340
+ }
341
+ prepend(fieldsToAdd);
342
+ setIsOpen(modalId, false);
343
+ };
344
+ };
345
+ const displayOrder = new Set(
346
+ [
347
+ initialProducts.length > 0 ? "product" /* PRODUCT */ : null,
348
+ initialProductTypes.length > 0 ? "product_type" /* PRODUCT_TYPE */ : null,
349
+ initialShippingOptions.length > 0 ? "shipping_option" /* SHIPPING_OPTION */ : null
350
+ ].filter(Boolean)
351
+ );
352
+ const disableRule = (type) => {
353
+ form.setValue(type, [], { shouldDirty: true });
354
+ form.setValue(`enabled_rules.${type}`, false, { shouldDirty: true });
355
+ displayOrder.delete(type);
356
+ };
357
+ const enableRule = (type) => {
358
+ form.setValue(`enabled_rules.${type}`, true, { shouldDirty: true });
359
+ form.setValue(type, [], { shouldDirty: true });
360
+ displayOrder.add(type);
361
+ };
362
+ const watchedEnabledRules = useWatch({
363
+ control: form.control,
364
+ name: "enabled_rules"
365
+ });
366
+ const addRule = () => {
367
+ const firstDisabledRule = Object.keys(watchedEnabledRules).find(
368
+ (key) => !watchedEnabledRules[key]
369
+ );
370
+ if (firstDisabledRule) {
371
+ enableRule(firstDisabledRule);
372
+ }
373
+ };
374
+ const visibleRuleTypes = referenceTypeOptions.filter((option) => watchedEnabledRules[option.value]).sort((a, b) => {
375
+ const orderArray = Array.from(displayOrder);
376
+ return orderArray.indexOf(a.value) - orderArray.indexOf(b.value);
377
+ });
378
+ const getAvailableRuleTypes = (type) => {
379
+ return referenceTypeOptions.filter((option) => {
380
+ return !visibleRuleTypes.some(
381
+ (visibleOption) => visibleOption.value === option.value
382
+ ) || option.value === type;
383
+ });
384
+ };
385
+ const showAddButton = Object.values(watchedEnabledRules).some(
386
+ (value) => !value
387
+ );
388
+ const isPending = isUpdating || isBatching;
389
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
390
+ KeyboundForm,
391
+ {
392
+ className: "flex flex-1 flex-col overflow-hidden",
393
+ onSubmit: handleSubmit,
394
+ children: [
395
+ /* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-6 overflow-auto", children: [
396
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4", children: [
397
+ /* @__PURE__ */ jsx(
398
+ Form.Field,
399
+ {
400
+ control: form.control,
401
+ name: "name",
402
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
403
+ /* @__PURE__ */ jsx(Form.Label, { children: "Name" }),
404
+ /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
405
+ /* @__PURE__ */ jsx(Form.ErrorMessage, {})
406
+ ] })
407
+ }
408
+ ),
409
+ /* @__PURE__ */ jsx(
410
+ Form.Field,
411
+ {
412
+ control: form.control,
413
+ name: "code",
414
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
415
+ /* @__PURE__ */ jsx(Form.Label, { children: "Code" }),
416
+ /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
417
+ /* @__PURE__ */ jsx(Form.ErrorMessage, {})
418
+ ] })
419
+ }
420
+ ),
421
+ /* @__PURE__ */ jsx(
422
+ Form.Field,
423
+ {
424
+ control: form.control,
425
+ name: "type",
426
+ render: ({ field: { onChange, ref, ...field } }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
427
+ /* @__PURE__ */ jsx(Form.Label, { children: "Type" }),
428
+ /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
429
+ /* @__PURE__ */ jsx(Select.Trigger, { ref, children: /* @__PURE__ */ jsx(Select.Value, {}) }),
430
+ /* @__PURE__ */ jsxs(Select.Content, { children: [
431
+ /* @__PURE__ */ jsx(Select.Item, { value: "percentage", children: "Percentage" }),
432
+ /* @__PURE__ */ jsx(Select.Item, { value: "fixed", children: "Fixed" })
433
+ ] })
434
+ ] }) }),
435
+ /* @__PURE__ */ jsx(Form.ErrorMessage, {})
436
+ ] })
437
+ }
438
+ ),
439
+ /* @__PURE__ */ jsx(
440
+ Form.Field,
441
+ {
442
+ control: form.control,
443
+ name: "target",
444
+ render: ({ field: { onChange, ref, ...field } }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
445
+ /* @__PURE__ */ jsx(Form.Label, { children: "Target" }),
446
+ /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
447
+ /* @__PURE__ */ jsx(Select.Trigger, { ref, children: /* @__PURE__ */ jsx(Select.Value, {}) }),
448
+ /* @__PURE__ */ jsxs(Select.Content, { children: [
449
+ /* @__PURE__ */ jsx(Select.Item, { value: "item", children: "Item" }),
450
+ /* @__PURE__ */ jsx(Select.Item, { value: "shipping", children: "Shipping" })
451
+ ] })
452
+ ] }) }),
453
+ /* @__PURE__ */ jsx(Form.ErrorMessage, {})
454
+ ] })
455
+ }
456
+ ),
457
+ /* @__PURE__ */ jsx(
458
+ Form.Field,
459
+ {
460
+ control: form.control,
461
+ name: "currency_code",
462
+ render: ({ field: { onChange, ref, ...field } }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
463
+ /* @__PURE__ */ jsx(Form.Label, { children: "Currency Code" }),
464
+ /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
465
+ /* @__PURE__ */ jsx(Select.Trigger, { ref, children: /* @__PURE__ */ jsx(Select.Value, { placeholder: "Select currency" }) }),
466
+ /* @__PURE__ */ jsx(Select.Content, { children: storeCurrencies.map((currency) => /* @__PURE__ */ jsx(
467
+ Select.Item,
468
+ {
469
+ value: currency.code.toLowerCase(),
470
+ children: currency.name
471
+ },
472
+ currency.code
473
+ )) })
474
+ ] }) }),
475
+ /* @__PURE__ */ jsx(Form.ErrorMessage, {})
476
+ ] })
477
+ }
478
+ ),
479
+ /* @__PURE__ */ jsx(
480
+ Form.Field,
481
+ {
482
+ control: form.control,
483
+ name: "value",
484
+ render: ({ field: { value, onChange, ...field } }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
485
+ /* @__PURE__ */ jsx(Form.Label, { children: "Rate" }),
486
+ /* @__PURE__ */ jsx(Form.Control, { children: watchType === "percentage" ? /* @__PURE__ */ jsx(
487
+ PercentageInput,
488
+ {
489
+ ...field,
490
+ value,
491
+ decimalsLimit: 4,
492
+ onValueChange: (_value, _name, values) => onChange(values?.float ?? 0)
493
+ }
494
+ ) : /* @__PURE__ */ jsx(
495
+ CurrencyInput,
496
+ {
497
+ min: 0,
498
+ onValueChange: (value2) => onChange(value2 ? parseInt(value2) : ""),
499
+ code: watchCurrency ?? "",
500
+ symbol: watchCurrency ? getCurrencySymbol(watchCurrency) : "",
501
+ ...field,
502
+ value
503
+ }
504
+ ) }),
505
+ /* @__PURE__ */ jsx(Form.ErrorMessage, {})
506
+ ] })
507
+ }
508
+ ),
509
+ /* @__PURE__ */ jsx(
510
+ Form.Field,
511
+ {
512
+ control: form.control,
513
+ name: "min_amount",
514
+ render: ({ field: { value, onChange, ...field } }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
515
+ /* @__PURE__ */ jsx(Form.Label, { children: "Minimum Amount" }),
516
+ /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
517
+ CurrencyInput,
518
+ {
519
+ min: 0,
520
+ onValueChange: (value2) => onChange(value2 ? parseInt(value2) : ""),
521
+ code: watchCurrency ?? "",
522
+ symbol: watchCurrency ? getCurrencySymbol(watchCurrency) : "",
523
+ ...field,
524
+ value
525
+ }
526
+ ) }),
527
+ /* @__PURE__ */ jsx(Form.ErrorMessage, {})
528
+ ] })
529
+ }
530
+ ),
531
+ /* @__PURE__ */ jsx(
532
+ Form.Field,
533
+ {
534
+ control: form.control,
535
+ name: "priority",
536
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
537
+ /* @__PURE__ */ jsx(Form.Label, { children: "Priority" }),
538
+ /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { type: "number", ...field }) }),
539
+ /* @__PURE__ */ jsx(Form.ErrorMessage, {})
540
+ ] })
541
+ }
542
+ ),
543
+ /* @__PURE__ */ jsx(
544
+ Form.Field,
545
+ {
546
+ control: form.control,
547
+ name: "include_tax",
548
+ render: ({ field: { value, onChange, ...field } }) => /* @__PURE__ */ jsxs(Form.Item, { children: [
549
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
550
+ /* @__PURE__ */ jsx(Form.Label, { children: "Include Tax" }),
551
+ /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
552
+ Switch,
553
+ {
554
+ ...field,
555
+ checked: value,
556
+ onCheckedChange: onChange
557
+ }
558
+ ) })
559
+ ] }),
560
+ /* @__PURE__ */ jsx(Form.ErrorMessage, {})
561
+ ] })
562
+ }
563
+ )
564
+ ] }),
565
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-3", children: [
566
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-4", children: [
567
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
568
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
569
+ /* @__PURE__ */ jsx(Label, { id: "commission_rules_label", htmlFor: "commission_rules", children: t("taxRegions.fields.targets.label") }),
570
+ /* @__PURE__ */ jsxs(
571
+ Text,
572
+ {
573
+ size: "small",
574
+ leading: "compact",
575
+ className: "text-ui-fg-muted",
576
+ children: [
577
+ "(",
578
+ t("fields.optional"),
579
+ ")"
580
+ ]
581
+ }
582
+ )
583
+ ] }),
584
+ /* @__PURE__ */ jsx(Hint, { id: "commission_rules_description", className: "text-pretty", children: t("taxRegions.fields.targets.hint") })
585
+ ] }),
586
+ showAddButton && /* @__PURE__ */ jsx(
587
+ Button,
588
+ {
589
+ onClick: addRule,
590
+ type: "button",
591
+ size: "small",
592
+ variant: "transparent",
593
+ className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover flex-shrink-0",
594
+ children: t("taxRegions.fields.targets.action")
595
+ }
596
+ )
597
+ ] }),
598
+ /* @__PURE__ */ jsx(
599
+ "div",
600
+ {
601
+ id: "commission_rules",
602
+ "aria-labelledby": "commission_rules_label",
603
+ "aria-describedby": "commission_rules_description",
604
+ role: "application",
605
+ className: "flex flex-col gap-y-3",
606
+ children: visibleRuleTypes.map((ruleType, index) => {
607
+ const type = ruleType.value;
608
+ const label = ruleType.label;
609
+ const isLast = index === visibleRuleTypes.length - 1;
610
+ const searchPlaceholder = searchPlaceholders[type];
611
+ const options = getAvailableRuleTypes(type);
612
+ const modalId = getStackedModalId(type);
613
+ const { fields, remove } = getControls(type);
614
+ const handler = getFieldHandler(type);
615
+ const handleChangeType = (value) => {
616
+ disableRule(type);
617
+ enableRule(value);
618
+ };
619
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
620
+ Form.Field,
621
+ {
622
+ control: form.control,
623
+ name: ruleType.value,
624
+ render: ({
625
+ field: { value: _value, onChange: _onChange, ...field }
626
+ }) => {
627
+ return /* @__PURE__ */ jsxs(Form.Item, { className: "space-y-0", children: [
628
+ /* @__PURE__ */ jsx(Form.Label, { className: "sr-only", children: label }),
629
+ /* @__PURE__ */ jsxs(
630
+ "div",
631
+ {
632
+ className: clx(
633
+ "bg-ui-bg-component shadow-elevation-card-rest transition-fg grid gap-1.5 rounded-xl py-1.5",
634
+ "aria-[invalid='true']:shadow-borders-error"
635
+ ),
636
+ role: "application",
637
+ ...field,
638
+ children: [
639
+ /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle grid gap-1.5 px-1.5 md:grid-cols-2", children: [
640
+ isLast ? /* @__PURE__ */ jsxs(
641
+ Select,
642
+ {
643
+ dir: direction,
644
+ value: type,
645
+ onValueChange: handleChangeType,
646
+ children: [
647
+ /* @__PURE__ */ jsx(Select.Trigger, { className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
648
+ /* @__PURE__ */ jsx(Select.Content, { children: options.map((option) => {
649
+ return /* @__PURE__ */ jsx(
650
+ Select.Item,
651
+ {
652
+ value: option.value,
653
+ children: option.label
654
+ },
655
+ option.value
656
+ );
657
+ }) })
658
+ ]
659
+ }
660
+ ) : /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-field shadow-borders-base txt-compact-small rounded-md px-2 py-1.5", children: label }),
661
+ /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-field shadow-borders-base txt-compact-small rounded-md px-2 py-1.5", children: t("taxRegions.fields.targets.operators.in") })
662
+ ] }),
663
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 px-1.5", children: [
664
+ /* @__PURE__ */ jsxs(StackedDrawer, { id: modalId, children: [
665
+ /* @__PURE__ */ jsx(StackedDrawer.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
666
+ "button",
667
+ {
668
+ type: "button",
669
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover shadow-borders-base txt-compact-small text-ui-fg-muted transition-fg focus-visible:shadow-borders-interactive-with-active flex flex-1 items-center gap-x-2 rounded-md px-2 py-1.5 outline-none",
670
+ children: [
671
+ /* @__PURE__ */ jsx(MagnifyingGlass, {}),
672
+ searchPlaceholder
673
+ ]
674
+ }
675
+ ) }),
676
+ /* @__PURE__ */ jsx(StackedDrawer.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: t("actions.browse") }) }),
677
+ /* @__PURE__ */ jsxs(StackedDrawer.Content, { children: [
678
+ /* @__PURE__ */ jsxs(StackedDrawer.Header, { children: [
679
+ /* @__PURE__ */ jsx(StackedDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: t(
680
+ "taxRegions.fields.targets.modal.header"
681
+ ) }) }),
682
+ /* @__PURE__ */ jsx(StackedDrawer.Description, { className: "sr-only", children: t("taxRegions.fields.targets.hint") })
683
+ ] }),
684
+ /* @__PURE__ */ jsx(
685
+ TargetForm,
686
+ {
687
+ type: "drawer",
688
+ referenceType: type,
689
+ state: fields,
690
+ setState: handler
691
+ }
692
+ )
693
+ ] })
694
+ ] }),
695
+ /* @__PURE__ */ jsx(
696
+ Button,
697
+ {
698
+ variant: "secondary",
699
+ onClick: () => disableRule(type),
700
+ type: "button",
701
+ children: t("actions.delete")
702
+ }
703
+ )
704
+ ] }),
705
+ fields.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1.5", children: [
706
+ /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
707
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-1.5", children: fields.map((field2, index2) => {
708
+ return /* @__PURE__ */ jsx(
709
+ TargetItem,
710
+ {
711
+ index: index2,
712
+ label: field2.label,
713
+ value: field2.value,
714
+ onRemove: remove
715
+ },
716
+ field2.id
717
+ );
718
+ }) })
719
+ ] }) : null
720
+ ]
721
+ }
722
+ ),
723
+ /* @__PURE__ */ jsx(Form.ErrorMessage, { className: "mt-2" })
724
+ ] });
725
+ }
726
+ }
727
+ ) }, type);
728
+ })
729
+ }
730
+ )
731
+ ] })
732
+ ] }),
733
+ /* @__PURE__ */ jsxs(RouteDrawer.Footer, { children: [
734
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
735
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: t("actions.save") })
736
+ ] })
737
+ ]
738
+ }
739
+ ) });
740
+ };
741
+
742
+ // src/pages/commission-rates/commission-rate-edit/commission-rate-edit.tsx
743
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
744
+ var CommissionRateEdit = () => {
745
+ const { id } = useParams();
746
+ const {
747
+ commission_rate,
748
+ isPending: isLoading,
749
+ isError,
750
+ error
751
+ } = useCommissionRate(id, { fields: "*rules" });
752
+ if (isError) {
753
+ throw error;
754
+ }
755
+ return /* @__PURE__ */ jsxs2(RouteDrawer, { children: [
756
+ /* @__PURE__ */ jsx2(RouteDrawer.Header, { children: /* @__PURE__ */ jsx2(Heading2, { children: "Edit Commission Rate" }) }),
757
+ !isLoading && commission_rate && /* @__PURE__ */ jsx2(EditCommissionRateForm, { commissionRate: commission_rate })
758
+ ] });
759
+ };
760
+ export {
761
+ CommissionRateEdit as Component
762
+ };