@medusajs/dashboard 2.12.3-preview-20251217090412 → 2.12.3-preview-20251217123836

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 (276) hide show
  1. package/dist/{add-campaign-promotions-4QLXO46G.mjs → add-campaign-promotions-OYPGISTF.mjs} +2 -2
  2. package/dist/add-locales-GGNZCABB.mjs +81 -0
  3. package/dist/{adjust-inventory-2MFA656V.mjs → adjust-inventory-26YXAXQL.mjs} +4 -3
  4. package/dist/{api-key-management-create-ZUVF3SLR.mjs → api-key-management-create-EMP32G2D.mjs} +6 -5
  5. package/dist/{api-key-management-detail-THD74G7I.mjs → api-key-management-detail-FRUN2KFK.mjs} +11 -10
  6. package/dist/{api-key-management-edit-42HNUSXL.mjs → api-key-management-edit-IBM3ZXHK.mjs} +6 -5
  7. package/dist/{api-key-management-list-66CFOILY.mjs → api-key-management-list-KC5GOWAU.mjs} +4 -3
  8. package/dist/{api-key-management-sales-channels-HN3THM5J.mjs → api-key-management-sales-channels-LUB5G6RC.mjs} +6 -5
  9. package/dist/app.css +72 -0
  10. package/dist/app.js +13657 -11324
  11. package/dist/app.mjs +12 -11
  12. package/dist/{campaign-budget-edit-6DMZGUCI.mjs → campaign-budget-edit-B5MSE26J.mjs} +2 -2
  13. package/dist/{campaign-configuration-UNFRB5HR.mjs → campaign-configuration-QOE3D2BE.mjs} +2 -2
  14. package/dist/{campaign-create-QXG7PD3S.mjs → campaign-create-FJOECKGT.mjs} +3 -3
  15. package/dist/{campaign-detail-WR3XHHV2.mjs → campaign-detail-HM3GQJLQ.mjs} +11 -10
  16. package/dist/{campaign-edit-HN4US7DV.mjs → campaign-edit-K2POQH7M.mjs} +2 -2
  17. package/dist/{categories-metadata-BCZ463KN.mjs → categories-metadata-WKL3MGD7.mjs} +14 -13
  18. package/dist/{category-create-FFIBWXAH.mjs → category-create-KHJZSC7G.mjs} +5 -4
  19. package/dist/{category-detail-4HXJ5Z7N.mjs → category-detail-UTWWDKFP.mjs} +29 -13
  20. package/dist/{category-edit-74MZ6TXN.mjs → category-edit-CTA2EPDG.mjs} +5 -4
  21. package/dist/{category-list-OCJY2UJV.mjs → category-list-QBYJ4T3R.mjs} +20 -4
  22. package/dist/{category-organize-B6EFBFKB.mjs → category-organize-SXP33XET.mjs} +5 -4
  23. package/dist/{category-products-2HXLZDHL.mjs → category-products-XXBTCXFF.mjs} +14 -13
  24. package/dist/{chunk-XIVBRONM.mjs → chunk-23GTCEOV.mjs} +1 -1
  25. package/dist/{chunk-2NZDHAOE.mjs → chunk-27MGH3HR.mjs} +2 -2
  26. package/dist/{chunk-N3FCYZV6.mjs → chunk-2XTBDCGE.mjs} +1 -1
  27. package/dist/{chunk-RU4ZS47V.mjs → chunk-4JQR6QNW.mjs} +2 -2
  28. package/dist/{chunk-F65T2X7G.mjs → chunk-5F427YCP.mjs} +5 -5
  29. package/dist/{chunk-PNPT4W2F.mjs → chunk-5ISRTMYH.mjs} +1 -1
  30. package/dist/{chunk-Z6NHG5LQ.mjs → chunk-6P4Q4AAP.mjs} +3 -3
  31. package/dist/{chunk-F5NZDW7L.mjs → chunk-A2WBKOXJ.mjs} +2 -2
  32. package/dist/{chunk-F63F3FIT.mjs → chunk-A4XYK3MY.mjs} +2 -2
  33. package/dist/{chunk-NT6C7CHT.mjs → chunk-AWRCV3ME.mjs} +1 -1
  34. package/dist/{chunk-5X6SKB2P.mjs → chunk-BMS2QLJY.mjs} +1 -1
  35. package/dist/{chunk-3YPRDSZ6.mjs → chunk-BZKI5J2M.mjs} +1 -1
  36. package/dist/{chunk-25UWYEJX.mjs → chunk-CQOOXWPZ.mjs} +1 -1
  37. package/dist/{chunk-42OOM4DJ.mjs → chunk-D6UW7URG.mjs} +23 -6
  38. package/dist/{chunk-4YAPXPLM.mjs → chunk-DQUXK4WW.mjs} +1 -1
  39. package/dist/{chunk-MY6I7UJG.mjs → chunk-DTCIBQO2.mjs} +3 -3
  40. package/dist/{chunk-W7SLPIO2.mjs → chunk-FKNW5MLZ.mjs} +676 -151
  41. package/dist/{chunk-N4O5FAUC.mjs → chunk-FYWHE3W5.mjs} +1 -1
  42. package/dist/{chunk-QPKW37WR.mjs → chunk-GLBHPDR4.mjs} +249 -14
  43. package/dist/chunk-HGRIOEAR.mjs +32 -0
  44. package/dist/{chunk-PXJFCRIV.mjs → chunk-HNJ65IND.mjs} +4 -4
  45. package/dist/{chunk-Y5UO73CH.mjs → chunk-HTCYX4VD.mjs} +1 -1
  46. package/dist/{chunk-34KFHPN6.mjs → chunk-IAV7IKJ6.mjs} +1 -1
  47. package/dist/{store-add-locales-JLRTXG3Q.mjs → chunk-IKTGFXWR.mjs} +3 -67
  48. package/dist/{chunk-6W3BKVOC.mjs → chunk-KFYQTOGB.mjs} +1 -1
  49. package/dist/{chunk-EQTBJSBZ.mjs → chunk-KIIT4BNH.mjs} +3 -0
  50. package/dist/{chunk-LHNU4DYZ.mjs → chunk-KSDXSKJ7.mjs} +2 -2
  51. package/dist/{chunk-D4J3CEWH.mjs → chunk-N3SAXQVR.mjs} +2 -2
  52. package/dist/{chunk-Q6MSICBU.mjs → chunk-O333RR6K.mjs} +1 -1
  53. package/dist/{chunk-YAPTGHGP.mjs → chunk-OK6NZN2A.mjs} +1 -1
  54. package/dist/{chunk-7AX6R6G6.mjs → chunk-OSHH5GAS.mjs} +13 -1
  55. package/dist/{chunk-35LSPN2U.mjs → chunk-QKALAT7P.mjs} +1 -1
  56. package/dist/{chunk-UM4OIJZ3.mjs → chunk-S22SJRPO.mjs} +1 -1
  57. package/dist/{chunk-HFT7Q5Y5.mjs → chunk-SG2JZPTG.mjs} +1 -1
  58. package/dist/{chunk-B3AOQW2B.mjs → chunk-U6G4M5LP.mjs} +1 -1
  59. package/dist/{chunk-HWKLNKOY.mjs → chunk-U726TGCM.mjs} +1 -1
  60. package/dist/{chunk-HKIF5HVL.mjs → chunk-UJ2TMPV4.mjs} +12 -0
  61. package/dist/{chunk-5DUMSVP6.mjs → chunk-UMCJYHAD.mjs} +3 -3
  62. package/dist/{chunk-NHDFPGQ3.mjs → chunk-UWY5ZV66.mjs} +13 -1
  63. package/dist/{chunk-7ZYDO3XO.mjs → chunk-VFF5WB7C.mjs} +299 -194
  64. package/dist/{chunk-XXBP2Z5M.mjs → chunk-WVA4O7QS.mjs} +1 -1
  65. package/dist/{chunk-AH4DORIW.mjs → chunk-XY7A7GZJ.mjs} +1 -1
  66. package/dist/{chunk-FQDPOKEK.mjs → chunk-Y2YVTIJI.mjs} +1 -1
  67. package/dist/{chunk-L4NOVTH5.mjs → chunk-YIOBBZUB.mjs} +2 -2
  68. package/dist/{chunk-LEJUZW3P.mjs → chunk-Z6BFNHEO.mjs} +12 -0
  69. package/dist/{collection-add-products-JWAQ277T.mjs → collection-add-products-42F7H77E.mjs} +14 -13
  70. package/dist/{collection-create-DCRW344Z.mjs → collection-create-GWKWVT7B.mjs} +5 -4
  71. package/dist/{collection-detail-F4ON763T.mjs → collection-detail-PXIS3G64.mjs} +28 -12
  72. package/dist/{collection-edit-UNFEW6HT.mjs → collection-edit-EZIO2BR5.mjs} +5 -4
  73. package/dist/{collection-list-4C5HVO6Y.mjs → collection-list-O74CGY24.mjs} +29 -13
  74. package/dist/{collection-metadata-P4A5DXBQ.mjs → collection-metadata-U6FMA4IC.mjs} +14 -13
  75. package/dist/{customer-create-XCLZENJS.mjs → customer-create-IA56MXE6.mjs} +2 -2
  76. package/dist/{customer-create-address-4HZUIAM7.mjs → customer-create-address-27M25HTO.mjs} +2 -2
  77. package/dist/{customer-detail-X3RQJPXP.mjs → customer-detail-OMTFJ6CE.mjs} +12 -11
  78. package/dist/{customer-edit-BW5GVTQI.mjs → customer-edit-XQ5NWIVX.mjs} +2 -2
  79. package/dist/{customer-group-add-customers-SOXMSWQH.mjs → customer-group-add-customers-XMR2WBXX.mjs} +2 -2
  80. package/dist/{customer-group-create-6YV7W6TI.mjs → customer-group-create-RY4FVEIW.mjs} +2 -2
  81. package/dist/{customer-group-detail-NG32WKJT.mjs → customer-group-detail-ADK3M5LG.mjs} +11 -10
  82. package/dist/{customer-group-edit-7NXU34BQ.mjs → customer-group-edit-MQWARIQZ.mjs} +2 -2
  83. package/dist/{customer-group-list-EBETHKKO.mjs → customer-group-list-7ZRQ2HWU.mjs} +11 -10
  84. package/dist/{customer-group-metadata-WK2BGEGO.mjs → customer-group-metadata-JQJRLLXG.mjs} +3 -3
  85. package/dist/{customer-metadata-ZUWCUTM7.mjs → customer-metadata-HN2DYD5I.mjs} +3 -3
  86. package/dist/{customers-add-customer-group-7FYD54MZ.mjs → customers-add-customer-group-5U27WHJB.mjs} +13 -12
  87. package/dist/{edit-inventory-item-Y5W6VTHJ.mjs → edit-inventory-item-H7DAZWIT.mjs} +4 -3
  88. package/dist/{edit-inventory-item-attributes-NAAZDFEJ.mjs → edit-inventory-item-attributes-7HTXXPGZ.mjs} +4 -3
  89. package/dist/{edit-reservation-2UD4RZJX.mjs → edit-reservation-OVTRZHJR.mjs} +5 -4
  90. package/dist/{edit-rules-2W3BXEXR.mjs → edit-rules-BM2ERGVJ.mjs} +13 -12
  91. package/dist/en.json +38 -0
  92. package/dist/{inventory-create-VQEK7C5T.mjs → inventory-create-7MA7B5N2.mjs} +14 -13
  93. package/dist/{inventory-detail-HUHQ6ZNE.mjs → inventory-detail-B4PRHZK3.mjs} +11 -10
  94. package/dist/{inventory-list-RUSSPKHE.mjs → inventory-list-RXJPSVZE.mjs} +2 -1
  95. package/dist/{inventory-metadata-X52VGHA7.mjs → inventory-metadata-C7MJ3GY5.mjs} +14 -13
  96. package/dist/{inventory-stock-EKTOYN2F.mjs → inventory-stock-WVTYPJTX.mjs} +15 -14
  97. package/dist/{invite-VKHAAF4Z.mjs → invite-FVE4ZBKB.mjs} +2 -2
  98. package/dist/{location-create-RPLEXUZR.mjs → location-create-WZ43K3W7.mjs} +2 -2
  99. package/dist/{location-detail-UVWYE6Q2.mjs → location-detail-KO6EBDK5.mjs} +12 -11
  100. package/dist/{location-edit-L4ISEQHX.mjs → location-edit-VCS7GVWQ.mjs} +2 -2
  101. package/dist/{location-fulfillment-providers-HZZUHPVL.mjs → location-fulfillment-providers-IORBE3E3.mjs} +15 -14
  102. package/dist/{location-list-Z42ZYHUF.mjs → location-list-KVBA6J47.mjs} +2 -2
  103. package/dist/{location-sales-channels-XIMOK66B.mjs → location-sales-channels-P3QJTFDT.mjs} +5 -4
  104. package/dist/{location-service-zone-create-7ZNVLEE3.mjs → location-service-zone-create-J43WN6G4.mjs} +3 -3
  105. package/dist/{location-service-zone-edit-6OUAFEZD.mjs → location-service-zone-edit-KHHMSPXD.mjs} +2 -2
  106. package/dist/{location-service-zone-manage-areas-EOULKRYD.mjs → location-service-zone-manage-areas-6ZPMKMSX.mjs} +3 -3
  107. package/dist/{location-service-zone-shipping-option-create-M7G4SKNP.mjs → location-service-zone-shipping-option-create-2R3ZFLVK.mjs} +15 -14
  108. package/dist/{location-service-zone-shipping-option-edit-M2HJAASG.mjs → location-service-zone-shipping-option-edit-4CGPQ3VT.mjs} +2 -2
  109. package/dist/{location-service-zone-shipping-option-pricing-23QLNSBT.mjs → location-service-zone-shipping-option-pricing-5HN2Z5RB.mjs} +4 -4
  110. package/dist/{login-NSCAMAU6.mjs → login-XKB6OR7I.mjs} +13 -12
  111. package/dist/{manage-locations-JD6FSBOT.mjs → manage-locations-7HH6R4UP.mjs} +4 -3
  112. package/dist/{order-allocate-items-5T57NZOB.mjs → order-allocate-items-HZGGYJ42.mjs} +6 -5
  113. package/dist/{order-create-claim-TE56IE7P.mjs → order-create-claim-NKCOGF4A.mjs} +15 -14
  114. package/dist/{order-create-edit-RDFYBVFY.mjs → order-create-edit-UNQYXGLL.mjs} +14 -13
  115. package/dist/{order-create-exchange-B5ZOEQCJ.mjs → order-create-exchange-WI7OA2WO.mjs} +15 -14
  116. package/dist/{order-create-fulfillment-SRRP6X64.mjs → order-create-fulfillment-2LJTEWDY.mjs} +13 -12
  117. package/dist/{order-create-refund-PTOM65QK.mjs → order-create-refund-7K6UJXGP.mjs} +13 -12
  118. package/dist/{order-create-return-3C2QVNYN.mjs → order-create-return-52GHGW5Z.mjs} +7 -6
  119. package/dist/{order-create-shipment-HNILNFXB.mjs → order-create-shipment-ZTDLLUBY.mjs} +13 -12
  120. package/dist/{order-detail-3OUZOQ7G.mjs → order-detail-JTRUMRLO.mjs} +15 -14
  121. package/dist/{order-edit-billing-address-3IO7GXIK.mjs → order-edit-billing-address-YHYNVLOE.mjs} +13 -12
  122. package/dist/{order-edit-email-QIAEOUBV.mjs → order-edit-email-TCQPEVZY.mjs} +13 -12
  123. package/dist/{order-edit-shipping-address-QGGMHGBC.mjs → order-edit-shipping-address-CFSYQLKD.mjs} +13 -12
  124. package/dist/{order-export-JYYFTOWR.mjs → order-export-G4SBNEJ7.mjs} +14 -13
  125. package/dist/{order-list-RFR3HNDQ.mjs → order-list-GRLQWN4L.mjs} +6 -5
  126. package/dist/{order-metadata-ZBDTMBHZ.mjs → order-metadata-KGPB37VL.mjs} +14 -13
  127. package/dist/{order-receive-return-V42FTCFY.mjs → order-receive-return-JER24SEV.mjs} +14 -13
  128. package/dist/{order-request-transfer-A6NNIN2O.mjs → order-request-transfer-3FBUYZNT.mjs} +13 -12
  129. package/dist/{price-list-configuration-RTUEJENE.mjs → price-list-configuration-6S3MLNXQ.mjs} +6 -5
  130. package/dist/{price-list-create-GRT27KOM.mjs → price-list-create-CXZCFFTP.mjs} +17 -16
  131. package/dist/{price-list-detail-VKIWM7HP.mjs → price-list-detail-XOMU6U5J.mjs} +13 -12
  132. package/dist/{price-list-edit-SW7YIR3Z.mjs → price-list-edit-53UW35L3.mjs} +5 -4
  133. package/dist/{price-list-list-LF2PL4B5.mjs → price-list-list-DG5YEZ44.mjs} +4 -3
  134. package/dist/{price-list-prices-add-ISLZDQNI.mjs → price-list-prices-add-SDX5CQME.mjs} +16 -15
  135. package/dist/{price-list-prices-edit-C6SX2TLJ.mjs → price-list-prices-edit-EKB6NI5D.mjs} +7 -6
  136. package/dist/{product-attributes-REJ5NF2D.mjs → product-attributes-MXDPSOWM.mjs} +14 -13
  137. package/dist/{product-create-4TFE3JHQ.mjs → product-create-3O34JJLS.mjs} +16 -15
  138. package/dist/{product-create-option-GEGQNSMQ.mjs → product-create-option-7AOXAA4S.mjs} +4 -3
  139. package/dist/{product-create-variant-WI6D5CDG.mjs → product-create-variant-OTJKT6WI.mjs} +14 -13
  140. package/dist/{product-detail-BEIDGPKY.mjs → product-detail-SYTLG5D3.mjs} +59 -17
  141. package/dist/{product-edit-ZRQUK5OQ.mjs → product-edit-W72S22NM.mjs} +14 -13
  142. package/dist/{product-edit-option-HBIOBQTS.mjs → product-edit-option-LWJT3CYJ.mjs} +4 -3
  143. package/dist/{product-export-GIEFG4MA.mjs → product-export-57UUAGXF.mjs} +15 -14
  144. package/dist/{product-image-variants-edit-AAMRK4KQ.mjs → product-image-variants-edit-2BW5BJON.mjs} +13 -12
  145. package/dist/{product-import-43UXKCL3.mjs → product-import-6EM4VUXP.mjs} +13 -12
  146. package/dist/{product-list-D4CVUBQQ.mjs → product-list-5V5GEH5K.mjs} +25 -12
  147. package/dist/{product-media-EGK66SRX.mjs → product-media-3VJ7KENL.mjs} +4 -3
  148. package/dist/{product-metadata-55CAQTPS.mjs → product-metadata-JZLHBLZQ.mjs} +14 -13
  149. package/dist/{product-organization-7J7MUM6F.mjs → product-organization-SVXTCWIF.mjs} +15 -14
  150. package/dist/{product-prices-WQDE4XYT.mjs → product-prices-5ZL2RP7A.mjs} +5 -4
  151. package/dist/{product-sales-channels-GIJ7Q57M.mjs → product-sales-channels-PPXUG4KT.mjs} +5 -4
  152. package/dist/{product-shipping-profile-KIDRTPWA.mjs → product-shipping-profile-ETQFZ7DC.mjs} +4 -3
  153. package/dist/{product-stock-22S2HGMM.mjs → product-stock-SJJABF6I.mjs} +15 -14
  154. package/dist/{product-tag-create-7GPE246H.mjs → product-tag-create-XXO4AQEC.mjs} +13 -12
  155. package/dist/{product-tag-detail-R6C2TTA4.mjs → product-tag-detail-BSK64HXL.mjs} +30 -14
  156. package/dist/{product-tag-edit-WA6FGSIP.mjs → product-tag-edit-ENCGDT7E.mjs} +13 -12
  157. package/dist/{product-tag-list-U7PLHMLF.mjs → product-tag-list-SLQGCNDZ.mjs} +30 -14
  158. package/dist/{product-tag-metadata-EJ7FEXSE.mjs → product-tag-metadata-EPXHMU2K.mjs} +14 -13
  159. package/dist/{product-type-create-HBDROTGB.mjs → product-type-create-DRFXTL5O.mjs} +4 -3
  160. package/dist/{product-type-detail-TYQ7MJFE.mjs → product-type-detail-4CRRU7YK.mjs} +29 -13
  161. package/dist/{product-type-edit-H3JCMVRV.mjs → product-type-edit-SRHCZDK7.mjs} +4 -3
  162. package/dist/{product-type-list-KIKWBPD7.mjs → product-type-list-QQKAHBJ3.mjs} +19 -3
  163. package/dist/{product-type-metadata-Q6W5GL7Z.mjs → product-type-metadata-73OKOGPP.mjs} +14 -13
  164. package/dist/{product-variant-detail-SPJ7MZTK.mjs → product-variant-detail-RPHLG4HU.mjs} +27 -11
  165. package/dist/{product-variant-edit-BW7QMHC5.mjs → product-variant-edit-JF7NN64Y.mjs} +13 -12
  166. package/dist/{product-variant-manage-inventory-items-BLHCH6QD.mjs → product-variant-manage-inventory-items-Y2VEOHP7.mjs} +4 -3
  167. package/dist/{product-variant-media-KLSUISGH.mjs → product-variant-media-2WLVNGI4.mjs} +4 -3
  168. package/dist/{product-variant-metadata-GDMVC4MZ.mjs → product-variant-metadata-HU2CXGPO.mjs} +14 -13
  169. package/dist/{profile-edit-YBBXXCCK.mjs → profile-edit-ZNXO6WME.mjs} +2 -2
  170. package/dist/{promotion-add-campaign-JRTM7WBR.mjs → promotion-add-campaign-DO67QK6M.mjs} +3 -3
  171. package/dist/{promotion-create-HF6DTKCC.mjs → promotion-create-BHA3FQG2.mjs} +15 -14
  172. package/dist/{promotion-detail-HTM3F2VO.mjs → promotion-detail-F3QSR52W.mjs} +11 -10
  173. package/dist/{promotion-edit-details-AREFQ6O5.mjs → promotion-edit-details-6BSOOWQN.mjs} +2 -2
  174. package/dist/{refund-reason-create-RKIH46D6.mjs → refund-reason-create-ZA5TKW2Z.mjs} +13 -12
  175. package/dist/{refund-reason-edit-V3KC6NMO.mjs → refund-reason-edit-N2CRCLKZ.mjs} +13 -12
  176. package/dist/{refund-reason-list-M5BOHFWU.mjs → refund-reason-list-SE4TMGMT.mjs} +11 -10
  177. package/dist/{region-add-countries-OF5RUSYU.mjs → region-add-countries-2VAVXMJQ.mjs} +2 -2
  178. package/dist/{region-create-BGOWVCTR.mjs → region-create-NA7Y2LN4.mjs} +2 -2
  179. package/dist/{region-edit-5GO25GDF.mjs → region-edit-WAU347DP.mjs} +2 -2
  180. package/dist/{region-metadata-5NGUNAXZ.mjs → region-metadata-O5NZBWXP.mjs} +14 -13
  181. package/dist/{reservation-create-Z2SUMBGT.mjs → reservation-create-ZCIYM6JI.mjs} +5 -4
  182. package/dist/{reservation-detail-JH77TQHN.mjs → reservation-detail-UFK6XIXE.mjs} +11 -10
  183. package/dist/{reservation-list-WHBGZSVH.mjs → reservation-list-B47DXTA7.mjs} +3 -2
  184. package/dist/{reservation-metadata-ERCWXYVL.mjs → reservation-metadata-AEJEKGLV.mjs} +14 -13
  185. package/dist/{reset-password-5TAYQEUV.mjs → reset-password-Y5WVXV4Q.mjs} +2 -2
  186. package/dist/{return-reason-create-NXWDC6AC.mjs → return-reason-create-HM54WRJY.mjs} +2 -2
  187. package/dist/{return-reason-edit-M6IKNNKB.mjs → return-reason-edit-VSIRHVQ6.mjs} +2 -2
  188. package/dist/{sales-channel-add-products-DTAXWL6H.mjs → sales-channel-add-products-2LMB7EF5.mjs} +14 -13
  189. package/dist/{sales-channel-create-E7BDTPWD.mjs → sales-channel-create-MI7HHZYE.mjs} +5 -4
  190. package/dist/{sales-channel-detail-XWHV7J7X.mjs → sales-channel-detail-EUQ4STQI.mjs} +12 -11
  191. package/dist/{sales-channel-edit-HMPA3Y3L.mjs → sales-channel-edit-VSHOIR37.mjs} +5 -4
  192. package/dist/{sales-channel-list-7NSEFCXQ.mjs → sales-channel-list-JXKGHX4G.mjs} +11 -10
  193. package/dist/{sales-channel-metadata-CMZN74K7.mjs → sales-channel-metadata-AJMQ5SQ2.mjs} +14 -13
  194. package/dist/{shipping-option-type-create-4BN2GBHP.mjs → shipping-option-type-create-YVVIA2XC.mjs} +13 -12
  195. package/dist/{shipping-option-type-detail-YB3TCED2.mjs → shipping-option-type-detail-ZZW36XLK.mjs} +12 -11
  196. package/dist/{shipping-option-type-edit-MDO7ALAU.mjs → shipping-option-type-edit-O6F74T3A.mjs} +13 -12
  197. package/dist/{shipping-option-type-list-DJAT4RKX.mjs → shipping-option-type-list-SPTE7MT6.mjs} +12 -11
  198. package/dist/{shipping-profile-create-752TMBBE.mjs → shipping-profile-create-26R64I3Z.mjs} +2 -2
  199. package/dist/{shipping-profile-metadata-HQI7PCPU.mjs → shipping-profile-metadata-7WFE55VG.mjs} +14 -13
  200. package/dist/{store-add-currencies-PEWNEWCH.mjs → store-add-currencies-OX2WXFMS.mjs} +2 -2
  201. package/dist/store-add-locales-GWCGIXHU.mjs +81 -0
  202. package/dist/{store-detail-MOLAYNQZ.mjs → store-detail-YLJLBBZE.mjs} +11 -10
  203. package/dist/{store-edit-FTLPT55E.mjs → store-edit-5ZS562ZO.mjs} +2 -2
  204. package/dist/{store-metadata-ZJD23O4D.mjs → store-metadata-BZ57I2E6.mjs} +14 -13
  205. package/dist/{tax-region-create-NCO2OQ3I.mjs → tax-region-create-FGTV7VJL.mjs} +13 -12
  206. package/dist/{tax-region-detail-RIABXU7D.mjs → tax-region-detail-PPIMD7OX.mjs} +21 -20
  207. package/dist/{tax-region-edit-YZALLSZY.mjs → tax-region-edit-ELZKA7YH.mjs} +13 -12
  208. package/dist/{tax-region-list-BXZBUXRJ.mjs → tax-region-list-P4LDOPZD.mjs} +3 -3
  209. package/dist/{tax-region-province-create-5JP3PVID.mjs → tax-region-province-create-GKJ7WMRS.mjs} +2 -2
  210. package/dist/{tax-region-province-detail-UKLRVJS2.mjs → tax-region-province-detail-FV2NDT3E.mjs} +20 -19
  211. package/dist/{tax-region-tax-override-create-33XGHH7A.mjs → tax-region-tax-override-create-N572MQPZ.mjs} +16 -15
  212. package/dist/{tax-region-tax-override-edit-WOKZSPTY.mjs → tax-region-tax-override-edit-5DCSJW6D.mjs} +17 -16
  213. package/dist/{tax-region-tax-rate-create-O2SDSXCH.mjs → tax-region-tax-rate-create-MECFGVPL.mjs} +2 -2
  214. package/dist/{tax-region-tax-rate-edit-W62VEVKT.mjs → tax-region-tax-rate-edit-7DYSPYOD.mjs} +2 -2
  215. package/dist/translation-list-FK7XYLHX.mjs +527 -0
  216. package/dist/translations-edit-VRXZI5KW.mjs +678 -0
  217. package/dist/{user-detail-KEDJ7N3Q.mjs → user-detail-BJUXLZZQ.mjs} +2 -1
  218. package/dist/{user-edit-LXQCTDGA.mjs → user-edit-ZBB4RMTP.mjs} +2 -2
  219. package/dist/{user-invite-YH33WUC2.mjs → user-invite-GAGIM5DO.mjs} +2 -2
  220. package/dist/{user-metadata-4WOICEE7.mjs → user-metadata-GRJZZ524.mjs} +14 -13
  221. package/dist/{workflow-execution-detail-OKM6P4SX.mjs → workflow-execution-detail-HXTFWGKG.mjs} +11 -10
  222. package/package.json +9 -9
  223. package/src/components/common/icon-avatar/icon-avatar.tsx +4 -0
  224. package/src/components/data-grid/components/data-grid-cell-container.tsx +13 -4
  225. package/src/components/data-grid/components/data-grid-multiline-cell.tsx +103 -0
  226. package/src/components/data-grid/components/data-grid-readonly-cell.tsx +13 -3
  227. package/src/components/data-grid/components/data-grid-root.tsx +271 -60
  228. package/src/components/data-grid/components/data-grid-text-cell.tsx +7 -7
  229. package/src/components/data-grid/components/data-grid-textarea-modal-cell.tsx +233 -0
  230. package/src/components/data-grid/components/index.ts +2 -0
  231. package/src/components/data-grid/data-grid.tsx +16 -1
  232. package/src/components/data-grid/helpers/create-data-grid-column-helper.ts +18 -0
  233. package/src/components/data-grid/hooks/use-data-grid-cell.tsx +13 -1
  234. package/src/components/data-grid/hooks/use-data-grid-form-handlers.tsx +1 -0
  235. package/src/components/data-grid/hooks/use-data-grid-keydown-event.tsx +65 -7
  236. package/src/components/data-grid/types.ts +1 -0
  237. package/src/components/layout/settings-layout/settings-layout.tsx +11 -1
  238. package/src/components/modals/route-focus-modal/route-focus-modal.tsx +8 -3
  239. package/src/components/modals/route-modal-form/route-modal-form.tsx +6 -1
  240. package/src/components/modals/route-modal-provider/route-provider.tsx +16 -4
  241. package/src/dashboard-app/routes/get-route.map.tsx +23 -0
  242. package/src/hooks/api/categories.tsx +32 -0
  243. package/src/hooks/api/collections.tsx +31 -0
  244. package/src/hooks/api/index.ts +1 -0
  245. package/src/hooks/api/product-types.tsx +32 -0
  246. package/src/hooks/api/product-variants.tsx +47 -3
  247. package/src/hooks/api/products.tsx +29 -0
  248. package/src/hooks/api/tags.tsx +32 -0
  249. package/src/hooks/api/translations.tsx +315 -0
  250. package/src/hooks/use-infinite-list.tsx +92 -0
  251. package/src/i18n/translations/$schema.json +122 -0
  252. package/src/i18n/translations/en.json +38 -0
  253. package/src/i18n/translations/es.json +38 -0
  254. package/src/routes/categories/category-detail/components/category-general-section/category-general-section.tsx +16 -1
  255. package/src/routes/categories/category-list/components/category-list-table/category-list-table.tsx +16 -1
  256. package/src/routes/collections/collection-detail/components/collection-general-section/collection-general-section.tsx +16 -1
  257. package/src/routes/collections/collection-list/components/collection-list-table/collection-row-actions.tsx +16 -1
  258. package/src/routes/product-tags/product-tag-detail/components/product-tag-general-section/product-tag-general-section.tsx +16 -1
  259. package/src/routes/product-tags/product-tag-list/components/product-tag-list-table/product-tag-list-table.tsx +16 -1
  260. package/src/routes/product-types/product-type-detail/components/product-type-general-section/product-type-general-section.tsx +16 -1
  261. package/src/routes/product-types/product-type-list/components/product-type-list-table/product-table-row-actions.tsx +16 -1
  262. package/src/routes/product-variants/product-variant-detail/components/variant-general-section/variant-general-section.tsx +16 -1
  263. package/src/routes/products/product-detail/components/product-general-section/product-general-section.tsx +16 -1
  264. package/src/routes/products/product-detail/components/product-variant-section/product-variant-section.tsx +32 -1
  265. package/src/routes/products/product-list/components/product-list-table/product-list-table.tsx +15 -1
  266. package/src/routes/translations/add-locales/add-locales.tsx +29 -0
  267. package/src/routes/translations/add-locales/index.tsx +1 -0
  268. package/src/routes/translations/translation-list/components/active-locales-section/active-locales-section.tsx +93 -0
  269. package/src/routes/translations/translation-list/components/translation-list-section/translation-list-section.tsx +48 -0
  270. package/src/routes/translations/translation-list/components/translations-completion-section/translations-completion-section.tsx +285 -0
  271. package/src/routes/translations/translation-list/index.tsx +1 -0
  272. package/src/routes/translations/translation-list/translation-list.tsx +138 -0
  273. package/src/routes/translations/translations-edit/components/translations-edit-form/index.ts +1 -0
  274. package/src/routes/translations/translations-edit/components/translations-edit-form/translations-edit-form.tsx +747 -0
  275. package/src/routes/translations/translations-edit/index.ts +1 -0
  276. package/src/routes/translations/translations-edit/translations-edit.tsx +90 -0
@@ -0,0 +1,747 @@
1
+ import { zodResolver } from "@hookform/resolvers/zod"
2
+ import { AdminStoreLocale, HttpTypes } from "@medusajs/types"
3
+ import { Button, Prompt, Select, toast, Text } from "@medusajs/ui"
4
+ import { ColumnDef } from "@tanstack/react-table"
5
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react"
6
+ import { useForm } from "react-hook-form"
7
+ import { useTranslation } from "react-i18next"
8
+ import { z } from "zod"
9
+
10
+ import {
11
+ createDataGridHelper,
12
+ DataGrid,
13
+ } from "../../../../../components/data-grid"
14
+ import {
15
+ RouteFocusModal,
16
+ useRouteModal,
17
+ } from "../../../../../components/modals"
18
+ import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
19
+ import { useBatchTranslations } from "../../../../../hooks/api/translations"
20
+
21
+ const EntityTranslationsSchema = z.object({
22
+ id: z.string().nullish(),
23
+ fields: z.record(z.string().optional()),
24
+ })
25
+ export type EntityTranslationsSchema = z.infer<typeof EntityTranslationsSchema>
26
+
27
+ export const TranslationsFormSchema = z.object({
28
+ entities: z.record(EntityTranslationsSchema),
29
+ })
30
+ export type TranslationsFormSchema = z.infer<typeof TranslationsFormSchema>
31
+
32
+ export type TranslationRow = EntityRow | FieldRow
33
+
34
+ export type EntityRow = {
35
+ _type: "entity"
36
+ reference_id: string
37
+ subRows: FieldRow[]
38
+ }
39
+
40
+ export type FieldRow = {
41
+ _type: "field"
42
+ reference_id: string
43
+ field_name: string
44
+ }
45
+
46
+ export function isEntityRow(row: TranslationRow): row is EntityRow {
47
+ return row._type === "entity"
48
+ }
49
+
50
+ export function isFieldRow(row: TranslationRow): row is FieldRow {
51
+ return row._type === "field"
52
+ }
53
+
54
+ type LocaleSnapshot = {
55
+ localeCode: string
56
+ entities: Record<string, EntityTranslationsSchema>
57
+ }
58
+
59
+ function buildLocaleSnapshot(
60
+ translations: HttpTypes.AdminTranslation[],
61
+ references: { id: string; [key: string]: string }[],
62
+ localeCode: string,
63
+ translatableFields: string[]
64
+ ): LocaleSnapshot {
65
+ const referenceTranslations = new Map<string, HttpTypes.AdminTranslation>()
66
+ for (const t of translations) {
67
+ if (t.locale_code === localeCode) {
68
+ referenceTranslations.set(t.reference_id, t)
69
+ }
70
+ }
71
+
72
+ const entities: Record<string, EntityTranslationsSchema> = {}
73
+ for (const ref of references) {
74
+ const existing = referenceTranslations.get(ref.id)
75
+ const fields: Record<string, string> = {}
76
+
77
+ for (const fieldName of translatableFields) {
78
+ fields[fieldName] = (existing?.translations?.[fieldName] as string) ?? ""
79
+ }
80
+
81
+ entities[ref.id] = {
82
+ id: existing?.id ?? null,
83
+ fields,
84
+ }
85
+ }
86
+
87
+ return { localeCode, entities }
88
+ }
89
+
90
+ function extendSnapshot(
91
+ snapshot: LocaleSnapshot,
92
+ translations: HttpTypes.AdminTranslation[],
93
+ newReferences: { id: string; [key: string]: string }[],
94
+ translatableFields: string[]
95
+ ): LocaleSnapshot {
96
+ const referenceTranslations = new Map<string, HttpTypes.AdminTranslation>()
97
+ for (const t of translations) {
98
+ if (t.locale_code === snapshot.localeCode) {
99
+ referenceTranslations.set(t.reference_id, t)
100
+ }
101
+ }
102
+
103
+ const extendedEntities = { ...snapshot.entities }
104
+
105
+ for (const ref of newReferences) {
106
+ if (!extendedEntities[ref.id]) {
107
+ const existing = referenceTranslations.get(ref.id)
108
+ const fields: Record<string, string> = {}
109
+
110
+ for (const fieldName of translatableFields) {
111
+ fields[fieldName] =
112
+ (existing?.translations?.[fieldName] as string) ?? ""
113
+ }
114
+
115
+ extendedEntities[ref.id] = {
116
+ id: existing?.id ?? null,
117
+ fields,
118
+ }
119
+ }
120
+ }
121
+
122
+ return { ...snapshot, entities: extendedEntities }
123
+ }
124
+
125
+ function snapshotToFormValues(
126
+ snapshot: LocaleSnapshot
127
+ ): TranslationsFormSchema {
128
+ return { entities: snapshot.entities }
129
+ }
130
+
131
+ type ChangeDetectionResult = {
132
+ hasChanges: boolean
133
+ payload: Required<HttpTypes.AdminBatchTranslations>
134
+ }
135
+
136
+ function computeChanges(
137
+ currentState: TranslationsFormSchema,
138
+ snapshot: LocaleSnapshot,
139
+ entityType: string,
140
+ localeCode: string
141
+ ): ChangeDetectionResult {
142
+ const payload: Required<HttpTypes.AdminBatchTranslations> = {
143
+ create: [],
144
+ update: [],
145
+ delete: [],
146
+ }
147
+
148
+ for (const [entityId, entityData] of Object.entries(currentState.entities)) {
149
+ const baseline = snapshot.entities[entityId]
150
+ if (!baseline) {
151
+ continue
152
+ }
153
+
154
+ const hasContent = Object.values(entityData.fields).some(
155
+ (v) => v !== undefined && v.trim() !== ""
156
+ )
157
+ const hadContent = Object.values(baseline.fields).some(
158
+ (v) => v !== undefined && v.trim() !== ""
159
+ )
160
+ const hasChanged =
161
+ JSON.stringify(entityData.fields) !== JSON.stringify(baseline.fields)
162
+
163
+ if (!entityData.id && hasContent) {
164
+ payload.create.push({
165
+ reference_id: entityId,
166
+ reference: entityType,
167
+ locale_code: localeCode,
168
+ translations: entityData.fields,
169
+ })
170
+ } else if (entityData.id && hasContent && hasChanged) {
171
+ payload.update.push({
172
+ id: entityData.id,
173
+ translations: entityData.fields,
174
+ })
175
+ } else if (entityData.id && !hasContent && hadContent) {
176
+ payload.delete.push(entityData.id)
177
+ }
178
+ }
179
+
180
+ const hasChanges =
181
+ payload.create.length > 0 ||
182
+ payload.update.length > 0 ||
183
+ payload.delete.length > 0
184
+
185
+ return { hasChanges, payload }
186
+ }
187
+
188
+ const columnHelper = createDataGridHelper<
189
+ TranslationRow,
190
+ TranslationsFormSchema
191
+ >()
192
+
193
+ const FIELD_COLUMN_WIDTH = 350
194
+
195
+ function buildTranslationRows(
196
+ references: { id: string; [key: string]: string }[],
197
+ translatableFields: string[]
198
+ ): TranslationRow[] {
199
+ return references.map((reference) => ({
200
+ _type: "entity" as const,
201
+ reference_id: reference.id,
202
+ subRows: translatableFields.map((fieldName) => ({
203
+ _type: "field" as const,
204
+ reference_id: reference.id,
205
+ field_name: fieldName,
206
+ })),
207
+ }))
208
+ }
209
+
210
+ function useTranslationsGridColumns({
211
+ entities,
212
+ availableLocales,
213
+ selectedLocale,
214
+ dynamicColumnWidth,
215
+ }: {
216
+ entities: { id: string; [key: string]: string }[]
217
+ availableLocales: AdminStoreLocale[]
218
+ selectedLocale: string
219
+ dynamicColumnWidth: number
220
+ }) {
221
+ const { t } = useTranslation()
222
+
223
+ return useMemo(() => {
224
+ const selectedLocaleData = availableLocales.find(
225
+ (l) => l.locale_code === selectedLocale
226
+ )
227
+
228
+ const columns: ColumnDef<TranslationRow>[] = [
229
+ columnHelper.column({
230
+ id: "field",
231
+ name: "field",
232
+ size: FIELD_COLUMN_WIDTH,
233
+ header: undefined,
234
+ cell: (context) => {
235
+ const row = context.row.original
236
+
237
+ if (isEntityRow(row)) {
238
+ return <DataGrid.ReadonlyCell context={context} />
239
+ }
240
+
241
+ return (
242
+ <DataGrid.ReadonlyCell context={context} color="normal">
243
+ <div className="flex h-full w-full items-center gap-x-2 overflow-hidden">
244
+ <Text
245
+ className="text-ui-fg-subtle truncate"
246
+ weight="plus"
247
+ size="small"
248
+ >
249
+ {t(`fields.${row.field_name}`, {
250
+ defaultValue: row.field_name,
251
+ })}
252
+ </Text>
253
+ </div>
254
+ </DataGrid.ReadonlyCell>
255
+ )
256
+ },
257
+ disableHiding: true,
258
+ }),
259
+ columnHelper.column({
260
+ id: "original",
261
+ name: "original",
262
+ size: dynamicColumnWidth,
263
+ header: () => (
264
+ <Text className="text-ui-fg-base" weight="plus" size="small">
265
+ {t("general.original")}
266
+ </Text>
267
+ ),
268
+ disableHiding: true,
269
+ cell: (context) => {
270
+ const row = context.row.original
271
+
272
+ if (isEntityRow(row)) {
273
+ return <DataGrid.ReadonlyCell context={context} />
274
+ }
275
+
276
+ const entity = entities.find((e) => e.id === row.reference_id)
277
+ if (!entity) {
278
+ return null
279
+ }
280
+
281
+ return (
282
+ <DataGrid.ReadonlyCell color="normal" context={context} isMultiLine>
283
+ <Text className="text-ui-fg-subtle" weight="plus" size="small">
284
+ {entity[row.field_name]}
285
+ </Text>
286
+ </DataGrid.ReadonlyCell>
287
+ )
288
+ },
289
+ }),
290
+ ]
291
+
292
+ if (selectedLocaleData) {
293
+ columns.push(
294
+ columnHelper.column({
295
+ id: selectedLocaleData.locale_code,
296
+ name: selectedLocaleData.locale.name,
297
+ size: dynamicColumnWidth,
298
+ header: () => (
299
+ <Text className="text-ui-fg-base" weight="plus" size="small">
300
+ {selectedLocaleData.locale.name}
301
+ </Text>
302
+ ),
303
+ cell: (context) => {
304
+ const row = context.row.original
305
+
306
+ if (isEntityRow(row)) {
307
+ return <DataGrid.ReadonlyCell context={context} isMultiLine />
308
+ }
309
+
310
+ return <DataGrid.MultilineCell context={context} />
311
+ },
312
+ field: (context) => {
313
+ const row = context.row.original
314
+
315
+ if (isEntityRow(row)) {
316
+ return null
317
+ }
318
+
319
+ return `entities.${row.reference_id}.fields.${row.field_name}`
320
+ },
321
+ type: "multiline-text",
322
+ })
323
+ )
324
+ }
325
+
326
+ return columns
327
+ }, [t, availableLocales, selectedLocale, entities, dynamicColumnWidth])
328
+ }
329
+
330
+ type TranslationsEditFormProps = {
331
+ translations: HttpTypes.AdminTranslation[]
332
+ references: { id: string; [key: string]: string }[]
333
+ entityType: string
334
+ availableLocales: AdminStoreLocale[]
335
+ translatableFields: string[]
336
+ fetchNextPage: () => void
337
+ hasNextPage: boolean
338
+ isFetchingNextPage: boolean
339
+ referenceCount: number
340
+ }
341
+
342
+ export const TranslationsEditForm = ({
343
+ translations,
344
+ references,
345
+ entityType,
346
+ availableLocales,
347
+ translatableFields,
348
+ fetchNextPage,
349
+ hasNextPage,
350
+ isFetchingNextPage,
351
+ referenceCount,
352
+ }: TranslationsEditFormProps) => {
353
+ const { t } = useTranslation()
354
+ const { handleSuccess, setCloseOnEscape } = useRouteModal()
355
+
356
+ const containerRef = useRef<HTMLDivElement>(null)
357
+ const [dynamicColumnWidth, setDynamicColumnWidth] = useState(400)
358
+
359
+ useEffect(() => {
360
+ const calculateColumnWidth = () => {
361
+ if (containerRef.current) {
362
+ const containerWidth = containerRef.current.offsetWidth
363
+ const availableWidth = containerWidth - FIELD_COLUMN_WIDTH - 16
364
+ const columnWidth = Math.max(300, Math.floor(availableWidth / 2))
365
+ setDynamicColumnWidth(columnWidth)
366
+ }
367
+ }
368
+
369
+ calculateColumnWidth()
370
+
371
+ const resizeObserver = new ResizeObserver(calculateColumnWidth)
372
+ if (containerRef.current) {
373
+ resizeObserver.observe(containerRef.current)
374
+ }
375
+
376
+ return () => resizeObserver.disconnect()
377
+ }, [])
378
+
379
+ const [selectedLocale, setSelectedLocale] = useState<string>(
380
+ availableLocales[0]?.locale_code ?? ""
381
+ )
382
+ const [showUnsavedPrompt, setShowUnsavedPrompt] = useState(false)
383
+ const [pendingLocale, setPendingLocale] = useState<string | null>(null)
384
+ const [isSwitchingLocale, setIsSwitchingLocale] = useState(false)
385
+
386
+ const snapshotRef = useRef<LocaleSnapshot>(
387
+ buildLocaleSnapshot(
388
+ translations,
389
+ references,
390
+ selectedLocale,
391
+ translatableFields
392
+ )
393
+ )
394
+
395
+ const knownEntityIdsRef = useRef<Set<string>>(
396
+ new Set(references.map((r) => r.id))
397
+ )
398
+
399
+ const latestPropsRef = useRef({ translations, references })
400
+ useEffect(() => {
401
+ latestPropsRef.current = { translations, references }
402
+ }, [translations, references])
403
+
404
+ const form = useForm<TranslationsFormSchema>({
405
+ resolver: zodResolver(TranslationsFormSchema),
406
+ defaultValues: snapshotToFormValues(snapshotRef.current),
407
+ })
408
+
409
+ useEffect(() => {
410
+ const currentIds = new Set(references.map((r) => r.id))
411
+ const newReferences = references.filter(
412
+ (r) => !knownEntityIdsRef.current.has(r.id)
413
+ )
414
+
415
+ if (newReferences.length === 0) {
416
+ return
417
+ }
418
+
419
+ knownEntityIdsRef.current = currentIds
420
+ snapshotRef.current = extendSnapshot(
421
+ snapshotRef.current,
422
+ translations,
423
+ newReferences,
424
+ translatableFields
425
+ )
426
+
427
+ const currentValues = form.getValues()
428
+ const newFormValues: TranslationsFormSchema = {
429
+ entities: { ...currentValues.entities },
430
+ }
431
+
432
+ for (const ref of newReferences) {
433
+ if (!newFormValues.entities[ref.id]) {
434
+ newFormValues.entities[ref.id] = snapshotRef.current.entities[ref.id]
435
+ }
436
+ }
437
+
438
+ form.reset(newFormValues, {
439
+ keepDirty: true,
440
+ keepDirtyValues: true,
441
+ })
442
+ }, [references, translations, translatableFields, form])
443
+
444
+ const rows = useMemo(
445
+ () => buildTranslationRows(references, translatableFields),
446
+ [references, translatableFields]
447
+ )
448
+
449
+ const totalRowCount = useMemo(
450
+ () => referenceCount * (translatableFields.length + 1),
451
+ [referenceCount, translatableFields]
452
+ )
453
+
454
+ const selectedLocaleDisplay = useMemo(
455
+ () =>
456
+ availableLocales.find((l) => l.locale_code === selectedLocale)?.locale
457
+ .name,
458
+ [availableLocales, selectedLocale]
459
+ )
460
+
461
+ const columns = useTranslationsGridColumns({
462
+ entities: references,
463
+ availableLocales,
464
+ selectedLocale,
465
+ dynamicColumnWidth,
466
+ })
467
+
468
+ const { mutateAsync, isPending, invalidateQueries } =
469
+ useBatchTranslations(entityType)
470
+
471
+ const saveCurrentLocale = useCallback(async () => {
472
+ const currentValues = form.getValues()
473
+ const { hasChanges, payload } = computeChanges(
474
+ currentValues,
475
+ snapshotRef.current,
476
+ entityType,
477
+ selectedLocale
478
+ )
479
+
480
+ if (!hasChanges) {
481
+ return true
482
+ }
483
+
484
+ try {
485
+ const BATCH_SIZE = 150
486
+ const totalItems =
487
+ payload.create.length + payload.update.length + payload.delete.length
488
+ const batchCount = Math.ceil(totalItems / BATCH_SIZE)
489
+
490
+ for (let i = 0; i < batchCount; i++) {
491
+ let currentBatchAvailable = BATCH_SIZE
492
+
493
+ const currentBatch: HttpTypes.AdminBatchTranslations = {
494
+ create: [],
495
+ update: [],
496
+ delete: [],
497
+ }
498
+
499
+ if (payload.create.length > 0) {
500
+ currentBatch.create = payload.create.splice(0, currentBatchAvailable)
501
+ currentBatchAvailable -= currentBatch.create.length
502
+ }
503
+ if (payload.update.length > 0) {
504
+ currentBatch.update = payload.update.splice(0, currentBatchAvailable)
505
+ currentBatchAvailable -= currentBatch.update.length
506
+ }
507
+ if (payload.delete.length > 0) {
508
+ currentBatch.delete = payload.delete.splice(0, currentBatchAvailable)
509
+ }
510
+
511
+ const response = await mutateAsync(currentBatch, {
512
+ onError: (error) => {
513
+ toast.error(error.message)
514
+ },
515
+ })
516
+
517
+ if (response.created) {
518
+ for (const created of response.created) {
519
+ form.setValue(`entities.${created.reference_id}.id`, created.id, {
520
+ shouldDirty: false,
521
+ })
522
+ if (snapshotRef.current.entities[created.reference_id]) {
523
+ snapshotRef.current.entities[created.reference_id].id = created.id
524
+ }
525
+ }
526
+ }
527
+ }
528
+
529
+ const savedValues = form.getValues()
530
+ for (const entityId of Object.keys(savedValues.entities)) {
531
+ if (snapshotRef.current.entities[entityId]) {
532
+ snapshotRef.current.entities[entityId] = {
533
+ ...savedValues.entities[entityId],
534
+ }
535
+ }
536
+ }
537
+
538
+ form.reset(savedValues)
539
+
540
+ return true
541
+ } catch (error) {
542
+ toast.error(
543
+ error instanceof Error ? error.message : "Failed to save translations"
544
+ )
545
+ return false
546
+ }
547
+ }, [form, entityType, selectedLocale, mutateAsync])
548
+
549
+ const switchToLocale = useCallback(
550
+ async (newLocale: string) => {
551
+ setIsSwitchingLocale(true)
552
+
553
+ try {
554
+ await invalidateQueries()
555
+
556
+ await new Promise((resolve) => requestAnimationFrame(resolve))
557
+
558
+ const { translations, references } = latestPropsRef.current
559
+
560
+ const newSnapshot = buildLocaleSnapshot(
561
+ translations,
562
+ references,
563
+ newLocale,
564
+ translatableFields
565
+ )
566
+
567
+ snapshotRef.current = newSnapshot
568
+ knownEntityIdsRef.current = new Set(references.map((r) => r.id))
569
+
570
+ form.reset(snapshotToFormValues(newSnapshot))
571
+
572
+ setSelectedLocale(newLocale)
573
+ } finally {
574
+ setIsSwitchingLocale(false)
575
+ }
576
+ },
577
+ [translatableFields, form, invalidateQueries]
578
+ )
579
+
580
+ const handleLocaleChange = useCallback(
581
+ (newLocale: string) => {
582
+ if (newLocale === selectedLocale) {
583
+ return
584
+ }
585
+
586
+ const currentValues = form.getValues()
587
+ const { hasChanges } = computeChanges(
588
+ currentValues,
589
+ snapshotRef.current,
590
+ entityType,
591
+ selectedLocale
592
+ )
593
+
594
+ if (hasChanges) {
595
+ setPendingLocale(newLocale)
596
+ setShowUnsavedPrompt(true)
597
+ } else {
598
+ switchToLocale(newLocale)
599
+ }
600
+ },
601
+ [selectedLocale, form, entityType, switchToLocale]
602
+ )
603
+
604
+ const handleSaveAndSwitch = useCallback(async () => {
605
+ const success = await saveCurrentLocale()
606
+ if (success && pendingLocale) {
607
+ toast.success(t("translations.edit.successToast"))
608
+ await switchToLocale(pendingLocale)
609
+ }
610
+ setShowUnsavedPrompt(false)
611
+ setPendingLocale(null)
612
+ }, [saveCurrentLocale, pendingLocale, t, switchToLocale])
613
+
614
+ const handleCancelSwitch = useCallback(() => {
615
+ setShowUnsavedPrompt(false)
616
+ setPendingLocale(null)
617
+ }, [])
618
+
619
+ const handleSave = useCallback(
620
+ async (closeOnSuccess: boolean = false) => {
621
+ const success = await saveCurrentLocale()
622
+ if (success) {
623
+ toast.success(t("translations.edit.successToast"))
624
+ if (closeOnSuccess) {
625
+ handleSuccess()
626
+ }
627
+ }
628
+ },
629
+ [saveCurrentLocale, t, handleSuccess]
630
+ )
631
+
632
+ const handleClose = useCallback(() => {
633
+ invalidateQueries()
634
+ }, [invalidateQueries])
635
+
636
+ const isLoading = isPending || isSwitchingLocale
637
+
638
+ return (
639
+ <RouteFocusModal.Form form={form} onClose={handleClose}>
640
+ <KeyboundForm
641
+ onSubmit={() => handleSave(true)}
642
+ className="flex h-full flex-col overflow-hidden"
643
+ >
644
+ <RouteFocusModal.Header />
645
+ <RouteFocusModal.Body className="size-full overflow-hidden">
646
+ <div ref={containerRef} className="size-full">
647
+ <DataGrid
648
+ showColumnsDropdown={false}
649
+ columns={columns}
650
+ data={rows}
651
+ getSubRows={(row) => {
652
+ if (isEntityRow(row)) {
653
+ return row.subRows
654
+ }
655
+ }}
656
+ state={form}
657
+ onEditingChange={(editing) => setCloseOnEscape(!editing)}
658
+ totalRowCount={totalRowCount}
659
+ onFetchMore={fetchNextPage}
660
+ isFetchingMore={isFetchingNextPage}
661
+ hasNextPage={hasNextPage}
662
+ headerContent={
663
+ <Select
664
+ disabled={isLoading}
665
+ value={selectedLocale}
666
+ onValueChange={handleLocaleChange}
667
+ size="small"
668
+ >
669
+ <Select.Trigger className="bg-ui-bg-base w-[200px]">
670
+ <Select.Value>{selectedLocaleDisplay}</Select.Value>
671
+ </Select.Trigger>
672
+ <Select.Content>
673
+ {availableLocales.map((locale) => (
674
+ <Select.Item
675
+ key={locale.locale_code}
676
+ value={locale.locale_code}
677
+ >
678
+ {locale.locale.name}
679
+ </Select.Item>
680
+ ))}
681
+ </Select.Content>
682
+ </Select>
683
+ }
684
+ />
685
+ </div>
686
+ </RouteFocusModal.Body>
687
+ <RouteFocusModal.Footer>
688
+ <div className="flex items-center justify-end gap-x-2">
689
+ <RouteFocusModal.Close asChild>
690
+ <Button
691
+ type="button"
692
+ size="small"
693
+ variant="secondary"
694
+ isLoading={isLoading}
695
+ >
696
+ {t("actions.cancel")}
697
+ </Button>
698
+ </RouteFocusModal.Close>
699
+ <Button
700
+ size="small"
701
+ type="button"
702
+ variant="secondary"
703
+ onClick={() => handleSave(false)}
704
+ isLoading={isLoading}
705
+ >
706
+ {t("actions.saveChanges")}
707
+ </Button>
708
+ <Button size="small" type="submit" isLoading={isLoading}>
709
+ {t("actions.saveAndClose")}
710
+ </Button>
711
+ </div>
712
+ </RouteFocusModal.Footer>
713
+ </KeyboundForm>
714
+
715
+ <Prompt open={showUnsavedPrompt} variant="confirmation">
716
+ <Prompt.Content>
717
+ <Prompt.Header>
718
+ <Prompt.Title>
719
+ {t("translations.edit.unsavedChanges.title")}
720
+ </Prompt.Title>
721
+ <Prompt.Description>
722
+ {t("translations.edit.unsavedChanges.description")}
723
+ </Prompt.Description>
724
+ </Prompt.Header>
725
+ <Prompt.Footer>
726
+ <Button
727
+ size="small"
728
+ variant="secondary"
729
+ onClick={handleCancelSwitch}
730
+ type="button"
731
+ >
732
+ {t("actions.close")}
733
+ </Button>
734
+ <Button
735
+ size="small"
736
+ onClick={handleSaveAndSwitch}
737
+ type="button"
738
+ isLoading={isLoading}
739
+ >
740
+ {t("actions.saveChanges")}
741
+ </Button>
742
+ </Prompt.Footer>
743
+ </Prompt.Content>
744
+ </Prompt>
745
+ </RouteFocusModal.Form>
746
+ )
747
+ }