@medusajs/dashboard 2.12.3-preview-20251217120154 → 2.12.3-snapshot-20251216185234

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