@medusajs/dashboard 2.10.4-snapshot-20250925172615 → 2.10.4-snapshot-20250925183036

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 (115) hide show
  1. package/dist/{api-key-management-detail-MM673US3.mjs → api-key-management-detail-ZQLQKGYF.mjs} +1 -2
  2. package/dist/app.js +176 -171
  3. package/dist/app.mjs +2 -3
  4. package/dist/{campaign-detail-G2VM7CRL.mjs → campaign-detail-LASOFZ2O.mjs} +1 -2
  5. package/dist/{categories-metadata-M4PAATNV.mjs → categories-metadata-HUIY6V4F.mjs} +1 -2
  6. package/dist/{category-detail-MTLPW4MR.mjs → category-detail-ZJJBYVFX.mjs} +2 -3
  7. package/dist/{category-products-DGWKONYE.mjs → category-products-7N4TITQ4.mjs} +2 -3
  8. package/dist/{chunk-I2QEZTVU.mjs → chunk-5WMJLYEP.mjs} +1 -1
  9. package/dist/{chunk-CGEJJR5K.mjs → chunk-7DFTLGA5.mjs} +101 -101
  10. package/dist/{chunk-IXMPYDY2.mjs → chunk-CXTAH75K.mjs} +1 -1
  11. package/dist/{chunk-CD7VQIPA.mjs → chunk-OFN7DIZA.mjs} +8 -4
  12. package/dist/{chunk-EILZIUOP.mjs → chunk-PAG2HG6I.mjs} +44 -0
  13. package/dist/{chunk-MAKOUE5W.mjs → chunk-QPLPGRYF.mjs} +1 -1
  14. package/dist/{chunk-G3VGLFVH.mjs → chunk-RBDAWRFF.mjs} +1 -1
  15. package/dist/{chunk-5FAWKUSU.mjs → chunk-VI7MI3US.mjs} +1 -1
  16. package/dist/{chunk-HOERC634.mjs → chunk-VWQYN2RW.mjs} +1 -1
  17. package/dist/{chunk-A4GWVZB4.mjs → chunk-XR7I5HGZ.mjs} +1 -1
  18. package/dist/{collection-add-products-KEB3ESAK.mjs → collection-add-products-WKMNYPLS.mjs} +2 -3
  19. package/dist/{collection-detail-V24IDEZQ.mjs → collection-detail-NONKXELG.mjs} +2 -3
  20. package/dist/{collection-list-GD2IJYOP.mjs → collection-list-3ZHLS2LP.mjs} +2 -3
  21. package/dist/{collection-metadata-Z2JMXTHW.mjs → collection-metadata-J6P3K7U6.mjs} +1 -2
  22. package/dist/{customer-detail-E7LPLLML.mjs → customer-detail-5Y7ICDMA.mjs} +1 -2
  23. package/dist/{customer-group-detail-5ZWHOJOD.mjs → customer-group-detail-PXP73BFA.mjs} +1 -2
  24. package/dist/{customer-group-list-N22GDJVL.mjs → customer-group-list-3DB643XQ.mjs} +1 -2
  25. package/dist/{customers-add-customer-group-LFEUVS5G.mjs → customers-add-customer-group-BVUVU46N.mjs} +1 -2
  26. package/dist/{edit-rules-BCGRJ4FJ.mjs → edit-rules-3MSTPCE5.mjs} +3 -4
  27. package/dist/{inventory-create-OPYAZF3M.mjs → inventory-create-NEYX7PZJ.mjs} +1 -2
  28. package/dist/{inventory-detail-PAVP7J2W.mjs → inventory-detail-66HDQL3W.mjs} +1 -2
  29. package/dist/{inventory-metadata-PMQLZCHW.mjs → inventory-metadata-OSTUWM23.mjs} +1 -2
  30. package/dist/{inventory-stock-7QXMAX45.mjs → inventory-stock-XY2OCAY3.mjs} +1 -2
  31. package/dist/{location-detail-IXHZ7DZS.mjs → location-detail-UZHD3IKW.mjs} +1 -2
  32. package/dist/{location-fulfillment-providers-3KPC4HQT.mjs → location-fulfillment-providers-D4RMKQXU.mjs} +2 -3
  33. package/dist/{location-service-zone-shipping-option-create-PVQ66CXW.mjs → location-service-zone-shipping-option-create-OASLL2K7.mjs} +2 -3
  34. package/dist/{location-service-zone-shipping-option-edit-JYM6GHTA.mjs → location-service-zone-shipping-option-edit-DOCLZOO7.mjs} +1 -1
  35. package/dist/{login-DVYOEF5F.mjs → login-LQRL2ZDY.mjs} +1 -2
  36. package/dist/{order-create-claim-FK4LIPAE.mjs → order-create-claim-7UF734QH.mjs} +2 -3
  37. package/dist/{order-create-edit-VGIWYKBB.mjs → order-create-edit-MZHUVTGE.mjs} +1 -2
  38. package/dist/{order-create-exchange-BMRCMN5G.mjs → order-create-exchange-2UGEF65S.mjs} +2 -3
  39. package/dist/{order-create-fulfillment-NLGPRK4J.mjs → order-create-fulfillment-HGJ2YPUB.mjs} +2 -3
  40. package/dist/{order-create-refund-TEMK6IEQ.mjs → order-create-refund-CJDKVBSE.mjs} +3 -5
  41. package/dist/{order-create-return-6FHAU3OZ.mjs → order-create-return-5IPRHHLJ.mjs} +1 -1
  42. package/dist/{order-create-shipment-WCEZXWM6.mjs → order-create-shipment-3FDVQ6WT.mjs} +1 -2
  43. package/dist/{order-detail-QABTBPGX.mjs → order-detail-SEPCRJW5.mjs} +2 -4
  44. package/dist/{order-edit-billing-address-MWF3L6GK.mjs → order-edit-billing-address-J75NQFRY.mjs} +1 -2
  45. package/dist/{order-edit-email-UDJOGYPP.mjs → order-edit-email-ABFQKE6A.mjs} +1 -2
  46. package/dist/{order-edit-shipping-address-O46U65WM.mjs → order-edit-shipping-address-OXW7TAJD.mjs} +1 -2
  47. package/dist/{order-metadata-SHCFZWCA.mjs → order-metadata-5NF3ICQL.mjs} +1 -2
  48. package/dist/{order-receive-return-MC4DIRK3.mjs → order-receive-return-IM65P7XQ.mjs} +1 -2
  49. package/dist/{order-request-transfer-MELQKMC4.mjs → order-request-transfer-LZ25KEDA.mjs} +2 -3
  50. package/dist/{price-list-create-TZUDGP2J.mjs → price-list-create-EC5VGCMW.mjs} +2 -3
  51. package/dist/{price-list-detail-DX74DH6G.mjs → price-list-detail-CRTJA5O4.mjs} +2 -3
  52. package/dist/{price-list-prices-add-IHMS7HIH.mjs → price-list-prices-add-HYCM4QDY.mjs} +2 -3
  53. package/dist/{product-attributes-AULEVQ5C.mjs → product-attributes-WVQRK3GQ.mjs} +3 -4
  54. package/dist/{product-create-2RPJZR2Q.mjs → product-create-PWSPOVUS.mjs} +3 -4
  55. package/dist/{product-create-variant-NKU6J7NG.mjs → product-create-variant-V2QGXFEF.mjs} +2 -3
  56. package/dist/{product-detail-NNTUGXU5.mjs → product-detail-EBPCCBI4.mjs} +3 -4
  57. package/dist/{product-edit-6WRMNGPM.mjs → product-edit-5E6D43KE.mjs} +3 -4
  58. package/dist/{product-export-W6KP2RGO.mjs → product-export-VFC3I5DK.mjs} +2 -3
  59. package/dist/{product-import-P76MITMC.mjs → product-import-V7EZJ2TU.mjs} +1 -2
  60. package/dist/{product-list-7H64APWI.mjs → product-list-FFZO57JG.mjs} +2 -3
  61. package/dist/{product-metadata-2G6DWHWG.mjs → product-metadata-VYQ65KYI.mjs} +1 -2
  62. package/dist/{product-organization-43YS5OUI.mjs → product-organization-OCVSTKEK.mjs} +4 -5
  63. package/dist/{product-shipping-profile-SFU2PVR4.mjs → product-shipping-profile-SG6NDHF4.mjs} +4 -5
  64. package/dist/{product-stock-GAWLELSE.mjs → product-stock-LJRYRSKN.mjs} +1 -2
  65. package/dist/{product-tag-create-FVU5JRL3.mjs → product-tag-create-EB5CVUOP.mjs} +1 -2
  66. package/dist/{product-tag-detail-VMVPWMZK.mjs → product-tag-detail-V5CZY4R4.mjs} +3 -4
  67. package/dist/{product-tag-edit-OWI3OFVF.mjs → product-tag-edit-YATSW5OK.mjs} +1 -2
  68. package/dist/{product-tag-list-YPIZII2D.mjs → product-tag-list-2LFGEFGL.mjs} +3 -4
  69. package/dist/{product-tag-metadata-B4YBSHOH.mjs → product-tag-metadata-R5P5FWAZ.mjs} +1 -2
  70. package/dist/{product-type-detail-243HFRBD.mjs → product-type-detail-BZNI5GJ5.mjs} +2 -3
  71. package/dist/{product-type-metadata-4YE4UEOF.mjs → product-type-metadata-SUQHWLWA.mjs} +1 -2
  72. package/dist/{product-variant-detail-LJE3IFNE.mjs → product-variant-detail-W2JHQQQJ.mjs} +1 -2
  73. package/dist/{product-variant-edit-IGJIWVQQ.mjs → product-variant-edit-DSY77FF4.mjs} +2 -3
  74. package/dist/{product-variant-manage-inventory-items-2M2KTPNK.mjs → product-variant-manage-inventory-items-JH65NAD4.mjs} +1 -1
  75. package/dist/{product-variant-metadata-F6BGFMMS.mjs → product-variant-metadata-HE3MRTJB.mjs} +1 -2
  76. package/dist/{promotion-add-campaign-YREHV6TQ.mjs → promotion-add-campaign-YOUUM6RB.mjs} +2 -2
  77. package/dist/{promotion-create-YGHBTAFC.mjs → promotion-create-NBFV4XQV.mjs} +4 -5
  78. package/dist/{promotion-detail-BIC23HFR.mjs → promotion-detail-247QD6DA.mjs} +1 -2
  79. package/dist/{refund-reason-create-YCWLRRBW.mjs → refund-reason-create-45ZZOX7F.mjs} +1 -2
  80. package/dist/{refund-reason-list-7GANH7KL.mjs → refund-reason-list-WI7NHRDS.mjs} +1 -2
  81. package/dist/{region-create-AFZTSM3N.mjs → region-create-AV2NJNNJ.mjs} +20 -26
  82. package/dist/region-edit-X7CSUICV.mjs +308 -0
  83. package/dist/{region-metadata-L5K6YENH.mjs → region-metadata-3JIGHAUI.mjs} +1 -2
  84. package/dist/{reservation-create-FV7QXGL3.mjs → reservation-create-FKBCGQA7.mjs} +1 -1
  85. package/dist/{reservation-detail-USDAVGWH.mjs → reservation-detail-FENCNQDA.mjs} +1 -2
  86. package/dist/{reservation-metadata-47C6RWYS.mjs → reservation-metadata-DQ3A7MHU.mjs} +1 -2
  87. package/dist/{sales-channel-add-products-NGPN4IRB.mjs → sales-channel-add-products-G4EUOCWY.mjs} +2 -3
  88. package/dist/{sales-channel-detail-IWWRX2Y3.mjs → sales-channel-detail-NT7PEVVH.mjs} +2 -3
  89. package/dist/{sales-channel-list-LCPDOQK3.mjs → sales-channel-list-REV2RETE.mjs} +1 -2
  90. package/dist/{sales-channel-metadata-VZ4TINYG.mjs → sales-channel-metadata-O5O6ADG5.mjs} +1 -2
  91. package/dist/{shipping-option-type-create-NOMFII5B.mjs → shipping-option-type-create-7FSJNHHA.mjs} +1 -2
  92. package/dist/{shipping-option-type-detail-6XIJRVZ5.mjs → shipping-option-type-detail-6UQST7RY.mjs} +2 -3
  93. package/dist/{shipping-option-type-edit-PEDYL6JQ.mjs → shipping-option-type-edit-B475WRRR.mjs} +1 -2
  94. package/dist/{shipping-option-type-list-GI5GBLIS.mjs → shipping-option-type-list-DTETSFSA.mjs} +2 -3
  95. package/dist/{shipping-profile-metadata-ZOR7MQFF.mjs → shipping-profile-metadata-PRINFNSY.mjs} +1 -2
  96. package/dist/{store-detail-MZAKRCTC.mjs → store-detail-QKF2TVNW.mjs} +1 -2
  97. package/dist/{store-edit-3DU5MC25.mjs → store-edit-ZPGTNZGL.mjs} +1 -1
  98. package/dist/{store-metadata-GO4TXB3W.mjs → store-metadata-M6GIKI5P.mjs} +1 -2
  99. package/dist/{tax-region-create-KDCNQGPC.mjs → tax-region-create-4DTM3RTZ.mjs} +2 -3
  100. package/dist/{tax-region-detail-O6U6ZVDB.mjs → tax-region-detail-SLCI3JYL.mjs} +1 -2
  101. package/dist/{tax-region-edit-T4B5DM55.mjs → tax-region-edit-CJ63JXFQ.mjs} +2 -3
  102. package/dist/{tax-region-province-detail-XH45ZAOJ.mjs → tax-region-province-detail-BGL2USQF.mjs} +1 -2
  103. package/dist/{tax-region-tax-override-create-MSL7HEM6.mjs → tax-region-tax-override-create-L4WOTSBO.mjs} +3 -4
  104. package/dist/{tax-region-tax-override-edit-AO6CYS62.mjs → tax-region-tax-override-edit-2JAVNE37.mjs} +3 -4
  105. package/dist/{user-metadata-2CR2AK3U.mjs → user-metadata-DFTGB46F.mjs} +1 -2
  106. package/dist/{workflow-execution-detail-ZD7OVL4W.mjs → workflow-execution-detail-YNT2RKIP.mjs} +1 -2
  107. package/package.json +9 -9
  108. package/src/components/inputs/combobox/combobox.tsx +11 -4
  109. package/src/hooks/api/payments.tsx +6 -1
  110. package/src/routes/regions/region-create/components/create-region-form/create-region-form.tsx +18 -10
  111. package/src/routes/regions/region-create/region-create.tsx +1 -10
  112. package/src/routes/regions/region-edit/components/edit-region-form/edit-region-form.tsx +21 -8
  113. package/src/routes/regions/region-edit/region-edit.tsx +0 -5
  114. package/dist/chunk-EA5GGT2Q.mjs +0 -64
  115. package/dist/region-edit-DSYIUI7W.mjs +0 -301
@@ -17,7 +17,7 @@ import { useForm, useWatch } from "react-hook-form"
17
17
  import { useTranslation } from "react-i18next"
18
18
  import * as zod from "zod"
19
19
 
20
- import { PaymentProviderDTO, RegionCountryDTO } from "@medusajs/types"
20
+ import { RegionCountryDTO } from "@medusajs/types"
21
21
 
22
22
  import { Form } from "../../../../../components/common/form"
23
23
  import { Combobox } from "../../../../../components/inputs/combobox"
@@ -38,10 +38,11 @@ import { useCountries } from "../../../common/hooks/use-countries"
38
38
  import { useCountryTableColumns } from "../../../common/hooks/use-country-table-columns"
39
39
  import { useCountryTableQuery } from "../../../common/hooks/use-country-table-query"
40
40
  import { useDocumentDirection } from "../../../../../hooks/use-document-direction"
41
+ import { useComboboxData } from "../../../../../hooks/use-combobox-data"
42
+ import { sdk } from "../../../../../lib/client"
41
43
 
42
44
  type CreateRegionFormProps = {
43
45
  currencies: CurrencyInfo[]
44
- paymentProviders: PaymentProviderDTO[]
45
46
  }
46
47
 
47
48
  const CreateRegionSchema = zod.object({
@@ -58,10 +59,7 @@ const PAGE_SIZE = 50
58
59
 
59
60
  const STACKED_MODAL_ID = "countries-modal"
60
61
 
61
- export const CreateRegionForm = ({
62
- currencies,
63
- paymentProviders,
64
- }: CreateRegionFormProps) => {
62
+ export const CreateRegionForm = ({ currencies }: CreateRegionFormProps) => {
65
63
  const { setIsOpen } = useStackedModal()
66
64
  const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
67
65
  const { handleSuccess } = useRouteModal()
@@ -181,6 +179,17 @@ export const CreateRegionForm = ({
181
179
  setRowSelection({})
182
180
  }
183
181
 
182
+ const comboboxProviders = useComboboxData({
183
+ queryFn: (params) =>
184
+ sdk.admin.payment.listPaymentProviders({ ...params, is_enabled: true }),
185
+ queryKey: ["payment_providers"],
186
+ getOptions: (data) =>
187
+ data.payment_providers.map((pp) => ({
188
+ label: formatProvider(pp.id),
189
+ value: pp.id,
190
+ })),
191
+ })
192
+
184
193
  return (
185
194
  <RouteFocusModal.Form form={form}>
186
195
  <KeyboundForm
@@ -415,10 +424,9 @@ export const CreateRegionForm = ({
415
424
  </Form.Label>
416
425
  <Form.Control>
417
426
  <Combobox
418
- options={paymentProviders.map((pp) => ({
419
- label: formatProvider(pp.id),
420
- value: pp.id,
421
- }))}
427
+ forceHideInput
428
+ options={comboboxProviders.options}
429
+ fetchNextPage={comboboxProviders.fetchNextPage}
422
430
  {...field}
423
431
  />
424
432
  </Form.Control>
@@ -1,5 +1,4 @@
1
1
  import { RouteFocusModal } from "../../../components/modals/route-focus-modal"
2
- import { usePaymentProviders } from "../../../hooks/api/payments"
3
2
  import { useStore } from "../../../hooks/api/store"
4
3
  import { currencies } from "../../../lib/data/currencies"
5
4
  import { CreateRegionForm } from "./components/create-region-form"
@@ -10,9 +9,6 @@ export const RegionCreate = () => {
10
9
  const storeCurrencies = (store?.supported_currencies ?? []).map(
11
10
  (c) => currencies[c.currency_code.toUpperCase()]
12
11
  )
13
- const { payment_providers: paymentProviders = [] } = usePaymentProviders({
14
- is_enabled: true,
15
- })
16
12
 
17
13
  if (isError) {
18
14
  throw error
@@ -20,12 +16,7 @@ export const RegionCreate = () => {
20
16
 
21
17
  return (
22
18
  <RouteFocusModal>
23
- {!isLoading && store && (
24
- <CreateRegionForm
25
- currencies={storeCurrencies}
26
- paymentProviders={paymentProviders}
27
- />
28
- )}
19
+ {!isLoading && store && <CreateRegionForm currencies={storeCurrencies} />}
29
20
  </RouteFocusModal>
30
21
  )
31
22
  }
@@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next"
5
5
  import * as zod from "zod"
6
6
 
7
7
  import { Form } from "../../../../../components/common/form/index.ts"
8
- import { Combobox } from "../../../../../components/inputs/combobox/index.ts"
8
+ import { Combobox } from "../../../../../components/inputs/combobox"
9
9
  import {
10
10
  RouteDrawer,
11
11
  useRouteModal,
@@ -15,11 +15,12 @@ import { useUpdateRegion } from "../../../../../hooks/api/regions.tsx"
15
15
  import { CurrencyInfo } from "../../../../../lib/data/currencies.ts"
16
16
  import { formatProvider } from "../../../../../lib/format-provider.ts"
17
17
  import { useDocumentDirection } from "../../../../../hooks/use-document-direction"
18
+ import { useComboboxData } from "../../../../../hooks/use-combobox-data.tsx"
19
+ import { sdk } from "../../../../../lib/client/index.ts"
18
20
 
19
21
  type EditRegionFormProps = {
20
22
  region: HttpTypes.AdminRegion
21
23
  currencies: CurrencyInfo[]
22
- paymentProviders: PaymentProviderDTO[]
23
24
  pricePreferences: HttpTypes.AdminPricePreference[]
24
25
  }
25
26
 
@@ -34,7 +35,6 @@ const EditRegionSchema = zod.object({
34
35
  export const EditRegionForm = ({
35
36
  region,
36
37
  currencies,
37
- paymentProviders,
38
38
  pricePreferences,
39
39
  }: EditRegionFormProps) => {
40
40
  const { t } = useTranslation()
@@ -54,6 +54,17 @@ export const EditRegionForm = ({
54
54
  },
55
55
  })
56
56
 
57
+ const comboboxProviders = useComboboxData({
58
+ queryKey: ["payment_providers"],
59
+ queryFn: (params) =>
60
+ sdk.admin.payment.listPaymentProviders({ ...params, is_enabled: true }),
61
+ getOptions: (data) =>
62
+ data.payment_providers.map((pp) => ({
63
+ label: formatProvider(pp.id),
64
+ value: pp.id,
65
+ })),
66
+ })
67
+
57
68
  const { mutateAsync: updateRegion, isPending: isPendingRegion } =
58
69
  useUpdateRegion(region.id)
59
70
 
@@ -80,7 +91,10 @@ export const EditRegionForm = ({
80
91
 
81
92
  return (
82
93
  <RouteDrawer.Form form={form}>
83
- <KeyboundForm onSubmit={handleSubmit} className="flex flex-1 flex-col overflow-hidden">
94
+ <KeyboundForm
95
+ onSubmit={handleSubmit}
96
+ className="flex flex-1 flex-col overflow-hidden"
97
+ >
84
98
  <RouteDrawer.Body className="overflow-y-auto">
85
99
  <div className="flex flex-col gap-y-8">
86
100
  <div className="flex flex-col gap-y-4">
@@ -205,10 +219,9 @@ export const EditRegionForm = ({
205
219
  <Form.Label>{t("fields.paymentProviders")}</Form.Label>
206
220
  <Form.Control>
207
221
  <Combobox
208
- options={paymentProviders.map((pp) => ({
209
- label: formatProvider(pp.id),
210
- value: pp.id,
211
- }))}
222
+ forceHideInput
223
+ options={comboboxProviders.options}
224
+ fetchNextPage={comboboxProviders.fetchNextPage}
212
225
  {...field}
213
226
  />
214
227
  </Form.Control>
@@ -48,10 +48,6 @@ export const RegionEdit = () => {
48
48
  const storeCurrencies = (store?.supported_currencies ?? []).map(
49
49
  (c) => currencies[c.currency_code.toUpperCase()]
50
50
  )
51
- const { payment_providers: paymentProviders = [] } = usePaymentProviders({
52
- limit: 999,
53
- is_enabled: true,
54
- })
55
51
 
56
52
  if (isRegionError) {
57
53
  throw regionError
@@ -74,7 +70,6 @@ export const RegionEdit = () => {
74
70
  <EditRegionForm
75
71
  region={region}
76
72
  currencies={storeCurrencies}
77
- paymentProviders={paymentProviders}
78
73
  pricePreferences={pricePreferences}
79
74
  />
80
75
  )}
@@ -1,64 +0,0 @@
1
- import {
2
- ordersQueryKeys
3
- } from "./chunk-U25RCIX2.mjs";
4
- import {
5
- queryClient
6
- } from "./chunk-FXYH54JP.mjs";
7
- import {
8
- queryKeysFactory
9
- } from "./chunk-774WSTCC.mjs";
10
- import {
11
- sdk
12
- } from "./chunk-DEQUVHHE.mjs";
13
-
14
- // src/hooks/api/payments.tsx
15
- import {
16
- useMutation,
17
- useQuery
18
- } from "@tanstack/react-query";
19
- var PAYMENT_QUERY_KEY = "payment";
20
- var paymentQueryKeys = queryKeysFactory(PAYMENT_QUERY_KEY);
21
- var usePaymentProviders = (query, options) => {
22
- const { data, ...rest } = useQuery({
23
- queryFn: async () => sdk.admin.payment.listPaymentProviders(query),
24
- queryKey: [],
25
- ...options
26
- });
27
- return { ...data, ...rest };
28
- };
29
- var useCapturePayment = (orderId, paymentId, options) => {
30
- return useMutation({
31
- mutationFn: (payload) => sdk.admin.payment.capture(paymentId, payload),
32
- onSuccess: (data, variables, context) => {
33
- queryClient.invalidateQueries({
34
- queryKey: ordersQueryKeys.details()
35
- });
36
- queryClient.invalidateQueries({
37
- queryKey: ordersQueryKeys.preview(orderId)
38
- });
39
- options?.onSuccess?.(data, variables, context);
40
- },
41
- ...options
42
- });
43
- };
44
- var useRefundPayment = (orderId, paymentId, options) => {
45
- return useMutation({
46
- mutationFn: (payload) => sdk.admin.payment.refund(paymentId, payload),
47
- onSuccess: (data, variables, context) => {
48
- queryClient.invalidateQueries({
49
- queryKey: ordersQueryKeys.details()
50
- });
51
- queryClient.invalidateQueries({
52
- queryKey: ordersQueryKeys.preview(orderId)
53
- });
54
- options?.onSuccess?.(data, variables, context);
55
- },
56
- ...options
57
- });
58
- };
59
-
60
- export {
61
- usePaymentProviders,
62
- useCapturePayment,
63
- useRefundPayment
64
- };
@@ -1,301 +0,0 @@
1
- import {
2
- formatProvider
3
- } from "./chunk-IR5DHEKS.mjs";
4
- import {
5
- Combobox
6
- } from "./chunk-CD7VQIPA.mjs";
7
- import {
8
- currencies
9
- } from "./chunk-DK4WIVY6.mjs";
10
- import {
11
- KeyboundForm
12
- } from "./chunk-6HTZNHPT.mjs";
13
- import {
14
- RouteDrawer,
15
- useRouteModal
16
- } from "./chunk-4TC5YS65.mjs";
17
- import {
18
- useDocumentDirection
19
- } from "./chunk-S4DMV3ZT.mjs";
20
- import {
21
- Form
22
- } from "./chunk-OBQI23QM.mjs";
23
- import {
24
- usePaymentProviders
25
- } from "./chunk-EA5GGT2Q.mjs";
26
- import "./chunk-U25RCIX2.mjs";
27
- import "./chunk-ITJEYJNB.mjs";
28
- import {
29
- useStore
30
- } from "./chunk-V2LANK5S.mjs";
31
- import {
32
- useRegion,
33
- useUpdateRegion
34
- } from "./chunk-QZ6PT4QV.mjs";
35
- import {
36
- usePricePreferences
37
- } from "./chunk-QL4XKIVL.mjs";
38
- import "./chunk-4QUHWHBD.mjs";
39
- import "./chunk-FXYH54JP.mjs";
40
- import "./chunk-774WSTCC.mjs";
41
- import "./chunk-DEQUVHHE.mjs";
42
- import "./chunk-RPUOO7AV.mjs";
43
-
44
- // src/routes/regions/region-edit/region-edit.tsx
45
- import { Heading } from "@medusajs/ui";
46
- import { useTranslation as useTranslation2 } from "react-i18next";
47
- import { useParams } from "react-router-dom";
48
-
49
- // src/routes/regions/region-edit/components/edit-region-form/edit-region-form.tsx
50
- import { Button, Input, Select, Switch, Text, toast } from "@medusajs/ui";
51
- import { useForm } from "react-hook-form";
52
- import { useTranslation } from "react-i18next";
53
- import * as zod from "zod";
54
- import { jsx, jsxs } from "react/jsx-runtime";
55
- var EditRegionSchema = zod.object({
56
- name: zod.string().min(1),
57
- currency_code: zod.string(),
58
- payment_providers: zod.array(zod.string()),
59
- automatic_taxes: zod.boolean(),
60
- is_tax_inclusive: zod.boolean()
61
- });
62
- var EditRegionForm = ({
63
- region,
64
- currencies: currencies2,
65
- paymentProviders,
66
- pricePreferences
67
- }) => {
68
- const { t } = useTranslation();
69
- const { handleSuccess } = useRouteModal();
70
- const pricePreferenceForRegion = pricePreferences?.find(
71
- (preference) => preference.attribute === "region_id" && preference.value === region.id
72
- );
73
- const direction = useDocumentDirection();
74
- const form = useForm({
75
- defaultValues: {
76
- name: region.name,
77
- currency_code: region.currency_code.toUpperCase(),
78
- payment_providers: region.payment_providers?.map((pp) => pp.id) || [],
79
- automatic_taxes: region.automatic_taxes,
80
- is_tax_inclusive: pricePreferenceForRegion?.is_tax_inclusive || false
81
- }
82
- });
83
- const { mutateAsync: updateRegion, isPending: isPendingRegion } = useUpdateRegion(region.id);
84
- const handleSubmit = form.handleSubmit(async (values) => {
85
- await updateRegion(
86
- {
87
- name: values.name,
88
- automatic_taxes: values.automatic_taxes,
89
- currency_code: values.currency_code.toLowerCase(),
90
- payment_providers: values.payment_providers,
91
- is_tax_inclusive: values.is_tax_inclusive
92
- },
93
- {
94
- onSuccess: () => {
95
- toast.success(t("regions.toast.edit"));
96
- handleSuccess();
97
- },
98
- onError: (e) => {
99
- toast.error(e.message);
100
- }
101
- }
102
- );
103
- });
104
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { onSubmit: handleSubmit, className: "flex flex-1 flex-col overflow-hidden", children: [
105
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-8", children: [
106
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
107
- /* @__PURE__ */ jsx(
108
- Form.Field,
109
- {
110
- control: form.control,
111
- name: "name",
112
- render: ({ field }) => {
113
- return /* @__PURE__ */ jsxs(Form.Item, { children: [
114
- /* @__PURE__ */ jsx(Form.Label, { children: t("fields.name") }),
115
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
116
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
117
- ] });
118
- }
119
- }
120
- ),
121
- /* @__PURE__ */ jsx(
122
- Form.Field,
123
- {
124
- control: form.control,
125
- name: "currency_code",
126
- render: ({ field: { onChange, ref, ...field } }) => {
127
- return /* @__PURE__ */ jsxs(Form.Item, { children: [
128
- /* @__PURE__ */ jsx(Form.Label, { children: t("fields.currency") }),
129
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(
130
- Select,
131
- {
132
- dir: direction,
133
- onValueChange: onChange,
134
- ...field,
135
- children: [
136
- /* @__PURE__ */ jsx(Select.Trigger, { ref, children: /* @__PURE__ */ jsx(Select.Value, {}) }),
137
- /* @__PURE__ */ jsx(Select.Content, { children: currencies2.map((c) => /* @__PURE__ */ jsx(Select.Item, { value: c.code, children: c.code.toUpperCase() }, c.code)) })
138
- ]
139
- }
140
- ) }),
141
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
142
- ] });
143
- }
144
- }
145
- )
146
- ] }),
147
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
148
- /* @__PURE__ */ jsx(
149
- Form.Field,
150
- {
151
- control: form.control,
152
- name: "automatic_taxes",
153
- render: ({ field: { value, onChange, ...field } }) => {
154
- return /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { children: [
155
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
156
- /* @__PURE__ */ jsx(Form.Label, { children: t("fields.automaticTaxes") }),
157
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
158
- Switch,
159
- {
160
- dir: "ltr",
161
- className: "rtl:rotate-180",
162
- ...field,
163
- checked: value,
164
- onCheckedChange: onChange
165
- }
166
- ) })
167
- ] }),
168
- /* @__PURE__ */ jsx(Form.Hint, { children: t("regions.automaticTaxesHint") }),
169
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
170
- ] }) });
171
- }
172
- }
173
- ),
174
- /* @__PURE__ */ jsx(
175
- Form.Field,
176
- {
177
- control: form.control,
178
- name: "is_tax_inclusive",
179
- render: ({ field: { value, onChange, ...field } }) => {
180
- return /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { children: [
181
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
182
- /* @__PURE__ */ jsx(Form.Label, { children: t("fields.taxInclusivePricing") }),
183
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
184
- Switch,
185
- {
186
- dir: "ltr",
187
- className: "rtl:rotate-180",
188
- ...field,
189
- checked: value,
190
- onCheckedChange: onChange
191
- }
192
- ) })
193
- ] }),
194
- /* @__PURE__ */ jsx(Form.Hint, { children: t("regions.taxInclusiveHint") }),
195
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
196
- ] }) });
197
- }
198
- }
199
- )
200
- ] }),
201
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
202
- /* @__PURE__ */ jsxs("div", { children: [
203
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: "Providers" }),
204
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: t("regions.providersHint") })
205
- ] }),
206
- /* @__PURE__ */ jsx(
207
- Form.Field,
208
- {
209
- control: form.control,
210
- name: "payment_providers",
211
- render: ({ field }) => {
212
- return /* @__PURE__ */ jsxs(Form.Item, { children: [
213
- /* @__PURE__ */ jsx(Form.Label, { children: t("fields.paymentProviders") }),
214
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
215
- Combobox,
216
- {
217
- options: paymentProviders.map((pp) => ({
218
- label: formatProvider(pp.id),
219
- value: pp.id
220
- })),
221
- ...field
222
- }
223
- ) }),
224
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
225
- ] });
226
- }
227
- }
228
- )
229
- ] })
230
- ] }) }),
231
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
232
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
233
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPendingRegion, children: t("actions.save") })
234
- ] }) })
235
- ] }) });
236
- };
237
-
238
- // src/routes/regions/region-edit/region-edit.tsx
239
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
240
- var RegionEdit = () => {
241
- const { t } = useTranslation2();
242
- const { id } = useParams();
243
- const {
244
- region,
245
- isPending: isRegionLoading,
246
- isError: isRegionError,
247
- error: regionError
248
- } = useRegion(id, {
249
- fields: "*payment_providers,*countries,+automatic_taxes"
250
- });
251
- const {
252
- store,
253
- isPending: isStoreLoading,
254
- isError: isStoreError,
255
- error: storeError
256
- } = useStore();
257
- const {
258
- price_preferences: pricePreferences = [],
259
- isPending: isPreferenceLoading,
260
- isError: isPreferenceError,
261
- error: preferenceError
262
- } = usePricePreferences(
263
- {
264
- attribute: "region_id",
265
- value: id
266
- },
267
- { enabled: !!region }
268
- );
269
- const isLoading = isRegionLoading || isStoreLoading || isPreferenceLoading;
270
- const storeCurrencies = (store?.supported_currencies ?? []).map(
271
- (c) => currencies[c.currency_code.toUpperCase()]
272
- );
273
- const { payment_providers: paymentProviders = [] } = usePaymentProviders({
274
- limit: 999,
275
- is_enabled: true
276
- });
277
- if (isRegionError) {
278
- throw regionError;
279
- }
280
- if (isStoreError) {
281
- throw storeError;
282
- }
283
- if (isPreferenceError) {
284
- throw preferenceError;
285
- }
286
- return /* @__PURE__ */ jsxs2(RouteDrawer, { children: [
287
- /* @__PURE__ */ jsx2(RouteDrawer.Header, { children: /* @__PURE__ */ jsx2(Heading, { children: t("regions.editRegion") }) }),
288
- !isLoading && region && /* @__PURE__ */ jsx2(
289
- EditRegionForm,
290
- {
291
- region,
292
- currencies: storeCurrencies,
293
- paymentProviders,
294
- pricePreferences
295
- }
296
- )
297
- ] });
298
- };
299
- export {
300
- RegionEdit as Component
301
- };