@mercurjs/admin 2.0.1 → 2.1.0-canary.4

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 (142) hide show
  1. package/dist/{add-campaign-promotions-TA7QC32P.js → add-campaign-promotions-MTQ7OZDE.js} +3 -3
  2. package/dist/{adjust-inventory-W4H5F2JA.js → adjust-inventory-5KY3SJY4.js} +1 -1
  3. package/dist/{api-key-management-detail-LMKKDTRJ.js → api-key-management-detail-D7NH5LTC.js} +1 -1
  4. package/dist/{attribute-create-IRJTPQCF.js → attribute-create-SXEM4KJD.js} +1 -1
  5. package/dist/{attribute-detail-7FLCTP3I.js → attribute-detail-Y3GONKA7.js} +1 -1
  6. package/dist/{attribute-edit-6YNHG3QV.js → attribute-edit-NGJEWLXP.js} +1 -1
  7. package/dist/{attribute-list-C5NS26AD.js → attribute-list-VODH4R2I.js} +1 -1
  8. package/dist/{campaign-detail-E37P67AC.js → campaign-detail-EFU3O644.js} +5 -5
  9. package/dist/{categories-metadata-34L5C2TK.js → categories-metadata-53FPHDOQ.js} +1 -1
  10. package/dist/{category-detail-B23F726Q.js → category-detail-6BSTZK72.js} +3 -3
  11. package/dist/{category-products-2LKOHEWO.js → category-products-SEL2KF5R.js} +2 -2
  12. package/dist/{chunk-HS322YUO.js → chunk-2SNDWSS5.js} +1 -1
  13. package/dist/{chunk-UYKWOC5A.js → chunk-627NOMMX.js} +1 -1
  14. package/dist/{chunk-KERA6OZN.js → chunk-6O25AZDD.js} +1 -1
  15. package/dist/{chunk-RRAIAUBR.js → chunk-7U6RLIWB.js} +1 -1
  16. package/dist/{chunk-BBANQAF4.js → chunk-C4V5XT6K.js} +1 -1
  17. package/dist/{chunk-F7VTQIU7.js → chunk-CZSJ7E5Q.js} +1 -1
  18. package/dist/{chunk-A2TQNJZP.js → chunk-FNHNSA3H.js} +2 -1
  19. package/dist/{chunk-ZFEGVWHT.js → chunk-GZWI6ROZ.js} +38 -6
  20. package/dist/{chunk-QIZUNM6F.js → chunk-HV7ETS5U.js} +1 -1
  21. package/dist/{chunk-EVGVH6CU.js → chunk-JN3XBZHG.js} +1 -1
  22. package/dist/{chunk-6OTK5LAS.js → chunk-L5SYZUAC.js} +1 -1
  23. package/dist/{chunk-LW57KBYK.js → chunk-LVUJDBZC.js} +1 -1
  24. package/dist/{chunk-M3YP3NX4.js → chunk-OVPKR4G7.js} +9 -0
  25. package/dist/{chunk-RVAVU222.js → chunk-PUNC2TLV.js} +1 -1
  26. package/dist/{chunk-WSR2ZXAJ.js → chunk-R2UP4YIY.js} +1 -1
  27. package/dist/{chunk-ZMDE5HEV.js → chunk-RMMKSTB4.js} +32 -4
  28. package/dist/{chunk-MMTCBVUV.js → chunk-TKRQTEWN.js} +1 -1
  29. package/dist/{chunk-AVXOG7CE.js → chunk-VTH3LTDK.js} +1 -1
  30. package/dist/{chunk-G4LGZF5F.js → chunk-VWE3LQEJ.js} +1 -1
  31. package/dist/{chunk-GYKVLGU4.js → chunk-WYJSLRW5.js} +1 -1
  32. package/dist/{chunk-N7QGYSFB.js → chunk-XGCSSCLB.js} +1 -1
  33. package/dist/{chunk-UBS6VEGB.js → chunk-XJHXEWWX.js} +1 -1
  34. package/dist/{chunk-NRKVFULI.js → chunk-XVRT2TFF.js} +353 -116
  35. package/dist/{chunk-CMX37MSO.js → chunk-ZRWRLDAH.js} +1 -1
  36. package/dist/{collection-add-products-RHIQZ37R.js → collection-add-products-4QUC6CYD.js} +2 -2
  37. package/dist/{collection-detail-SJ4ZZLWY.js → collection-detail-YS424JMR.js} +3 -3
  38. package/dist/{collection-list-OFZGXVJA.js → collection-list-4LAFOABI.js} +2 -2
  39. package/dist/{collection-metadata-3CDRKSCP.js → collection-metadata-GA7WIUTG.js} +1 -1
  40. package/dist/{commission-rate-create-OOVFRTYM.js → commission-rate-create-NZY3GFV4.js} +3 -3
  41. package/dist/{commission-rate-detail-5XFV6XH2.js → commission-rate-detail-Z3P43MU7.js} +1 -1
  42. package/dist/{commission-rate-edit-6B4P2GOV.js → commission-rate-edit-EOO7YGWQ.js} +3 -3
  43. package/dist/{customer-detail-Q4K56AZ4.js → customer-detail-EHMESZAY.js} +1 -1
  44. package/dist/{customer-group-detail-NSEFUNCF.js → customer-group-detail-CXVPY32U.js} +1 -1
  45. package/dist/{customer-group-list-GCEKCBUE.js → customer-group-list-L474CRAE.js} +1 -1
  46. package/dist/{customer-group-metadata-LXJK3IMS.js → customer-group-metadata-YO3J3DWX.js} +1 -1
  47. package/dist/{customer-metadata-ZZSCYFHY.js → customer-metadata-T4Y3LP5Y.js} +1 -1
  48. package/dist/{customers-add-customer-group-TIBDJPYF.js → customers-add-customer-group-J7EZP5OJ.js} +1 -1
  49. package/dist/{edit-inventory-item-Y3CIG6L5.js → edit-inventory-item-DBMS75NM.js} +1 -1
  50. package/dist/{edit-inventory-item-attributes-CZNIVWXY.js → edit-inventory-item-attributes-655BP5CZ.js} +1 -1
  51. package/dist/{edit-rules-G7GRUQL6.js → edit-rules-JNV3HBLD.js} +1 -1
  52. package/dist/index.js +157 -156
  53. package/dist/{inventory-create-MFCGCJFB.js → inventory-create-ZHD7BUCH.js} +1 -1
  54. package/dist/{inventory-detail-6V43ZQDK.js → inventory-detail-TQSQQAOS.js} +1 -1
  55. package/dist/{inventory-metadata-PFXMJTSB.js → inventory-metadata-YHRVDL3T.js} +1 -1
  56. package/dist/{inventory-stock-B4FYZAQB.js → inventory-stock-BF2G57RR.js} +1 -1
  57. package/dist/{location-detail-NOUHQA4M.js → location-detail-OMR5VQNR.js} +1 -1
  58. package/dist/{location-fulfillment-providers-A27CQMJN.js → location-fulfillment-providers-LRVFTKYQ.js} +2 -2
  59. package/dist/{location-list-AVCPUKBH.js → location-list-TJWKHGHC.js} +1 -1
  60. package/dist/{location-service-zone-shipping-option-create-DREWJ7SR.js → location-service-zone-shipping-option-create-TE7I3OGE.js} +1 -1
  61. package/dist/{login-QCYKZCZP.js → login-2UEH2J2Z.js} +1 -1
  62. package/dist/{marketplace-detail-CYMZCRWM.js → marketplace-detail-RHJL3RKS.js} +1 -1
  63. package/dist/{marketplace-metadata-LYNL3W6L.js → marketplace-metadata-IPXXRTER.js} +1 -1
  64. package/dist/{order-create-claim-HWZI4OEK.js → order-create-claim-KGBBZAJ4.js} +1 -1
  65. package/dist/{order-create-edit-VIIAC2AA.js → order-create-edit-5IHO5BMD.js} +1 -1
  66. package/dist/{order-create-exchange-KRGBFSCC.js → order-create-exchange-FRKAMGEB.js} +1 -1
  67. package/dist/{order-create-fulfillment-K4LB6U6E.js → order-create-fulfillment-ZXPUXY2M.js} +1 -1
  68. package/dist/{order-create-refund-2OCPOAJS.js → order-create-refund-SBU4PTFE.js} +1 -1
  69. package/dist/{order-create-shipment-BD3DKSJX.js → order-create-shipment-BUDXW54A.js} +1 -1
  70. package/dist/{order-detail-GETGE7YJ.js → order-detail-J7SR4MOZ.js} +2 -2
  71. package/dist/{order-edit-billing-address-3GN3QU4Y.js → order-edit-billing-address-LITRQ5LJ.js} +2 -2
  72. package/dist/{order-edit-email-D6KSNSY4.js → order-edit-email-TACZI5EX.js} +1 -1
  73. package/dist/{order-edit-shipping-address-Z7RP4UBB.js → order-edit-shipping-address-FPTJB5L5.js} +1 -1
  74. package/dist/{order-list-727TI7BS.js → order-list-D44NOK54.js} +2 -2
  75. package/dist/{order-metadata-UCAS6KEK.js → order-metadata-6JOL5X6I.js} +1 -1
  76. package/dist/{order-receive-return-YZGUVELT.js → order-receive-return-5YMKBTQ3.js} +1 -1
  77. package/dist/{order-request-transfer-DBXAIXEG.js → order-request-transfer-LSANIPZ5.js} +1 -1
  78. package/dist/pages/index.d.ts +165 -165
  79. package/dist/pages/index.js +23 -23
  80. package/dist/{price-list-create-SJBCYSRX.js → price-list-create-P5JB34NQ.js} +3 -3
  81. package/dist/{price-list-detail-VA4F6JQJ.js → price-list-detail-Y5GY2XNE.js} +3 -3
  82. package/dist/{price-list-prices-add-BLORGT25.js → price-list-prices-add-3PIDYNA4.js} +3 -3
  83. package/dist/{price-list-prices-edit-7WHKIZHY.js → price-list-prices-edit-DCESLO3A.js} +1 -1
  84. package/dist/{product-create-KEJB3U44.js → product-create-DRZFQDRY.js} +4 -4
  85. package/dist/{product-create-variant-YZODW67L.js → product-create-variant-ZB3IHAFV.js} +1 -1
  86. package/dist/{product-detail-Y24FRUWA.js → product-detail-57X454TL.js} +1 -1
  87. package/dist/{product-export-4G44DDXA.js → product-export-I3PPG7KC.js} +2 -2
  88. package/dist/{product-import-TIPIYEJJ.js → product-import-MNEGYIKE.js} +1 -1
  89. package/dist/{product-list-BLFQWHIA.js → product-list-UZQDS36T.js} +3 -3
  90. package/dist/{product-media-IKMGI2QA.js → product-media-X6GYGJDU.js} +2 -2
  91. package/dist/{product-metadata-SKNZWKWO.js → product-metadata-6P42YQNI.js} +1 -1
  92. package/dist/{product-stock-WIPVYJUH.js → product-stock-P2QSUR4K.js} +1 -1
  93. package/dist/{product-tag-create-3QK7MKMI.js → product-tag-create-QKHJET6O.js} +1 -1
  94. package/dist/{product-tag-detail-LSMLNJW6.js → product-tag-detail-NQGZEEFG.js} +3 -3
  95. package/dist/{product-tag-edit-NHRQ55DX.js → product-tag-edit-TC3UMIAJ.js} +1 -1
  96. package/dist/{product-tag-list-UHBM6KBT.js → product-tag-list-3DLJ3G7X.js} +2 -2
  97. package/dist/{product-tag-metadata-DGH7UF4L.js → product-tag-metadata-DKYMVBXL.js} +1 -1
  98. package/dist/{product-type-detail-GNRN4KTB.js → product-type-detail-VJJITHJS.js} +3 -3
  99. package/dist/{product-type-metadata-NFMNORIB.js → product-type-metadata-I4RC764V.js} +1 -1
  100. package/dist/{product-variant-detail-TGSUSOEB.js → product-variant-detail-Z3BZJ6EJ.js} +1 -1
  101. package/dist/{product-variant-edit-6OJRQWC6.js → product-variant-edit-P3NBX6LJ.js} +1 -1
  102. package/dist/{product-variant-metadata-4MWJAXYI.js → product-variant-metadata-HMBGDFCO.js} +1 -1
  103. package/dist/{promotion-create-CPRWDBDW.js → promotion-create-JMTQ5U53.js} +1 -1
  104. package/dist/{promotion-detail-KGIX6TA2.js → promotion-detail-CWBF3HPU.js} +4 -4
  105. package/dist/{promotion-list-U7PXQLZT.js → promotion-list-JVR5ZF26.js} +4 -4
  106. package/dist/{refund-reason-create-KYM2BCJ2.js → refund-reason-create-H6BJDVQQ.js} +1 -1
  107. package/dist/{refund-reason-edit-JIG7FL7D.js → refund-reason-edit-JXP5LXF6.js} +1 -1
  108. package/dist/{refund-reason-list-IO4INIKF.js → refund-reason-list-O26REP5X.js} +1 -1
  109. package/dist/region-create-NI7QPOS5.js +659 -0
  110. package/dist/{region-edit-75ZVOJ3U.js → region-edit-AGC3N4RU.js} +5 -1
  111. package/dist/{region-metadata-NJUXGJJZ.js → region-metadata-JUTPPKPR.js} +1 -1
  112. package/dist/{reservation-detail-TKILHE26.js → reservation-detail-4EJK3HEF.js} +1 -1
  113. package/dist/{reservation-metadata-V7BLDGSJ.js → reservation-metadata-VOJDR77H.js} +1 -1
  114. package/dist/{reset-password-SXAC55FW.js → reset-password-FCS4752B.js} +1 -1
  115. package/dist/{sales-channel-add-products-27YLUPZP.js → sales-channel-add-products-MOA6UWOB.js} +2 -2
  116. package/dist/{sales-channel-detail-EW2YN7VL.js → sales-channel-detail-RZES4ARA.js} +3 -3
  117. package/dist/{sales-channel-list-JOSLAWUO.js → sales-channel-list-7VVGSGC5.js} +1 -1
  118. package/dist/{sales-channel-metadata-YABMFKT3.js → sales-channel-metadata-U4JWJDUK.js} +1 -1
  119. package/dist/{shipping-option-type-create-KXRPACLG.js → shipping-option-type-create-3S6VXMCK.js} +1 -1
  120. package/dist/{shipping-option-type-detail-KHX2BRFP.js → shipping-option-type-detail-6QINYVWX.js} +1 -1
  121. package/dist/{shipping-option-type-edit-N3L4TPUK.js → shipping-option-type-edit-2JFDG4D5.js} +1 -1
  122. package/dist/{shipping-option-type-list-5A676BZT.js → shipping-option-type-list-FGCS5LGL.js} +1 -1
  123. package/dist/{shipping-profile-metadata-WDM4Y653.js → shipping-profile-metadata-NBCZ3JVM.js} +1 -1
  124. package/dist/{store-address-edit-7BBZSSIP.js → store-address-edit-ATQ6TYQO.js} +1 -1
  125. package/dist/{store-closure-edit-CN5JR4F5.js → store-closure-edit-5KFXHH6R.js} +1 -1
  126. package/dist/{store-create-FUYTHJL5.js → store-create-3S5LJOUB.js} +1 -1
  127. package/dist/{store-details-65JQK3M3.js → store-details-UB3QR3RN.js} +12 -3
  128. package/dist/{store-edit-IQAVLFU5.js → store-edit-O4D6F4SA.js} +3 -3
  129. package/dist/{store-list-DWFAFCKV.js → store-list-35G4TP5I.js} +3 -3
  130. package/dist/{store-member-invite-GAWCXSWL.js → store-member-invite-2SEYT7EL.js} +1 -1
  131. package/dist/{store-payment-details-edit-Z3GLY4TO.js → store-payment-details-edit-DAULPMDU.js} +1 -1
  132. package/dist/{store-professional-details-edit-7KWQOK46.js → store-professional-details-edit-CVQW4R4J.js} +1 -1
  133. package/dist/{tax-region-create-6VHCIPP7.js → tax-region-create-Q6TXHTRE.js} +2 -2
  134. package/dist/{tax-region-detail-AZVNX4QN.js → tax-region-detail-BSLXK42P.js} +1 -1
  135. package/dist/{tax-region-edit-7A6MZBXC.js → tax-region-edit-3FNGCVR2.js} +1 -1
  136. package/dist/{tax-region-metadata-UZYHKPTE.js → tax-region-metadata-WSHLDCN6.js} +1 -1
  137. package/dist/{tax-region-province-detail-7ERAOT3Y.js → tax-region-province-detail-4RV3L5QO.js} +1 -1
  138. package/dist/{tax-region-tax-override-create-TIPPPVTR.js → tax-region-tax-override-create-HEY53Y3G.js} +3 -3
  139. package/dist/{tax-region-tax-override-edit-HDQ4NS5I.js → tax-region-tax-override-edit-6KET7TJP.js} +3 -3
  140. package/dist/{user-metadata-JGCXU4OO.js → user-metadata-JNQQLJAM.js} +1 -1
  141. package/package.json +5 -5
  142. package/dist/region-create-BFA7ATKB.js +0 -508
@@ -0,0 +1,659 @@
1
+ import {
2
+ useCountries,
3
+ useCountryTableColumns,
4
+ useCountryTableQuery
5
+ } from "./chunk-TUJIAA5O.js";
6
+ import {
7
+ formatProvider
8
+ } from "./chunk-VW56KWO2.js";
9
+ import {
10
+ countries
11
+ } from "./chunk-JRTZWK77.js";
12
+ import "./chunk-FQERBIVS.js";
13
+ import {
14
+ _DataTable,
15
+ useDataTable
16
+ } from "./chunk-ULJ3OMWU.js";
17
+ import "./chunk-YBZWO4ZV.js";
18
+ import "./chunk-KAZ5BYTQ.js";
19
+ import "./chunk-3EF54XFY.js";
20
+ import {
21
+ currencies
22
+ } from "./chunk-IQPN4PZJ.js";
23
+ import {
24
+ useComboboxData
25
+ } from "./chunk-AEFDAU3Y.js";
26
+ import {
27
+ Combobox
28
+ } from "./chunk-AW77UWCZ.js";
29
+ import "./chunk-TKGWSUEI.js";
30
+ import {
31
+ KeyboundForm
32
+ } from "./chunk-U2ZFCAPX.js";
33
+ import "./chunk-INNFZYX2.js";
34
+ import {
35
+ useDocumentDirection
36
+ } from "./chunk-Y7QKP6QU.js";
37
+ import "./chunk-KBYZLKI4.js";
38
+ import "./chunk-YWWUOGJA.js";
39
+ import "./chunk-THHRRYRS.js";
40
+ import "./chunk-UZWFZMOX.js";
41
+ import "./chunk-XQNVC4Q7.js";
42
+ import {
43
+ RouteFocusModal,
44
+ StackedFocusModal,
45
+ useRouteModal,
46
+ useStackedModal
47
+ } from "./chunk-OV7R2AH5.js";
48
+ import {
49
+ Form
50
+ } from "./chunk-3QSRE5LS.js";
51
+ import {
52
+ useCreateRegion
53
+ } from "./chunk-W5UPPL3W.js";
54
+ import {
55
+ useStore
56
+ } from "./chunk-LC6TM5OT.js";
57
+ import "./chunk-7SJC6BWZ.js";
58
+ import "./chunk-RHKRREUU.js";
59
+ import "./chunk-ZA2KFUFR.js";
60
+ import {
61
+ sdk
62
+ } from "./chunk-RIN4CBRB.js";
63
+ import "./chunk-NBMM2TZK.js";
64
+
65
+ // src/pages/regions/region-create/components/create-region-form/create-region-form.tsx
66
+ import { zodResolver } from "@hookform/resolvers/zod";
67
+ import { XMarkMini } from "@medusajs/icons";
68
+ import {
69
+ Button,
70
+ Checkbox,
71
+ Heading,
72
+ Input,
73
+ Select,
74
+ Switch,
75
+ Text,
76
+ clx,
77
+ toast
78
+ } from "@medusajs/ui";
79
+ import { createColumnHelper } from "@tanstack/react-table";
80
+ import { useMemo, useState } from "react";
81
+ import { useForm, useWatch } from "react-hook-form";
82
+ import { useTranslation } from "react-i18next";
83
+ import * as zod from "zod";
84
+ import { jsx, jsxs } from "react/jsx-runtime";
85
+ var CreateRegionSchema = zod.object({
86
+ name: zod.string().min(1),
87
+ currency_code: zod.string().min(2, "Select a currency"),
88
+ automatic_taxes: zod.boolean(),
89
+ is_tax_inclusive: zod.boolean(),
90
+ countries: zod.array(zod.object({ code: zod.string(), name: zod.string() })),
91
+ payment_providers: zod.array(zod.string()).min(1)
92
+ });
93
+ var PREFIX = "cr";
94
+ var PAGE_SIZE = 50;
95
+ var STACKED_MODAL_ID = "countries-modal";
96
+ var CreateRegionForm = ({ currencies: currencies2 }) => {
97
+ const { setIsOpen } = useStackedModal();
98
+ const [rowSelection, setRowSelection] = useState({});
99
+ const { handleSuccess } = useRouteModal();
100
+ const direction = useDocumentDirection();
101
+ const form = useForm({
102
+ defaultValues: {
103
+ name: "",
104
+ currency_code: "",
105
+ automatic_taxes: true,
106
+ is_tax_inclusive: false,
107
+ countries: [],
108
+ payment_providers: []
109
+ },
110
+ resolver: zodResolver(CreateRegionSchema)
111
+ });
112
+ const selectedCountries = useWatch({
113
+ control: form.control,
114
+ name: "countries",
115
+ defaultValue: []
116
+ });
117
+ const { t } = useTranslation();
118
+ const { mutateAsync: createRegion, isPending: isPendingRegion } = useCreateRegion();
119
+ const handleSubmit = form.handleSubmit(async (values) => {
120
+ await createRegion(
121
+ {
122
+ name: values.name,
123
+ countries: values.countries.map((c) => c.code),
124
+ currency_code: values.currency_code,
125
+ payment_providers: values.payment_providers,
126
+ automatic_taxes: values.automatic_taxes,
127
+ is_tax_inclusive: values.is_tax_inclusive
128
+ },
129
+ {
130
+ onSuccess: ({ region }) => {
131
+ toast.success(t("regions.toast.create"));
132
+ handleSuccess(`../${region.id}`);
133
+ },
134
+ onError: (e) => {
135
+ toast.error(e.message);
136
+ }
137
+ }
138
+ );
139
+ });
140
+ const { searchParams, raw } = useCountryTableQuery({
141
+ pageSize: PAGE_SIZE,
142
+ prefix: PREFIX
143
+ });
144
+ const { countries: countries2, count } = useCountries({
145
+ countries: countries.map((c, i) => ({
146
+ display_name: c.display_name,
147
+ name: c.name,
148
+ id: i,
149
+ iso_2: c.iso_2,
150
+ iso_3: c.iso_3,
151
+ num_code: c.num_code,
152
+ region_id: null,
153
+ region: {}
154
+ })),
155
+ ...searchParams
156
+ });
157
+ const columns = useColumns();
158
+ const { table } = useDataTable({
159
+ data: countries2 || [],
160
+ columns,
161
+ count,
162
+ enablePagination: true,
163
+ enableRowSelection: true,
164
+ rowSelection: {
165
+ state: rowSelection,
166
+ updater: setRowSelection
167
+ },
168
+ getRowId: (row) => row.iso_2,
169
+ pageSize: PAGE_SIZE,
170
+ prefix: PREFIX
171
+ });
172
+ const saveCountries = () => {
173
+ const selected = Object.keys(rowSelection).filter(
174
+ (key) => rowSelection[key]
175
+ );
176
+ form.setValue(
177
+ "countries",
178
+ selected.map((key) => ({
179
+ code: key,
180
+ name: countries.find((c) => c.iso_2 === key).display_name
181
+ })),
182
+ { shouldDirty: true, shouldTouch: true }
183
+ );
184
+ setIsOpen(STACKED_MODAL_ID, false);
185
+ };
186
+ const removeCountry = (code) => {
187
+ const update = selectedCountries.filter((c) => c.code !== code);
188
+ const ids = update.map((c) => c.code).reduce((acc, c) => {
189
+ acc[c] = true;
190
+ return acc;
191
+ }, {});
192
+ form.setValue("countries", update, {
193
+ shouldDirty: true,
194
+ shouldTouch: true
195
+ });
196
+ setRowSelection(ids);
197
+ };
198
+ const clearCountries = () => {
199
+ form.setValue("countries", [], { shouldDirty: true, shouldTouch: true });
200
+ setRowSelection({});
201
+ };
202
+ const comboboxProviders = useComboboxData({
203
+ queryFn: (params) => sdk.admin.payments.paymentProviders.query({
204
+ ...params,
205
+ is_enabled: true,
206
+ id: []
207
+ }),
208
+ queryKey: ["payment_providers"],
209
+ getOptions: (data) => data.payment_providers.map((pp) => ({
210
+ label: formatProvider(pp.id),
211
+ value: pp.id
212
+ }))
213
+ });
214
+ return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, "data-testid": "region-create-form", children: /* @__PURE__ */ jsxs(
215
+ KeyboundForm,
216
+ {
217
+ className: "flex h-full flex-col overflow-hidden",
218
+ onSubmit: handleSubmit,
219
+ children: [
220
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, { "data-testid": "region-create-form-header" }),
221
+ /* @__PURE__ */ jsx(
222
+ RouteFocusModal.Body,
223
+ {
224
+ className: "flex overflow-hidden",
225
+ "data-testid": "region-create-form-body",
226
+ children: /* @__PURE__ */ jsx(
227
+ "div",
228
+ {
229
+ className: clx(
230
+ "flex h-full w-full flex-col items-center overflow-y-auto p-16"
231
+ ),
232
+ id: "form-section",
233
+ children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
234
+ /* @__PURE__ */ jsxs("div", { "data-testid": "region-create-form-header-section", children: [
235
+ /* @__PURE__ */ jsx(Heading, { "data-testid": "region-create-form-heading", children: t("regions.createRegion") }),
236
+ /* @__PURE__ */ jsx(
237
+ Text,
238
+ {
239
+ size: "small",
240
+ className: "text-ui-fg-subtle",
241
+ "data-testid": "region-create-form-hint",
242
+ children: t("regions.createRegionHint")
243
+ }
244
+ )
245
+ ] }),
246
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
247
+ /* @__PURE__ */ jsx(
248
+ Form.Field,
249
+ {
250
+ control: form.control,
251
+ name: "name",
252
+ render: ({ field }) => {
253
+ return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "region-create-form-name-item", children: [
254
+ /* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-name-label", children: t("fields.name") }),
255
+ /* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-name-control", children: /* @__PURE__ */ jsx(
256
+ Input,
257
+ {
258
+ ...field,
259
+ "data-testid": "region-create-form-name-input"
260
+ }
261
+ ) }),
262
+ /* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-name-error" })
263
+ ] });
264
+ }
265
+ }
266
+ ),
267
+ /* @__PURE__ */ jsx(
268
+ Form.Field,
269
+ {
270
+ control: form.control,
271
+ name: "currency_code",
272
+ render: ({ field: { onChange, ref, ...field } }) => {
273
+ return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "region-create-form-currency-item", children: [
274
+ /* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-currency-label", children: t("fields.currency") }),
275
+ /* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-currency-control", children: /* @__PURE__ */ jsxs(
276
+ Select,
277
+ {
278
+ dir: direction,
279
+ ...field,
280
+ onValueChange: onChange,
281
+ "data-testid": "region-create-form-currency-select",
282
+ children: [
283
+ /* @__PURE__ */ jsx(
284
+ Select.Trigger,
285
+ {
286
+ ref,
287
+ "data-testid": "region-create-form-currency-select-trigger",
288
+ children: /* @__PURE__ */ jsx(Select.Value, {})
289
+ }
290
+ ),
291
+ /* @__PURE__ */ jsx(Select.Content, { "data-testid": "region-create-form-currency-select-content", children: currencies2.map((currency) => /* @__PURE__ */ jsx(
292
+ Select.Item,
293
+ {
294
+ value: currency.code,
295
+ "data-testid": `region-create-form-currency-select-option-${currency.code}`,
296
+ children: currency.name
297
+ },
298
+ currency.code
299
+ )) })
300
+ ]
301
+ }
302
+ ) }),
303
+ /* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-currency-error" })
304
+ ] });
305
+ }
306
+ }
307
+ )
308
+ ] }) }),
309
+ /* @__PURE__ */ jsx(
310
+ Form.Field,
311
+ {
312
+ control: form.control,
313
+ name: "automatic_taxes",
314
+ render: ({ field: { value, onChange, ...field } }) => {
315
+ return /* @__PURE__ */ jsx(Form.Item, { "data-testid": "region-create-form-automatic-taxes-item", children: /* @__PURE__ */ jsxs("div", { children: [
316
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
317
+ /* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-automatic-taxes-label", children: t("fields.automaticTaxes") }),
318
+ /* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-automatic-taxes-control", children: /* @__PURE__ */ jsx(
319
+ Switch,
320
+ {
321
+ dir: "ltr",
322
+ className: "rtl:rotate-180",
323
+ ...field,
324
+ checked: value,
325
+ onCheckedChange: onChange,
326
+ "data-testid": "region-create-form-automatic-taxes-switch"
327
+ }
328
+ ) })
329
+ ] }),
330
+ /* @__PURE__ */ jsx(Form.Hint, { "data-testid": "region-create-form-automatic-taxes-hint", children: t("regions.automaticTaxesHint") }),
331
+ /* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-automatic-taxes-error" })
332
+ ] }) });
333
+ }
334
+ }
335
+ ),
336
+ /* @__PURE__ */ jsx(
337
+ Form.Field,
338
+ {
339
+ control: form.control,
340
+ name: "is_tax_inclusive",
341
+ render: ({ field: { value, onChange, ...field } }) => {
342
+ return /* @__PURE__ */ jsx(Form.Item, { "data-testid": "region-create-form-tax-inclusive-item", children: /* @__PURE__ */ jsxs("div", { children: [
343
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
344
+ /* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-tax-inclusive-label", children: t("fields.taxInclusivePricing") }),
345
+ /* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-tax-inclusive-control", children: /* @__PURE__ */ jsx(
346
+ Switch,
347
+ {
348
+ className: "rtl:rotate-180",
349
+ dir: "ltr",
350
+ ...field,
351
+ checked: value,
352
+ onCheckedChange: onChange,
353
+ "data-testid": "region-create-form-tax-inclusive-switch"
354
+ }
355
+ ) })
356
+ ] }),
357
+ /* @__PURE__ */ jsx(Form.Hint, { "data-testid": "region-create-form-tax-inclusive-hint", children: t("regions.taxInclusiveHint") }),
358
+ /* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-tax-inclusive-error" })
359
+ ] }) });
360
+ }
361
+ }
362
+ ),
363
+ /* @__PURE__ */ jsx("div", { className: "bg-ui-border-base h-px w-full" }),
364
+ /* @__PURE__ */ jsxs(
365
+ "div",
366
+ {
367
+ className: "flex flex-col gap-y-4",
368
+ "data-testid": "region-create-form-countries-section",
369
+ children: [
370
+ /* @__PURE__ */ jsxs("div", { "data-testid": "region-create-form-countries-header", children: [
371
+ /* @__PURE__ */ jsx(
372
+ Text,
373
+ {
374
+ size: "small",
375
+ leading: "compact",
376
+ weight: "plus",
377
+ "data-testid": "region-create-form-countries-label",
378
+ children: t("fields.countries")
379
+ }
380
+ ),
381
+ /* @__PURE__ */ jsx(
382
+ Text,
383
+ {
384
+ size: "small",
385
+ className: "text-ui-fg-subtle",
386
+ "data-testid": "region-create-form-countries-hint",
387
+ children: t("regions.countriesHint")
388
+ }
389
+ )
390
+ ] }),
391
+ selectedCountries.length > 0 && /* @__PURE__ */ jsxs(
392
+ "div",
393
+ {
394
+ className: "flex flex-wrap gap-2",
395
+ "data-testid": "region-create-form-countries-selected",
396
+ children: [
397
+ selectedCountries.map((country) => /* @__PURE__ */ jsx(
398
+ CountryTag,
399
+ {
400
+ country,
401
+ onRemove: removeCountry
402
+ },
403
+ country.code
404
+ )),
405
+ /* @__PURE__ */ jsx(
406
+ Button,
407
+ {
408
+ variant: "transparent",
409
+ size: "small",
410
+ className: "text-ui-fg-muted hover:text-ui-fg-subtle",
411
+ onClick: clearCountries,
412
+ "data-testid": "region-create-form-countries-clear-all-button",
413
+ children: t("actions.clearAll")
414
+ }
415
+ )
416
+ ]
417
+ }
418
+ ),
419
+ /* @__PURE__ */ jsxs(
420
+ StackedFocusModal,
421
+ {
422
+ id: STACKED_MODAL_ID,
423
+ "data-testid": "region-create-form-countries-modal",
424
+ children: [
425
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
426
+ Button,
427
+ {
428
+ variant: "secondary",
429
+ size: "small",
430
+ "data-testid": "region-create-form-countries-add-button",
431
+ children: t("regions.addCountries")
432
+ }
433
+ ) }) }),
434
+ /* @__PURE__ */ jsx(StackedFocusModal.Content, { "data-testid": "region-create-form-countries-modal-content", children: /* @__PURE__ */ jsxs("div", { className: "flex size-full flex-col overflow-hidden", children: [
435
+ /* @__PURE__ */ jsx(StackedFocusModal.Header, { "data-testid": "region-create-form-countries-modal-header", children: /* @__PURE__ */ jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("regions.addCountries") }) }) }),
436
+ /* @__PURE__ */ jsx(
437
+ StackedFocusModal.Body,
438
+ {
439
+ className: "overflow-hidden",
440
+ "data-testid": "region-create-form-countries-modal-body",
441
+ children: /* @__PURE__ */ jsx(
442
+ _DataTable,
443
+ {
444
+ table,
445
+ columns,
446
+ count,
447
+ pageSize: PAGE_SIZE,
448
+ orderBy: [
449
+ { key: "display_name", label: t("fields.name") },
450
+ { key: "iso_2", label: t("fields.code") }
451
+ ],
452
+ pagination: true,
453
+ search: "autofocus",
454
+ layout: "fill",
455
+ queryObject: raw,
456
+ prefix: PREFIX,
457
+ "data-testid": "region-create-form-countries-modal-table"
458
+ }
459
+ )
460
+ }
461
+ ),
462
+ /* @__PURE__ */ jsx(StackedFocusModal.Footer, { "data-testid": "region-create-form-countries-modal-footer", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
463
+ /* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(
464
+ Button,
465
+ {
466
+ variant: "secondary",
467
+ size: "small",
468
+ "data-testid": "region-create-form-countries-modal-cancel-button",
469
+ children: t("actions.cancel")
470
+ }
471
+ ) }),
472
+ /* @__PURE__ */ jsx(
473
+ Button,
474
+ {
475
+ size: "small",
476
+ type: "button",
477
+ onClick: saveCountries,
478
+ "data-testid": "region-create-form-countries-modal-save-button",
479
+ children: t("actions.save")
480
+ }
481
+ )
482
+ ] }) })
483
+ ] }) })
484
+ ]
485
+ }
486
+ )
487
+ ]
488
+ }
489
+ ),
490
+ /* @__PURE__ */ jsx("div", { className: "bg-ui-border-base h-px w-full" }),
491
+ /* @__PURE__ */ jsxs(
492
+ "div",
493
+ {
494
+ className: "flex flex-col gap-y-4",
495
+ "data-testid": "region-create-form-payment-providers-section",
496
+ children: [
497
+ /* @__PURE__ */ jsxs("div", { "data-testid": "region-create-form-payment-providers-header", children: [
498
+ /* @__PURE__ */ jsx(
499
+ Text,
500
+ {
501
+ size: "small",
502
+ leading: "compact",
503
+ weight: "plus",
504
+ "data-testid": "region-create-form-payment-providers-label",
505
+ children: t("fields.providers")
506
+ }
507
+ ),
508
+ /* @__PURE__ */ jsx(
509
+ Text,
510
+ {
511
+ size: "small",
512
+ className: "text-ui-fg-subtle",
513
+ "data-testid": "region-create-form-payment-providers-hint",
514
+ children: t("regions.providersHint")
515
+ }
516
+ )
517
+ ] }),
518
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: /* @__PURE__ */ jsx(
519
+ Form.Field,
520
+ {
521
+ control: form.control,
522
+ name: "payment_providers",
523
+ render: ({ field }) => {
524
+ return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "region-create-form-payment-providers-item", children: [
525
+ /* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-payment-providers-item-label", children: t("fields.paymentProviders") }),
526
+ /* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-payment-providers-item-control", children: /* @__PURE__ */ jsx(
527
+ Combobox,
528
+ {
529
+ forceHideInput: true,
530
+ options: comboboxProviders.options,
531
+ fetchNextPage: comboboxProviders.fetchNextPage,
532
+ ...field,
533
+ "data-testid": "region-create-form-payment-providers-combobox"
534
+ }
535
+ ) }),
536
+ /* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-payment-providers-item-error" })
537
+ ] });
538
+ }
539
+ }
540
+ ) })
541
+ ]
542
+ }
543
+ )
544
+ ] })
545
+ }
546
+ )
547
+ }
548
+ ),
549
+ /* @__PURE__ */ jsxs(RouteFocusModal.Footer, { "data-testid": "region-create-form-footer", children: [
550
+ /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(
551
+ Button,
552
+ {
553
+ size: "small",
554
+ variant: "secondary",
555
+ "data-testid": "region-create-form-cancel-button",
556
+ children: t("actions.cancel")
557
+ }
558
+ ) }),
559
+ /* @__PURE__ */ jsx(
560
+ Button,
561
+ {
562
+ size: "small",
563
+ type: "submit",
564
+ isLoading: isPendingRegion,
565
+ "data-testid": "region-create-form-save-button",
566
+ children: t("actions.save")
567
+ }
568
+ )
569
+ ] })
570
+ ]
571
+ }
572
+ ) });
573
+ };
574
+ var columnHelper = createColumnHelper();
575
+ var useColumns = () => {
576
+ const base = useCountryTableColumns();
577
+ return useMemo(
578
+ () => [
579
+ columnHelper.display({
580
+ id: "select",
581
+ header: ({ table }) => {
582
+ return /* @__PURE__ */ jsx(
583
+ Checkbox,
584
+ {
585
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
586
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value),
587
+ "data-testid": "region-create-form-countries-modal-select-all-checkbox"
588
+ }
589
+ );
590
+ },
591
+ cell: ({ row }) => {
592
+ const isPreselected = !row.getCanSelect();
593
+ return /* @__PURE__ */ jsx(
594
+ Checkbox,
595
+ {
596
+ checked: row.getIsSelected() || isPreselected,
597
+ disabled: isPreselected,
598
+ onCheckedChange: (value) => row.toggleSelected(!!value),
599
+ onClick: (e) => {
600
+ e.stopPropagation();
601
+ },
602
+ "data-testid": `region-create-form-countries-modal-select-checkbox-${row.original.iso_2}`
603
+ }
604
+ );
605
+ }
606
+ }),
607
+ ...base
608
+ ],
609
+ [base]
610
+ );
611
+ };
612
+ var CountryTag = ({
613
+ country,
614
+ onRemove
615
+ }) => {
616
+ return /* @__PURE__ */ jsxs(
617
+ "div",
618
+ {
619
+ className: "bg-ui-bg-field shadow-borders-base transition-fg hover:bg-ui-bg-field-hover flex h-7 items-center overflow-hidden rounded-md",
620
+ "data-testid": `region-create-form-country-tag-${country.code}`,
621
+ children: [
622
+ /* @__PURE__ */ jsx(
623
+ "div",
624
+ {
625
+ className: "txt-compact-small-plus flex h-full select-none items-center justify-center px-2 py-0.5",
626
+ "data-testid": `region-create-form-country-tag-${country.code}-name`,
627
+ children: country.name
628
+ }
629
+ ),
630
+ /* @__PURE__ */ jsx(
631
+ "button",
632
+ {
633
+ type: "button",
634
+ onClick: () => onRemove(country.code),
635
+ className: "focus-visible:bg-ui-bg-field-hover transition-fg hover:bg-ui-bg-field-hover flex h-full w-7 items-center justify-center border-l outline-none",
636
+ "data-testid": `region-create-form-country-tag-${country.code}-remove-button`,
637
+ children: /* @__PURE__ */ jsx(XMarkMini, { className: "text-ui-fg-muted" })
638
+ }
639
+ )
640
+ ]
641
+ }
642
+ );
643
+ };
644
+
645
+ // src/pages/regions/region-create/region-create.tsx
646
+ import { jsx as jsx2 } from "react/jsx-runtime";
647
+ var RegionCreate = () => {
648
+ const { store, isPending: isLoading, isError, error } = useStore();
649
+ const storeCurrencies = (store?.supported_currencies ?? []).map(
650
+ (c) => currencies[c.currency_code.toUpperCase()]
651
+ );
652
+ if (isError) {
653
+ throw error;
654
+ }
655
+ return /* @__PURE__ */ jsx2(RouteFocusModal, { "data-testid": "region-create-modal", children: !isLoading && store && /* @__PURE__ */ jsx2(CreateRegionForm, { currencies: storeCurrencies }) });
656
+ };
657
+ export {
658
+ RegionCreate as Component
659
+ };
@@ -80,7 +80,11 @@ var EditRegionForm = ({
80
80
  });
81
81
  const comboboxProviders = useComboboxData({
82
82
  queryKey: ["payment_providers"],
83
- queryFn: (params) => sdk.admin.payment.listPaymentProviders({ ...params, is_enabled: true }),
83
+ queryFn: (params) => sdk.admin.payments.paymentProviders.query({
84
+ ...params,
85
+ is_enabled: true,
86
+ id: []
87
+ }),
84
88
  getOptions: (data) => data.payment_providers.map((pp) => ({
85
89
  label: formatProvider(pp.id),
86
90
  value: pp.id
@@ -29,7 +29,7 @@ import "./chunk-K4BGK3CO.js";
29
29
  import "./chunk-YYTI5JIC.js";
30
30
  import "./chunk-HAFZQK53.js";
31
31
  import "./chunk-IJWG755C.js";
32
- import "./chunk-M3YP3NX4.js";
32
+ import "./chunk-OVPKR4G7.js";
33
33
  import "./chunk-UU2RQMXS.js";
34
34
  import "./chunk-O4STPJR2.js";
35
35
  import "./chunk-R74OHYTB.js";