@mercurjs/vendor 2.2.0-canary.8 → 2.2.0-rc.0

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 (305) hide show
  1. package/dist/{[id]-GMJAPZPU.js → [id]-3LNKC5OJ.js} +41 -40
  2. package/dist/[id]-4HO4S2PX.js +3074 -0
  3. package/dist/{[id]-QWL6SUOB.js → [id]-4LIIFGET.js} +14 -14
  4. package/dist/{[id]-5ADOHZ45.js → [id]-5EECCIRP.js} +151 -58
  5. package/dist/{[id]-K2CT7BXQ.js → [id]-5P5LTATX.js} +3 -3
  6. package/dist/{[id]-T7USGHIY.js → [id]-AQUUZFRX.js} +11 -11
  7. package/dist/{[id]-BTGQJ3UD.js → [id]-CUBGVODE.js} +177 -85
  8. package/dist/{[id]-ZAQYATGN.js → [id]-DCGPICT3.js} +39 -38
  9. package/dist/{[id]-IWCWVNVI.js → [id]-DT5YJVKG.js} +32 -32
  10. package/dist/{[id]-L6FD7BRE.js → [id]-IEBZ6V3W.js} +51 -48
  11. package/dist/{[id]-ZCMSBEVM.js → [id]-N7JEZFXQ.js} +6 -6
  12. package/dist/[id]-U6FKX5UQ.js +975 -0
  13. package/dist/{[id]-BPAZLOLW.js → [id]-XB45DY2D.js} +19 -19
  14. package/dist/[id]-XP5KEMNX.js +602 -0
  15. package/dist/{[location_id]-NUBXDDJC.js → [location_id]-I4HHUHWY.js} +14 -14
  16. package/dist/{[province_id]-5KZGMQER.js → [province_id]-OYX4MOCF.js} +31 -31
  17. package/dist/{add-KMHJ6OC6.js → add-3T4GBFMM.js} +63 -57
  18. package/dist/{add-Y6GMGLYX.js → add-RPRJWCYU.js} +99 -34
  19. package/dist/{add-customer-groups-NXSWICFI.js → add-customer-groups-FB5T6PQN.js} +44 -42
  20. package/dist/{add-products-LXYF57BK.js → add-products-F243SWGD.js} +40 -40
  21. package/dist/{add-promotions-VTYAEDCN.js → add-promotions-TJDK7HLW.js} +18 -18
  22. package/dist/{add-to-campaign-DLP7PSQB.js → add-to-campaign-Q6OAJMUJ.js} +6 -6
  23. package/dist/{address-JFXH3M7D.js → address-XVBSNMFU.js} +24 -24
  24. package/dist/{adjust-inventory-V2V7NWWH.js → adjust-inventory-IZLRMQXV.js} +4 -4
  25. package/dist/allocate-items-Q3VALDYT.js +685 -0
  26. package/dist/{areas-FB63OQAI.js → areas-IYGBRCRH.js} +14 -14
  27. package/dist/attributes-LGEM2JJW.js +353 -0
  28. package/dist/breadcrumb-BC6XN2SE.js +13 -0
  29. package/dist/{breadcrumb-THJ2HPRB.js → breadcrumb-BFNJWOJ4.js} +10 -9
  30. package/dist/{breadcrumb-S4V7MJUM.js → breadcrumb-BXD3SRM7.js} +3 -3
  31. package/dist/{breadcrumb-HV67K43U.js → breadcrumb-FEYGZFJU.js} +4 -4
  32. package/dist/{breadcrumb-EG3ANCVO.js → breadcrumb-H45Z2WNG.js} +3 -3
  33. package/dist/breadcrumb-ILEAQRW7.js +33 -0
  34. package/dist/breadcrumb-K4HBKZUE.js +28 -0
  35. package/dist/{breadcrumb-YBBYFQYG.js → breadcrumb-KZPOPXGG.js} +2 -2
  36. package/dist/{breadcrumb-F3BN5753.js → breadcrumb-L262VPBO.js} +2 -2
  37. package/dist/{breadcrumb-3Z7KZG62.js → breadcrumb-LEFHXFLT.js} +3 -3
  38. package/dist/{breadcrumb-D3UDTWGE.js → breadcrumb-MOA2DBOE.js} +2 -2
  39. package/dist/breadcrumb-NZYOCEEM.js +47 -0
  40. package/dist/breadcrumb-VY5DNTTJ.js +46 -0
  41. package/dist/{breadcrumb-UAUX7XCV.js → breadcrumb-WG6TIF4C.js} +2 -2
  42. package/dist/{breadcrumb-7R6E6G2X.js → breadcrumb-XEZCMI55.js} +2 -2
  43. package/dist/{breadcrumb-FES7EKUR.js → breadcrumb-XGXKCDYS.js} +4 -4
  44. package/dist/{breadcrumb-Y5UW3I4C.js → breadcrumb-YOY6Z36F.js} +2 -2
  45. package/dist/{campaigns-JAQTSA4Z.js → campaigns-DZKRNCA4.js} +9 -9
  46. package/dist/{categories-6TVMTN62.js → categories-JZJA2IBQ.js} +13 -11
  47. package/dist/{chunk-SFQKKIHA.js → chunk-27WLUOI2.js} +1 -1
  48. package/dist/{chunk-U5XDKYZG.js → chunk-2KA4TGBQ.js} +3 -3
  49. package/dist/{chunk-6RH3VDF7.js → chunk-2NPD4S55.js} +4 -4
  50. package/dist/{chunk-M6GKMFTC.js → chunk-3ALBZK4M.js} +1 -1
  51. package/dist/{chunk-PXYDR7WQ.js → chunk-3BXCPHN6.js} +3 -2
  52. package/dist/{chunk-X4INVIWL.js → chunk-3C2T27YW.js} +3 -3
  53. package/dist/{chunk-QXLRABYH.js → chunk-3I6ZAMGN.js} +1 -1
  54. package/dist/{chunk-THMXGEZU.js → chunk-3SH24DGG.js} +2 -2
  55. package/dist/chunk-3TST3EWQ.js +438 -0
  56. package/dist/chunk-42R54Z2X.js +8 -0
  57. package/dist/{chunk-UDJ2I5A2.js → chunk-4IRQSBA7.js} +5 -6
  58. package/dist/chunk-5ALC4Z2H.js +23 -0
  59. package/dist/chunk-5BQO3YQP.js +62 -0
  60. package/dist/{chunk-QGGMG3OU.js → chunk-5BYYDBLS.js} +7 -7
  61. package/dist/{chunk-4LVP635F.js → chunk-5FBQOAXU.js} +135 -126
  62. package/dist/{chunk-2BCAQ4BB.js → chunk-5PAUN3PM.js} +3 -3
  63. package/dist/{chunk-E2HQPY32.js → chunk-5RMLLTR7.js} +5 -5
  64. package/dist/{chunk-3EF54XFY.js → chunk-634XVU3D.js} +1 -1
  65. package/dist/{chunk-LJO34DKJ.js → chunk-6FDPVW7Y.js} +35 -21
  66. package/dist/{chunk-3X3LUKDM.js → chunk-6Q3J6ZMM.js} +5 -5
  67. package/dist/chunk-7BFQKYCJ.js +127 -0
  68. package/dist/chunk-7EXKHL5L.js +30 -0
  69. package/dist/{chunk-M6N4ISXL.js → chunk-7MARNXFG.js} +1 -1
  70. package/dist/{chunk-WHSE47DM.js → chunk-AOLE7MBM.js} +1 -1
  71. package/dist/{chunk-YIZK67RW.js → chunk-BQHVM46E.js} +29 -49
  72. package/dist/chunk-CRYZK4NU.js +185 -0
  73. package/dist/{chunk-JYPPXAJG.js → chunk-CUAGC54B.js} +33 -35
  74. package/dist/{chunk-KIFSQOM2.js → chunk-D76WZZSB.js} +5 -5
  75. package/dist/{chunk-QLBIBLOY.js → chunk-DQ7LZZJX.js} +5 -5
  76. package/dist/{chunk-UCYSCKZV.js → chunk-DSTHXHJ5.js} +2114 -1699
  77. package/dist/{chunk-L7QKFC5N.js → chunk-E6W57UP3.js} +32 -122
  78. package/dist/{chunk-UFFVRF4V.js → chunk-EAAZV3B7.js} +6 -11
  79. package/dist/chunk-EDV4MTTT.js +434 -0
  80. package/dist/chunk-EEBJYXWA.js +15 -0
  81. package/dist/{chunk-UORPTGV2.js → chunk-EPRYM3FA.js} +11 -15
  82. package/dist/{chunk-YQYRAD5C.js → chunk-FCZJAYMM.js} +1 -1
  83. package/dist/{chunk-JMRWREVE.js → chunk-FDKFUIYV.js} +23 -36
  84. package/dist/chunk-FWPGOIFA.js +22 -0
  85. package/dist/{chunk-B234IELY.js → chunk-G6YNCIVF.js} +24 -41
  86. package/dist/{chunk-PVZBDWLK.js → chunk-GRH7C3QN.js} +1 -1
  87. package/dist/chunk-GSH6ZGI6.js +353 -0
  88. package/dist/{chunk-IQWK723D.js → chunk-GZ4KTAWS.js} +1 -1
  89. package/dist/{chunk-MJCL3WID.js → chunk-H6LZ77GX.js} +1 -1
  90. package/dist/{chunk-WLT7K7K7.js → chunk-HDEOZN2Q.js} +21 -24
  91. package/dist/{chunk-FDR22JMM.js → chunk-HFRHHT36.js} +8 -63
  92. package/dist/{chunk-GNDFMMC6.js → chunk-IEVN722X.js} +1 -1
  93. package/dist/{chunk-DARJTN4I.js → chunk-IMJ62GAP.js} +10 -5
  94. package/dist/{chunk-SGR4DMCW.js → chunk-INYLPVCG.js} +3 -3
  95. package/dist/{chunk-5T6UWTRU.js → chunk-IV57G2CB.js} +19 -11
  96. package/dist/chunk-J6XCRFBW.js +30 -0
  97. package/dist/{chunk-BLRZB63H.js → chunk-JDNXS37G.js} +61 -62
  98. package/dist/{chunk-3B34B2M2.js → chunk-JJP6AKMV.js} +1 -1
  99. package/dist/{chunk-XEU5ZLSB.js → chunk-JK4M3ZKY.js} +5 -5
  100. package/dist/{chunk-VXMOPVRH.js → chunk-JR7AABT5.js} +2 -2
  101. package/dist/{chunk-PBD36EZJ.js → chunk-JTHDMXZV.js} +5 -5
  102. package/dist/{chunk-Q75AC3DZ.js → chunk-JY2XON7H.js} +2 -2
  103. package/dist/{chunk-6OUPJNYO.js → chunk-KCHYLLVG.js} +2 -2
  104. package/dist/{chunk-YGRTRAWX.js → chunk-KDE4HKH2.js} +1 -0
  105. package/dist/{chunk-VPKMBJ5B.js → chunk-KG2NUK4J.js} +6 -6
  106. package/dist/{chunk-VXWN37PT.js → chunk-KIURBTC4.js} +1 -1
  107. package/dist/{chunk-7LVNAFEI.js → chunk-KTJLJTFO.js} +547 -882
  108. package/dist/{chunk-FCJ7MLQK.js → chunk-KZQFIPY2.js} +264 -76
  109. package/dist/chunk-L57USMYC.js +39 -0
  110. package/dist/{chunk-4KNL46BT.js → chunk-LWFBBTJ3.js} +5 -5
  111. package/dist/{chunk-RIN4CBRB.js → chunk-LXZXXOJ3.js} +1 -17
  112. package/dist/chunk-LYYM7H7H.js +59 -0
  113. package/dist/{chunk-MWQQVKRU.js → chunk-MAVQ636Y.js} +1 -1
  114. package/dist/{chunk-VDHW6H5F.js → chunk-MAW6ZT3D.js} +4 -4
  115. package/dist/{chunk-7CMRFP5Q.js → chunk-MJP5V3JN.js} +3 -3
  116. package/dist/{chunk-S7EKBD2C.js → chunk-MNHP6YRC.js} +3 -3
  117. package/dist/{chunk-QZJIDKQR.js → chunk-MT6WOKIW.js} +4 -4
  118. package/dist/chunk-MUGQQY6P.js +315 -0
  119. package/dist/{chunk-QT7YFHCA.js → chunk-MVEHWM7K.js} +13 -1
  120. package/dist/{chunk-VV6IKGCN.js → chunk-NTJ3BMOE.js} +1 -1
  121. package/dist/{chunk-JXQJQYGD.js → chunk-O7BGGWW6.js} +2 -2
  122. package/dist/{chunk-LWJF63JW.js → chunk-OYUJYPDF.js} +90 -15
  123. package/dist/{chunk-4S6XGIC6.js → chunk-PUAWN7SS.js} +1 -1
  124. package/dist/{chunk-U6PBLMXD.js → chunk-Q6SPIHFR.js} +8 -3
  125. package/dist/{chunk-F4OJN2F2.js → chunk-QIF4QE7T.js} +1 -1
  126. package/dist/{chunk-X22KTLZ7.js → chunk-QWJTJSIT.js} +1 -1
  127. package/dist/{chunk-2USXZSTK.js → chunk-QWW6RHZC.js} +5 -5
  128. package/dist/{chunk-TODJFRLH.js → chunk-RILHLBKW.js} +3 -3
  129. package/dist/{chunk-PP754CO7.js → chunk-RPU4UOQK.js} +1 -1
  130. package/dist/{chunk-AVOZ7TX2.js → chunk-RTMMO6IU.js} +6 -6
  131. package/dist/chunk-S7NGDLZ3.js +173 -0
  132. package/dist/{chunk-U2ZFCAPX.js → chunk-SITRHMZZ.js} +11 -8
  133. package/dist/chunk-SPFLYPY6.js +6 -0
  134. package/dist/{chunk-EIUYXS7E.js → chunk-TJKZ5QCJ.js} +4 -4
  135. package/dist/{chunk-WCSQDWMS.js → chunk-TPGIMZLI.js} +1 -1
  136. package/dist/chunk-UM7ZR3VU.js +14 -0
  137. package/dist/{chunk-PGW3VYK4.js → chunk-UNE4VD5U.js} +3 -3
  138. package/dist/chunk-UX5UYDCY.js +33 -0
  139. package/dist/{chunk-IXAQNTE7.js → chunk-V5K6HISS.js} +2 -2
  140. package/dist/chunk-VCUUITW6.js +35 -0
  141. package/dist/{chunk-T5MJWWDX.js → chunk-VD27SL7H.js} +5 -5
  142. package/dist/{chunk-LRARA622.js → chunk-VE6GRIIN.js} +2 -2
  143. package/dist/{chunk-SSUUT5LK.js → chunk-W3UHAQCV.js} +5 -4
  144. package/dist/{chunk-U5G3AVED.js → chunk-WBCWER26.js} +1 -1
  145. package/dist/{chunk-PXI47JL5.js → chunk-WCXFUBEF.js} +13 -13
  146. package/dist/{chunk-AVOIZO63.js → chunk-WFE6CT6M.js} +77 -21
  147. package/dist/{chunk-E2L5EX5A.js → chunk-WFHGJGCW.js} +7 -6
  148. package/dist/{chunk-LQD232FW.js → chunk-WJ5EU3KW.js} +1 -1
  149. package/dist/{chunk-6YA3C4NB.js → chunk-XBKWFLJG.js} +4 -13
  150. package/dist/chunk-XQUF3WIS.js +159 -0
  151. package/dist/{chunk-SS46VQJA.js → chunk-Y4PM3IDZ.js} +1 -1
  152. package/dist/chunk-YBF45CX5.js +23 -0
  153. package/dist/{chunk-JQV7CXEC.js → chunk-YNGA3GRX.js} +17 -2
  154. package/dist/chunk-ZHFFTT3I.js +17 -0
  155. package/dist/{chunk-BOZJOOGW.js → chunk-ZLHCZ5F2.js} +1 -1
  156. package/dist/{chunk-LHKHQAAY.js → chunk-ZLYGEART.js} +1 -1
  157. package/dist/{chunk-NBPMNUKZ.js → chunk-ZQCCVCHB.js} +1 -1
  158. package/dist/{chunk-ADGVQVHP.js → chunk-ZTOYVPGA.js} +3 -3
  159. package/dist/collections-XIHCTMSJ.js +70 -0
  160. package/dist/{configuration-C4IGBNXH.js → configuration-3GCBMM27.js} +3 -3
  161. package/dist/{configuration-JI22M76Z.js → configuration-FWZTMYXY.js} +5 -5
  162. package/dist/{create-OXR7WG5F.js → create-2RGNAVVY.js} +32 -32
  163. package/dist/{create-5QLYFVEK.js → create-32MXB6FD.js} +24 -24
  164. package/dist/create-3AMFYYI6.js +245 -0
  165. package/dist/create-AMNH3WXL.js +75 -0
  166. package/dist/{create-UPYB65PD.js → create-BV3QDTK2.js} +4 -4
  167. package/dist/{create-POK6SJSZ.js → create-FHIFVCSG.js} +52 -49
  168. package/dist/{create-EATFT5AB.js → create-GO7APBBU.js} +31 -31
  169. package/dist/create-HEZYB7RF.js +1179 -0
  170. package/dist/{create-R7K3ECN6.js → create-K26SM34L.js} +3 -3
  171. package/dist/{create-6I43IPLO.js → create-N534JQPH.js} +14 -14
  172. package/dist/create-NEK6JCKR.js +1798 -0
  173. package/dist/{create-YBF4YGWG.js → create-NF2LPVXA.js} +3 -3
  174. package/dist/{create-F7IDSSTP.js → create-PJVLJ7T6.js} +50 -45
  175. package/dist/{create-CK4X357V.js → create-RPBHXU32.js} +28 -28
  176. package/dist/{create-SFU3W3ZH.js → create-U64NEOEL.js} +3 -3
  177. package/dist/create-VL7LDTVE.js +1931 -0
  178. package/dist/{create-XVHOCZHJ.js → create-X5SOAPD3.js} +3 -3
  179. package/dist/{create-2XZLOG5Z.js → create-XLYGW5PN.js} +69 -41
  180. package/dist/{create-GB3ZA4LH.js → create-YKYLCEAK.js} +6 -6
  181. package/dist/customer-group-add-customers-2C53NFBJ.js +251 -0
  182. package/dist/customer-group-create-75QQEQZF.js +147 -0
  183. package/dist/customer-group-detail-AOQYYAOG.js +58 -0
  184. package/dist/customer-group-edit-N77RCW6I.js +138 -0
  185. package/dist/customer-groups-GNFV7VMT.js +284 -0
  186. package/dist/{customers-SOLJ2KQQ.js → customers-HNINO6YL.js} +11 -11
  187. package/dist/{edit-TZ4EXLKJ.js → edit-3DUCWSLA.js} +62 -46
  188. package/dist/{edit-ORXS3A2Y.js → edit-3V34KJS2.js} +3 -3
  189. package/dist/{edit-RJ3EZ5CD.js → edit-4PWAJ7A3.js} +25 -25
  190. package/dist/{edit-ZQP4MNJU.js → edit-7CLOJ3UZ.js} +50 -47
  191. package/dist/{edit-ZAHCMF5U.js → edit-7SBPHN6P.js} +3 -3
  192. package/dist/edit-BSD6667Q.js +367 -0
  193. package/dist/{edit-Q3UQIOLS.js → edit-I2RJUPWV.js} +4 -4
  194. package/dist/{edit-UUP3BQV3.js → edit-IJ6DCBUU.js} +5 -5
  195. package/dist/{edit-ZMERG3L7.js → edit-JB7KVBOL.js} +5 -5
  196. package/dist/{edit-O4JLGKQR.js → edit-NHQJLCAK.js} +4 -4
  197. package/dist/edit-O65JD54W.js +103 -0
  198. package/dist/{edit-4OEBCCXJ.js → edit-SIKOSSHF.js} +24 -24
  199. package/dist/edit-TD7QFM4Z.js +871 -0
  200. package/dist/{edit-C4OCKQVU.js → edit-UNN3QTEJ.js} +3 -3
  201. package/dist/{edit-PFAJZUWI.js → edit-WEUFBORT.js} +33 -34
  202. package/dist/{edit-KAKVPHZZ.js → edit-WN2Q3TOX.js} +4 -4
  203. package/dist/{edit-QPPMI7MU.js → edit-ZGAOUZYP.js} +33 -34
  204. package/dist/{edit-522DG3BY.js → edit-ZOLSAIKF.js} +3 -3
  205. package/dist/{edit-2LGAEKH6.js → edit-ZORE6RUD.js} +25 -25
  206. package/dist/{edit-budget-L3CCEWNF.js → edit-budget-D22WMVYR.js} +3 -3
  207. package/dist/{edit-inventory-item-A7KAPATR.js → edit-inventory-item-QMYWEBZ3.js} +3 -3
  208. package/dist/{edit-inventory-item-attributes-RNBOJR66.js → edit-inventory-item-attributes-HLG6JR6S.js} +3 -3
  209. package/dist/edit-price-F7ZWM3FN.js +197 -0
  210. package/dist/edit-stock-ITAZNHPU.js +230 -0
  211. package/dist/fulfillment-U2GRQ6DD.js +641 -0
  212. package/dist/{fulfillment-providers-6WDXCGAI.js → fulfillment-providers-CMU2JB5X.js} +40 -40
  213. package/dist/index.css +120 -24
  214. package/dist/index.js +355 -235
  215. package/dist/{offer-inventory-batch-page-4QNXDUWN.js → inventory-4JKLAZ2Q.js} +20 -20
  216. package/dist/{inventory-IOVM7GDU.js → inventory-FKEXULLT.js} +10 -10
  217. package/dist/{invite-HRKSQI4B.js → invite-3R2CEWLN.js} +23 -23
  218. package/dist/{invite-UBH7PYSH.js → invite-MNAX6EUC.js} +39 -39
  219. package/dist/loader-HTPUNIOS.js +34 -0
  220. package/dist/loader-MAAMUP2Z.js +33 -0
  221. package/dist/{locations-INS6FTMJ.js → locations-2VWSMWHL.js} +3 -3
  222. package/dist/login-YUWOWICV.js +39 -0
  223. package/dist/{manage-locations-TIYOCOZU.js → manage-locations-RWGDXXJQ.js} +3 -3
  224. package/dist/{media-EXWUWWNB.js → media-P6WSFHY4.js} +31 -30
  225. package/dist/media-YB4G5CMV.js +316 -0
  226. package/dist/{metadata-JIMHXPKE.js → metadata-5Q6FLVX4.js} +27 -27
  227. package/dist/{metadata-T6MLCEZ2.js → metadata-6OYHLPLA.js} +25 -25
  228. package/dist/{metadata-JCNPERR3.js → metadata-ADXGD4Y6.js} +25 -25
  229. package/dist/{metadata-ITS3VPE3.js → metadata-J447GEBP.js} +27 -27
  230. package/dist/{metadata-YOQEXEGO.js → metadata-VTQ2CGZX.js} +27 -27
  231. package/dist/{offer-create-page-6YTTQAXZ.js → offer-create-page-ACPKTNHA.js} +245 -266
  232. package/dist/offer-detail-page-S4R4N5GL.js +584 -0
  233. package/dist/offer-variant-detail-page-XUMDXZUD.js +402 -0
  234. package/dist/offers-OTZJBW43.js +54 -0
  235. package/dist/{onboarding-GCRT6P6M.js → onboarding-TUGXFOA6.js} +23 -23
  236. package/dist/orders-PJSJNGZS.js +63 -0
  237. package/dist/{organization-5AFVFFZQ.js → organization-YIOAVFHN.js} +26 -26
  238. package/dist/{organize-QXDKGP2X.js → organize-BTA7NJD2.js} +4 -4
  239. package/dist/{organize-AZYAANZM.js → organize-OWT5QSJR.js} +4 -4
  240. package/dist/pages/index.d.ts +232 -232
  241. package/dist/pages/index.js +89 -87
  242. package/dist/{payment-details-ENUWDVGI.js → payment-details-K2XFATEL.js} +24 -24
  243. package/dist/{payouts-2QBQSNDR.js → payouts-K5IDTJV3.js} +11 -11
  244. package/dist/{price-lists-2WBNENE7.js → price-lists-DNPIPDAW.js} +13 -13
  245. package/dist/{offer-pricing-edit-page-WZNP3TWV.js → pricing-5VUPPNKS.js} +21 -19
  246. package/dist/{pricing-4Y73YJHP.js → pricing-J5FIDZIY.js} +32 -32
  247. package/dist/{product-tags-DE32PERU.js → product-tags-SJYIGXEV.js} +47 -44
  248. package/dist/{product-types-PKUEL7X5.js → product-types-4PTJW5DE.js} +10 -10
  249. package/dist/product-variant-detail-FO6J3RFA.js +371 -0
  250. package/dist/{product-variant-edit-ESLPI5ES.js → product-variant-edit-55TAIBZO.js} +45 -27
  251. package/dist/{products-WLGCX6Z7.js → products-EQMANSO6.js} +41 -40
  252. package/dist/products-XM57LXJK.js +92 -0
  253. package/dist/{professional-details-OCVQO2MV.js → professional-details-WWZPTXSX.js} +24 -24
  254. package/dist/{profile-2HW5NX6K.js → profile-5IADQ727.js} +30 -30
  255. package/dist/{promotions-FPV6QOEQ.js → promotions-BYW6TZ5B.js} +12 -12
  256. package/dist/receive-MTXKKPKZ.js +578 -0
  257. package/dist/refund-3IXGYA7W.js +268 -0
  258. package/dist/{register-PZOHGO7N.js → register-U5PQZATC.js} +25 -25
  259. package/dist/{reset-password-Q7BNWHHO.js → reset-password-SKUJJLSV.js} +3 -3
  260. package/dist/{return-reasons-J2WFZOQH.js → return-reasons-QDPSIJG3.js} +22 -19
  261. package/dist/{sales-channels-I3PR34U5.js → sales-channels-GBSTCWVP.js} +12 -13
  262. package/dist/{sales-channels-HPG2ND4W.js → sales-channels-N4NE3FXP.js} +14 -15
  263. package/dist/{settings-RZNYWACF.js → settings-ZUBBFS67.js} +54 -51
  264. package/dist/shipment-TKSCPC3M.js +241 -0
  265. package/dist/shipping-DODEUYOQ.js +125 -0
  266. package/dist/{shipping-profile-M3GGADFI.js → shipping-profile-O4JMJLN7.js} +5 -9
  267. package/dist/shipping-profiles-4TJ4IH6U.js +46 -0
  268. package/dist/{stock-3HVQ6FYP.js → stock-GYK2GHJN.js} +27 -27
  269. package/dist/{store-LDVMG7CV.js → store-XWOALZ5Q.js} +36 -36
  270. package/dist/{store-closure-EZ2YPOPL.js → store-closure-46B3XZ2I.js} +24 -24
  271. package/dist/{store-select-AM4AE7AL.js → store-select-E77E3ZY7.js} +24 -24
  272. package/dist/{tax-regions-HDLBFZVG.js → tax-regions-S2LFRTMP.js} +9 -9
  273. package/dist/{team-6NTDISM4.js → team-N2C5JPSU.js} +37 -37
  274. package/package.json +12 -12
  275. package/dist/[id]-MOOCGOWO.js +0 -480
  276. package/dist/[id]-UVQXCYXD.js +0 -1219
  277. package/dist/[id]-VUX4FUOO.js +0 -1557
  278. package/dist/allocate-items-OK5PVJGR.js +0 -533
  279. package/dist/attributes-TRAUBTCO.js +0 -278
  280. package/dist/breadcrumb-6FV7PWEN.js +0 -33
  281. package/dist/breadcrumb-EX4C3AZY.js +0 -47
  282. package/dist/breadcrumb-Q3XSG7B2.js +0 -46
  283. package/dist/chunk-27KRIXMQ.js +0 -71
  284. package/dist/chunk-432S4FGR.js +0 -0
  285. package/dist/chunk-BDZOSMAX.js +0 -23
  286. package/dist/chunk-CFRWIQIZ.js +0 -43
  287. package/dist/chunk-G7BL4L3L.js +0 -66
  288. package/dist/chunk-RXV7INUV.js +0 -426
  289. package/dist/chunk-T6LHVNWO.js +0 -27
  290. package/dist/collections-DS63FT2E.js +0 -68
  291. package/dist/create-HR4I33SE.js +0 -73
  292. package/dist/create-UFHLPXET.js +0 -215
  293. package/dist/edit-GQNIINRR.js +0 -192
  294. package/dist/fulfillment-OIIPL7B7.js +0 -559
  295. package/dist/loader-VDYPD3RI.js +0 -31
  296. package/dist/login-HON44E3S.js +0 -39
  297. package/dist/metadata-5BPOBBU2.js +0 -45
  298. package/dist/offer-detail-page-OMZN2NTA.js +0 -492
  299. package/dist/offer-edit-page-3MO566RP.js +0 -151
  300. package/dist/offers-GVN5LCK6.js +0 -32
  301. package/dist/orders-CHSS4ASB.js +0 -63
  302. package/dist/product-variant-detail-MWUBPCOP.js +0 -209
  303. package/dist/products-XOHAQHUJ.js +0 -91
  304. package/dist/shipment-KWUXQZWK.js +0 -176
  305. package/dist/shipping-profiles-L27STQ7K.js +0 -46
@@ -0,0 +1,1931 @@
1
+ import {
2
+ ItemPlaceholder
3
+ } from "./chunk-ZHFFTT3I.js";
4
+ import {
5
+ getOfferRestockPreview
6
+ } from "./chunk-J6XCRFBW.js";
7
+ import {
8
+ useReturnReasons
9
+ } from "./chunk-ZLYGEART.js";
10
+ import {
11
+ useAddExchangeInboundItems,
12
+ useAddExchangeInboundShipping,
13
+ useAddExchangeOutboundItems,
14
+ useAddExchangeOutboundShipping,
15
+ useCancelExchangeBegin,
16
+ useCreateExchange,
17
+ useRemoveExchangeInboundItem,
18
+ useRemoveExchangeOutboundItem,
19
+ useRequestExchange,
20
+ useUpdateExchangeInboundItem,
21
+ useUpdateExchangeOutboundItem
22
+ } from "./chunk-CRYZK4NU.js";
23
+ import {
24
+ getReturnableQuantity
25
+ } from "./chunk-UM7ZR3VU.js";
26
+ import {
27
+ EXCHANGE_POLICY_DAYS
28
+ } from "./chunk-VCUUITW6.js";
29
+ import {
30
+ MoneyAmountCell
31
+ } from "./chunk-L57USMYC.js";
32
+ import {
33
+ getStylizedAmount
34
+ } from "./chunk-3BXCPHN6.js";
35
+ import {
36
+ ProductCell,
37
+ ProductHeader
38
+ } from "./chunk-FWPGOIFA.js";
39
+ import {
40
+ PlaceholderCell
41
+ } from "./chunk-PHOCVOZ5.js";
42
+ import "./chunk-IQPN4PZJ.js";
43
+ import {
44
+ Combobox
45
+ } from "./chunk-VBRTC2VU.js";
46
+ import "./chunk-TKGWSUEI.js";
47
+ import {
48
+ KeyboundForm
49
+ } from "./chunk-SITRHMZZ.js";
50
+ import {
51
+ RouteFocusModal,
52
+ StackedFocusModal,
53
+ useRouteModal,
54
+ useStackedModal
55
+ } from "./chunk-GDWBOQI5.js";
56
+ import {
57
+ Form
58
+ } from "./chunk-3QSRE5LS.js";
59
+ import "./chunk-FQERBIVS.js";
60
+ import {
61
+ _DataTable,
62
+ useDataTable
63
+ } from "./chunk-W3UHAQCV.js";
64
+ import "./chunk-YN3FGNJM.js";
65
+ import "./chunk-KCHYLLVG.js";
66
+ import "./chunk-634XVU3D.js";
67
+ import {
68
+ useQueryParams
69
+ } from "./chunk-THHRRYRS.js";
70
+ import "./chunk-LRD242C7.js";
71
+ import {
72
+ Thumbnail
73
+ } from "./chunk-WIYFXWRI.js";
74
+ import "./chunk-INNFZYX2.js";
75
+ import {
76
+ ActionMenu
77
+ } from "./chunk-BDGZ4EQO.js";
78
+ import "./chunk-LAVHRER2.js";
79
+ import "./chunk-QHQWEERJ.js";
80
+ import "./chunk-Y7QKP6QU.js";
81
+ import {
82
+ useShippingOptions
83
+ } from "./chunk-JR7AABT5.js";
84
+ import {
85
+ useStockLocations
86
+ } from "./chunk-ZQCCVCHB.js";
87
+ import {
88
+ useOffers
89
+ } from "./chunk-EPRYM3FA.js";
90
+ import {
91
+ useOrder,
92
+ useOrderPreview
93
+ } from "./chunk-6FDPVW7Y.js";
94
+ import "./chunk-G6YNCIVF.js";
95
+ import "./chunk-A5DJIOHN.js";
96
+ import "./chunk-RHKRREUU.js";
97
+ import "./chunk-ZA2KFUFR.js";
98
+ import "./chunk-LXZXXOJ3.js";
99
+ import "./chunk-NBMM2TZK.js";
100
+
101
+ // src/pages/orders/[id]/exchanges/create/index.tsx
102
+ import { useTranslation as useTranslation12 } from "react-i18next";
103
+
104
+ // src/pages/orders/[id]/exchanges/create/_components/exchange-create-form/exchange-create-form.tsx
105
+ import { zodResolver } from "@hookform/resolvers/zod";
106
+ import { Button as Button3, Heading as Heading3, Switch, Text as Text5, toast as toast3, usePrompt } from "@medusajs/ui";
107
+ import { useEffect as useEffect3, useMemo as useMemo7, useState as useState3 } from "react";
108
+ import { useForm } from "react-hook-form";
109
+ import { useNavigate, useParams } from "react-router-dom";
110
+ import { useTranslation as useTranslation11 } from "react-i18next";
111
+
112
+ // src/pages/orders/[id]/exchanges/create/_components/exchange-create-form/exchange-inbound-section.tsx
113
+ import { Button, Heading, Text as Text2, toast } from "@medusajs/ui";
114
+ import { useEffect, useMemo as useMemo3 } from "react";
115
+ import { useFieldArray } from "react-hook-form";
116
+ import { useTranslation as useTranslation5 } from "react-i18next";
117
+
118
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-inbound-items-table/add-exchange-inbound-items-table.tsx
119
+ import { useMemo as useMemo2, useState } from "react";
120
+ import { useTranslation as useTranslation3 } from "react-i18next";
121
+
122
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-inbound-items-table/use-exchange-item-table-columns.tsx
123
+ import { Checkbox } from "@medusajs/ui";
124
+ import { createColumnHelper } from "@tanstack/react-table";
125
+ import { useMemo } from "react";
126
+ import { useTranslation } from "react-i18next";
127
+ import { jsx } from "react/jsx-runtime";
128
+ var columnHelper = createColumnHelper();
129
+ var useExchangeItemTableColumns = (currencyCode) => {
130
+ const { t } = useTranslation();
131
+ return useMemo(
132
+ () => [
133
+ columnHelper.display({
134
+ id: "select",
135
+ header: ({ table }) => {
136
+ return /* @__PURE__ */ jsx(
137
+ Checkbox,
138
+ {
139
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
140
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
141
+ }
142
+ );
143
+ },
144
+ cell: ({ row }) => {
145
+ const isSelectable = row.getCanSelect();
146
+ return /* @__PURE__ */ jsx(
147
+ Checkbox,
148
+ {
149
+ disabled: !isSelectable,
150
+ checked: row.getIsSelected(),
151
+ onCheckedChange: (value) => row.toggleSelected(!!value),
152
+ onClick: (e) => {
153
+ e.stopPropagation();
154
+ }
155
+ }
156
+ );
157
+ }
158
+ }),
159
+ columnHelper.display({
160
+ id: "product",
161
+ header: () => /* @__PURE__ */ jsx(ProductHeader, {}),
162
+ cell: ({ row }) => /* @__PURE__ */ jsx(
163
+ ProductCell,
164
+ {
165
+ product: {
166
+ thumbnail: row.original.thumbnail,
167
+ title: row.original.product_title
168
+ }
169
+ }
170
+ )
171
+ }),
172
+ columnHelper.accessor("variant.sku", {
173
+ header: t("fields.sku"),
174
+ cell: ({ getValue }) => {
175
+ return getValue() || "-";
176
+ }
177
+ }),
178
+ columnHelper.accessor("variant.title", {
179
+ header: t("fields.variant")
180
+ }),
181
+ columnHelper.accessor("quantity", {
182
+ header: () => /* @__PURE__ */ jsx("div", { className: "flex size-full items-center overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t("fields.quantity") }) }),
183
+ cell: ({ row }) => {
184
+ return getReturnableQuantity(row.original);
185
+ }
186
+ }),
187
+ columnHelper.accessor("refundable_total", {
188
+ header: () => /* @__PURE__ */ jsx("div", { className: "flex size-full items-center justify-end overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t("fields.price") }) }),
189
+ cell: ({ getValue }) => {
190
+ const amount = getValue() || 0;
191
+ const stylized = getStylizedAmount(amount, currencyCode);
192
+ return /* @__PURE__ */ jsx("div", { className: "flex size-full items-center justify-end overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: stylized }) });
193
+ }
194
+ })
195
+ ],
196
+ [t, currencyCode]
197
+ );
198
+ };
199
+
200
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-inbound-items-table/use-exchange-item-table-filters.tsx
201
+ import { useTranslation as useTranslation2 } from "react-i18next";
202
+ var useExchangeItemTableFilters = () => {
203
+ const { t } = useTranslation2();
204
+ const filters = [
205
+ {
206
+ key: "created_at",
207
+ label: t("fields.createdAt"),
208
+ type: "date"
209
+ },
210
+ {
211
+ key: "updated_at",
212
+ label: t("fields.updatedAt"),
213
+ type: "date"
214
+ }
215
+ ];
216
+ return filters;
217
+ };
218
+
219
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-inbound-items-table/use-exchange-item-table-query.tsx
220
+ var useExchangeItemTableQuery = ({
221
+ pageSize = 50,
222
+ prefix
223
+ }) => {
224
+ const raw = useQueryParams(
225
+ ["q", "offset", "order", "created_at", "updated_at"],
226
+ prefix
227
+ );
228
+ const { offset, created_at, updated_at, ...rest } = raw;
229
+ const searchParams = {
230
+ ...rest,
231
+ limit: pageSize,
232
+ offset: offset ? Number(offset) : 0,
233
+ created_at: created_at ? JSON.parse(created_at) : void 0,
234
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0
235
+ };
236
+ return { searchParams, raw };
237
+ };
238
+
239
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-inbound-items-table/add-exchange-inbound-items-table.tsx
240
+ import { jsx as jsx2 } from "react/jsx-runtime";
241
+ var PAGE_SIZE = 50;
242
+ var PREFIX = "rit";
243
+ var AddExchangeInboundItemsTable = ({
244
+ onSelectionChange,
245
+ selectedItems,
246
+ items,
247
+ currencyCode
248
+ }) => {
249
+ const { t } = useTranslation3();
250
+ const [rowSelection, setRowSelection] = useState(
251
+ selectedItems.reduce((acc, id) => {
252
+ acc[id] = true;
253
+ return acc;
254
+ }, {})
255
+ );
256
+ const updater = (fn) => {
257
+ const newState = typeof fn === "function" ? fn(rowSelection) : fn;
258
+ setRowSelection(newState);
259
+ onSelectionChange(Object.keys(newState));
260
+ };
261
+ const { searchParams, raw } = useExchangeItemTableQuery({
262
+ pageSize: PAGE_SIZE,
263
+ prefix: PREFIX
264
+ });
265
+ const queriedItems = useMemo2(() => {
266
+ const { order, offset, limit, q, created_at, updated_at } = searchParams;
267
+ let results = items;
268
+ if (q) {
269
+ const needle = q.toLowerCase();
270
+ results = results.filter((i) => {
271
+ return i.product_title?.toLowerCase().includes(needle) || i.variant_title?.toLowerCase().includes(needle) || i.variant_sku?.toLowerCase().includes(needle);
272
+ });
273
+ }
274
+ if (order) {
275
+ const direction = order[0] === "-" ? "desc" : "asc";
276
+ const field = order.replace("-", "");
277
+ results = sortItems(results, field, direction);
278
+ }
279
+ if (created_at) {
280
+ results = filterByDate(
281
+ results,
282
+ created_at,
283
+ "created_at"
284
+ );
285
+ }
286
+ if (updated_at) {
287
+ results = filterByDate(
288
+ results,
289
+ updated_at,
290
+ "updated_at"
291
+ );
292
+ }
293
+ return results.slice(offset, offset + limit);
294
+ }, [items, searchParams]);
295
+ const columns = useExchangeItemTableColumns(currencyCode);
296
+ const filters = useExchangeItemTableFilters();
297
+ const { table } = useDataTable({
298
+ data: queriedItems,
299
+ columns,
300
+ count: queriedItems.length,
301
+ enablePagination: true,
302
+ getRowId: (row) => row.id,
303
+ pageSize: PAGE_SIZE,
304
+ enableRowSelection: (row) => {
305
+ return getReturnableQuantity(row.original) > 0;
306
+ },
307
+ rowSelection: {
308
+ state: rowSelection,
309
+ updater
310
+ }
311
+ });
312
+ return /* @__PURE__ */ jsx2("div", { className: "flex size-full flex-col overflow-hidden", children: /* @__PURE__ */ jsx2(
313
+ _DataTable,
314
+ {
315
+ table,
316
+ columns,
317
+ pageSize: PAGE_SIZE,
318
+ count: queriedItems.length,
319
+ filters,
320
+ pagination: true,
321
+ layout: "fill",
322
+ search: true,
323
+ orderBy: [
324
+ { key: "product_title", label: t("fields.product") },
325
+ { key: "variant_title", label: t("fields.variant") },
326
+ { key: "sku", label: t("fields.sku") }
327
+ ],
328
+ prefix: PREFIX,
329
+ queryObject: raw
330
+ }
331
+ ) });
332
+ };
333
+ var sortItems = (items, field, direction) => {
334
+ return items.sort((a, b) => {
335
+ let aValue;
336
+ let bValue;
337
+ if (field === "product_title") {
338
+ aValue = a.product_title;
339
+ bValue = b.product_title;
340
+ } else if (field === "variant_title") {
341
+ aValue = a.variant_title;
342
+ bValue = b.variant_title;
343
+ } else if (field === "sku") {
344
+ aValue = a.variant_sku;
345
+ bValue = b.variant_sku;
346
+ }
347
+ const aSafe = aValue ?? "";
348
+ const bSafe = bValue ?? "";
349
+ if (aSafe < bSafe) {
350
+ return direction === "asc" ? -1 : 1;
351
+ }
352
+ if (aSafe > bSafe) {
353
+ return direction === "asc" ? 1 : -1;
354
+ }
355
+ return 0;
356
+ });
357
+ };
358
+ var filterByDate = (items, date, field) => {
359
+ const { gt, gte, lt, lte } = date;
360
+ return items.filter((i) => {
361
+ const itemDate = new Date(i[field]);
362
+ let isValid = true;
363
+ if (gt) {
364
+ isValid = isValid && itemDate > new Date(gt);
365
+ }
366
+ if (gte) {
367
+ isValid = isValid && itemDate >= new Date(gte);
368
+ }
369
+ if (lt) {
370
+ isValid = isValid && itemDate < new Date(lt);
371
+ }
372
+ if (lte) {
373
+ isValid = isValid && itemDate <= new Date(lte);
374
+ }
375
+ return isValid;
376
+ });
377
+ };
378
+
379
+ // src/pages/orders/[id]/exchanges/create/_components/exchange-create-form/exchange-inbound-item.tsx
380
+ import { ChatBubble, DocumentText, XCircle, XMark } from "@medusajs/icons";
381
+ import { IconButton, Input, Text } from "@medusajs/ui";
382
+ import { useTranslation as useTranslation4 } from "react-i18next";
383
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
384
+ function ExchangeInboundItem({
385
+ item,
386
+ previewItem,
387
+ currencyCode,
388
+ form,
389
+ onRemove,
390
+ onUpdate,
391
+ index,
392
+ locationName
393
+ }) {
394
+ const { t } = useTranslation4();
395
+ const { return_reasons = [] } = useReturnReasons({ fields: "+label" });
396
+ const returnReasons = return_reasons;
397
+ const formItem = form.watch(`inbound_items.${index}`);
398
+ const showReturnReason = typeof formItem?.reason_id === "string";
399
+ const showNote = typeof formItem?.note === "string";
400
+ const quantity = formItem?.quantity ?? 0;
401
+ const appliedPromoCodes = (previewItem?.adjustments ?? []).map((adjustment) => adjustment.code).filter((code) => Boolean(code));
402
+ return /* @__PURE__ */ jsxs(
403
+ "div",
404
+ {
405
+ className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl",
406
+ "data-testid": `exchange-inbound-item-${item.id}`,
407
+ children: [
408
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-x-3 gap-y-2 p-3 text-sm md:flex-row", children: [
409
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center gap-x-3", children: [
410
+ /* @__PURE__ */ jsx3(Thumbnail, { src: item.thumbnail }),
411
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-grow flex-col", children: [
412
+ /* @__PURE__ */ jsxs("div", { children: [
413
+ /* @__PURE__ */ jsxs(Text, { className: "txt-small", as: "span", weight: "plus", children: [
414
+ item.title,
415
+ " "
416
+ ] }),
417
+ item.variant_sku && /* @__PURE__ */ jsxs("span", { children: [
418
+ "(",
419
+ item.variant_sku,
420
+ ")"
421
+ ] })
422
+ ] }),
423
+ /* @__PURE__ */ jsx3(Text, { as: "div", className: "text-ui-fg-subtle txt-small", children: item.product_title })
424
+ ] }),
425
+ appliedPromoCodes.length > 0 && /* @__PURE__ */ jsx3(
426
+ "div",
427
+ {
428
+ className: "flex flex-shrink",
429
+ title: appliedPromoCodes.join(", ")
430
+ }
431
+ )
432
+ ] }),
433
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 justify-between", children: [
434
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-grow items-center gap-2", children: [
435
+ /* @__PURE__ */ jsx3(
436
+ Form.Field,
437
+ {
438
+ control: form.control,
439
+ name: `inbound_items.${index}.quantity`,
440
+ render: ({ field }) => {
441
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
442
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
443
+ Input,
444
+ {
445
+ ...field,
446
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
447
+ min: 1,
448
+ max: item.quantity,
449
+ type: "number",
450
+ "data-testid": `exchange-inbound-item-${item.id}-qty`,
451
+ onBlur: (e) => {
452
+ const val = e.target.value;
453
+ const payload = val === "" ? null : Number(val);
454
+ field.onChange(payload);
455
+ if (payload) {
456
+ onUpdate({ quantity: payload });
457
+ }
458
+ }
459
+ }
460
+ ) }),
461
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
462
+ ] });
463
+ }
464
+ }
465
+ ),
466
+ /* @__PURE__ */ jsx3(Text, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
467
+ ] }),
468
+ /* @__PURE__ */ jsx3("div", { className: "text-ui-fg-subtle txt-small mr-2 flex flex-shrink-0", children: /* @__PURE__ */ jsx3(
469
+ MoneyAmountCell,
470
+ {
471
+ currencyCode,
472
+ amount: previewItem?.return_requested_total ?? 0
473
+ }
474
+ ) }),
475
+ /* @__PURE__ */ jsx3(
476
+ ActionMenu,
477
+ {
478
+ groups: [
479
+ {
480
+ actions: [
481
+ !showReturnReason && {
482
+ label: t("actions.addReason"),
483
+ onClick: () => form.setValue(`inbound_items.${index}.reason_id`, ""),
484
+ icon: /* @__PURE__ */ jsx3(ChatBubble, {})
485
+ },
486
+ !showNote && {
487
+ label: t("actions.addNote"),
488
+ onClick: () => form.setValue(`inbound_items.${index}.note`, ""),
489
+ icon: /* @__PURE__ */ jsx3(DocumentText, {})
490
+ },
491
+ {
492
+ label: t("actions.remove"),
493
+ onClick: onRemove,
494
+ icon: /* @__PURE__ */ jsx3(XCircle, {})
495
+ }
496
+ ].filter(Boolean)
497
+ }
498
+ ]
499
+ }
500
+ )
501
+ ] })
502
+ ] }),
503
+ locationName && quantity > 0 && /* @__PURE__ */ jsx3(
504
+ ExchangeRestockPreview,
505
+ {
506
+ item,
507
+ quantity,
508
+ locationName
509
+ }
510
+ ),
511
+ showReturnReason && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
512
+ /* @__PURE__ */ jsxs("div", { children: [
513
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.reason") }),
514
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.reasonHint") })
515
+ ] }),
516
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
517
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
518
+ Form.Field,
519
+ {
520
+ control: form.control,
521
+ name: `inbound_items.${index}.reason_id`,
522
+ render: ({ field: { value, onChange, ref: _ref, ...field } }) => {
523
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
524
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
525
+ Combobox,
526
+ {
527
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
528
+ value: value ?? void 0,
529
+ onChange: (v) => {
530
+ onUpdate({ reason_id: v ?? null });
531
+ onChange(v);
532
+ },
533
+ ...field,
534
+ options: returnReasons.map((reason) => ({
535
+ label: reason.label ?? reason.value ?? reason.id,
536
+ value: reason.id
537
+ }))
538
+ }
539
+ ) }),
540
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
541
+ ] });
542
+ }
543
+ }
544
+ ) }),
545
+ /* @__PURE__ */ jsx3(
546
+ IconButton,
547
+ {
548
+ type: "button",
549
+ className: "flex-shrink",
550
+ variant: "transparent",
551
+ onClick: () => {
552
+ form.setValue(`inbound_items.${index}.reason_id`, null);
553
+ onUpdate({ reason_id: null });
554
+ },
555
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
556
+ }
557
+ )
558
+ ] })
559
+ ] }),
560
+ showNote && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
561
+ /* @__PURE__ */ jsxs("div", { children: [
562
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.note") }),
563
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.noteHint") })
564
+ ] }),
565
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
566
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
567
+ Form.Field,
568
+ {
569
+ control: form.control,
570
+ name: `inbound_items.${index}.note`,
571
+ render: ({ field: { ref: _ref, value, ...field } }) => {
572
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
573
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
574
+ Input,
575
+ {
576
+ ...field,
577
+ value: value ?? "",
578
+ "data-testid": `exchange-inbound-item-${item.id}-note`,
579
+ onBlur: (e) => {
580
+ const next = e.target.value;
581
+ field.onChange(next);
582
+ onUpdate({ internal_note: next || null });
583
+ },
584
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover"
585
+ }
586
+ ) }),
587
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
588
+ ] });
589
+ }
590
+ }
591
+ ) }),
592
+ /* @__PURE__ */ jsx3(
593
+ IconButton,
594
+ {
595
+ type: "button",
596
+ className: "flex-shrink",
597
+ variant: "transparent",
598
+ onClick: () => {
599
+ form.setValue(`inbound_items.${index}.note`, null);
600
+ onUpdate({ internal_note: null });
601
+ },
602
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
603
+ }
604
+ )
605
+ ] })
606
+ ] })
607
+ ]
608
+ }
609
+ );
610
+ }
611
+ var ExchangeRestockPreview = ({
612
+ item,
613
+ quantity,
614
+ locationName
615
+ }) => {
616
+ const { t } = useTranslation4();
617
+ const preview = getOfferRestockPreview(item, quantity);
618
+ if (!preview.length) {
619
+ return null;
620
+ }
621
+ const offerSku = item.offer?.sku ?? item.variant_sku ?? null;
622
+ return /* @__PURE__ */ jsx3("div", { className: "bg-ui-bg-subtle flex flex-col gap-y-1 rounded-md px-3 py-2", children: preview.map((row) => /* @__PURE__ */ jsx3(
623
+ Text,
624
+ {
625
+ size: "xsmall",
626
+ className: "text-ui-fg-subtle",
627
+ "data-testid": `exchange-inbound-item-${item.id}-restock-${row.inventoryItemId}`,
628
+ children: t("orders.returns.restockPreview", {
629
+ quantity,
630
+ offerSku: offerSku ?? "\u2014",
631
+ delta: row.delta,
632
+ inventoryItem: row.inventoryItemLabel,
633
+ location: locationName ?? "\u2014"
634
+ })
635
+ },
636
+ row.inventoryItemId
637
+ )) });
638
+ };
639
+
640
+ // src/pages/orders/[id]/exchanges/create/_components/exchange-create-form/exchange-inbound-section.tsx
641
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
642
+ var itemsToAdd = [];
643
+ var itemsToRemove = [];
644
+ var ExchangeInboundSection = ({
645
+ order,
646
+ preview,
647
+ exchange,
648
+ form,
649
+ orderReturn
650
+ }) => {
651
+ const { t } = useTranslation5();
652
+ const { setIsOpen } = useStackedModal();
653
+ const { mutateAsync: addInboundShipping } = useAddExchangeInboundShipping(
654
+ exchange.id,
655
+ order.id
656
+ );
657
+ const { mutateAsync: addInboundItem } = useAddExchangeInboundItems(
658
+ exchange.id,
659
+ order.id
660
+ );
661
+ const { mutateAsync: updateInboundItem } = useUpdateExchangeInboundItem(
662
+ exchange.id,
663
+ order.id
664
+ );
665
+ const { mutateAsync: removeInboundItem } = useRemoveExchangeInboundItem(
666
+ exchange.id,
667
+ order.id
668
+ );
669
+ const previewInboundItems = useMemo3(
670
+ () => (preview?.items ?? []).filter(
671
+ (i) => !!i.actions?.find((a) => a.exchange_id === exchange.id)
672
+ ),
673
+ [preview.items, exchange.id]
674
+ );
675
+ const inboundPreviewItems = previewInboundItems.filter(
676
+ (item) => !!item.actions?.find((a) => a.action === "RETURN_ITEM")
677
+ );
678
+ const itemsMap = useMemo3(
679
+ () => new Map((order?.items ?? []).map((i) => [i.id, i])),
680
+ [order.items]
681
+ );
682
+ const locationId = form.watch("location_id");
683
+ const { stock_locations = [] } = useStockLocations({
684
+ limit: 999
685
+ });
686
+ const { shipping_options = [] } = useShippingOptions(
687
+ {
688
+ limit: 999,
689
+ stock_location_id: locationId
690
+ },
691
+ { enabled: !!locationId }
692
+ );
693
+ const inboundShippingOptions = shipping_options.filter(
694
+ (shippingOption) => !!shippingOption.rules?.find(
695
+ (r) => r.attribute === "is_return" && r.value === "true"
696
+ )
697
+ );
698
+ const {
699
+ fields: inboundItems,
700
+ append,
701
+ remove,
702
+ update
703
+ } = useFieldArray({
704
+ name: "inbound_items",
705
+ control: form.control
706
+ });
707
+ const inboundItemsMap = useMemo3(
708
+ () => new Map(previewInboundItems.map((i) => [i.id, i])),
709
+ [previewInboundItems]
710
+ );
711
+ useEffect(() => {
712
+ const existingItemsMap = {};
713
+ inboundPreviewItems.forEach((i) => {
714
+ const ind = inboundItems.findIndex((field) => field.item_id === i.id);
715
+ const requested = i.detail?.return_requested_quantity ?? 0;
716
+ existingItemsMap[i.id] = true;
717
+ if (ind > -1) {
718
+ if (inboundItems[ind].quantity !== requested) {
719
+ const returnItemAction = i.actions?.find(
720
+ (a) => a.action === "RETURN_ITEM"
721
+ );
722
+ update(ind, {
723
+ ...inboundItems[ind],
724
+ quantity: requested,
725
+ note: returnItemAction?.internal_note ?? void 0,
726
+ reason_id: returnItemAction?.details?.reason_id
727
+ });
728
+ }
729
+ } else {
730
+ append(
731
+ { item_id: i.id, quantity: requested },
732
+ { shouldFocus: false }
733
+ );
734
+ }
735
+ });
736
+ inboundItems.forEach((i, ind) => {
737
+ if (!(i.item_id in existingItemsMap)) {
738
+ remove(ind);
739
+ }
740
+ });
741
+ }, [previewInboundItems]);
742
+ useEffect(() => {
743
+ const inboundShippingMethod = (preview.shipping_methods ?? []).find(
744
+ (s) => s.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
745
+ );
746
+ if (inboundShippingMethod?.shipping_option_id) {
747
+ form.setValue("inbound_option_id", inboundShippingMethod.shipping_option_id);
748
+ } else {
749
+ form.setValue("inbound_option_id", "");
750
+ }
751
+ }, [preview.shipping_methods]);
752
+ useEffect(() => {
753
+ if (orderReturn?.location_id) {
754
+ form.setValue("location_id", orderReturn.location_id);
755
+ }
756
+ }, [orderReturn]);
757
+ const showInboundItemsPlaceholder = !inboundItems.length;
758
+ const onItemsSelected = async () => {
759
+ if (itemsToAdd.length) {
760
+ await addInboundItem(
761
+ {
762
+ items: itemsToAdd.map((id) => ({
763
+ id,
764
+ quantity: 1
765
+ }))
766
+ },
767
+ {
768
+ onError: (error) => {
769
+ toast.error(error.message);
770
+ }
771
+ }
772
+ );
773
+ }
774
+ for (const itemToRemove of itemsToRemove) {
775
+ const actionId = previewInboundItems.find((i) => i.id === itemToRemove)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
776
+ if (actionId) {
777
+ await removeInboundItem(actionId, {
778
+ onError: (error) => {
779
+ toast.error(error.message);
780
+ }
781
+ });
782
+ }
783
+ }
784
+ setIsOpen("inbound-items", false);
785
+ };
786
+ const onLocationChange = (_selectedLocationId) => {
787
+ };
788
+ const onShippingOptionChange = async (selectedOptionId) => {
789
+ if (selectedOptionId) {
790
+ await addInboundShipping(
791
+ { shipping_option_id: selectedOptionId },
792
+ {
793
+ onError: (error) => {
794
+ toast.error(error.message);
795
+ }
796
+ }
797
+ );
798
+ }
799
+ };
800
+ return /* @__PURE__ */ jsxs2("div", { children: [
801
+ /* @__PURE__ */ jsxs2("div", { className: "mt-8 flex items-center justify-between", children: [
802
+ /* @__PURE__ */ jsx4(Heading, { level: "h2", children: t("orders.returns.inbound") }),
803
+ /* @__PURE__ */ jsxs2(StackedFocusModal, { id: "inbound-items", children: [
804
+ /* @__PURE__ */ jsx4(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx4(
805
+ "a",
806
+ {
807
+ href: "#",
808
+ onClick: (e) => e.preventDefault(),
809
+ className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400",
810
+ children: t("actions.addItems")
811
+ }
812
+ ) }),
813
+ /* @__PURE__ */ jsxs2(StackedFocusModal.Content, { children: [
814
+ /* @__PURE__ */ jsx4(StackedFocusModal.Header, {}),
815
+ /* @__PURE__ */ jsx4(
816
+ AddExchangeInboundItemsTable,
817
+ {
818
+ items: order.items ?? [],
819
+ selectedItems: inboundItems.map((i) => i.item_id),
820
+ currencyCode: order.currency_code,
821
+ onSelectionChange: (finalSelection) => {
822
+ const alreadySelected = inboundItems.map((i) => i.item_id);
823
+ itemsToAdd = finalSelection.filter(
824
+ (selection) => !alreadySelected.includes(selection)
825
+ );
826
+ itemsToRemove = alreadySelected.filter(
827
+ (selection) => !finalSelection.includes(selection)
828
+ );
829
+ }
830
+ }
831
+ ),
832
+ /* @__PURE__ */ jsx4(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsx4("div", { className: "flex w-full items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-end gap-x-2", children: [
833
+ /* @__PURE__ */ jsx4(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx4(Button, { type: "button", variant: "secondary", size: "small", children: t("actions.cancel") }) }),
834
+ /* @__PURE__ */ jsx4(
835
+ Button,
836
+ {
837
+ type: "submit",
838
+ variant: "primary",
839
+ size: "small",
840
+ onClick: async () => await onItemsSelected(),
841
+ children: t("actions.save")
842
+ },
843
+ "submit-button"
844
+ )
845
+ ] }) }) })
846
+ ] })
847
+ ] })
848
+ ] }),
849
+ showInboundItemsPlaceholder && /* @__PURE__ */ jsx4(ItemPlaceholder, {}),
850
+ inboundItems.map((item, index) => {
851
+ const previewItem = inboundItemsMap.get(item.item_id);
852
+ const sourceItem = itemsMap.get(item.item_id);
853
+ if (!previewItem || !sourceItem) {
854
+ return null;
855
+ }
856
+ const locationName = stock_locations.find(
857
+ (l) => l.id === locationId
858
+ )?.name ?? null;
859
+ return /* @__PURE__ */ jsx4(
860
+ ExchangeInboundItem,
861
+ {
862
+ item: sourceItem,
863
+ previewItem,
864
+ currencyCode: order.currency_code,
865
+ form,
866
+ locationName,
867
+ onRemove: () => {
868
+ const actionId = previewInboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
869
+ if (actionId) {
870
+ removeInboundItem(actionId, {
871
+ onError: (error) => {
872
+ toast.error(error.message);
873
+ }
874
+ });
875
+ }
876
+ },
877
+ onUpdate: (payload) => {
878
+ const action = previewInboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM");
879
+ if (action?.id) {
880
+ updateInboundItem(
881
+ { $actionId: action.id, ...payload },
882
+ {
883
+ onError: (error) => {
884
+ if (action.details?.quantity && payload.quantity) {
885
+ form.setValue(
886
+ `inbound_items.${index}.quantity`,
887
+ action.details.quantity
888
+ );
889
+ }
890
+ toast.error(error.message);
891
+ }
892
+ }
893
+ );
894
+ }
895
+ },
896
+ index
897
+ },
898
+ item.id
899
+ );
900
+ }),
901
+ !showInboundItemsPlaceholder && /* @__PURE__ */ jsxs2("div", { className: "mt-8 flex flex-col gap-y-4", children: [
902
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
903
+ /* @__PURE__ */ jsxs2("div", { children: [
904
+ /* @__PURE__ */ jsx4(Form.Label, { children: t("orders.returns.location") }),
905
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.locationHint") })
906
+ ] }),
907
+ /* @__PURE__ */ jsx4(
908
+ Form.Field,
909
+ {
910
+ control: form.control,
911
+ name: "location_id",
912
+ render: ({ field: { value, onChange, ...field } }) => {
913
+ return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(
914
+ Combobox,
915
+ {
916
+ ...field,
917
+ value: value ?? void 0,
918
+ onChange: (v) => {
919
+ onChange(v);
920
+ onLocationChange(v);
921
+ },
922
+ options: stock_locations.map((stockLocation) => ({
923
+ label: stockLocation.name,
924
+ value: stockLocation.id
925
+ }))
926
+ }
927
+ ) }) });
928
+ }
929
+ }
930
+ )
931
+ ] }),
932
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
933
+ /* @__PURE__ */ jsxs2("div", { children: [
934
+ /* @__PURE__ */ jsxs2(Form.Label, { children: [
935
+ t("orders.returns.inboundShipping"),
936
+ /* @__PURE__ */ jsxs2(
937
+ Text2,
938
+ {
939
+ size: "small",
940
+ leading: "compact",
941
+ className: "text-ui-fg-muted ml-1 inline",
942
+ children: [
943
+ "(",
944
+ t("fields.optional"),
945
+ ")"
946
+ ]
947
+ }
948
+ )
949
+ ] }),
950
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.inboundShippingHint") })
951
+ ] }),
952
+ /* @__PURE__ */ jsx4(
953
+ Form.Field,
954
+ {
955
+ control: form.control,
956
+ name: "inbound_option_id",
957
+ render: ({ field: { value, onChange, ...field } }) => {
958
+ return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(
959
+ Combobox,
960
+ {
961
+ allowClear: true,
962
+ value: value ?? void 0,
963
+ onChange: (val) => {
964
+ onChange(val);
965
+ onShippingOptionChange(val);
966
+ },
967
+ ...field,
968
+ options: inboundShippingOptions.map((so) => ({
969
+ label: so.name,
970
+ value: so.id
971
+ })),
972
+ disabled: !locationId
973
+ }
974
+ ) }) });
975
+ }
976
+ }
977
+ )
978
+ ] })
979
+ ] })
980
+ ] });
981
+ };
982
+
983
+ // src/pages/orders/[id]/exchanges/create/_components/exchange-create-form/exchange-outbound-section.tsx
984
+ import { Button as Button2, Heading as Heading2, toast as toast2 } from "@medusajs/ui";
985
+ import { useEffect as useEffect2, useMemo as useMemo6 } from "react";
986
+ import { useFieldArray as useFieldArray2 } from "react-hook-form";
987
+ import { useTranslation as useTranslation10 } from "react-i18next";
988
+
989
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-outbound-items-table/add-exchange-outbound-items-table.tsx
990
+ import { useMemo as useMemo5, useState as useState2 } from "react";
991
+ import { useTranslation as useTranslation8 } from "react-i18next";
992
+
993
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-outbound-items-table/use-exchange-outbound-item-table-columns.tsx
994
+ import { Checkbox as Checkbox2, Text as Text3 } from "@medusajs/ui";
995
+ import { createColumnHelper as createColumnHelper2 } from "@tanstack/react-table";
996
+ import { useMemo as useMemo4 } from "react";
997
+ import { useTranslation as useTranslation6 } from "react-i18next";
998
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
999
+ var columnHelper2 = createColumnHelper2();
1000
+ var useExchangeOutboundItemTableColumns = () => {
1001
+ const { t } = useTranslation6();
1002
+ return useMemo4(
1003
+ () => [
1004
+ columnHelper2.display({
1005
+ id: "select",
1006
+ header: ({ table }) => /* @__PURE__ */ jsx5(
1007
+ Checkbox2,
1008
+ {
1009
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
1010
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
1011
+ }
1012
+ ),
1013
+ cell: ({ row }) => {
1014
+ const isSelectable = row.getCanSelect();
1015
+ return /* @__PURE__ */ jsx5(
1016
+ Checkbox2,
1017
+ {
1018
+ disabled: !isSelectable,
1019
+ checked: row.getIsSelected(),
1020
+ onCheckedChange: (value) => row.toggleSelected(!!value),
1021
+ onClick: (e) => {
1022
+ e.stopPropagation();
1023
+ }
1024
+ }
1025
+ );
1026
+ }
1027
+ }),
1028
+ columnHelper2.display({
1029
+ id: "product",
1030
+ header: t("fields.product"),
1031
+ cell: ({ row }) => {
1032
+ const variant = row.original.product_variant;
1033
+ const productTitle = variant?.product?.title;
1034
+ if (!productTitle) {
1035
+ return /* @__PURE__ */ jsx5(PlaceholderCell, {});
1036
+ }
1037
+ return /* @__PURE__ */ jsxs3("div", { className: "flex h-full w-full max-w-[300px] items-center gap-x-3 overflow-hidden", children: [
1038
+ /* @__PURE__ */ jsx5(Thumbnail, { src: variant?.product?.thumbnail }),
1039
+ /* @__PURE__ */ jsx5(
1040
+ Text3,
1041
+ {
1042
+ size: "small",
1043
+ leading: "compact",
1044
+ className: "truncate",
1045
+ title: productTitle,
1046
+ children: productTitle
1047
+ }
1048
+ )
1049
+ ] });
1050
+ }
1051
+ }),
1052
+ columnHelper2.accessor("sku", {
1053
+ header: t("fields.sku"),
1054
+ cell: ({ getValue }) => {
1055
+ const sku = getValue();
1056
+ if (!sku) return /* @__PURE__ */ jsx5(PlaceholderCell, {});
1057
+ return /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", className: "truncate", children: sku });
1058
+ }
1059
+ }),
1060
+ columnHelper2.display({
1061
+ id: "variant_title",
1062
+ header: t("fields.title"),
1063
+ cell: ({ row }) => {
1064
+ const title = row.original.product_variant?.title;
1065
+ if (!title) return /* @__PURE__ */ jsx5(PlaceholderCell, {});
1066
+ return /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", className: "truncate", children: title });
1067
+ }
1068
+ })
1069
+ ],
1070
+ [t]
1071
+ );
1072
+ };
1073
+
1074
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-outbound-items-table/use-exchange-outbound-item-table-filters.tsx
1075
+ import { useTranslation as useTranslation7 } from "react-i18next";
1076
+ var useExchangeOutboundItemTableFilters = () => {
1077
+ const { t } = useTranslation7();
1078
+ const filters = [
1079
+ {
1080
+ key: "created_at",
1081
+ label: t("fields.createdAt"),
1082
+ type: "date"
1083
+ },
1084
+ {
1085
+ key: "updated_at",
1086
+ label: t("fields.updatedAt"),
1087
+ type: "date"
1088
+ }
1089
+ ];
1090
+ return filters;
1091
+ };
1092
+
1093
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-outbound-items-table/use-exchange-outbound-item-table-query.tsx
1094
+ var useExchangeOutboundItemTableQuery = ({
1095
+ pageSize = 50,
1096
+ prefix
1097
+ }) => {
1098
+ const raw = useQueryParams(
1099
+ ["q", "offset", "order", "created_at", "updated_at"],
1100
+ prefix
1101
+ );
1102
+ const { offset, created_at, updated_at, ...rest } = raw;
1103
+ const searchParams = {
1104
+ ...rest,
1105
+ limit: pageSize,
1106
+ offset: offset ? Number(offset) : 0,
1107
+ created_at: created_at ? JSON.parse(created_at) : void 0,
1108
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0
1109
+ };
1110
+ return { searchParams, raw };
1111
+ };
1112
+
1113
+ // src/pages/orders/[id]/exchanges/create/_components/add-exchange-outbound-items-table/add-exchange-outbound-items-table.tsx
1114
+ import { jsx as jsx6 } from "react/jsx-runtime";
1115
+ var PAGE_SIZE2 = 50;
1116
+ var PREFIX2 = "rit";
1117
+ var OFFER_PICKER_FIELDS = [
1118
+ "id",
1119
+ "sku",
1120
+ "variant_id",
1121
+ "seller_id",
1122
+ "prices.amount",
1123
+ "prices.currency_code",
1124
+ "product_variant.id",
1125
+ "product_variant.title",
1126
+ "product_variant.product.id",
1127
+ "product_variant.product.title",
1128
+ "product_variant.product.thumbnail",
1129
+ "product_variant.manage_inventory",
1130
+ "product_variant.inventory_quantity",
1131
+ "product_variant.inventory_items.required_quantity",
1132
+ "product_variant.inventory_items.inventory.location_levels.available_quantity"
1133
+ ].join(",");
1134
+ var offerHasInventory = (offer) => {
1135
+ const variant = offer.product_variant;
1136
+ if (!variant) return false;
1137
+ if (variant.manage_inventory === false) return true;
1138
+ const links = variant.inventory_items ?? [];
1139
+ if (!links.length) {
1140
+ return (variant.inventory_quantity ?? 0) > 0;
1141
+ }
1142
+ return links.every((link) => {
1143
+ const available = (link.inventory?.location_levels ?? []).reduce(
1144
+ (acc, lvl) => acc + (lvl.available_quantity ?? 0),
1145
+ 0
1146
+ );
1147
+ const required = link.required_quantity ?? 1;
1148
+ return required > 0 && available >= required;
1149
+ });
1150
+ };
1151
+ var AddExchangeOutboundItemsTable = ({
1152
+ currencyCode,
1153
+ onSelectionChange,
1154
+ selectedItems = []
1155
+ }) => {
1156
+ const { t } = useTranslation8();
1157
+ const [rowSelection, setRowSelection] = useState2(
1158
+ selectedItems.reduce((acc, id) => {
1159
+ acc[id] = true;
1160
+ return acc;
1161
+ }, {})
1162
+ );
1163
+ const updater = (fn) => {
1164
+ const newState = typeof fn === "function" ? fn(rowSelection) : fn;
1165
+ setRowSelection(newState);
1166
+ onSelectionChange(Object.keys(newState));
1167
+ };
1168
+ const { searchParams, raw } = useExchangeOutboundItemTableQuery({
1169
+ pageSize: PAGE_SIZE2,
1170
+ prefix: PREFIX2
1171
+ });
1172
+ const offersResponse = useOffers({
1173
+ ...searchParams,
1174
+ fields: OFFER_PICKER_FIELDS
1175
+ });
1176
+ const rawOffers = useMemo5(
1177
+ () => offersResponse.offers ?? [],
1178
+ [offersResponse.offers]
1179
+ );
1180
+ const rawCount = offersResponse.count ?? 0;
1181
+ const offers = useMemo5(() => {
1182
+ return rawOffers.filter((offer) => {
1183
+ if (currencyCode) {
1184
+ const hasPrice = (offer.prices ?? []).some(
1185
+ (p) => p.currency_code === currencyCode
1186
+ );
1187
+ if (!hasPrice) return false;
1188
+ }
1189
+ return offerHasInventory(offer);
1190
+ });
1191
+ }, [rawOffers, currencyCode]);
1192
+ const count = offers.length;
1193
+ void rawCount;
1194
+ const columns = useExchangeOutboundItemTableColumns();
1195
+ const filters = useExchangeOutboundItemTableFilters();
1196
+ const { table } = useDataTable({
1197
+ data: offers,
1198
+ columns,
1199
+ count,
1200
+ enablePagination: true,
1201
+ // Row id = offer id so onSelectionChange yields offer_ids that the
1202
+ // modal layer sends to the backend item-add routes (which accept
1203
+ // `offer_id` and resolve to variant_id + unit_price server-side).
1204
+ getRowId: (row) => row.id,
1205
+ pageSize: PAGE_SIZE2,
1206
+ enableRowSelection: () => true,
1207
+ rowSelection: {
1208
+ state: rowSelection,
1209
+ updater
1210
+ }
1211
+ });
1212
+ return /* @__PURE__ */ jsx6(
1213
+ "div",
1214
+ {
1215
+ className: "flex size-full flex-col overflow-hidden",
1216
+ "data-testid": "add-offers-picker",
1217
+ children: /* @__PURE__ */ jsx6(
1218
+ _DataTable,
1219
+ {
1220
+ table,
1221
+ columns,
1222
+ pageSize: PAGE_SIZE2,
1223
+ count,
1224
+ filters,
1225
+ pagination: true,
1226
+ layout: "fill",
1227
+ search: true,
1228
+ orderBy: [
1229
+ { key: "sku", label: t("fields.sku") },
1230
+ { key: "created_at", label: t("fields.createdAt") },
1231
+ { key: "updated_at", label: t("fields.updatedAt") }
1232
+ ],
1233
+ prefix: PREFIX2,
1234
+ queryObject: raw
1235
+ }
1236
+ )
1237
+ }
1238
+ );
1239
+ };
1240
+
1241
+ // src/pages/orders/[id]/exchanges/create/_components/exchange-create-form/exchange-outbound-item.tsx
1242
+ import { XCircle as XCircle2 } from "@medusajs/icons";
1243
+ import { Input as Input2, Text as Text4 } from "@medusajs/ui";
1244
+ import { useTranslation as useTranslation9 } from "react-i18next";
1245
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1246
+ function ExchangeOutboundItem({
1247
+ previewItem,
1248
+ currencyCode,
1249
+ form,
1250
+ onRemove,
1251
+ onUpdate,
1252
+ index
1253
+ }) {
1254
+ const { t } = useTranslation9();
1255
+ const appliedPromoCodes = (previewItem.adjustments ?? []).map((adjustment) => adjustment.code).filter((code) => Boolean(code));
1256
+ return /* @__PURE__ */ jsx7(
1257
+ "div",
1258
+ {
1259
+ className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl",
1260
+ "data-testid": `exchange-outbound-item-${previewItem.id}`,
1261
+ children: /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-x-3 gap-y-2 p-3 text-sm md:flex-row", children: [
1262
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-1 items-center gap-x-3", children: [
1263
+ /* @__PURE__ */ jsx7(Thumbnail, { src: previewItem.thumbnail ?? void 0 }),
1264
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-grow flex-col", children: [
1265
+ /* @__PURE__ */ jsxs4("div", { children: [
1266
+ /* @__PURE__ */ jsxs4(Text4, { className: "txt-small", as: "span", weight: "plus", children: [
1267
+ previewItem.title,
1268
+ " "
1269
+ ] }),
1270
+ previewItem.variant_sku && /* @__PURE__ */ jsxs4("span", { children: [
1271
+ "(",
1272
+ previewItem.variant_sku,
1273
+ ")"
1274
+ ] })
1275
+ ] }),
1276
+ /* @__PURE__ */ jsx7(Text4, { as: "div", className: "text-ui-fg-subtle txt-small", children: previewItem.subtitle ?? previewItem.variant_title ?? "" })
1277
+ ] }),
1278
+ appliedPromoCodes.length > 0 && /* @__PURE__ */ jsx7(
1279
+ "div",
1280
+ {
1281
+ className: "flex flex-shrink",
1282
+ title: appliedPromoCodes.join(", ")
1283
+ }
1284
+ )
1285
+ ] }),
1286
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-1 justify-between", children: [
1287
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-grow items-center gap-2", children: [
1288
+ /* @__PURE__ */ jsx7(
1289
+ Form.Field,
1290
+ {
1291
+ control: form.control,
1292
+ name: `outbound_items.${index}.quantity`,
1293
+ render: ({ field }) => {
1294
+ return /* @__PURE__ */ jsxs4(Form.Item, { children: [
1295
+ /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(
1296
+ Input2,
1297
+ {
1298
+ ...field,
1299
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
1300
+ min: 1,
1301
+ type: "number",
1302
+ "data-testid": `exchange-outbound-item-${previewItem.id}-qty`,
1303
+ onBlur: (e) => {
1304
+ const val = e.target.value;
1305
+ const payload = val === "" ? null : Number(val);
1306
+ field.onChange(payload);
1307
+ if (payload) {
1308
+ onUpdate({ quantity: payload });
1309
+ }
1310
+ }
1311
+ }
1312
+ ) }),
1313
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
1314
+ ] });
1315
+ }
1316
+ }
1317
+ ),
1318
+ /* @__PURE__ */ jsx7(Text4, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
1319
+ ] }),
1320
+ /* @__PURE__ */ jsx7("div", { className: "text-ui-fg-subtle txt-small mr-2 flex flex-shrink-0", children: /* @__PURE__ */ jsx7(
1321
+ MoneyAmountCell,
1322
+ {
1323
+ currencyCode,
1324
+ amount: previewItem.total ?? 0
1325
+ }
1326
+ ) }),
1327
+ /* @__PURE__ */ jsx7(
1328
+ ActionMenu,
1329
+ {
1330
+ groups: [
1331
+ {
1332
+ actions: [
1333
+ {
1334
+ label: t("actions.remove"),
1335
+ onClick: onRemove,
1336
+ icon: /* @__PURE__ */ jsx7(XCircle2, {})
1337
+ }
1338
+ ]
1339
+ }
1340
+ ]
1341
+ }
1342
+ )
1343
+ ] })
1344
+ ] })
1345
+ }
1346
+ );
1347
+ }
1348
+
1349
+ // src/pages/orders/[id]/exchanges/create/_components/exchange-create-form/exchange-outbound-section.tsx
1350
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1351
+ var offersToAdd = [];
1352
+ var offersToRemove = [];
1353
+ var ExchangeOutboundSection = ({
1354
+ order,
1355
+ preview,
1356
+ exchange,
1357
+ form
1358
+ }) => {
1359
+ const { t } = useTranslation10();
1360
+ const { setIsOpen } = useStackedModal();
1361
+ const { mutateAsync: addOutboundShipping } = useAddExchangeOutboundShipping(
1362
+ exchange.id,
1363
+ order.id
1364
+ );
1365
+ const { mutateAsync: addOutboundItem } = useAddExchangeOutboundItems(
1366
+ exchange.id,
1367
+ order.id
1368
+ );
1369
+ const { mutateAsync: updateOutboundItem } = useUpdateExchangeOutboundItem(
1370
+ exchange.id,
1371
+ order.id
1372
+ );
1373
+ const { mutateAsync: removeOutboundItem } = useRemoveExchangeOutboundItem(
1374
+ exchange.id,
1375
+ order.id
1376
+ );
1377
+ const previewOutboundItems = useMemo6(
1378
+ () => (preview?.items ?? []).filter(
1379
+ (i) => !!i.actions?.find(
1380
+ (a) => a.exchange_id === exchange.id && a.action === "ITEM_ADD"
1381
+ )
1382
+ ),
1383
+ [preview.items, exchange.id]
1384
+ );
1385
+ const {
1386
+ fields: outboundItems,
1387
+ append,
1388
+ remove,
1389
+ update
1390
+ } = useFieldArray2({
1391
+ name: "outbound_items",
1392
+ control: form.control
1393
+ });
1394
+ const previewItemsMap = useMemo6(
1395
+ () => new Map(previewOutboundItems.map((i) => [i.id, i])),
1396
+ [previewOutboundItems]
1397
+ );
1398
+ useEffect2(() => {
1399
+ const existingItemsMap = {};
1400
+ previewOutboundItems.forEach((i) => {
1401
+ const ind = outboundItems.findIndex((field) => field.item_id === i.id);
1402
+ const requested = i.detail?.quantity ?? 0;
1403
+ existingItemsMap[i.id] = true;
1404
+ if (ind > -1) {
1405
+ if (outboundItems[ind].quantity !== requested) {
1406
+ update(ind, {
1407
+ ...outboundItems[ind],
1408
+ quantity: requested
1409
+ });
1410
+ }
1411
+ } else {
1412
+ append(
1413
+ {
1414
+ item_id: i.id,
1415
+ quantity: requested,
1416
+ variant_id: i.variant_id ?? void 0
1417
+ },
1418
+ { shouldFocus: false }
1419
+ );
1420
+ }
1421
+ });
1422
+ outboundItems.forEach((i, ind) => {
1423
+ if (!(i.item_id in existingItemsMap)) {
1424
+ remove(ind);
1425
+ }
1426
+ });
1427
+ }, [previewOutboundItems]);
1428
+ const showOutboundItemsPlaceholder = !outboundItems.length;
1429
+ const onItemsSelected = async () => {
1430
+ if (offersToAdd.length) {
1431
+ await addOutboundItem(
1432
+ {
1433
+ // Vendor route resolves `offer_id` server-side.
1434
+ items: offersToAdd.map((offer_id) => ({
1435
+ offer_id,
1436
+ quantity: 1
1437
+ }))
1438
+ },
1439
+ {
1440
+ onError: (error) => {
1441
+ toast2.error(error.message);
1442
+ }
1443
+ }
1444
+ );
1445
+ }
1446
+ for (const offerToRemove of offersToRemove) {
1447
+ const field = outboundItems.find(
1448
+ (f) => f.offer_id === offerToRemove
1449
+ );
1450
+ const previewMatch = field ? previewOutboundItems.find((i) => i.id === field.item_id) : void 0;
1451
+ const actionId = previewMatch?.actions?.find(
1452
+ (a) => a.action === "ITEM_ADD"
1453
+ )?.id;
1454
+ if (actionId) {
1455
+ await removeOutboundItem(actionId, {
1456
+ onError: (error) => {
1457
+ toast2.error(error.message);
1458
+ }
1459
+ });
1460
+ }
1461
+ }
1462
+ setIsOpen("outbound-items", false);
1463
+ };
1464
+ useEffect2(() => {
1465
+ const outboundShipping = (preview.shipping_methods ?? []).find(
1466
+ (s) => !!s.actions?.find((a) => a.action === "SHIPPING_ADD" && !a.return_id)
1467
+ );
1468
+ if (outboundShipping?.shipping_option_id) {
1469
+ form.setValue("outbound_option_id", outboundShipping.shipping_option_id);
1470
+ } else {
1471
+ form.setValue("outbound_option_id", "");
1472
+ }
1473
+ }, [preview.shipping_methods]);
1474
+ const onShippingOptionChange = async (selectedOptionId) => {
1475
+ if (selectedOptionId) {
1476
+ await addOutboundShipping(
1477
+ { shipping_option_id: selectedOptionId },
1478
+ {
1479
+ onError: (error) => {
1480
+ toast2.error(error.message);
1481
+ }
1482
+ }
1483
+ );
1484
+ }
1485
+ };
1486
+ return /* @__PURE__ */ jsxs5("div", { children: [
1487
+ /* @__PURE__ */ jsxs5("div", { className: "mt-8 flex items-center justify-between", children: [
1488
+ /* @__PURE__ */ jsx8(Heading2, { level: "h2", children: t("orders.returns.outbound") }),
1489
+ /* @__PURE__ */ jsxs5(StackedFocusModal, { id: "outbound-items", children: [
1490
+ /* @__PURE__ */ jsx8(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx8(
1491
+ "a",
1492
+ {
1493
+ href: "#",
1494
+ onClick: (e) => e.preventDefault(),
1495
+ className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400",
1496
+ children: t("actions.addItems")
1497
+ }
1498
+ ) }),
1499
+ /* @__PURE__ */ jsxs5(StackedFocusModal.Content, { children: [
1500
+ /* @__PURE__ */ jsx8(StackedFocusModal.Header, {}),
1501
+ /* @__PURE__ */ jsx8(
1502
+ AddExchangeOutboundItemsTable,
1503
+ {
1504
+ selectedItems: outboundItems.map((i) => i.offer_id).filter(Boolean),
1505
+ currencyCode: order.currency_code,
1506
+ onSelectionChange: (finalSelection) => {
1507
+ const alreadySelected = outboundItems.map((i) => i.offer_id).filter(Boolean);
1508
+ offersToAdd = finalSelection.filter(
1509
+ (selection) => !alreadySelected.includes(selection)
1510
+ );
1511
+ offersToRemove = alreadySelected.filter(
1512
+ (selection) => !finalSelection.includes(selection)
1513
+ );
1514
+ }
1515
+ }
1516
+ ),
1517
+ /* @__PURE__ */ jsx8(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsx8("div", { className: "flex w-full items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-end gap-x-2", children: [
1518
+ /* @__PURE__ */ jsx8(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx8(Button2, { type: "button", variant: "secondary", size: "small", children: t("actions.cancel") }) }),
1519
+ /* @__PURE__ */ jsx8(
1520
+ Button2,
1521
+ {
1522
+ type: "submit",
1523
+ variant: "primary",
1524
+ size: "small",
1525
+ onClick: async () => await onItemsSelected(),
1526
+ children: t("actions.save")
1527
+ },
1528
+ "submit-button"
1529
+ )
1530
+ ] }) }) })
1531
+ ] })
1532
+ ] })
1533
+ ] }),
1534
+ showOutboundItemsPlaceholder && /* @__PURE__ */ jsx8(ItemPlaceholder, {}),
1535
+ outboundItems.map((item, index) => {
1536
+ const previewItem = previewItemsMap.get(item.item_id);
1537
+ if (!previewItem) {
1538
+ return null;
1539
+ }
1540
+ return /* @__PURE__ */ jsx8(
1541
+ ExchangeOutboundItem,
1542
+ {
1543
+ previewItem,
1544
+ currencyCode: order.currency_code,
1545
+ form,
1546
+ onRemove: () => {
1547
+ const actionId = previewOutboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "ITEM_ADD")?.id;
1548
+ if (actionId) {
1549
+ removeOutboundItem(actionId, {
1550
+ onError: (error) => {
1551
+ toast2.error(error.message);
1552
+ }
1553
+ });
1554
+ }
1555
+ },
1556
+ onUpdate: (payload) => {
1557
+ const actionId = previewOutboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "ITEM_ADD")?.id;
1558
+ if (actionId) {
1559
+ updateOutboundItem(
1560
+ { $actionId: actionId, ...payload },
1561
+ {
1562
+ onError: (error) => {
1563
+ toast2.error(error.message);
1564
+ }
1565
+ }
1566
+ );
1567
+ }
1568
+ },
1569
+ index
1570
+ },
1571
+ item.id
1572
+ );
1573
+ }),
1574
+ !showOutboundItemsPlaceholder && /* @__PURE__ */ jsx8("div", { className: "mt-8 flex flex-col gap-y-4", children: /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
1575
+ /* @__PURE__ */ jsxs5("div", { children: [
1576
+ /* @__PURE__ */ jsx8(Form.Label, { children: t("orders.exchanges.outboundShipping") }),
1577
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.exchanges.outboundShippingHint") })
1578
+ ] }),
1579
+ /* @__PURE__ */ jsx8(
1580
+ Form.Field,
1581
+ {
1582
+ control: form.control,
1583
+ name: "outbound_option_id",
1584
+ render: ({ field: { value, onChange, ...field } }) => {
1585
+ return /* @__PURE__ */ jsx8(Form.Item, { children: /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(
1586
+ Combobox,
1587
+ {
1588
+ allowClear: true,
1589
+ value: value ?? void 0,
1590
+ onChange: (val) => {
1591
+ onChange(val);
1592
+ onShippingOptionChange(val);
1593
+ },
1594
+ ...field,
1595
+ options: [],
1596
+ disabled: true
1597
+ }
1598
+ ) }) });
1599
+ }
1600
+ }
1601
+ )
1602
+ ] }) })
1603
+ ] });
1604
+ };
1605
+
1606
+ // src/pages/orders/[id]/exchanges/create/_components/exchange-create-form/schema.ts
1607
+ import { z } from "zod";
1608
+ var ExchangeCreateSchema = z.object({
1609
+ inbound_items: z.array(
1610
+ z.object({
1611
+ item_id: z.string(),
1612
+ variant_id: z.string().nullish(),
1613
+ quantity: z.number(),
1614
+ reason_id: z.string().nullish(),
1615
+ note: z.string().nullish()
1616
+ })
1617
+ ),
1618
+ outbound_items: z.array(
1619
+ z.object({
1620
+ item_id: z.string(),
1621
+ offer_id: z.string().nullish(),
1622
+ variant_id: z.string().nullish(),
1623
+ quantity: z.number()
1624
+ })
1625
+ ),
1626
+ location_id: z.string().optional(),
1627
+ inbound_option_id: z.string().nullish(),
1628
+ outbound_option_id: z.string().nullish(),
1629
+ send_notification: z.boolean().optional()
1630
+ });
1631
+
1632
+ // src/pages/orders/[id]/exchanges/create/_components/exchange-create-form/exchange-create-form.tsx
1633
+ import { Fragment, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1634
+ var readExchangeId = (change) => {
1635
+ if (change && typeof change === "object" && "exchange_id" in change && typeof change.exchange_id === "string") {
1636
+ return change.exchange_id;
1637
+ }
1638
+ return void 0;
1639
+ };
1640
+ var IS_REQUEST_RUNNING = false;
1641
+ var ExchangeCreateForm = () => {
1642
+ const { id } = useParams();
1643
+ const { t } = useTranslation11();
1644
+ const navigate = useNavigate();
1645
+ const { handleSuccess } = useRouteModal();
1646
+ const orderId = id ?? "";
1647
+ const { order } = useOrder(orderId, {
1648
+ fields: "currency_code,total,items.*,items.variant.*"
1649
+ });
1650
+ const { order: preview } = useOrderPreview(orderId);
1651
+ const [exchangeId, setExchangeId] = useState3("");
1652
+ const [submitting, setSubmitting] = useState3(false);
1653
+ const [canceling, setCanceling] = useState3(false);
1654
+ const form = useForm({
1655
+ defaultValues: {
1656
+ inbound_items: [],
1657
+ outbound_items: [],
1658
+ location_id: void 0,
1659
+ inbound_option_id: null,
1660
+ outbound_option_id: null,
1661
+ send_notification: false
1662
+ },
1663
+ resolver: zodResolver(ExchangeCreateSchema)
1664
+ });
1665
+ const { mutateAsync: createExchange } = useCreateExchange(orderId);
1666
+ const { mutateAsync: cancelBegin } = useCancelExchangeBegin(
1667
+ exchangeId,
1668
+ orderId
1669
+ );
1670
+ const { mutateAsync: requestExchange, isPending: isConfirming } = useRequestExchange(exchangeId, orderId);
1671
+ useEffect3(() => {
1672
+ async function run() {
1673
+ if (IS_REQUEST_RUNNING || exchangeId || !preview) {
1674
+ return;
1675
+ }
1676
+ if (preview.order_change) {
1677
+ if (preview.order_change.change_type !== "exchange") {
1678
+ navigate(`/orders/${orderId}`, { replace: true });
1679
+ toast3.error(t("orders.exchanges.activeChangeError"));
1680
+ return;
1681
+ }
1682
+ const existingExchangeId = readExchangeId(preview.order_change);
1683
+ if (existingExchangeId) {
1684
+ setExchangeId(existingExchangeId);
1685
+ }
1686
+ return;
1687
+ }
1688
+ IS_REQUEST_RUNNING = true;
1689
+ try {
1690
+ const { exchange } = await createExchange({ order_id: orderId });
1691
+ setExchangeId(exchange.id);
1692
+ } catch (e) {
1693
+ toast3.error(
1694
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
1695
+ );
1696
+ navigate(`/orders/${orderId}`, { replace: true });
1697
+ } finally {
1698
+ IS_REQUEST_RUNNING = false;
1699
+ }
1700
+ }
1701
+ run();
1702
+ }, [preview, orderId, exchangeId]);
1703
+ const inboundItemsWatch = form.watch("inbound_items");
1704
+ const outboundItemsWatch = form.watch("outbound_items");
1705
+ const hasSelection = useMemo7(
1706
+ () => (inboundItemsWatch?.length ?? 0) > 0 || (outboundItemsWatch?.length ?? 0) > 0,
1707
+ [inboundItemsWatch, outboundItemsWatch]
1708
+ );
1709
+ const previewItems = useMemo7(() => {
1710
+ if (!exchangeId) return [];
1711
+ return (preview?.items ?? []).filter(
1712
+ (i) => !!i.actions?.find((a) => a.exchange_id === exchangeId)
1713
+ );
1714
+ }, [preview, exchangeId]);
1715
+ const inboundPreviewItems = useMemo7(
1716
+ () => previewItems.filter(
1717
+ (item) => !!item.actions?.find((a) => a.action === "RETURN_ITEM")
1718
+ ),
1719
+ [previewItems]
1720
+ );
1721
+ const outboundPreviewItems = useMemo7(
1722
+ () => previewItems.filter(
1723
+ (item) => !!item.actions?.find((a) => a.action === "ITEM_ADD")
1724
+ ),
1725
+ [previewItems]
1726
+ );
1727
+ const currencyCode = order?.currency_code ?? "";
1728
+ const inboundTotal = useMemo7(() => {
1729
+ return inboundPreviewItems.reduce((acc, item) => {
1730
+ const action = item.actions?.find((a) => a.action === "RETURN_ITEM");
1731
+ const requested = Number(action?.details?.quantity || 0);
1732
+ const itemQty = item.quantity ?? 0;
1733
+ const itemTotal = item.total ?? 0;
1734
+ if (!itemQty) return acc;
1735
+ return acc + requested / itemQty * itemTotal;
1736
+ }, 0);
1737
+ }, [inboundPreviewItems]);
1738
+ const outboundTotal = useMemo7(() => {
1739
+ return outboundPreviewItems.reduce(
1740
+ (acc, item) => acc + (item.total ?? 0),
1741
+ 0
1742
+ );
1743
+ }, [outboundPreviewItems]);
1744
+ const inboundShippingTotal = useMemo7(() => {
1745
+ const methods = preview?.shipping_methods ?? [];
1746
+ const method = methods.find(
1747
+ (sm) => !!sm.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
1748
+ );
1749
+ return method?.total ?? 0;
1750
+ }, [preview]);
1751
+ const outboundShippingTotal = useMemo7(() => {
1752
+ const methods = preview?.shipping_methods ?? [];
1753
+ const method = methods.find(
1754
+ (sm) => !!sm.actions?.find((a) => a.action === "SHIPPING_ADD" && !a.return_id)
1755
+ );
1756
+ return method?.total ?? 0;
1757
+ }, [preview]);
1758
+ const estimatedDifference = useMemo7(() => {
1759
+ const summary = preview?.summary;
1760
+ return (summary?.pending_difference ?? 0) - inboundTotal;
1761
+ }, [preview, inboundTotal]);
1762
+ const prompt = usePrompt();
1763
+ const handleSubmit = form.handleSubmit(async (data) => {
1764
+ if (!exchangeId) {
1765
+ return;
1766
+ }
1767
+ const res = await prompt({
1768
+ title: t("general.areYouSure"),
1769
+ description: t("orders.exchanges.confirmText"),
1770
+ confirmText: t("actions.continue"),
1771
+ cancelText: t("actions.cancel"),
1772
+ variant: "confirmation"
1773
+ });
1774
+ if (!res) {
1775
+ return;
1776
+ }
1777
+ setSubmitting(true);
1778
+ try {
1779
+ await requestExchange(
1780
+ { no_notification: !data.send_notification }
1781
+ );
1782
+ toast3.success(t("orders.exchanges.toast.confirmedSuccessfully"));
1783
+ handleSuccess(`/orders/${orderId}`);
1784
+ } catch (e) {
1785
+ toast3.error(t("general.error"), {
1786
+ description: e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
1787
+ });
1788
+ } finally {
1789
+ setSubmitting(false);
1790
+ }
1791
+ });
1792
+ const handleClose = async () => {
1793
+ if (!exchangeId) {
1794
+ navigate(`/orders/${orderId}`, { replace: true });
1795
+ return;
1796
+ }
1797
+ setCanceling(true);
1798
+ try {
1799
+ await cancelBegin();
1800
+ toast3.success(t("orders.exchanges.toast.canceledSuccessfully"));
1801
+ } catch {
1802
+ } finally {
1803
+ setCanceling(false);
1804
+ navigate(`/orders/${orderId}`, { replace: true });
1805
+ }
1806
+ };
1807
+ const ready = !!order && !!preview && !!exchangeId;
1808
+ return /* @__PURE__ */ jsx9(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs6(KeyboundForm, { onSubmit: handleSubmit, className: "flex h-full flex-col", children: [
1809
+ /* @__PURE__ */ jsx9(RouteFocusModal.Header, {}),
1810
+ /* @__PURE__ */ jsx9(RouteFocusModal.Body, { className: "flex size-full justify-center overflow-y-auto", children: /* @__PURE__ */ jsxs6("div", { className: "mt-16 w-[720px] max-w-[100%] px-4 md:p-0", children: [
1811
+ /* @__PURE__ */ jsx9(Heading3, { level: "h1", children: t("orders.exchanges.create") }),
1812
+ /* @__PURE__ */ jsx9(Text5, { size: "small", className: "text-ui-fg-subtle mt-2", children: t("orders.exchanges.policyHint", {
1813
+ days: EXCHANGE_POLICY_DAYS
1814
+ }) }),
1815
+ ready && /* @__PURE__ */ jsxs6(Fragment, { children: [
1816
+ /* @__PURE__ */ jsx9(
1817
+ ExchangeInboundSection,
1818
+ {
1819
+ form,
1820
+ preview,
1821
+ order,
1822
+ exchange: { id: exchangeId }
1823
+ }
1824
+ ),
1825
+ /* @__PURE__ */ jsx9(
1826
+ ExchangeOutboundSection,
1827
+ {
1828
+ form,
1829
+ preview,
1830
+ order,
1831
+ exchange: { id: exchangeId }
1832
+ }
1833
+ ),
1834
+ /* @__PURE__ */ jsxs6("div", { className: "mt-8 border-y border-dotted py-4", children: [
1835
+ /* @__PURE__ */ jsxs6("div", { className: "mb-2 flex items-center justify-between", children: [
1836
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.inboundTotal") }),
1837
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(-1 * inboundTotal, currencyCode) })
1838
+ ] }),
1839
+ /* @__PURE__ */ jsxs6("div", { className: "mb-2 flex items-center justify-between", children: [
1840
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.exchanges.outboundTotal") }),
1841
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(outboundTotal, currencyCode) })
1842
+ ] }),
1843
+ /* @__PURE__ */ jsxs6("div", { className: "mb-2 flex items-center justify-between", children: [
1844
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.inboundShipping") }),
1845
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(inboundShippingTotal, currencyCode) })
1846
+ ] }),
1847
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between", children: [
1848
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.exchanges.outboundShipping") }),
1849
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(outboundShippingTotal, currencyCode) })
1850
+ ] }),
1851
+ /* @__PURE__ */ jsxs6("div", { className: "mt-4 flex items-center justify-between border-t border-dotted pt-4", children: [
1852
+ /* @__PURE__ */ jsx9("span", { className: "txt-small font-medium", children: t("orders.exchanges.refundAmount") }),
1853
+ /* @__PURE__ */ jsx9("span", { className: "txt-small font-medium", children: getStylizedAmount(estimatedDifference, currencyCode) })
1854
+ ] })
1855
+ ] })
1856
+ ] }),
1857
+ /* @__PURE__ */ jsx9("div", { className: "bg-ui-bg-field mt-8 rounded-lg border py-2 pl-2 pr-4", children: /* @__PURE__ */ jsx9(
1858
+ Form.Field,
1859
+ {
1860
+ control: form.control,
1861
+ name: "send_notification",
1862
+ render: ({ field: { onChange, value, ...field } }) => /* @__PURE__ */ jsxs6(Form.Item, { children: [
1863
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center", children: [
1864
+ /* @__PURE__ */ jsx9(Form.Control, { className: "mr-4 self-start", children: /* @__PURE__ */ jsx9(
1865
+ Switch,
1866
+ {
1867
+ dir: "ltr",
1868
+ className: "mt-[2px] rtl:rotate-180",
1869
+ checked: !!value,
1870
+ onCheckedChange: onChange,
1871
+ ...field,
1872
+ "data-testid": "exchange-create-notify"
1873
+ }
1874
+ ) }),
1875
+ /* @__PURE__ */ jsxs6("div", { className: "block", children: [
1876
+ /* @__PURE__ */ jsx9(Form.Label, { children: t("orders.returns.sendNotification") }),
1877
+ /* @__PURE__ */ jsx9(Form.Hint, { className: "!mt-1", children: t("orders.returns.sendNotificationHint") })
1878
+ ] })
1879
+ ] }),
1880
+ /* @__PURE__ */ jsx9(Form.ErrorMessage, {})
1881
+ ] })
1882
+ }
1883
+ ) }),
1884
+ /* @__PURE__ */ jsx9("div", { className: "p-8" })
1885
+ ] }) }),
1886
+ /* @__PURE__ */ jsx9(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx9("div", { className: "flex w-full items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-end gap-x-2", children: [
1887
+ /* @__PURE__ */ jsx9(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx9(
1888
+ Button3,
1889
+ {
1890
+ type: "button",
1891
+ onClick: handleClose,
1892
+ variant: "secondary",
1893
+ size: "small",
1894
+ isLoading: canceling,
1895
+ disabled: submitting,
1896
+ "data-testid": "exchange-cancel",
1897
+ children: t("orders.exchanges.cancel.title")
1898
+ }
1899
+ ) }),
1900
+ /* @__PURE__ */ jsx9(
1901
+ Button3,
1902
+ {
1903
+ type: "submit",
1904
+ variant: "primary",
1905
+ size: "small",
1906
+ isLoading: submitting || isConfirming,
1907
+ disabled: !exchangeId || canceling || !hasSelection,
1908
+ "data-testid": "exchange-confirm",
1909
+ children: t("orders.exchanges.confirm")
1910
+ },
1911
+ "submit-button"
1912
+ )
1913
+ ] }) }) })
1914
+ ] }) });
1915
+ };
1916
+
1917
+ // src/pages/orders/[id]/exchanges/create/index.tsx
1918
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
1919
+ var Component = () => {
1920
+ const { t } = useTranslation12();
1921
+ return /* @__PURE__ */ jsxs7(RouteFocusModal, { children: [
1922
+ /* @__PURE__ */ jsx10(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx10("span", { className: "sr-only", children: t("orders.exchanges.title") }) }),
1923
+ /* @__PURE__ */ jsx10(RouteFocusModal.Description, { className: "sr-only", children: t("orders.exchanges.title") }),
1924
+ /* @__PURE__ */ jsx10(ExchangeCreateForm, {})
1925
+ ] });
1926
+ };
1927
+ var create_default = Component;
1928
+ export {
1929
+ Component,
1930
+ create_default as default
1931
+ };