@medusajs/dashboard 2.12.4-preview-20251220032313 → 2.12.4-snapshot-20251217150114

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 (167) hide show
  1. package/dist/{add-locales-QBVJ5Q2A.mjs → add-locales-GGNZCABB.mjs} +12 -12
  2. package/dist/{adjust-inventory-O6XSKODS.mjs → adjust-inventory-26YXAXQL.mjs} +2 -2
  3. package/dist/{api-key-management-create-PHBRTKUI.mjs → api-key-management-create-EMP32G2D.mjs} +4 -4
  4. package/dist/{api-key-management-detail-USGXO5H2.mjs → api-key-management-detail-FRUN2KFK.mjs} +11 -11
  5. package/dist/{api-key-management-edit-KYBWESGG.mjs → api-key-management-edit-IBM3ZXHK.mjs} +4 -4
  6. package/dist/{api-key-management-list-2T35G3KT.mjs → api-key-management-list-KC5GOWAU.mjs} +4 -4
  7. package/dist/{api-key-management-sales-channels-WZAGFYC5.mjs → api-key-management-sales-channels-LUB5G6RC.mjs} +4 -4
  8. package/dist/app.js +243 -59
  9. package/dist/app.mjs +12 -12
  10. package/dist/{campaign-detail-L7USOSG7.mjs → campaign-detail-HM3GQJLQ.mjs} +11 -11
  11. package/dist/{categories-metadata-3GYVMP6Q.mjs → categories-metadata-WKL3MGD7.mjs} +11 -11
  12. package/dist/{category-create-G2JK5KDF.mjs → category-create-KHJZSC7G.mjs} +3 -3
  13. package/dist/{category-detail-6YJNXJZI.mjs → category-detail-UTWWDKFP.mjs} +13 -13
  14. package/dist/{category-edit-4V4SHFZL.mjs → category-edit-CTA2EPDG.mjs} +3 -3
  15. package/dist/{category-list-WHGMREI2.mjs → category-list-QBYJ4T3R.mjs} +4 -4
  16. package/dist/{category-organize-B4I6TDK4.mjs → category-organize-SXP33XET.mjs} +3 -3
  17. package/dist/{category-products-FJV2QX6O.mjs → category-products-XXBTCXFF.mjs} +12 -12
  18. package/dist/{chunk-C32SLRTC.mjs → chunk-23GTCEOV.mjs} +1 -1
  19. package/dist/{chunk-RNV5E7NV.mjs → chunk-2XTBDCGE.mjs} +1 -1
  20. package/dist/{chunk-73OGFYCU.mjs → chunk-4JQR6QNW.mjs} +2 -2
  21. package/dist/{chunk-RUXFTSJR.mjs → chunk-5F427YCP.mjs} +4 -4
  22. package/dist/{chunk-YOSHYW6O.mjs → chunk-6P4Q4AAP.mjs} +3 -3
  23. package/dist/{chunk-2WYSM6OA.mjs → chunk-A2WBKOXJ.mjs} +2 -2
  24. package/dist/{chunk-3XBFXGEA.mjs → chunk-A4XYK3MY.mjs} +2 -2
  25. package/dist/{chunk-XGSMYYUJ.mjs → chunk-AWRCV3ME.mjs} +1 -1
  26. package/dist/{chunk-BMJ5RYIO.mjs → chunk-BMS2QLJY.mjs} +1 -1
  27. package/dist/{chunk-2BF4242O.mjs → chunk-DTCIBQO2.mjs} +3 -3
  28. package/dist/{chunk-R3FD2XEU.mjs → chunk-FYWHE3W5.mjs} +1 -1
  29. package/dist/{chunk-GRID7K27.mjs → chunk-GLBHPDR4.mjs} +178 -43
  30. package/dist/chunk-HGRIOEAR.mjs +32 -0
  31. package/dist/{chunk-JSL6RQIX.mjs → chunk-HNJ65IND.mjs} +3 -3
  32. package/dist/{chunk-FWRPGWPC.mjs → chunk-HTCYX4VD.mjs} +1 -1
  33. package/dist/{chunk-SR45O6K3.mjs → chunk-IAV7IKJ6.mjs} +1 -1
  34. package/dist/{chunk-ML4BEONO.mjs → chunk-IKTGFXWR.mjs} +1 -1
  35. package/dist/{chunk-ITNDUP2W.mjs → chunk-LWYKUORZ.mjs} +152 -152
  36. package/dist/{chunk-FDOVSLDC.mjs → chunk-OK6NZN2A.mjs} +1 -1
  37. package/dist/{chunk-6X2UTJF3.mjs → chunk-OSHH5GAS.mjs} +13 -1
  38. package/dist/{chunk-JUZ754L2.mjs → chunk-QKALAT7P.mjs} +1 -1
  39. package/dist/{chunk-JPXDZWRN.mjs → chunk-SG2JZPTG.mjs} +1 -1
  40. package/dist/{chunk-43TDMTAG.mjs → chunk-U6G4M5LP.mjs} +1 -1
  41. package/dist/{chunk-QBIQEVTU.mjs → chunk-UJ2TMPV4.mjs} +12 -0
  42. package/dist/{chunk-YBCCF4FO.mjs → chunk-UMCJYHAD.mjs} +1 -1
  43. package/dist/{chunk-6F74MBBU.mjs → chunk-UWY5ZV66.mjs} +13 -1
  44. package/dist/{chunk-5FMYPGTX.mjs → chunk-XY7A7GZJ.mjs} +1 -1
  45. package/dist/{chunk-H65COXEW.mjs → chunk-Y2YVTIJI.mjs} +1 -1
  46. package/dist/{chunk-3TPUO6MD.mjs → chunk-Z6BFNHEO.mjs} +12 -0
  47. package/dist/{collection-add-products-KDTKR543.mjs → collection-add-products-42F7H77E.mjs} +12 -12
  48. package/dist/{collection-create-PBAAYBMB.mjs → collection-create-GWKWVT7B.mjs} +3 -3
  49. package/dist/{collection-detail-6ZXVOL75.mjs → collection-detail-PXIS3G64.mjs} +12 -12
  50. package/dist/{collection-edit-7GW5PA32.mjs → collection-edit-EZIO2BR5.mjs} +3 -3
  51. package/dist/{collection-list-MSWHXF4U.mjs → collection-list-O74CGY24.mjs} +13 -13
  52. package/dist/{collection-metadata-TJQOWR5R.mjs → collection-metadata-U6FMA4IC.mjs} +11 -11
  53. package/dist/{customer-detail-3CT4TIOM.mjs → customer-detail-OMTFJ6CE.mjs} +12 -12
  54. package/dist/{customer-group-detail-YSIYKTFF.mjs → customer-group-detail-ADK3M5LG.mjs} +11 -11
  55. package/dist/{customer-group-list-M3ZXYW3T.mjs → customer-group-list-7ZRQ2HWU.mjs} +11 -11
  56. package/dist/{customers-add-customer-group-J737AKRI.mjs → customers-add-customer-group-5U27WHJB.mjs} +11 -11
  57. package/dist/{edit-inventory-item-ELQTABU4.mjs → edit-inventory-item-H7DAZWIT.mjs} +2 -2
  58. package/dist/{edit-inventory-item-attributes-P4WS4UTE.mjs → edit-inventory-item-attributes-7HTXXPGZ.mjs} +2 -2
  59. package/dist/{edit-reservation-77DUKBGX.mjs → edit-reservation-OVTRZHJR.mjs} +3 -3
  60. package/dist/{edit-rules-WSLQZ66N.mjs → edit-rules-BM2ERGVJ.mjs} +11 -11
  61. package/dist/{inventory-create-JE4Y7NIG.mjs → inventory-create-7MA7B5N2.mjs} +11 -11
  62. package/dist/{inventory-detail-G26VODHQ.mjs → inventory-detail-B4PRHZK3.mjs} +11 -11
  63. package/dist/{inventory-list-IPORNDO4.mjs → inventory-list-RXJPSVZE.mjs} +2 -2
  64. package/dist/{inventory-metadata-J5NVL5SV.mjs → inventory-metadata-C7MJ3GY5.mjs} +11 -11
  65. package/dist/{inventory-stock-M227HL6G.mjs → inventory-stock-WVTYPJTX.mjs} +11 -11
  66. package/dist/{location-detail-NL2TN3V7.mjs → location-detail-KO6EBDK5.mjs} +11 -11
  67. package/dist/{location-fulfillment-providers-E4PCYUKY.mjs → location-fulfillment-providers-IORBE3E3.mjs} +13 -13
  68. package/dist/{location-sales-channels-P6O7KJAO.mjs → location-sales-channels-P3QJTFDT.mjs} +3 -3
  69. package/dist/{location-service-zone-shipping-option-create-PYRQ7BPE.mjs → location-service-zone-shipping-option-create-2R3ZFLVK.mjs} +11 -11
  70. package/dist/{login-4CLCYYEA.mjs → login-XKB6OR7I.mjs} +11 -11
  71. package/dist/{manage-locations-PWHIZBEM.mjs → manage-locations-7HH6R4UP.mjs} +2 -2
  72. package/dist/{order-allocate-items-PL4YRRG4.mjs → order-allocate-items-HZGGYJ42.mjs} +4 -4
  73. package/dist/{order-create-claim-YL7MD5XD.mjs → order-create-claim-NKCOGF4A.mjs} +13 -13
  74. package/dist/{order-create-edit-XAWVTQD4.mjs → order-create-edit-UNQYXGLL.mjs} +12 -12
  75. package/dist/{order-create-exchange-FJMXI6K5.mjs → order-create-exchange-WI7OA2WO.mjs} +13 -13
  76. package/dist/{order-create-fulfillment-FYURNIMY.mjs → order-create-fulfillment-2LJTEWDY.mjs} +11 -11
  77. package/dist/{order-create-refund-AABCH2MP.mjs → order-create-refund-7K6UJXGP.mjs} +11 -11
  78. package/dist/{order-create-return-W3KT5LKU.mjs → order-create-return-52GHGW5Z.mjs} +5 -5
  79. package/dist/{order-create-shipment-HABAVTEQ.mjs → order-create-shipment-ZTDLLUBY.mjs} +11 -11
  80. package/dist/{order-detail-DLFW35N5.mjs → order-detail-JTRUMRLO.mjs} +15 -15
  81. package/dist/{order-edit-billing-address-7RBMI4U7.mjs → order-edit-billing-address-YHYNVLOE.mjs} +11 -11
  82. package/dist/{order-edit-email-U7SUTU4P.mjs → order-edit-email-TCQPEVZY.mjs} +11 -11
  83. package/dist/{order-edit-shipping-address-I2WW7QC5.mjs → order-edit-shipping-address-CFSYQLKD.mjs} +11 -11
  84. package/dist/{order-export-VJXXQ7WN.mjs → order-export-G4SBNEJ7.mjs} +12 -12
  85. package/dist/{order-list-3I4REXYI.mjs → order-list-GRLQWN4L.mjs} +6 -6
  86. package/dist/{order-metadata-TSZZQQTZ.mjs → order-metadata-KGPB37VL.mjs} +11 -11
  87. package/dist/{order-receive-return-2JBWHY4Z.mjs → order-receive-return-JER24SEV.mjs} +12 -12
  88. package/dist/{order-request-transfer-2WNT5G27.mjs → order-request-transfer-3FBUYZNT.mjs} +11 -11
  89. package/dist/{price-list-configuration-OH3KGRDN.mjs → price-list-configuration-6S3MLNXQ.mjs} +3 -3
  90. package/dist/{price-list-create-ZGOKBAWP.mjs → price-list-create-CXZCFFTP.mjs} +12 -12
  91. package/dist/{price-list-detail-JIS454OY.mjs → price-list-detail-XOMU6U5J.mjs} +13 -13
  92. package/dist/{price-list-edit-WMWJFW7S.mjs → price-list-edit-53UW35L3.mjs} +3 -3
  93. package/dist/{price-list-list-JJXWBCTJ.mjs → price-list-list-DG5YEZ44.mjs} +4 -4
  94. package/dist/{price-list-prices-add-QJWBPI5A.mjs → price-list-prices-add-SDX5CQME.mjs} +12 -12
  95. package/dist/{price-list-prices-edit-ICTQBHHM.mjs → price-list-prices-edit-EKB6NI5D.mjs} +3 -3
  96. package/dist/{product-attributes-VSFKRDLE.mjs → product-attributes-STD47BGC.mjs} +12 -12
  97. package/dist/{product-create-7R5YXGU2.mjs → product-create-LVGWVQAT.mjs} +13 -13
  98. package/dist/{product-create-option-FWBTGNZG.mjs → product-create-option-7AOXAA4S.mjs} +2 -2
  99. package/dist/{product-create-variant-R6HXRAYY.mjs → product-create-variant-OTJKT6WI.mjs} +11 -11
  100. package/dist/{product-detail-LZP26A35.mjs → product-detail-OYVHJH3D.mjs} +12 -12
  101. package/dist/{product-edit-K25SVTO3.mjs → product-edit-3SIUUIW4.mjs} +12 -12
  102. package/dist/{product-edit-option-FIDTMKUN.mjs → product-edit-option-LWJT3CYJ.mjs} +2 -2
  103. package/dist/{product-export-UX5DTA3Q.mjs → product-export-57UUAGXF.mjs} +13 -13
  104. package/dist/{product-image-variants-edit-L4RTIYTJ.mjs → product-image-variants-edit-2BW5BJON.mjs} +11 -11
  105. package/dist/{product-import-PEOW5NN6.mjs → product-import-6EM4VUXP.mjs} +11 -11
  106. package/dist/{product-list-HYVJZLCR.mjs → product-list-5V5GEH5K.mjs} +12 -12
  107. package/dist/{product-media-CG4RFOTX.mjs → product-media-3VJ7KENL.mjs} +2 -2
  108. package/dist/{product-metadata-THI2FNZW.mjs → product-metadata-JZLHBLZQ.mjs} +11 -11
  109. package/dist/{product-organization-RYZELVUL.mjs → product-organization-3PQ45C4B.mjs} +13 -13
  110. package/dist/{product-prices-LAVS64HJ.mjs → product-prices-5ZL2RP7A.mjs} +2 -2
  111. package/dist/{product-sales-channels-XBALPVAL.mjs → product-sales-channels-PPXUG4KT.mjs} +3 -3
  112. package/dist/{product-shipping-profile-KKDCYD3N.mjs → product-shipping-profile-ETQFZ7DC.mjs} +2 -2
  113. package/dist/{product-stock-LGNNLO7C.mjs → product-stock-SJJABF6I.mjs} +11 -11
  114. package/dist/{product-tag-create-7SHCIBB3.mjs → product-tag-create-XXO4AQEC.mjs} +11 -11
  115. package/dist/{product-tag-detail-GG7CO6BN.mjs → product-tag-detail-BSK64HXL.mjs} +14 -14
  116. package/dist/{product-tag-edit-E2RW4EDQ.mjs → product-tag-edit-ENCGDT7E.mjs} +11 -11
  117. package/dist/{product-tag-list-DCORIKKF.mjs → product-tag-list-SLQGCNDZ.mjs} +14 -14
  118. package/dist/{product-tag-metadata-LDYF45YH.mjs → product-tag-metadata-EPXHMU2K.mjs} +11 -11
  119. package/dist/{product-type-create-NRLNMABQ.mjs → product-type-create-DRFXTL5O.mjs} +2 -2
  120. package/dist/{product-type-detail-AJ54QEZ7.mjs → product-type-detail-4CRRU7YK.mjs} +13 -13
  121. package/dist/{product-type-edit-BHTPMMVI.mjs → product-type-edit-SRHCZDK7.mjs} +2 -2
  122. package/dist/{product-type-list-MQ2PW2IE.mjs → product-type-list-QQKAHBJ3.mjs} +3 -3
  123. package/dist/{product-type-metadata-BBV4BL2F.mjs → product-type-metadata-73OKOGPP.mjs} +11 -11
  124. package/dist/{product-variant-detail-27TBRV44.mjs → product-variant-detail-RPHLG4HU.mjs} +11 -11
  125. package/dist/{product-variant-edit-M3EFPB7I.mjs → product-variant-edit-JF7NN64Y.mjs} +11 -11
  126. package/dist/{product-variant-manage-inventory-items-QK7Z4KHF.mjs → product-variant-manage-inventory-items-Y2VEOHP7.mjs} +2 -2
  127. package/dist/{product-variant-media-IOAZGVL2.mjs → product-variant-media-2WLVNGI4.mjs} +2 -2
  128. package/dist/{product-variant-metadata-DJSINBPO.mjs → product-variant-metadata-HU2CXGPO.mjs} +11 -11
  129. package/dist/{promotion-create-VGJCTHU3.mjs → promotion-create-BHA3FQG2.mjs} +11 -11
  130. package/dist/{promotion-detail-AWLQVJNN.mjs → promotion-detail-F3QSR52W.mjs} +11 -11
  131. package/dist/{refund-reason-create-EXAC2PMO.mjs → refund-reason-create-ZA5TKW2Z.mjs} +11 -11
  132. package/dist/{refund-reason-edit-NEXHR2RT.mjs → refund-reason-edit-N2CRCLKZ.mjs} +11 -11
  133. package/dist/{refund-reason-list-2IXZQWFF.mjs → refund-reason-list-SE4TMGMT.mjs} +11 -11
  134. package/dist/{region-metadata-VO2S34JP.mjs → region-metadata-O5NZBWXP.mjs} +11 -11
  135. package/dist/{reservation-create-M3NKBTYW.mjs → reservation-create-ZCIYM6JI.mjs} +3 -3
  136. package/dist/{reservation-detail-VQJLWDL3.mjs → reservation-detail-UFK6XIXE.mjs} +11 -11
  137. package/dist/{reservation-list-HSF22GFZ.mjs → reservation-list-B47DXTA7.mjs} +3 -3
  138. package/dist/{reservation-metadata-RRGKR7AK.mjs → reservation-metadata-AEJEKGLV.mjs} +11 -11
  139. package/dist/{sales-channel-add-products-ZZE7LM4K.mjs → sales-channel-add-products-2LMB7EF5.mjs} +12 -12
  140. package/dist/{sales-channel-create-BW5VCR34.mjs → sales-channel-create-MI7HHZYE.mjs} +3 -3
  141. package/dist/{sales-channel-detail-27FFRS5I.mjs → sales-channel-detail-EUQ4STQI.mjs} +12 -12
  142. package/dist/{sales-channel-edit-NCWKYFYJ.mjs → sales-channel-edit-VSHOIR37.mjs} +3 -3
  143. package/dist/{sales-channel-list-JK7HQZM5.mjs → sales-channel-list-JXKGHX4G.mjs} +11 -11
  144. package/dist/{sales-channel-metadata-ZSXMTQ6L.mjs → sales-channel-metadata-AJMQ5SQ2.mjs} +11 -11
  145. package/dist/{shipping-option-type-create-YLAEM4M6.mjs → shipping-option-type-create-YVVIA2XC.mjs} +11 -11
  146. package/dist/{shipping-option-type-detail-33A6BZMB.mjs → shipping-option-type-detail-ZZW36XLK.mjs} +12 -12
  147. package/dist/{shipping-option-type-edit-WBGIOJ3L.mjs → shipping-option-type-edit-O6F74T3A.mjs} +11 -11
  148. package/dist/{shipping-option-type-list-SYE2CFWK.mjs → shipping-option-type-list-SPTE7MT6.mjs} +12 -12
  149. package/dist/{shipping-profile-metadata-6CIPN25L.mjs → shipping-profile-metadata-7WFE55VG.mjs} +11 -11
  150. package/dist/{store-add-locales-K5OOQ25D.mjs → store-add-locales-GWCGIXHU.mjs} +12 -12
  151. package/dist/{store-detail-RVGISZXQ.mjs → store-detail-YLJLBBZE.mjs} +11 -11
  152. package/dist/{store-metadata-HPGZG23A.mjs → store-metadata-BZ57I2E6.mjs} +11 -11
  153. package/dist/{tax-region-create-EOT7GTKU.mjs → tax-region-create-FGTV7VJL.mjs} +11 -11
  154. package/dist/{tax-region-detail-E5ZNBHJY.mjs → tax-region-detail-PPIMD7OX.mjs} +16 -16
  155. package/dist/{tax-region-edit-5IM2XJZP.mjs → tax-region-edit-ELZKA7YH.mjs} +11 -11
  156. package/dist/{tax-region-province-detail-MNNQWTQ7.mjs → tax-region-province-detail-FV2NDT3E.mjs} +16 -16
  157. package/dist/{tax-region-tax-override-create-EYESRMIT.mjs → tax-region-tax-override-create-N572MQPZ.mjs} +14 -14
  158. package/dist/{tax-region-tax-override-edit-ULQESLZ2.mjs → tax-region-tax-override-edit-5DCSJW6D.mjs} +15 -15
  159. package/dist/{translation-list-GFZVEND6.mjs → translation-list-FK7XYLHX.mjs} +11 -11
  160. package/dist/{translations-edit-YZ26SQEB.mjs → translations-edit-VRXZI5KW.mjs} +22 -17
  161. package/dist/{user-detail-3IEU4KU4.mjs → user-detail-BJUXLZZQ.mjs} +2 -2
  162. package/dist/{user-metadata-7P4OECLX.mjs → user-metadata-GRJZZ524.mjs} +11 -11
  163. package/dist/{workflow-execution-detail-EAN7OEWP.mjs → workflow-execution-detail-HXTFWGKG.mjs} +11 -11
  164. package/package.json +9 -9
  165. package/src/hooks/api/translations.tsx +182 -85
  166. package/src/routes/translations/translations-edit/translations-edit.tsx +13 -8
  167. package/dist/chunk-7AXHHXCX.mjs +0 -4
@@ -2,16 +2,25 @@ import { FetchError } from "@medusajs/js-sdk"
2
2
  import { HttpTypes } from "@medusajs/types"
3
3
  import {
4
4
  QueryKey,
5
- useInfiniteQuery,
6
5
  UseInfiniteQueryOptions,
6
+ UseInfiniteQueryResult,
7
7
  useMutation,
8
8
  UseMutationOptions,
9
9
  useQuery,
10
10
  UseQueryOptions,
11
11
  } from "@tanstack/react-query"
12
12
  import { sdk } from "../../lib/client"
13
- import { queryClient } from "../../lib/query-client"
14
13
  import { queryKeysFactory } from "../../lib/query-key-factory"
14
+ import { queryClient } from "../../lib/query-client"
15
+ import { productsQueryKeys, useInfiniteProducts } from "./products"
16
+ import {
17
+ productVariantQueryKeys,
18
+ useInfiniteVariants,
19
+ } from "./product-variants"
20
+ import { categoriesQueryKeys, useInfiniteCategories } from "./categories"
21
+ import { collectionsQueryKeys, useInfiniteCollections } from "./collections"
22
+ import { productTagsQueryKeys, useInfiniteProductTags } from "./tags"
23
+ import { productTypesQueryKeys, useInfiniteProductTypes } from "./product-types"
15
24
 
16
25
  const TRANSLATIONS_QUERY_KEY = "translations" as const
17
26
  export const translationsQueryKeys = queryKeysFactory(TRANSLATIONS_QUERY_KEY)
@@ -26,77 +35,177 @@ export const translationStatisticsQueryKeys = queryKeysFactory(
26
35
  TRANSLATION_STATISTICS_QUERY_KEY
27
36
  )
28
37
 
29
- const TRANSLATION_ENTITIES_QUERY_KEY = "translation_entities" as const
30
- export const translationEntitiesQueryKeys = queryKeysFactory(
31
- TRANSLATION_ENTITIES_QUERY_KEY
32
- )
33
-
34
- const DEFAULT_PAGE_SIZE = 20
35
-
36
- /**
37
- * Hook to fetch entities with their translatable fields and all translations.
38
- * Uses the /admin/translations/entities endpoint which returns entities
39
- * with all their translations for all locales.
40
- *
41
- * @param reference - The entity type (e.g., "product", "product_variant")
42
- * @param referenceId - Optional ID(s) to filter specific entities
43
- * @param options - React Query options
44
- */
45
38
  export const useReferenceTranslations = (
46
39
  reference: string,
40
+ translatableFields: string[],
47
41
  referenceId?: string | string[],
48
42
  options?: Omit<
49
- UseInfiniteQueryOptions<
50
- HttpTypes.AdminTranslationEntitiesResponse,
51
- FetchError,
52
- {
53
- pages: HttpTypes.AdminTranslationEntitiesResponse[]
54
- pageParams: number[]
55
- },
56
- HttpTypes.AdminTranslationEntitiesResponse,
57
- QueryKey,
58
- number
59
- >,
43
+ UseInfiniteQueryOptions<any, FetchError, any, any, QueryKey, number>,
60
44
  "queryFn" | "queryKey" | "initialPageParam" | "getNextPageParam"
61
45
  >
62
46
  ) => {
63
- const { data, ...rest } = useInfiniteQuery({
64
- queryKey: translationEntitiesQueryKeys.list({
65
- type: reference,
66
- id: referenceId,
67
- }),
68
- queryFn: async ({ pageParam = 0 }) => {
69
- return sdk.admin.translation.entities({
70
- type: reference,
71
- id: referenceId,
72
- limit: DEFAULT_PAGE_SIZE,
73
- offset: pageParam,
74
- })
75
- },
76
- initialPageParam: 0,
77
- getNextPageParam: (lastPage) => {
78
- const nextOffset = lastPage.offset + lastPage.limit
79
- return nextOffset < lastPage.count ? nextOffset : undefined
80
- },
81
- ...options,
82
- })
47
+ const referenceHookMap = new Map<
48
+ string,
49
+ () => Omit<UseInfiniteQueryResult<any, FetchError>, "data"> & {
50
+ data: {
51
+ translations: HttpTypes.AdminTranslation[]
52
+ references: (Record<string, any> & { id: string })[]
53
+ count: number
54
+ }
55
+ }
56
+ >([
57
+ [
58
+ "product",
59
+ () => {
60
+ const fields = translatableFields.concat(["translations.*"]).join(",")
83
61
 
84
- const entitiesWithTranslations =
85
- data?.pages.flatMap((page) => page.data) ?? []
86
- const translations = entitiesWithTranslations.flatMap(
87
- (entity) => entity.translations ?? []
88
- )
89
- const references = entitiesWithTranslations.map(
90
- ({ translations: _, ...entity }) => entity
91
- )
92
- const count = data?.pages[0]?.count ?? 0
62
+ const { data, ...rest } = useInfiniteProducts(
63
+ { fields, id: referenceId ?? [] },
64
+ options
65
+ )
66
+ const products = data?.pages.flatMap((page) => page.products) ?? []
93
67
 
94
- return {
95
- references,
96
- translations,
97
- count,
98
- ...rest,
68
+ return {
69
+ ...rest,
70
+ data: {
71
+ translations:
72
+ products?.flatMap((product) => product.translations ?? []) ?? [],
73
+ references: products ?? [],
74
+ count: data?.pages[0]?.count ?? 0,
75
+ },
76
+ }
77
+ },
78
+ ],
79
+ [
80
+ "product_variant",
81
+ () => {
82
+ const fields = translatableFields.concat(["translations.*"]).join(",")
83
+
84
+ const { data, ...rest } = useInfiniteVariants(
85
+ { id: referenceId ?? [], fields },
86
+ options
87
+ )
88
+ const variants = data?.pages.flatMap((page) => page.variants) ?? []
89
+
90
+ return {
91
+ ...rest,
92
+ data: {
93
+ translations:
94
+ variants?.flatMap((variant) => variant.translations ?? []) ?? [],
95
+ references: variants ?? [],
96
+ translatableFields,
97
+ count: data?.pages[0]?.count ?? 0,
98
+ },
99
+ }
100
+ },
101
+ ],
102
+ [
103
+ "product_category",
104
+ () => {
105
+ const fields = translatableFields.concat(["translations.*"]).join(",")
106
+
107
+ const { data, ...rest } = useInfiniteCategories(
108
+ { id: referenceId ?? [], fields },
109
+ options
110
+ )
111
+ const categories =
112
+ data?.pages.flatMap((page) => page.product_categories) ?? []
113
+
114
+ return {
115
+ ...rest,
116
+ data: {
117
+ translations:
118
+ categories?.flatMap((category) => category.translations ?? []) ??
119
+ [],
120
+ references: categories ?? [],
121
+ translatableFields,
122
+ count: data?.pages[0]?.count ?? 0,
123
+ },
124
+ }
125
+ },
126
+ ],
127
+ [
128
+ "product_collection",
129
+ () => {
130
+ const fields = translatableFields.concat(["translations.*"]).join(",")
131
+
132
+ const { data, ...rest } = useInfiniteCollections(
133
+ { id: referenceId ?? [], fields },
134
+ options
135
+ )
136
+ const collections =
137
+ data?.pages.flatMap((page) => page.collections) ?? []
138
+
139
+ return {
140
+ ...rest,
141
+ data: {
142
+ translations:
143
+ collections?.flatMap(
144
+ (collection) => collection.translations ?? []
145
+ ) ?? [],
146
+ references: collections ?? [],
147
+ translatableFields,
148
+ count: data?.pages[0]?.count ?? 0,
149
+ },
150
+ }
151
+ },
152
+ ],
153
+ [
154
+ "product_type",
155
+ () => {
156
+ const fields = translatableFields.concat(["translations.*"]).join(",")
157
+
158
+ const { data, ...rest } = useInfiniteProductTypes(
159
+ { id: referenceId ?? [], fields },
160
+ options
161
+ )
162
+ const product_types =
163
+ data?.pages.flatMap((page) => page.product_types) ?? []
164
+
165
+ return {
166
+ ...rest,
167
+ data: {
168
+ translations:
169
+ product_types?.flatMap((type) => type.translations ?? []) ?? [],
170
+ references: product_types ?? [],
171
+ count: data?.pages[0]?.count ?? 0,
172
+ translatableFields,
173
+ },
174
+ }
175
+ },
176
+ ],
177
+ [
178
+ "product_tag",
179
+ () => {
180
+ const fields = translatableFields.concat(["translations.*"]).join(",")
181
+
182
+ const { data, ...rest } = useInfiniteProductTags(
183
+ { id: referenceId ?? [], fields },
184
+ options
185
+ )
186
+ const product_tags =
187
+ data?.pages.flatMap((page) => page.product_tags) ?? []
188
+
189
+ return {
190
+ ...rest,
191
+ data: {
192
+ translations:
193
+ product_tags?.flatMap((tag) => tag.translations ?? []) ?? [],
194
+ references: product_tags ?? [],
195
+ translatableFields,
196
+ count: data?.pages[0]?.count ?? 0,
197
+ },
198
+ }
199
+ },
200
+ ],
201
+ // TODO: product option and option values
202
+ ])
203
+ const referenceHook = referenceHookMap.get(reference)
204
+ if (!referenceHook) {
205
+ throw new Error(`No hook found for reference type: ${reference}`)
99
206
  }
207
+ const { data, ...rest } = referenceHook()
208
+ return { ...data, ...rest }
100
209
  }
101
210
 
102
211
  export const useTranslations = (
@@ -120,6 +229,15 @@ export const useTranslations = (
120
229
  return { ...data, ...rest }
121
230
  }
122
231
 
232
+ const referenceInvalidationKeysMap = new Map<string, QueryKey>([
233
+ ["product", productsQueryKeys.lists()],
234
+ ["product_variant", productVariantQueryKeys.lists()],
235
+ ["product_category", categoriesQueryKeys.lists()],
236
+ ["product_collection", collectionsQueryKeys.lists()],
237
+ ["product_type", productTypesQueryKeys.lists()],
238
+ ["product_tag", productTagsQueryKeys.lists()],
239
+ ])
240
+
123
241
  export const useBatchTranslations = (
124
242
  reference: string,
125
243
  options?: UseMutationOptions<
@@ -140,7 +258,7 @@ export const useBatchTranslations = (
140
258
  const invalidateQueries = async () => {
141
259
  await Promise.all([
142
260
  queryClient.invalidateQueries({
143
- queryKey: translationEntitiesQueryKeys.list({ type: reference }),
261
+ queryKey: referenceInvalidationKeysMap.get(reference),
144
262
  }),
145
263
  queryClient.invalidateQueries({
146
264
  queryKey: translationStatisticsQueryKeys.lists(),
@@ -175,27 +293,6 @@ export const useTranslationSettings = (
175
293
  return { ...data, ...rest }
176
294
  }
177
295
 
178
- export const useTranslationEntities = (
179
- query: HttpTypes.AdminTranslationEntitiesParams,
180
- options?: Omit<
181
- UseQueryOptions<
182
- HttpTypes.AdminTranslationEntitiesResponse,
183
- FetchError,
184
- HttpTypes.AdminTranslationEntitiesResponse,
185
- QueryKey
186
- >,
187
- "queryFn" | "queryKey"
188
- >
189
- ) => {
190
- const { data, ...rest } = useQuery({
191
- queryKey: translationEntitiesQueryKeys.list(query),
192
- queryFn: () => sdk.admin.translation.entities(query),
193
- ...options,
194
- })
195
-
196
- return { ...data, ...rest }
197
- }
198
-
199
296
  export const useTranslationStatistics = (
200
297
  query?: HttpTypes.AdminTranslationStatisticsParams,
201
298
  options?: Omit<
@@ -1,14 +1,14 @@
1
- import { keepPreviousData } from "@tanstack/react-query"
2
- import { useEffect } from "react"
3
1
  import { useNavigate, useSearchParams } from "react-router-dom"
4
- import { RouteFocusModal } from "../../../components/modals"
5
2
  import {
6
3
  useReferenceTranslations,
7
4
  useStore,
8
5
  useTranslationSettings,
9
6
  } from "../../../hooks/api"
10
- import { useFeatureFlag } from "../../../providers/feature-flag-provider"
11
7
  import { TranslationsEditForm } from "./components/translations-edit-form"
8
+ import { useEffect } from "react"
9
+ import { RouteFocusModal } from "../../../components/modals"
10
+ import { useFeatureFlag } from "../../../providers/feature-flag-provider"
11
+ import { keepPreviousData } from "@tanstack/react-query"
12
12
 
13
13
  export const TranslationsEdit = () => {
14
14
  const isTranslationsEnabled = useFeatureFlag("translation")
@@ -41,10 +41,15 @@ export const TranslationsEdit = () => {
41
41
  isPending,
42
42
  isError,
43
43
  error,
44
- } = useReferenceTranslations(reference!, referenceIdParam, {
45
- enabled: !!reference,
46
- placeholderData: keepPreviousData,
47
- })
44
+ } = useReferenceTranslations(
45
+ reference!,
46
+ translatable_fields?.[reference!] ?? [],
47
+ referenceIdParam,
48
+ {
49
+ enabled: !!translatable_fields && !!reference,
50
+ placeholderData: keepPreviousData,
51
+ }
52
+ )
48
53
  const {
49
54
  store,
50
55
  isPending: isStorePending,
@@ -1,4 +0,0 @@
1
- // src/hooks/use-infinite-list.tsx
2
- import {
3
- useInfiniteQuery
4
- } from "@tanstack/react-query";