@mercurjs/admin 2.0.0-canary.24

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 (358) hide show
  1. package/dist/add-campaign-promotions-JDC36EOE.js +265 -0
  2. package/dist/adjust-inventory-2YLC4O4I.js +262 -0
  3. package/dist/api-key-management-create-KERROZ6Z.js +282 -0
  4. package/dist/api-key-management-detail-PXY2ZH4V.js +481 -0
  5. package/dist/api-key-management-edit-7IPPTW37.js +106 -0
  6. package/dist/api-key-management-list-QQHOCVV4.js +350 -0
  7. package/dist/api-key-management-sales-channels-AO6SRCAW.js +201 -0
  8. package/dist/campaign-budget-edit-C5PCVES3.js +147 -0
  9. package/dist/campaign-configuration-ONC2CL7Q.js +154 -0
  10. package/dist/campaign-create-J2PN77A6.js +29 -0
  11. package/dist/campaign-detail-2XJ7PXOQ.js +666 -0
  12. package/dist/campaign-edit-MU4TVOEC.js +206 -0
  13. package/dist/campaign-list-BWYHTJL2.js +187 -0
  14. package/dist/categories-metadata-UC3N6YSC.js +83 -0
  15. package/dist/category-create-DRJZI3EM.js +427 -0
  16. package/dist/category-detail-DEGYVUXB.js +544 -0
  17. package/dist/category-edit-PTYOK7VV.js +220 -0
  18. package/dist/category-list-T4GPTLOA.js +286 -0
  19. package/dist/category-organize-MLBY54BT.js +110 -0
  20. package/dist/category-products-W7U2VZTZ.js +281 -0
  21. package/dist/chunk-25LYVP3C.js +37 -0
  22. package/dist/chunk-26OOAKQ6.js +18 -0
  23. package/dist/chunk-2I3BDP2Z.js +61 -0
  24. package/dist/chunk-2KCF3ZIB.js +32 -0
  25. package/dist/chunk-2MKZ4HD4.js +175 -0
  26. package/dist/chunk-2PZGY332.js +88 -0
  27. package/dist/chunk-2QKPRGNK.js +107 -0
  28. package/dist/chunk-2Y3WMGN6.js +39 -0
  29. package/dist/chunk-2ZFELO2L.js +13 -0
  30. package/dist/chunk-33XUAKRP.js +6 -0
  31. package/dist/chunk-362QMJZM.js +77 -0
  32. package/dist/chunk-3CKTAFTR.js +143 -0
  33. package/dist/chunk-3EF54XFY.js +64 -0
  34. package/dist/chunk-3KOTDGC2.js +18 -0
  35. package/dist/chunk-3LDJURK5.js +296 -0
  36. package/dist/chunk-3QSRE5LS.js +161 -0
  37. package/dist/chunk-3XPXUIK3.js +34 -0
  38. package/dist/chunk-4F5GP7J7.js +45 -0
  39. package/dist/chunk-4GPAS5GW.js +36 -0
  40. package/dist/chunk-54EPH67T.js +34 -0
  41. package/dist/chunk-54RTJBYO.js +153 -0
  42. package/dist/chunk-54TMLQH3.js +9 -0
  43. package/dist/chunk-5LZ2G4ZX.js +422 -0
  44. package/dist/chunk-5S6J5PG5.js +182 -0
  45. package/dist/chunk-6IJMSVC6.js +16 -0
  46. package/dist/chunk-6KI3GDYH.js +46 -0
  47. package/dist/chunk-7AV5EJJ5.js +29 -0
  48. package/dist/chunk-7RPRNVBS.js +45 -0
  49. package/dist/chunk-7SVLKK6Q.js +31 -0
  50. package/dist/chunk-AW77UWCZ.js +363 -0
  51. package/dist/chunk-AWZFIP25.js +117 -0
  52. package/dist/chunk-AYVH6Q5O.js +31 -0
  53. package/dist/chunk-BDGZ4EQO.js +86 -0
  54. package/dist/chunk-BMNW3AEU.js +373 -0
  55. package/dist/chunk-BRUOBAPY.js +234 -0
  56. package/dist/chunk-BYZIWSBB.js +185 -0
  57. package/dist/chunk-C6SUTRP2.js +13 -0
  58. package/dist/chunk-CBRSGM3X.js +342 -0
  59. package/dist/chunk-CI5Z6FGV.js +87 -0
  60. package/dist/chunk-CMHI2RPL.js +20 -0
  61. package/dist/chunk-CP5IL4P6.js +98 -0
  62. package/dist/chunk-D3KDXELJ.js +110 -0
  63. package/dist/chunk-D6IERBVW.js +43 -0
  64. package/dist/chunk-DB6ANJBO.js +35 -0
  65. package/dist/chunk-DLKKSPFE.js +50 -0
  66. package/dist/chunk-DV73MHTN.js +457 -0
  67. package/dist/chunk-DXZOR4AG.js +69 -0
  68. package/dist/chunk-DY3XQPHC.js +31 -0
  69. package/dist/chunk-EOZUAYQL.js +6 -0
  70. package/dist/chunk-ERTSYQAI.js +121 -0
  71. package/dist/chunk-EZIB4NST.js +94 -0
  72. package/dist/chunk-FGZCSG7T.js +232 -0
  73. package/dist/chunk-FI474ADU.js +0 -0
  74. package/dist/chunk-FLCYR7E5.js +467 -0
  75. package/dist/chunk-FMFVTERD.js +0 -0
  76. package/dist/chunk-FODCCP6C.js +76 -0
  77. package/dist/chunk-FQERBIVS.js +0 -0
  78. package/dist/chunk-FWPGOIFA.js +22 -0
  79. package/dist/chunk-G5OVX555.js +26 -0
  80. package/dist/chunk-GUIDZSDY.js +41 -0
  81. package/dist/chunk-H22XDSXD.js +47 -0
  82. package/dist/chunk-HC25LNX7.js +45 -0
  83. package/dist/chunk-HINXQTCW.js +97 -0
  84. package/dist/chunk-HYUGYB23.js +161 -0
  85. package/dist/chunk-I43SCBL3.js +106 -0
  86. package/dist/chunk-IGTRIAUC.js +84 -0
  87. package/dist/chunk-INNFZYX2.js +183 -0
  88. package/dist/chunk-IQPN4PZJ.js +749 -0
  89. package/dist/chunk-IZ5RG5XI.js +72 -0
  90. package/dist/chunk-JDGE23BZ.js +332 -0
  91. package/dist/chunk-JHIMVLB2.js +42 -0
  92. package/dist/chunk-JISYRXUS.js +389 -0
  93. package/dist/chunk-JJVGCTKT.js +243 -0
  94. package/dist/chunk-JQV7CXEC.js +37 -0
  95. package/dist/chunk-JRTZWK77.js +1764 -0
  96. package/dist/chunk-KAZ5BYTQ.js +132 -0
  97. package/dist/chunk-KBYZLKI4.js +1093 -0
  98. package/dist/chunk-KTKL7M34.js +90 -0
  99. package/dist/chunk-KUWNYCGL.js +4113 -0
  100. package/dist/chunk-KW56S7WF.js +67 -0
  101. package/dist/chunk-LAVHRER2.js +17 -0
  102. package/dist/chunk-LCZXAT4Q.js +58 -0
  103. package/dist/chunk-LFKTHNWI.js +83 -0
  104. package/dist/chunk-LGJWR5LX.js +164 -0
  105. package/dist/chunk-LLWK3OR6.js +169 -0
  106. package/dist/chunk-LQSLDDPT.js +67 -0
  107. package/dist/chunk-LR4ACD6E.js +86676 -0
  108. package/dist/chunk-LTBX54CI.js +11 -0
  109. package/dist/chunk-LXP7K6HL.js +817 -0
  110. package/dist/chunk-LXSBG6LK.js +18 -0
  111. package/dist/chunk-LZALOVO3.js +372 -0
  112. package/dist/chunk-M6SOYQJ6.js +39 -0
  113. package/dist/chunk-MAEP2UCK.js +110 -0
  114. package/dist/chunk-MG4GKUJW.js +31 -0
  115. package/dist/chunk-MWOKFNRO.js +446 -0
  116. package/dist/chunk-N2TQXB44.js +1280 -0
  117. package/dist/chunk-N5IUYCUZ.js +31 -0
  118. package/dist/chunk-NBMM2TZK.js +33 -0
  119. package/dist/chunk-NCMUZ6BQ.js +0 -0
  120. package/dist/chunk-NCYTM57J.js +160 -0
  121. package/dist/chunk-NIRWGTM3.js +1104 -0
  122. package/dist/chunk-NS5CHWOH.js +80 -0
  123. package/dist/chunk-NWQRHWE5.js +9461 -0
  124. package/dist/chunk-NXDFDEKP.js +0 -0
  125. package/dist/chunk-NZJGUN67.js +266 -0
  126. package/dist/chunk-NZN7PFPB.js +169 -0
  127. package/dist/chunk-O5HZRJPB.js +55 -0
  128. package/dist/chunk-O5VKW5FL.js +41 -0
  129. package/dist/chunk-O67KME6D.js +110 -0
  130. package/dist/chunk-ODBDAABQ.js +88 -0
  131. package/dist/chunk-OGYWOPHZ.js +96 -0
  132. package/dist/chunk-ORW4HNX5.js +357 -0
  133. package/dist/chunk-P3IZB24Y.js +109 -0
  134. package/dist/chunk-PHOCVOZ5.js +9 -0
  135. package/dist/chunk-PVZBDWLK.js +41 -0
  136. package/dist/chunk-PX675AEP.js +129 -0
  137. package/dist/chunk-PXYDR7WQ.js +48 -0
  138. package/dist/chunk-QDPLZDMX.js +17 -0
  139. package/dist/chunk-QG6PLWNH.js +106 -0
  140. package/dist/chunk-QSGR43JM.js +30 -0
  141. package/dist/chunk-RK5N3XIX.js +56 -0
  142. package/dist/chunk-RLMLYJDI.js +38 -0
  143. package/dist/chunk-RMXYSYK4.js +50 -0
  144. package/dist/chunk-RPIJY6TT.js +637 -0
  145. package/dist/chunk-RSBZREKG.js +144 -0
  146. package/dist/chunk-RXM4B6HR.js +8 -0
  147. package/dist/chunk-S2WEYEQR.js +14 -0
  148. package/dist/chunk-S4SVK5DE.js +39 -0
  149. package/dist/chunk-S6LPCNXQ.js +29 -0
  150. package/dist/chunk-SMQT3ZNO.js +8 -0
  151. package/dist/chunk-T435NFHC.js +490 -0
  152. package/dist/chunk-THHRRYRS.js +16 -0
  153. package/dist/chunk-TKGWSUEI.js +0 -0
  154. package/dist/chunk-TLE6YHGH.js +26 -0
  155. package/dist/chunk-TN4TIT7O.js +116 -0
  156. package/dist/chunk-TUJIAA5O.js +101 -0
  157. package/dist/chunk-U2EI2ZLM.js +32 -0
  158. package/dist/chunk-U2L77ZDR.js +17 -0
  159. package/dist/chunk-U2UCL2VG.js +369 -0
  160. package/dist/chunk-U2ZFCAPX.js +34 -0
  161. package/dist/chunk-U5MJIHLY.js +87 -0
  162. package/dist/chunk-U62GYN4A.js +227 -0
  163. package/dist/chunk-UM7ZR3VU.js +14 -0
  164. package/dist/chunk-UQITHKTH.js +342 -0
  165. package/dist/chunk-UZJ2NQSN.js +257 -0
  166. package/dist/chunk-UZWFZMOX.js +40 -0
  167. package/dist/chunk-V74Y5NIV.js +49 -0
  168. package/dist/chunk-VBMMWVB5.js +49 -0
  169. package/dist/chunk-VKOE5J66.js +31 -0
  170. package/dist/chunk-VOHEQ7B5.js +31 -0
  171. package/dist/chunk-VVTSF42Z.js +52 -0
  172. package/dist/chunk-VW56KWO2.js +9 -0
  173. package/dist/chunk-VWGKHDZ6.js +528 -0
  174. package/dist/chunk-W6Y3PPU5.js +73 -0
  175. package/dist/chunk-WCEMRNW4.js +6 -0
  176. package/dist/chunk-WDZFLCSQ.js +77 -0
  177. package/dist/chunk-WIYFXWRI.js +30 -0
  178. package/dist/chunk-WMA3WTCM.js +117 -0
  179. package/dist/chunk-WWANSDFM.js +175 -0
  180. package/dist/chunk-XBMLI2YI.js +85 -0
  181. package/dist/chunk-XBVIP2BA.js +609 -0
  182. package/dist/chunk-XCMR2HTV.js +102 -0
  183. package/dist/chunk-XFR5JLNF.js +44 -0
  184. package/dist/chunk-XL52SYWY.js +23 -0
  185. package/dist/chunk-XQNVC4Q7.js +212 -0
  186. package/dist/chunk-XSX255FK.js +12 -0
  187. package/dist/chunk-Y2M536WR.js +67 -0
  188. package/dist/chunk-Y456KVIN.js +116 -0
  189. package/dist/chunk-Y7QKP6QU.js +35 -0
  190. package/dist/chunk-YBZWO4ZV.js +57 -0
  191. package/dist/chunk-YGQUBTKR.js +81 -0
  192. package/dist/chunk-YGSM5PVN.js +170 -0
  193. package/dist/chunk-YVCBMOJG.js +50 -0
  194. package/dist/chunk-YWWUOGJA.js +62 -0
  195. package/dist/chunk-YXFG3M2D.js +792 -0
  196. package/dist/chunk-ZAUMHCIL.js +42 -0
  197. package/dist/chunk-ZDJWCSZ4.js +85 -0
  198. package/dist/chunk-ZQZHFMD7.js +19 -0
  199. package/dist/chunk-ZYNBKBY3.js +14 -0
  200. package/dist/collection-add-products-IUDEIUM5.js +284 -0
  201. package/dist/collection-create-AQ3GUG3G.js +133 -0
  202. package/dist/collection-detail-SDFALX6M.js +444 -0
  203. package/dist/collection-edit-AAHL2WFH.js +121 -0
  204. package/dist/collection-list-JGKC5EVM.js +228 -0
  205. package/dist/collection-metadata-YQWA2JTU.js +80 -0
  206. package/dist/customer-create-5VT2TB6S.js +183 -0
  207. package/dist/customer-create-address-ICEFEFD2.js +299 -0
  208. package/dist/customer-detail-CDELSJ77.js +695 -0
  209. package/dist/customer-edit-DZAD53JC.js +192 -0
  210. package/dist/customer-list-EIQP23FQ.js +152 -0
  211. package/dist/customer-metadata-ATAORBRN.js +81 -0
  212. package/dist/customers-add-customer-group-542PUCCT.js +308 -0
  213. package/dist/edit-inventory-item-P2HVULPA.js +152 -0
  214. package/dist/edit-inventory-item-attributes-V2HK3WTQ.js +323 -0
  215. package/dist/edit-reservation-LX2Z6KVD.js +246 -0
  216. package/dist/edit-rules-Q5UNWAUD.js +316 -0
  217. package/dist/home-I3OILW5Z.js +16 -0
  218. package/dist/index.css +6 -0
  219. package/dist/index.d.ts +41 -0
  220. package/dist/index.js +4824 -0
  221. package/dist/inventory-create-FT7GL4RK.js +616 -0
  222. package/dist/inventory-detail-LNZ5QC67.js +771 -0
  223. package/dist/inventory-list-UXY7PU3N.js +432 -0
  224. package/dist/inventory-metadata-OYETRH5X.js +83 -0
  225. package/dist/inventory-stock-3MBERL3K.js +288 -0
  226. package/dist/invite-HJ7BRO6H.js +372 -0
  227. package/dist/location-create-ZVVQT2KP.js +238 -0
  228. package/dist/location-detail-A5SHPUQN.js +823 -0
  229. package/dist/location-edit-QSRHHDQ2.js +253 -0
  230. package/dist/location-fulfillment-providers-4HMT5L7L.js +289 -0
  231. package/dist/location-list-TC5FEN5R.js +346 -0
  232. package/dist/location-sales-channels-STDHWQSC.js +215 -0
  233. package/dist/location-service-zone-create-63LUYCJI.js +173 -0
  234. package/dist/location-service-zone-edit-UNXI5BQV.js +134 -0
  235. package/dist/location-service-zone-manage-areas-UMD6CZDZ.js +154 -0
  236. package/dist/location-service-zone-shipping-option-create-5L73SAGE.js +807 -0
  237. package/dist/location-service-zone-shipping-option-edit-2FEWQD6Y.js +362 -0
  238. package/dist/location-service-zone-shipping-option-pricing-QSB56QZD.js +362 -0
  239. package/dist/login-V4HZQTCQ.js +254 -0
  240. package/dist/manage-locations-NVHONEZE.js +249 -0
  241. package/dist/no-match-JLVLPCRH.js +33 -0
  242. package/dist/order-allocate-items-F7CXZQGX.js +558 -0
  243. package/dist/order-create-claim-GDVWGZJA.js +2203 -0
  244. package/dist/order-create-edit-6YYKYT66.js +936 -0
  245. package/dist/order-create-exchange-NLDIMGBG.js +2190 -0
  246. package/dist/order-create-fulfillment-EIYGSKXP.js +621 -0
  247. package/dist/order-create-refund-BBXEZNWA.js +403 -0
  248. package/dist/order-create-return-6TA5J3AW.js +1292 -0
  249. package/dist/order-create-shipment-T4C6UE2K.js +208 -0
  250. package/dist/order-detail-Y4EG3P5F.js +3846 -0
  251. package/dist/order-edit-billing-address-NNIFUC5C.js +400 -0
  252. package/dist/order-edit-email-VXOX62P6.js +171 -0
  253. package/dist/order-edit-shipping-address-WDKCQRRG.js +397 -0
  254. package/dist/order-list-XDOAXZXN.js +231 -0
  255. package/dist/order-metadata-S6N3GDOA.js +82 -0
  256. package/dist/order-receive-return-5VWUPWZJ.js +549 -0
  257. package/dist/order-request-transfer-VFSY5IFF.js +571 -0
  258. package/dist/price-list-configuration-GH67LL2N.js +356 -0
  259. package/dist/price-list-create-INX5HG7G.js +973 -0
  260. package/dist/price-list-detail-5LGPE67O.js +540 -0
  261. package/dist/price-list-edit-HRWPEIZI.js +227 -0
  262. package/dist/price-list-list-IXZVTXU5.js +228 -0
  263. package/dist/price-list-prices-add-QHE3TUTV.js +614 -0
  264. package/dist/price-list-prices-edit-TMVJ7S7J.js +326 -0
  265. package/dist/product-attributes-P7WFH4I2.js +358 -0
  266. package/dist/product-create-YC6MCJ2M.js +2305 -0
  267. package/dist/product-create-option-BNF2KKJM.js +144 -0
  268. package/dist/product-create-variant-SIJX7AE3.js +837 -0
  269. package/dist/product-detail-2GJ3PGHW.js +1638 -0
  270. package/dist/product-edit-YOGTWZ4I.js +397 -0
  271. package/dist/product-edit-option-4MUSMFS7.js +152 -0
  272. package/dist/product-export-5L4HNM3W.js +127 -0
  273. package/dist/product-import-Y54VG4AC.js +261 -0
  274. package/dist/product-list-EV2TS3Y4.js +313 -0
  275. package/dist/product-media-ZSMGHCNP.js +879 -0
  276. package/dist/product-metadata-572YVJH3.js +80 -0
  277. package/dist/product-organization-LVKRBJOQ.js +312 -0
  278. package/dist/product-prices-K5YM2TL6.js +266 -0
  279. package/dist/product-sales-channels-J3OH4NWX.js +157 -0
  280. package/dist/product-shipping-profile-NOOFEUBZ.js +146 -0
  281. package/dist/product-stock-J4LTIX64.js +540 -0
  282. package/dist/product-tag-create-5JJPPELP.js +122 -0
  283. package/dist/product-tag-detail-CGLCH3BJ.js +281 -0
  284. package/dist/product-tag-edit-OR7KSC7I.js +134 -0
  285. package/dist/product-tag-list-DY7GJUJQ.js +259 -0
  286. package/dist/product-tag-metadata-BFGPRMME.js +80 -0
  287. package/dist/product-type-create-FPVSGIKL.js +101 -0
  288. package/dist/product-type-detail-JYW2DAM4.js +242 -0
  289. package/dist/product-type-edit-FBT4Z4ZJ.js +113 -0
  290. package/dist/product-type-list-FK237DSQ.js +175 -0
  291. package/dist/product-type-metadata-SFJR5OQN.js +80 -0
  292. package/dist/product-variant-detail-6KPB3HL7.js +485 -0
  293. package/dist/product-variant-edit-QFHGNDW7.js +538 -0
  294. package/dist/product-variant-manage-inventory-items-ZEX2IW53.js +340 -0
  295. package/dist/product-variant-metadata-F45CSWU6.js +86 -0
  296. package/dist/profile-detail-LLXUNQOT.js +89 -0
  297. package/dist/profile-edit-UDYMDQLT.js +176 -0
  298. package/dist/promotion-add-campaign-U6X2FNWZ.js +43 -0
  299. package/dist/promotion-create-QB7E277L.js +1258 -0
  300. package/dist/promotion-detail-7D6D6PQ7.js +486 -0
  301. package/dist/promotion-edit-details-HYQJAZDF.js +512 -0
  302. package/dist/promotion-list-HTJ5GIWG.js +206 -0
  303. package/dist/refund-reason-create-LZCL6QJI.js +192 -0
  304. package/dist/refund-reason-edit-QNGFKZMN.js +192 -0
  305. package/dist/refund-reason-list-ZEKWYQ45.js +233 -0
  306. package/dist/region-add-countries-CWJ62VPK.js +226 -0
  307. package/dist/region-create-Z3JQFIKN.js +507 -0
  308. package/dist/region-detail-46R3HACJ.js +508 -0
  309. package/dist/region-edit-W5IVVP7Z.js +380 -0
  310. package/dist/region-list-DCU6NQFA.js +205 -0
  311. package/dist/region-metadata-VG5DLCOK.js +83 -0
  312. package/dist/reservation-create-VG5FSV3F.js +309 -0
  313. package/dist/reservation-detail-36BA3V2F.js +221 -0
  314. package/dist/reservation-list-R5UBPNI4.js +298 -0
  315. package/dist/reservation-metadata-KR4HOHTH.js +83 -0
  316. package/dist/reset-password-VZPICVMM.js +458 -0
  317. package/dist/return-reason-create-KTKI6NJE.js +165 -0
  318. package/dist/return-reason-edit-5KU7WKJF.js +168 -0
  319. package/dist/return-reason-list-HBSKNIMW.js +240 -0
  320. package/dist/sales-channel-add-products-6TUDLE4D.js +274 -0
  321. package/dist/sales-channel-create-2BTWSYIK.js +154 -0
  322. package/dist/sales-channel-detail-IQIQDN3L.js +437 -0
  323. package/dist/sales-channel-edit-YBNPALFT.js +163 -0
  324. package/dist/sales-channel-list-5KNN734B.js +193 -0
  325. package/dist/sales-channel-metadata-SVW6FYSV.js +88 -0
  326. package/dist/seller-details-HBVN4GGD.js +77 -0
  327. package/dist/seller-edit-OXDARXYJ.js +387 -0
  328. package/dist/seller-list-HG2VXA6V.js +192 -0
  329. package/dist/settings-D43GVDOO.js +19 -0
  330. package/dist/shipping-option-type-create-7KYU5NNF.js +195 -0
  331. package/dist/shipping-option-type-detail-4CNTT3MO.js +169 -0
  332. package/dist/shipping-option-type-edit-AN6IPVI6.js +191 -0
  333. package/dist/shipping-option-type-list-36ZS2QZO.js +266 -0
  334. package/dist/shipping-profile-create-3OWHNAOB.js +123 -0
  335. package/dist/shipping-profile-detail-WW7IVUVV.js +157 -0
  336. package/dist/shipping-profile-metadata-AD3DSZLR.js +84 -0
  337. package/dist/shipping-profiles-list-WOGGP7IT.js +241 -0
  338. package/dist/store-add-currencies-PIGEOZ4G.js +304 -0
  339. package/dist/store-detail-MFHPXBIN.js +525 -0
  340. package/dist/store-edit-WBF6EL5N.js +246 -0
  341. package/dist/store-metadata-LSK7UVSC.js +85 -0
  342. package/dist/tax-region-create-XTX4YWRA.js +300 -0
  343. package/dist/tax-region-detail-XUYJHBHI.js +320 -0
  344. package/dist/tax-region-edit-AC64YA64.js +162 -0
  345. package/dist/tax-region-list-XRAYDYK3.js +91 -0
  346. package/dist/tax-region-metadata-YDQX3Y4X.js +83 -0
  347. package/dist/tax-region-province-create-GDL65SQF.js +315 -0
  348. package/dist/tax-region-province-detail-QMPIKT7K.js +215 -0
  349. package/dist/tax-region-tax-override-create-X2QWOHSU.js +679 -0
  350. package/dist/tax-region-tax-override-edit-VZJ6EPSU.js +788 -0
  351. package/dist/tax-region-tax-rate-create-VC2WDVJJ.js +193 -0
  352. package/dist/tax-region-tax-rate-edit-SDW36H6I.js +192 -0
  353. package/dist/user-detail-IEIX24PZ.js +163 -0
  354. package/dist/user-edit-CJ7TNY3H.js +115 -0
  355. package/dist/user-invite-OTBYWV4L.js +389 -0
  356. package/dist/user-list-BJXFPTJ7.js +341 -0
  357. package/dist/user-metadata-ZLC6T6XH.js +83 -0
  358. package/package.json +87 -0
@@ -0,0 +1,2190 @@
1
+ import {
2
+ useAddExchangeInboundItems,
3
+ useAddExchangeInboundShipping,
4
+ useAddExchangeOutboundItems,
5
+ useAddExchangeOutboundShipping,
6
+ useCancelExchangeRequest,
7
+ useCreateExchange,
8
+ useDeleteExchangeInboundShipping,
9
+ useDeleteExchangeOutboundShipping,
10
+ useExchange,
11
+ useExchangeConfirmRequest,
12
+ useRemoveExchangeInboundItem,
13
+ useRemoveExchangeOutboundItem,
14
+ useUpdateExchangeInboundItem,
15
+ useUpdateExchangeInboundShipping,
16
+ useUpdateExchangeOutboundItems,
17
+ useUpdateExchangeOutboundShipping
18
+ } from "./chunk-CBRSGM3X.js";
19
+ import {
20
+ ItemPlaceholder
21
+ } from "./chunk-U2L77ZDR.js";
22
+ import {
23
+ getFormattedShippingOptionLocationName
24
+ } from "./chunk-HC25LNX7.js";
25
+ import {
26
+ OutboundShippingPlaceholder,
27
+ ReturnShippingPlaceholder
28
+ } from "./chunk-S4SVK5DE.js";
29
+ import {
30
+ useReturnReasons
31
+ } from "./chunk-ZDJWCSZ4.js";
32
+ import {
33
+ getReturnableQuantity
34
+ } from "./chunk-UM7ZR3VU.js";
35
+ import {
36
+ DEFAULT_FIELDS
37
+ } from "./chunk-Y2M536WR.js";
38
+ import {
39
+ useReturn,
40
+ useUpdateReturn
41
+ } from "./chunk-DV73MHTN.js";
42
+ import {
43
+ MoneyAmountCell
44
+ } from "./chunk-2Y3WMGN6.js";
45
+ import {
46
+ getStylizedAmount
47
+ } from "./chunk-PXYDR7WQ.js";
48
+ import {
49
+ ProductCell,
50
+ ProductHeader
51
+ } from "./chunk-FWPGOIFA.js";
52
+ import "./chunk-FQERBIVS.js";
53
+ import "./chunk-PHOCVOZ5.js";
54
+ import {
55
+ _DataTable,
56
+ useDataTable
57
+ } from "./chunk-FLCYR7E5.js";
58
+ import "./chunk-YBZWO4ZV.js";
59
+ import "./chunk-KAZ5BYTQ.js";
60
+ import "./chunk-3EF54XFY.js";
61
+ import {
62
+ Thumbnail
63
+ } from "./chunk-WIYFXWRI.js";
64
+ import {
65
+ Combobox
66
+ } from "./chunk-AW77UWCZ.js";
67
+ import {
68
+ currencies
69
+ } from "./chunk-IQPN4PZJ.js";
70
+ import {
71
+ KeyboundForm
72
+ } from "./chunk-U2ZFCAPX.js";
73
+ import "./chunk-KBYZLKI4.js";
74
+ import "./chunk-YWWUOGJA.js";
75
+ import {
76
+ RouteFocusModal,
77
+ StackedFocusModal,
78
+ useRouteModal,
79
+ useStackedModal
80
+ } from "./chunk-MWOKFNRO.js";
81
+ import {
82
+ Form
83
+ } from "./chunk-3QSRE5LS.js";
84
+ import "./chunk-INNFZYX2.js";
85
+ import {
86
+ ActionMenu
87
+ } from "./chunk-BDGZ4EQO.js";
88
+ import "./chunk-LAVHRER2.js";
89
+ import "./chunk-Y7QKP6QU.js";
90
+ import {
91
+ useQueryParams
92
+ } from "./chunk-THHRRYRS.js";
93
+ import "./chunk-UZWFZMOX.js";
94
+ import "./chunk-XQNVC4Q7.js";
95
+ import {
96
+ useVariants
97
+ } from "./chunk-ORW4HNX5.js";
98
+ import "./chunk-ODBDAABQ.js";
99
+ import "./chunk-YGQUBTKR.js";
100
+ import "./chunk-362QMJZM.js";
101
+ import "./chunk-FODCCP6C.js";
102
+ import "./chunk-AWZFIP25.js";
103
+ import "./chunk-2QKPRGNK.js";
104
+ import "./chunk-XBMLI2YI.js";
105
+ import "./chunk-XL52SYWY.js";
106
+ import "./chunk-NS5CHWOH.js";
107
+ import "./chunk-WDZFLCSQ.js";
108
+ import "./chunk-VVTSF42Z.js";
109
+ import "./chunk-D3KDXELJ.js";
110
+ import "./chunk-2MKZ4HD4.js";
111
+ import "./chunk-OGYWOPHZ.js";
112
+ import "./chunk-U62GYN4A.js";
113
+ import {
114
+ useShippingOptions
115
+ } from "./chunk-KTKL7M34.js";
116
+ import {
117
+ useOrder,
118
+ useOrderPreview,
119
+ useOrderShippingOptions
120
+ } from "./chunk-JJVGCTKT.js";
121
+ import "./chunk-I43SCBL3.js";
122
+ import {
123
+ useStockLocations
124
+ } from "./chunk-LLWK3OR6.js";
125
+ import "./chunk-HYUGYB23.js";
126
+ import "./chunk-XCMR2HTV.js";
127
+ import "./chunk-CI5Z6FGV.js";
128
+ import "./chunk-LCZXAT4Q.js";
129
+ import "./chunk-S6LPCNXQ.js";
130
+ import "./chunk-T435NFHC.js";
131
+ import "./chunk-2KCF3ZIB.js";
132
+ import {
133
+ sdk
134
+ } from "./chunk-ZYNBKBY3.js";
135
+ import "./chunk-NBMM2TZK.js";
136
+
137
+ // src/pages/orders/order-create-exchange/exchange-create.tsx
138
+ import { toast as toast4 } from "@medusajs/ui";
139
+ import { useEffect as useEffect4, useState as useState6 } from "react";
140
+ import { useTranslation as useTranslation12 } from "react-i18next";
141
+ import { useNavigate, useParams } from "react-router-dom";
142
+
143
+ // src/pages/orders/order-create-exchange/components/exchange-create-form/exchange-create-form.tsx
144
+ import { zodResolver } from "@hookform/resolvers/zod";
145
+ import { PencilSquare } from "@medusajs/icons";
146
+ import {
147
+ Button as Button3,
148
+ CurrencyInput,
149
+ Heading as Heading3,
150
+ IconButton as IconButton2,
151
+ Switch,
152
+ toast as toast3,
153
+ usePrompt
154
+ } from "@medusajs/ui";
155
+ import { useEffect as useEffect3, useMemo as useMemo6, useState as useState5 } from "react";
156
+ import { useForm } from "react-hook-form";
157
+ import { useTranslation as useTranslation11 } from "react-i18next";
158
+
159
+ // src/pages/orders/order-create-exchange/components/exchange-create-form/schema.ts
160
+ import { z } from "zod";
161
+ var ExchangeCreateSchema = z.object({
162
+ inbound_items: z.array(
163
+ z.object({
164
+ item_id: z.string(),
165
+ quantity: z.number(),
166
+ reason_id: z.string().nullish(),
167
+ note: z.string().nullish()
168
+ })
169
+ ),
170
+ outbound_items: z.array(
171
+ z.object({
172
+ item_id: z.string(),
173
+ quantity: z.number()
174
+ })
175
+ ),
176
+ location_id: z.string().optional(),
177
+ inbound_option_id: z.string().nullish(),
178
+ outbound_option_id: z.string().nullish(),
179
+ send_notification: z.boolean().optional()
180
+ });
181
+
182
+ // src/pages/orders/order-create-exchange/components/exchange-create-form/exchange-inbound-section.tsx
183
+ import { Alert, Button, Heading, Text as Text2, toast } from "@medusajs/ui";
184
+ import { useEffect, useMemo as useMemo3, useState as useState2 } from "react";
185
+ import { useFieldArray } from "react-hook-form";
186
+ import { useTranslation as useTranslation5 } from "react-i18next";
187
+
188
+ // src/pages/orders/order-create-exchange/components/add-exchange-inbound-items-table/add-exchange-inbound-items-table.tsx
189
+ import { useMemo as useMemo2, useState } from "react";
190
+ import { useTranslation as useTranslation3 } from "react-i18next";
191
+
192
+ // src/pages/orders/order-create-exchange/components/add-exchange-inbound-items-table/use-exchange-item-table-columns.tsx
193
+ import { Checkbox } from "@medusajs/ui";
194
+ import { createColumnHelper } from "@tanstack/react-table";
195
+ import { useMemo } from "react";
196
+ import { useTranslation } from "react-i18next";
197
+ import { jsx } from "react/jsx-runtime";
198
+ var columnHelper = createColumnHelper();
199
+ var useExchangeItemTableColumns = (currencyCode) => {
200
+ const { t } = useTranslation();
201
+ return useMemo(
202
+ () => [
203
+ columnHelper.display({
204
+ id: "select",
205
+ header: ({ table }) => {
206
+ return /* @__PURE__ */ jsx(
207
+ Checkbox,
208
+ {
209
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
210
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
211
+ }
212
+ );
213
+ },
214
+ cell: ({ row }) => {
215
+ const isSelectable = row.getCanSelect();
216
+ return /* @__PURE__ */ jsx(
217
+ Checkbox,
218
+ {
219
+ disabled: !isSelectable,
220
+ checked: row.getIsSelected(),
221
+ onCheckedChange: (value) => row.toggleSelected(!!value),
222
+ onClick: (e) => {
223
+ e.stopPropagation();
224
+ }
225
+ }
226
+ );
227
+ }
228
+ }),
229
+ columnHelper.display({
230
+ id: "product",
231
+ header: () => /* @__PURE__ */ jsx(ProductHeader, {}),
232
+ cell: ({ row }) => /* @__PURE__ */ jsx(
233
+ ProductCell,
234
+ {
235
+ product: {
236
+ thumbnail: row.original.thumbnail,
237
+ title: row.original.product_title
238
+ }
239
+ }
240
+ )
241
+ }),
242
+ columnHelper.accessor("variant.sku", {
243
+ header: t("fields.sku"),
244
+ cell: ({ getValue }) => {
245
+ return getValue() || "-";
246
+ }
247
+ }),
248
+ columnHelper.accessor("variant.title", {
249
+ header: t("fields.variant")
250
+ }),
251
+ columnHelper.accessor("quantity", {
252
+ header: () => /* @__PURE__ */ jsx("div", { className: "flex size-full items-center overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t("fields.quantity") }) }),
253
+ cell: ({ row }) => {
254
+ return getReturnableQuantity(row.original);
255
+ }
256
+ }),
257
+ columnHelper.accessor("refundable_total", {
258
+ 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") }) }),
259
+ cell: ({ getValue }) => {
260
+ const amount = getValue() || 0;
261
+ const stylized = getStylizedAmount(amount, currencyCode);
262
+ return /* @__PURE__ */ jsx("div", { className: "flex size-full items-center justify-end overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: stylized }) });
263
+ }
264
+ })
265
+ ],
266
+ [t, currencyCode]
267
+ );
268
+ };
269
+
270
+ // src/pages/orders/order-create-exchange/components/add-exchange-inbound-items-table/use-exchange-item-table-filters.tsx
271
+ import { useTranslation as useTranslation2 } from "react-i18next";
272
+ var useExchangeItemTableFilters = () => {
273
+ const { t } = useTranslation2();
274
+ const filters = [
275
+ {
276
+ key: "created_at",
277
+ label: t("fields.createdAt"),
278
+ type: "date"
279
+ },
280
+ {
281
+ key: "updated_at",
282
+ label: t("fields.updatedAt"),
283
+ type: "date"
284
+ }
285
+ ];
286
+ return filters;
287
+ };
288
+
289
+ // src/pages/orders/order-create-exchange/components/add-exchange-inbound-items-table/use-exchange-item-table-query.tsx
290
+ var useExchangeItemTableQuery = ({
291
+ pageSize = 50,
292
+ prefix
293
+ }) => {
294
+ const raw = useQueryParams(
295
+ ["q", "offset", "order", "created_at", "updated_at"],
296
+ prefix
297
+ );
298
+ const { offset, created_at, updated_at, ...rest } = raw;
299
+ const searchParams = {
300
+ ...rest,
301
+ limit: pageSize,
302
+ offset: offset ? Number(offset) : 0,
303
+ created_at: created_at ? JSON.parse(created_at) : void 0,
304
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0
305
+ };
306
+ return { searchParams, raw };
307
+ };
308
+
309
+ // src/pages/orders/order-create-exchange/components/add-exchange-inbound-items-table/add-exchange-inbound-items-table.tsx
310
+ import { jsx as jsx2 } from "react/jsx-runtime";
311
+ var PAGE_SIZE = 50;
312
+ var PREFIX = "rit";
313
+ var AddExchangeInboundItemsTable = ({
314
+ onSelectionChange,
315
+ selectedItems,
316
+ items,
317
+ currencyCode
318
+ }) => {
319
+ const { t } = useTranslation3();
320
+ const [rowSelection, setRowSelection] = useState(
321
+ selectedItems.reduce((acc, id) => {
322
+ acc[id] = true;
323
+ return acc;
324
+ }, {})
325
+ );
326
+ const updater = (fn) => {
327
+ const newState = typeof fn === "function" ? fn(rowSelection) : fn;
328
+ setRowSelection(newState);
329
+ onSelectionChange(Object.keys(newState));
330
+ };
331
+ const { searchParams, raw } = useExchangeItemTableQuery({
332
+ pageSize: PAGE_SIZE,
333
+ prefix: PREFIX
334
+ });
335
+ const queriedItems = useMemo2(() => {
336
+ const { order, offset, limit, q, created_at, updated_at } = searchParams;
337
+ let results = items;
338
+ if (q) {
339
+ results = results.filter((i) => {
340
+ return i.product_title?.toLowerCase().includes(q.toLowerCase()) || i.variant_title?.toLowerCase().includes(q.toLowerCase()) || i.variant_sku?.toLowerCase().includes(q.toLowerCase());
341
+ });
342
+ }
343
+ if (order) {
344
+ const direction = order[0] === "-" ? "desc" : "asc";
345
+ const field = order.replace("-", "");
346
+ results = sortItems(results, field, direction);
347
+ }
348
+ if (created_at) {
349
+ results = filterByDate(results, created_at, "created_at");
350
+ }
351
+ if (updated_at) {
352
+ results = filterByDate(results, updated_at, "updated_at");
353
+ }
354
+ return results.slice(offset, offset + limit);
355
+ }, [items, currencyCode, searchParams]);
356
+ const columns = useExchangeItemTableColumns(currencyCode);
357
+ const filters = useExchangeItemTableFilters();
358
+ const { table } = useDataTable({
359
+ data: queriedItems,
360
+ columns,
361
+ count: queriedItems.length,
362
+ enablePagination: true,
363
+ getRowId: (row) => row.id,
364
+ pageSize: PAGE_SIZE,
365
+ enableRowSelection: (row) => {
366
+ return getReturnableQuantity(row.original) > 0;
367
+ },
368
+ rowSelection: {
369
+ state: rowSelection,
370
+ updater
371
+ }
372
+ });
373
+ return /* @__PURE__ */ jsx2("div", { className: "flex size-full flex-col overflow-hidden", children: /* @__PURE__ */ jsx2(
374
+ _DataTable,
375
+ {
376
+ table,
377
+ columns,
378
+ pageSize: PAGE_SIZE,
379
+ count: queriedItems.length,
380
+ filters,
381
+ pagination: true,
382
+ layout: "fill",
383
+ search: true,
384
+ orderBy: [
385
+ { key: "product_title", label: t("fields.product") },
386
+ { key: "variant_title", label: t("fields.variant") },
387
+ { key: "sku", label: t("fields.sku") }
388
+ ],
389
+ prefix: PREFIX,
390
+ queryObject: raw
391
+ }
392
+ ) });
393
+ };
394
+ var sortItems = (items, field, direction) => {
395
+ return items.sort((a, b) => {
396
+ let aValue;
397
+ let bValue;
398
+ if (field === "product_title") {
399
+ aValue = a.product_title;
400
+ bValue = b.product_title;
401
+ } else if (field === "variant_title") {
402
+ aValue = a.variant_title;
403
+ bValue = b.variant_title;
404
+ } else if (field === "sku") {
405
+ aValue = a.variant_sku;
406
+ bValue = b.variant_sku;
407
+ }
408
+ if (aValue < bValue) {
409
+ return direction === "asc" ? -1 : 1;
410
+ }
411
+ if (aValue > bValue) {
412
+ return direction === "asc" ? 1 : -1;
413
+ }
414
+ return 0;
415
+ });
416
+ };
417
+ var filterByDate = (items, date, field) => {
418
+ const { gt, gte, lt, lte } = date;
419
+ return items.filter((i) => {
420
+ const itemDate = new Date(i[field]);
421
+ let isValid = true;
422
+ if (gt) {
423
+ isValid = isValid && itemDate > new Date(gt);
424
+ }
425
+ if (gte) {
426
+ isValid = isValid && itemDate >= new Date(gte);
427
+ }
428
+ if (lt) {
429
+ isValid = isValid && itemDate < new Date(lt);
430
+ }
431
+ if (lte) {
432
+ isValid = isValid && itemDate <= new Date(lte);
433
+ }
434
+ return isValid;
435
+ });
436
+ };
437
+
438
+ // src/pages/orders/order-create-exchange/components/exchange-create-form/exchange-inbound-item.tsx
439
+ import { ChatBubble, DocumentText, XCircle, XMark } from "@medusajs/icons";
440
+ import { IconButton, Input, Text } from "@medusajs/ui";
441
+ import { useTranslation as useTranslation4 } from "react-i18next";
442
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
443
+ function ExchangeInboundItem({
444
+ item,
445
+ previewItem,
446
+ currencyCode,
447
+ form,
448
+ onRemove,
449
+ onUpdate,
450
+ index
451
+ }) {
452
+ const { t } = useTranslation4();
453
+ const { return_reasons = [] } = useReturnReasons({ fields: "+label" });
454
+ const formItem = form.watch(`inbound_items.${index}`);
455
+ const showReturnReason = typeof formItem.reason_id === "string";
456
+ const showNote = typeof formItem.note === "string";
457
+ return /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl ", children: [
458
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-x-2 gap-y-2 p-3 text-sm md:flex-row", children: [
459
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center gap-x-3", children: [
460
+ /* @__PURE__ */ jsx3(Thumbnail, { src: item.thumbnail }),
461
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
462
+ /* @__PURE__ */ jsxs("div", { children: [
463
+ /* @__PURE__ */ jsxs(Text, { className: "txt-small", as: "span", weight: "plus", children: [
464
+ item.title,
465
+ " "
466
+ ] }),
467
+ item.variant_sku && /* @__PURE__ */ jsxs("span", { children: [
468
+ "(",
469
+ item.variant_sku,
470
+ ")"
471
+ ] })
472
+ ] }),
473
+ /* @__PURE__ */ jsx3(Text, { as: "div", className: "text-ui-fg-subtle txt-small", children: item.product_title })
474
+ ] })
475
+ ] }),
476
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 justify-between", children: [
477
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-grow items-center gap-2", children: [
478
+ /* @__PURE__ */ jsx3(
479
+ Form.Field,
480
+ {
481
+ control: form.control,
482
+ name: `inbound_items.${index}.quantity`,
483
+ render: ({ field }) => {
484
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
485
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
486
+ Input,
487
+ {
488
+ ...field,
489
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
490
+ min: 1,
491
+ max: item.quantity,
492
+ type: "number",
493
+ onBlur: (e) => {
494
+ const val = e.target.value;
495
+ const payload = val === "" ? null : Number(val);
496
+ field.onChange(payload);
497
+ if (payload) {
498
+ onUpdate({ quantity: payload });
499
+ }
500
+ }
501
+ }
502
+ ) }),
503
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
504
+ ] });
505
+ }
506
+ }
507
+ ),
508
+ /* @__PURE__ */ jsx3(Text, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
509
+ ] }),
510
+ /* @__PURE__ */ jsx3("div", { className: "text-ui-fg-subtle txt-small mr-2 flex flex-shrink-0", children: /* @__PURE__ */ jsx3(
511
+ MoneyAmountCell,
512
+ {
513
+ currencyCode,
514
+ amount: previewItem.return_requested_total
515
+ }
516
+ ) }),
517
+ /* @__PURE__ */ jsx3(
518
+ ActionMenu,
519
+ {
520
+ groups: [
521
+ {
522
+ actions: [
523
+ !showReturnReason && {
524
+ label: t("actions.addReason"),
525
+ onClick: () => form.setValue(`inbound_items.${index}.reason_id`, ""),
526
+ icon: /* @__PURE__ */ jsx3(ChatBubble, {})
527
+ },
528
+ !showNote && {
529
+ label: t("actions.addNote"),
530
+ onClick: () => form.setValue(`inbound_items.${index}.note`, ""),
531
+ icon: /* @__PURE__ */ jsx3(DocumentText, {})
532
+ },
533
+ {
534
+ label: t("actions.remove"),
535
+ onClick: onRemove,
536
+ icon: /* @__PURE__ */ jsx3(XCircle, {})
537
+ }
538
+ ].filter(Boolean)
539
+ }
540
+ ]
541
+ }
542
+ )
543
+ ] })
544
+ ] }),
545
+ /* @__PURE__ */ jsxs(Fragment, { children: [
546
+ showReturnReason && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
547
+ /* @__PURE__ */ jsxs("div", { children: [
548
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.reason") }),
549
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.reasonHint") })
550
+ ] }),
551
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
552
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
553
+ Form.Field,
554
+ {
555
+ control: form.control,
556
+ name: `inbound_items.${index}.reason_id`,
557
+ render: ({ field: { ref, value, onChange, ...field } }) => {
558
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
559
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
560
+ Combobox,
561
+ {
562
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
563
+ value,
564
+ onChange: (v) => {
565
+ onUpdate({ reason_id: v });
566
+ onChange(v);
567
+ },
568
+ ...field,
569
+ options: return_reasons.map((reason) => ({
570
+ label: reason.label,
571
+ value: reason.id
572
+ }))
573
+ }
574
+ ) }),
575
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
576
+ ] });
577
+ }
578
+ }
579
+ ) }),
580
+ /* @__PURE__ */ jsx3(
581
+ IconButton,
582
+ {
583
+ type: "button",
584
+ className: "flex-shrink",
585
+ variant: "transparent",
586
+ onClick: () => {
587
+ form.setValue(`inbound_items.${index}.reason_id`, null);
588
+ onUpdate({ reason_id: null });
589
+ },
590
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
591
+ }
592
+ )
593
+ ] })
594
+ ] }),
595
+ showNote && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
596
+ /* @__PURE__ */ jsxs("div", { children: [
597
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.note") }),
598
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.noteHint") })
599
+ ] }),
600
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
601
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
602
+ Form.Field,
603
+ {
604
+ control: form.control,
605
+ name: `inbound_items.${index}.note`,
606
+ render: ({ field: { ref, ...field } }) => {
607
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
608
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
609
+ Input,
610
+ {
611
+ ...field,
612
+ onBlur: () => {
613
+ field.onChange(field.value);
614
+ onUpdate({ internal_note: field.value });
615
+ },
616
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover"
617
+ }
618
+ ) }),
619
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
620
+ ] });
621
+ }
622
+ }
623
+ ) }),
624
+ /* @__PURE__ */ jsx3(
625
+ IconButton,
626
+ {
627
+ type: "button",
628
+ className: "flex-shrink",
629
+ variant: "transparent",
630
+ onClick: () => {
631
+ form.setValue(`inbound_items.${index}.note`, null);
632
+ onUpdate({ internal_note: null });
633
+ },
634
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
635
+ }
636
+ )
637
+ ] })
638
+ ] })
639
+ ] })
640
+ ] });
641
+ }
642
+
643
+ // src/pages/orders/order-create-exchange/components/exchange-create-form/exchange-inbound-section.tsx
644
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
645
+ var itemsToAdd = [];
646
+ var itemsToRemove = [];
647
+ var ExchangeInboundSection = ({
648
+ order,
649
+ preview,
650
+ exchange,
651
+ form,
652
+ orderReturn
653
+ }) => {
654
+ const { t } = useTranslation5();
655
+ const { setIsOpen } = useStackedModal();
656
+ const [inventoryMap, setInventoryMap] = useState2({});
657
+ const { mutateAsync: updateReturn } = useUpdateReturn(
658
+ preview?.order_change?.return_id,
659
+ order.id
660
+ );
661
+ const { mutateAsync: addInboundShipping } = useAddExchangeInboundShipping(
662
+ exchange.id,
663
+ order.id
664
+ );
665
+ const { mutateAsync: deleteInboundShipping } = useDeleteExchangeInboundShipping(exchange.id, order.id);
666
+ const { mutateAsync: addInboundItem } = useAddExchangeInboundItems(
667
+ exchange.id,
668
+ order.id
669
+ );
670
+ const { mutateAsync: updateInboundItem } = useUpdateExchangeInboundItem(
671
+ exchange.id,
672
+ order.id
673
+ );
674
+ const { mutateAsync: removeInboundItem } = useRemoveExchangeInboundItem(
675
+ exchange.id,
676
+ order.id
677
+ );
678
+ const previewInboundItems = useMemo3(
679
+ () => preview?.items?.filter(
680
+ (i) => !!i.actions?.find((a) => a.exchange_id === exchange.id)
681
+ ),
682
+ [preview.items]
683
+ );
684
+ const inboundPreviewItems = previewInboundItems.filter(
685
+ (item) => !!item.actions?.find((a) => a.action === "RETURN_ITEM")
686
+ );
687
+ const itemsMap = useMemo3(
688
+ () => new Map(order?.items?.map((i) => [i.id, i])),
689
+ [order.items]
690
+ );
691
+ const locationId = form.watch("location_id");
692
+ const { stock_locations = [] } = useStockLocations({ limit: 999 });
693
+ const { shipping_options = [] } = useShippingOptions(
694
+ {
695
+ limit: 999,
696
+ fields: "*prices,+service_zone.fulfillment_set.location.id",
697
+ stock_location_id: locationId
698
+ },
699
+ {
700
+ enabled: !!locationId
701
+ }
702
+ );
703
+ const inboundShippingOptions = shipping_options.filter(
704
+ (shippingOption) => !!shippingOption.rules.find(
705
+ (r) => r.attribute === "is_return" && r.value === "true"
706
+ )
707
+ );
708
+ const {
709
+ fields: inboundItems,
710
+ append,
711
+ remove,
712
+ update
713
+ } = useFieldArray({
714
+ name: "inbound_items",
715
+ control: form.control
716
+ });
717
+ const inboundItemsMap = useMemo3(
718
+ () => new Map(previewInboundItems.map((i) => [i.id, i])),
719
+ [previewInboundItems, inboundItems]
720
+ );
721
+ useEffect(() => {
722
+ const existingItemsMap = {};
723
+ inboundPreviewItems.forEach((i) => {
724
+ const ind = inboundItems.findIndex((field) => field.item_id === i.id);
725
+ existingItemsMap[i.id] = true;
726
+ if (ind > -1) {
727
+ if (inboundItems[ind].quantity !== i.detail.return_requested_quantity) {
728
+ const returnItemAction = i.actions?.find(
729
+ (a) => a.action === "RETURN_ITEM"
730
+ );
731
+ update(ind, {
732
+ ...inboundItems[ind],
733
+ quantity: i.detail.return_requested_quantity,
734
+ note: returnItemAction?.internal_note,
735
+ reason_id: returnItemAction?.details?.reason_id
736
+ });
737
+ }
738
+ } else {
739
+ append(
740
+ { item_id: i.id, quantity: i.detail.return_requested_quantity },
741
+ { shouldFocus: false }
742
+ );
743
+ }
744
+ });
745
+ inboundItems.forEach((i, ind) => {
746
+ if (!(i.item_id in existingItemsMap)) {
747
+ remove(ind);
748
+ }
749
+ });
750
+ }, [previewInboundItems]);
751
+ useEffect(() => {
752
+ const inboundShippingMethod = preview.shipping_methods.find(
753
+ (s) => s.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
754
+ );
755
+ if (inboundShippingMethod) {
756
+ form.setValue(
757
+ "inbound_option_id",
758
+ inboundShippingMethod.shipping_option_id
759
+ );
760
+ } else {
761
+ form.setValue("inbound_option_id", "");
762
+ }
763
+ }, [preview.shipping_methods]);
764
+ useEffect(() => {
765
+ form.setValue("location_id", orderReturn?.location_id);
766
+ }, [orderReturn]);
767
+ const showInboundItemsPlaceholder = !inboundItems.length;
768
+ const onItemsSelected = async () => {
769
+ itemsToAdd.length && await addInboundItem(
770
+ {
771
+ items: itemsToAdd.map((id) => ({
772
+ id,
773
+ quantity: 1
774
+ }))
775
+ },
776
+ {
777
+ onError: (error) => {
778
+ toast.error(error.message);
779
+ }
780
+ }
781
+ );
782
+ for (const itemToRemove of itemsToRemove) {
783
+ const actionId = previewInboundItems.find((i) => i.id === itemToRemove)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
784
+ if (actionId) {
785
+ await removeInboundItem(actionId, {
786
+ onError: (error) => {
787
+ toast.error(error.message);
788
+ }
789
+ });
790
+ }
791
+ }
792
+ setIsOpen("inbound-items", false);
793
+ };
794
+ const onLocationChange = async (selectedLocationId) => {
795
+ await updateReturn({ location_id: selectedLocationId });
796
+ };
797
+ const onShippingOptionChange = async (selectedOptionId) => {
798
+ const inboundShippingMethods = preview.shipping_methods.filter(
799
+ (s) => s.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
800
+ );
801
+ const promises = inboundShippingMethods.filter(Boolean).map((inboundShippingMethod) => {
802
+ const action = inboundShippingMethod.actions?.find(
803
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
804
+ );
805
+ if (action) {
806
+ return deleteInboundShipping(action.id);
807
+ }
808
+ });
809
+ await Promise.all(promises);
810
+ if (selectedOptionId) {
811
+ await addInboundShipping(
812
+ { shipping_option_id: selectedOptionId },
813
+ {
814
+ onError: (error) => {
815
+ toast.error(error.message);
816
+ }
817
+ }
818
+ );
819
+ }
820
+ };
821
+ const showLevelsWarning = useMemo3(() => {
822
+ if (!locationId) {
823
+ return false;
824
+ }
825
+ const allItemsHaveLocation = inboundItems.map((_i) => {
826
+ const item = itemsMap.get(_i.item_id);
827
+ if (!item?.variant_id || !item?.variant) {
828
+ return true;
829
+ }
830
+ if (!item.variant?.manage_inventory) {
831
+ return true;
832
+ }
833
+ return inventoryMap[item.variant_id]?.find(
834
+ (l) => l.location_id === locationId
835
+ );
836
+ }).every(Boolean);
837
+ return !allItemsHaveLocation;
838
+ }, [inboundItems, inventoryMap, locationId]);
839
+ useEffect(() => {
840
+ const getInventoryMap = async () => {
841
+ const ret = {};
842
+ if (!inboundItems.length) {
843
+ return ret;
844
+ }
845
+ const variantIds = inboundItems.map((item) => item?.variant_id).filter(Boolean);
846
+ const variants = (await sdk.admin.productVariant.list({
847
+ id: variantIds,
848
+ fields: "*inventory.location_levels"
849
+ })).variants;
850
+ variants.forEach((variant) => {
851
+ ret[variant.id] = variant.inventory?.[0]?.location_levels || [];
852
+ });
853
+ return ret;
854
+ };
855
+ getInventoryMap().then((map) => {
856
+ setInventoryMap(map);
857
+ });
858
+ }, [inboundItems]);
859
+ return /* @__PURE__ */ jsxs2("div", { children: [
860
+ /* @__PURE__ */ jsxs2("div", { className: "mt-8 flex items-center justify-between", children: [
861
+ /* @__PURE__ */ jsx4(Heading, { level: "h2", children: t("orders.returns.inbound") }),
862
+ /* @__PURE__ */ jsxs2(StackedFocusModal, { id: "inbound-items", children: [
863
+ /* @__PURE__ */ jsx4(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx4("a", { className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400", children: t("actions.addItems") }) }),
864
+ /* @__PURE__ */ jsxs2(StackedFocusModal.Content, { children: [
865
+ /* @__PURE__ */ jsx4(StackedFocusModal.Header, {}),
866
+ /* @__PURE__ */ jsx4(
867
+ AddExchangeInboundItemsTable,
868
+ {
869
+ items: order.items,
870
+ selectedItems: inboundItems.map((i) => i.item_id),
871
+ currencyCode: order.currency_code,
872
+ onSelectionChange: (finalSelection) => {
873
+ const alreadySelected = inboundItems.map((i) => i.item_id);
874
+ itemsToAdd = finalSelection.filter(
875
+ (selection) => !alreadySelected.includes(selection)
876
+ );
877
+ itemsToRemove = alreadySelected.filter(
878
+ (selection) => !finalSelection.includes(selection)
879
+ );
880
+ }
881
+ }
882
+ ),
883
+ /* @__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: [
884
+ /* @__PURE__ */ jsx4(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx4(Button, { type: "button", variant: "secondary", size: "small", children: t("actions.cancel") }) }),
885
+ /* @__PURE__ */ jsx4(
886
+ Button,
887
+ {
888
+ type: "submit",
889
+ variant: "primary",
890
+ size: "small",
891
+ role: "button",
892
+ onClick: async () => await onItemsSelected(),
893
+ children: t("actions.save")
894
+ },
895
+ "submit-button"
896
+ )
897
+ ] }) }) })
898
+ ] })
899
+ ] })
900
+ ] }),
901
+ showInboundItemsPlaceholder && /* @__PURE__ */ jsx4(ItemPlaceholder, {}),
902
+ inboundItems.map(
903
+ (item, index) => inboundItemsMap.get(item.item_id) && itemsMap.get(item.item_id) && /* @__PURE__ */ jsx4(
904
+ ExchangeInboundItem,
905
+ {
906
+ item: itemsMap.get(item.item_id),
907
+ previewItem: inboundItemsMap.get(item.item_id),
908
+ currencyCode: order.currency_code,
909
+ form,
910
+ onRemove: () => {
911
+ const actionId = previewInboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
912
+ if (actionId) {
913
+ removeInboundItem(actionId, {
914
+ onError: (error) => {
915
+ toast.error(error.message);
916
+ }
917
+ });
918
+ }
919
+ },
920
+ onUpdate: (payload) => {
921
+ const action = previewInboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM");
922
+ if (action) {
923
+ updateInboundItem(
924
+ { ...payload, actionId: action.id },
925
+ {
926
+ onError: (error) => {
927
+ if (action.details?.quantity && payload.quantity) {
928
+ form.setValue(
929
+ `inbound_items.${index}.quantity`,
930
+ action.details?.quantity
931
+ );
932
+ }
933
+ toast.error(error.message);
934
+ }
935
+ }
936
+ );
937
+ }
938
+ },
939
+ index
940
+ },
941
+ item.id
942
+ )
943
+ ),
944
+ !showInboundItemsPlaceholder && /* @__PURE__ */ jsxs2("div", { className: "mt-8 flex flex-col gap-y-4", children: [
945
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
946
+ /* @__PURE__ */ jsxs2("div", { children: [
947
+ /* @__PURE__ */ jsx4(Form.Label, { children: t("orders.returns.location") }),
948
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.locationHint") })
949
+ ] }),
950
+ /* @__PURE__ */ jsx4(
951
+ Form.Field,
952
+ {
953
+ control: form.control,
954
+ name: "location_id",
955
+ render: ({ field: { value, onChange, ...field } }) => {
956
+ return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(
957
+ Combobox,
958
+ {
959
+ ...field,
960
+ value: value ?? void 0,
961
+ onChange: (v) => {
962
+ onChange(v);
963
+ onLocationChange(v);
964
+ },
965
+ options: (stock_locations ?? []).map(
966
+ (stockLocation) => ({
967
+ label: stockLocation.name,
968
+ value: stockLocation.id
969
+ })
970
+ )
971
+ }
972
+ ) }) });
973
+ }
974
+ }
975
+ )
976
+ ] }),
977
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
978
+ /* @__PURE__ */ jsxs2("div", { children: [
979
+ /* @__PURE__ */ jsxs2(Form.Label, { children: [
980
+ t("orders.returns.inboundShipping"),
981
+ /* @__PURE__ */ jsxs2(
982
+ Text2,
983
+ {
984
+ size: "small",
985
+ leading: "compact",
986
+ className: "text-ui-fg-muted ml-1 inline",
987
+ children: [
988
+ "(",
989
+ t("fields.optional"),
990
+ ")"
991
+ ]
992
+ }
993
+ )
994
+ ] }),
995
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.inboundShippingHint") })
996
+ ] }),
997
+ /* @__PURE__ */ jsx4(
998
+ Form.Field,
999
+ {
1000
+ control: form.control,
1001
+ name: "inbound_option_id",
1002
+ render: ({ field: { value, onChange, ...field } }) => {
1003
+ return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(
1004
+ Combobox,
1005
+ {
1006
+ allowClear: true,
1007
+ value: value ?? void 0,
1008
+ onChange: (val) => {
1009
+ onChange(val);
1010
+ onShippingOptionChange(val);
1011
+ },
1012
+ ...field,
1013
+ options: inboundShippingOptions.map((so) => ({
1014
+ label: so.name,
1015
+ value: so.id
1016
+ })),
1017
+ disabled: !locationId,
1018
+ noResultsPlaceholder: /* @__PURE__ */ jsx4(ReturnShippingPlaceholder, {})
1019
+ }
1020
+ ) }) });
1021
+ }
1022
+ }
1023
+ )
1024
+ ] })
1025
+ ] }),
1026
+ showLevelsWarning && /* @__PURE__ */ jsxs2(Alert, { variant: "warning", dismissible: true, className: "mt-4 p-5", children: [
1027
+ /* @__PURE__ */ jsx4("div", { className: "text-ui-fg-subtle txt-small pb-2 font-medium leading-[20px]", children: t("orders.returns.noInventoryLevel") }),
1028
+ /* @__PURE__ */ jsx4(Text2, { className: "text-ui-fg-subtle txt-small leading-normal", children: t("orders.returns.noInventoryLevelDesc") })
1029
+ ] })
1030
+ ] });
1031
+ };
1032
+
1033
+ // src/pages/orders/order-create-exchange/components/exchange-create-form/exchange-outbound-section.tsx
1034
+ import { Alert as Alert2, Button as Button2, Heading as Heading2, Text as Text4, toast as toast2 } from "@medusajs/ui";
1035
+ import { useEffect as useEffect2, useMemo as useMemo5, useState as useState4 } from "react";
1036
+ import { useFieldArray as useFieldArray2 } from "react-hook-form";
1037
+ import { useTranslation as useTranslation10 } from "react-i18next";
1038
+
1039
+ // src/pages/orders/order-create-exchange/components/add-exchange-outbound-items-table/add-exchange-outbound-items-table.tsx
1040
+ import { useState as useState3 } from "react";
1041
+ import { useTranslation as useTranslation8 } from "react-i18next";
1042
+
1043
+ // src/pages/orders/order-create-exchange/components/add-exchange-outbound-items-table/use-exchange-outbound-item-table-columns.tsx
1044
+ import { Checkbox as Checkbox2 } from "@medusajs/ui";
1045
+ import { createColumnHelper as createColumnHelper2 } from "@tanstack/react-table";
1046
+ import { useMemo as useMemo4 } from "react";
1047
+ import { useTranslation as useTranslation6 } from "react-i18next";
1048
+ import { jsx as jsx5 } from "react/jsx-runtime";
1049
+ var columnHelper2 = createColumnHelper2();
1050
+ var useExchangeOutboundItemTableColumns = (currencyCode) => {
1051
+ const { t } = useTranslation6();
1052
+ return useMemo4(
1053
+ () => [
1054
+ columnHelper2.display({
1055
+ id: "select",
1056
+ header: ({ table }) => {
1057
+ return /* @__PURE__ */ jsx5(
1058
+ Checkbox2,
1059
+ {
1060
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
1061
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
1062
+ }
1063
+ );
1064
+ },
1065
+ cell: ({ row }) => {
1066
+ const isSelectable = row.getCanSelect();
1067
+ return /* @__PURE__ */ jsx5(
1068
+ Checkbox2,
1069
+ {
1070
+ disabled: !isSelectable,
1071
+ checked: row.getIsSelected(),
1072
+ onCheckedChange: (value) => row.toggleSelected(!!value),
1073
+ onClick: (e) => {
1074
+ e.stopPropagation();
1075
+ }
1076
+ }
1077
+ );
1078
+ }
1079
+ }),
1080
+ columnHelper2.display({
1081
+ id: "product",
1082
+ header: () => /* @__PURE__ */ jsx5(ProductHeader, {}),
1083
+ cell: ({ row }) => {
1084
+ return /* @__PURE__ */ jsx5(ProductCell, { product: row.original.product });
1085
+ }
1086
+ }),
1087
+ columnHelper2.accessor("sku", {
1088
+ header: t("fields.sku"),
1089
+ cell: ({ getValue }) => {
1090
+ return getValue() || "-";
1091
+ }
1092
+ }),
1093
+ columnHelper2.accessor("title", {
1094
+ header: t("fields.title")
1095
+ })
1096
+ ],
1097
+ [t, currencyCode]
1098
+ );
1099
+ };
1100
+
1101
+ // src/pages/orders/order-create-exchange/components/add-exchange-outbound-items-table/use-exchange-outbound-item-table-filters.tsx
1102
+ import { useTranslation as useTranslation7 } from "react-i18next";
1103
+ var useExchangeOutboundItemTableFilters = () => {
1104
+ const { t } = useTranslation7();
1105
+ const filters = [
1106
+ {
1107
+ key: "created_at",
1108
+ label: t("fields.createdAt"),
1109
+ type: "date"
1110
+ },
1111
+ {
1112
+ key: "updated_at",
1113
+ label: t("fields.updatedAt"),
1114
+ type: "date"
1115
+ }
1116
+ ];
1117
+ return filters;
1118
+ };
1119
+
1120
+ // src/pages/orders/order-create-exchange/components/add-exchange-outbound-items-table/use-exchange-outbound-item-table-query.tsx
1121
+ var useExchangeOutboundItemTableQuery = ({
1122
+ pageSize = 50,
1123
+ prefix
1124
+ }) => {
1125
+ const raw = useQueryParams(
1126
+ ["q", "offset", "order", "created_at", "updated_at"],
1127
+ prefix
1128
+ );
1129
+ const { offset, created_at, updated_at, ...rest } = raw;
1130
+ const searchParams = {
1131
+ ...rest,
1132
+ limit: pageSize,
1133
+ offset: offset ? Number(offset) : 0,
1134
+ created_at: created_at ? JSON.parse(created_at) : void 0,
1135
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0
1136
+ };
1137
+ return { searchParams, raw };
1138
+ };
1139
+
1140
+ // src/pages/orders/order-create-exchange/components/add-exchange-outbound-items-table/add-exchange-outbound-items-table.tsx
1141
+ import { jsx as jsx6 } from "react/jsx-runtime";
1142
+ var PAGE_SIZE2 = 50;
1143
+ var PREFIX2 = "rit";
1144
+ var AddExchangeOutboundItemsTable = ({
1145
+ onSelectionChange,
1146
+ selectedItems,
1147
+ currencyCode
1148
+ }) => {
1149
+ const { t } = useTranslation8();
1150
+ const [rowSelection, setRowSelection] = useState3(
1151
+ selectedItems.reduce((acc, id) => {
1152
+ acc[id] = true;
1153
+ return acc;
1154
+ }, {})
1155
+ );
1156
+ const updater = (fn) => {
1157
+ const newState = typeof fn === "function" ? fn(rowSelection) : fn;
1158
+ setRowSelection(newState);
1159
+ onSelectionChange(Object.keys(newState));
1160
+ };
1161
+ const { searchParams, raw } = useExchangeOutboundItemTableQuery({
1162
+ pageSize: PAGE_SIZE2,
1163
+ prefix: PREFIX2
1164
+ });
1165
+ const { variants = [], count } = useVariants({
1166
+ ...searchParams,
1167
+ fields: "*inventory_items.inventory.location_levels,+inventory_quantity"
1168
+ });
1169
+ const columns = useExchangeOutboundItemTableColumns(currencyCode);
1170
+ const filters = useExchangeOutboundItemTableFilters();
1171
+ const { table } = useDataTable({
1172
+ data: variants,
1173
+ columns,
1174
+ count,
1175
+ enablePagination: true,
1176
+ getRowId: (row) => row.id,
1177
+ pageSize: PAGE_SIZE2,
1178
+ enableRowSelection: (_row) => {
1179
+ return true;
1180
+ },
1181
+ rowSelection: {
1182
+ state: rowSelection,
1183
+ updater
1184
+ }
1185
+ });
1186
+ return /* @__PURE__ */ jsx6("div", { className: "flex size-full flex-col overflow-hidden", children: /* @__PURE__ */ jsx6(
1187
+ _DataTable,
1188
+ {
1189
+ table,
1190
+ columns,
1191
+ pageSize: PAGE_SIZE2,
1192
+ count,
1193
+ filters,
1194
+ pagination: true,
1195
+ layout: "fill",
1196
+ search: true,
1197
+ orderBy: [
1198
+ { key: "product_id", label: t("fields.product") },
1199
+ { key: "title", label: t("fields.title") },
1200
+ { key: "sku", label: t("fields.sku") }
1201
+ ],
1202
+ prefix: PREFIX2,
1203
+ queryObject: raw
1204
+ }
1205
+ ) });
1206
+ };
1207
+
1208
+ // src/pages/orders/order-create-exchange/components/exchange-create-form/exchange-outbound-item.tsx
1209
+ import { XCircle as XCircle2 } from "@medusajs/icons";
1210
+ import { Input as Input2, Text as Text3 } from "@medusajs/ui";
1211
+ import { useTranslation as useTranslation9 } from "react-i18next";
1212
+ import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
1213
+ function ExchangeOutboundItem({
1214
+ previewItem,
1215
+ currencyCode,
1216
+ form,
1217
+ onRemove,
1218
+ onUpdate,
1219
+ index
1220
+ }) {
1221
+ const { t } = useTranslation9();
1222
+ return /* @__PURE__ */ jsx7("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl ", children: /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-center gap-x-2 gap-y-2 p-3 text-sm md:flex-row", children: [
1223
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 items-center gap-x-3", children: [
1224
+ /* @__PURE__ */ jsx7(Thumbnail, { src: previewItem.thumbnail }),
1225
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col", children: [
1226
+ /* @__PURE__ */ jsxs3("div", { children: [
1227
+ /* @__PURE__ */ jsxs3(Text3, { className: "txt-small", as: "span", weight: "plus", children: [
1228
+ previewItem.title,
1229
+ " "
1230
+ ] }),
1231
+ previewItem.variant_sku && /* @__PURE__ */ jsxs3("span", { children: [
1232
+ "(",
1233
+ previewItem.variant_sku,
1234
+ ")"
1235
+ ] })
1236
+ ] }),
1237
+ /* @__PURE__ */ jsx7(Text3, { as: "div", className: "text-ui-fg-subtle txt-small", children: previewItem.subtitle })
1238
+ ] })
1239
+ ] }),
1240
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 justify-between", children: [
1241
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-grow items-center gap-2", children: [
1242
+ /* @__PURE__ */ jsx7(
1243
+ Form.Field,
1244
+ {
1245
+ control: form.control,
1246
+ name: `outbound_items.${index}.quantity`,
1247
+ render: ({ field }) => {
1248
+ return /* @__PURE__ */ jsxs3(Form.Item, { children: [
1249
+ /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(
1250
+ Input2,
1251
+ {
1252
+ ...field,
1253
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
1254
+ min: 1,
1255
+ type: "number",
1256
+ onBlur: (e) => {
1257
+ const val = e.target.value;
1258
+ const payload = val === "" ? null : Number(val);
1259
+ field.onChange(payload);
1260
+ if (payload) {
1261
+ onUpdate({ quantity: payload });
1262
+ }
1263
+ }
1264
+ }
1265
+ ) }),
1266
+ /* @__PURE__ */ jsx7(Form.ErrorMessage, {})
1267
+ ] });
1268
+ }
1269
+ }
1270
+ ),
1271
+ /* @__PURE__ */ jsx7(Text3, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
1272
+ ] }),
1273
+ /* @__PURE__ */ jsx7("div", { className: "text-ui-fg-subtle txt-small mr-2 flex flex-shrink-0", children: /* @__PURE__ */ jsx7(
1274
+ MoneyAmountCell,
1275
+ {
1276
+ currencyCode,
1277
+ amount: previewItem.total
1278
+ }
1279
+ ) }),
1280
+ /* @__PURE__ */ jsx7(
1281
+ ActionMenu,
1282
+ {
1283
+ groups: [
1284
+ {
1285
+ actions: [
1286
+ {
1287
+ label: t("actions.remove"),
1288
+ onClick: onRemove,
1289
+ icon: /* @__PURE__ */ jsx7(XCircle2, {})
1290
+ }
1291
+ ].filter(Boolean)
1292
+ }
1293
+ ]
1294
+ }
1295
+ )
1296
+ ] })
1297
+ ] }) });
1298
+ }
1299
+
1300
+ // src/pages/orders/order-create-exchange/components/exchange-create-form/exchange-outbound-section.tsx
1301
+ import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1302
+ var itemsToAdd2 = [];
1303
+ var itemsToRemove2 = [];
1304
+ var ExchangeOutboundSection = ({
1305
+ order,
1306
+ preview,
1307
+ exchange,
1308
+ form
1309
+ }) => {
1310
+ const { t } = useTranslation10();
1311
+ const { setIsOpen } = useStackedModal();
1312
+ const [inventoryMap, setInventoryMap] = useState4({});
1313
+ const { shipping_options = [] } = useOrderShippingOptions(order.id);
1314
+ const outboundShippingOptions = shipping_options.filter(
1315
+ (so) => !so.rules?.find((r) => r.attribute === "is_return" && r.value === "true")
1316
+ );
1317
+ const { mutateAsync: addOutboundShipping } = useAddExchangeOutboundShipping(
1318
+ exchange.id,
1319
+ order.id
1320
+ );
1321
+ const { mutateAsync: deleteOutboundShipping } = useDeleteExchangeOutboundShipping(exchange.id, order.id);
1322
+ const { mutateAsync: addOutboundItem } = useAddExchangeOutboundItems(
1323
+ exchange.id,
1324
+ order.id
1325
+ );
1326
+ const { mutateAsync: updateOutboundItem } = useUpdateExchangeOutboundItems(
1327
+ exchange.id,
1328
+ order.id
1329
+ );
1330
+ const { mutateAsync: removeOutboundItem } = useRemoveExchangeOutboundItem(
1331
+ exchange.id,
1332
+ order.id
1333
+ );
1334
+ const previewOutboundItems = useMemo5(
1335
+ () => preview?.items?.filter(
1336
+ (i) => !!i.actions?.find(
1337
+ (a) => a.exchange_id === exchange.id && a.action === "ITEM_ADD"
1338
+ )
1339
+ ),
1340
+ [preview.items]
1341
+ );
1342
+ const variantItemMap = useMemo5(
1343
+ () => new Map(order?.items?.map((i) => [i.variant_id, i])),
1344
+ [order.items]
1345
+ );
1346
+ const {
1347
+ fields: outboundItems,
1348
+ append,
1349
+ remove,
1350
+ update
1351
+ } = useFieldArray2({
1352
+ name: "outbound_items",
1353
+ control: form.control
1354
+ });
1355
+ const variantOutboundMap = useMemo5(
1356
+ () => new Map(previewOutboundItems.map((i) => [i.variant_id, i])),
1357
+ [previewOutboundItems, outboundItems]
1358
+ );
1359
+ useEffect2(() => {
1360
+ const existingItemsMap = {};
1361
+ previewOutboundItems.forEach((i) => {
1362
+ const ind = outboundItems.findIndex((field) => field.item_id === i.id);
1363
+ existingItemsMap[i.id] = true;
1364
+ if (ind > -1) {
1365
+ if (outboundItems[ind].quantity !== i.detail.quantity) {
1366
+ update(ind, {
1367
+ ...outboundItems[ind],
1368
+ quantity: i.detail.quantity
1369
+ });
1370
+ }
1371
+ } else {
1372
+ append(
1373
+ {
1374
+ item_id: i.id,
1375
+ quantity: i.detail.quantity,
1376
+ variant_id: i.variant_id
1377
+ },
1378
+ { shouldFocus: false }
1379
+ );
1380
+ }
1381
+ });
1382
+ outboundItems.forEach((i, ind) => {
1383
+ if (!(i.item_id in existingItemsMap)) {
1384
+ remove(ind);
1385
+ }
1386
+ });
1387
+ }, [previewOutboundItems]);
1388
+ const locationId = form.watch("location_id");
1389
+ const showOutboundItemsPlaceholder = !outboundItems.length;
1390
+ const onItemsSelected = async () => {
1391
+ itemsToAdd2.length && await addOutboundItem(
1392
+ {
1393
+ items: itemsToAdd2.map((variantId) => ({
1394
+ variant_id: variantId,
1395
+ quantity: 1
1396
+ }))
1397
+ },
1398
+ {
1399
+ onError: (error) => {
1400
+ toast2.error(error.message);
1401
+ }
1402
+ }
1403
+ );
1404
+ for (const itemToRemove of itemsToRemove2) {
1405
+ const action = previewOutboundItems.find((i) => i.variant_id === itemToRemove)?.actions?.find((a) => a.action === "ITEM_ADD");
1406
+ if (action?.id) {
1407
+ await removeOutboundItem(action?.id, {
1408
+ onError: (error) => {
1409
+ toast2.error(error.message);
1410
+ }
1411
+ });
1412
+ }
1413
+ }
1414
+ setIsOpen("outbound-items", false);
1415
+ };
1416
+ useEffect2(() => {
1417
+ const outboundShipping = preview.shipping_methods.find(
1418
+ (s) => !!s.actions?.find((a) => a.action === "SHIPPING_ADD" && !a.return_id)
1419
+ );
1420
+ if (outboundShipping) {
1421
+ form.setValue("outbound_option_id", outboundShipping.shipping_option_id);
1422
+ } else {
1423
+ form.setValue("outbound_option_id", "");
1424
+ }
1425
+ }, [preview.shipping_methods]);
1426
+ const onShippingOptionChange = async (selectedOptionId) => {
1427
+ const outboundShippingMethods = preview.shipping_methods.filter(
1428
+ (s) => !!s.actions?.find((a) => a.action === "SHIPPING_ADD" && !a.return_id)
1429
+ );
1430
+ const promises = outboundShippingMethods.filter(Boolean).map((outboundShippingMethod) => {
1431
+ const action = outboundShippingMethod.actions?.find(
1432
+ (a) => a.action === "SHIPPING_ADD" && !a.return_id
1433
+ );
1434
+ if (action) {
1435
+ return deleteOutboundShipping(action.id);
1436
+ }
1437
+ });
1438
+ await Promise.all(promises);
1439
+ if (selectedOptionId) {
1440
+ await addOutboundShipping(
1441
+ { shipping_option_id: selectedOptionId },
1442
+ {
1443
+ onError: (error) => {
1444
+ toast2.error(error.message);
1445
+ }
1446
+ }
1447
+ );
1448
+ }
1449
+ };
1450
+ const showLevelsWarning = useMemo5(() => {
1451
+ if (!locationId) {
1452
+ return false;
1453
+ }
1454
+ const allItemsHaveLocation = outboundItems.map((i) => {
1455
+ const item = variantItemMap.get(i.variant_id);
1456
+ if (!item?.variant_id || !item?.variant) {
1457
+ return true;
1458
+ }
1459
+ if (!item.variant?.manage_inventory) {
1460
+ return true;
1461
+ }
1462
+ return inventoryMap[item.variant_id]?.find(
1463
+ (l) => l.location_id === locationId
1464
+ );
1465
+ }).every(Boolean);
1466
+ return !allItemsHaveLocation;
1467
+ }, [outboundItems, inventoryMap, locationId]);
1468
+ useEffect2(() => {
1469
+ const getInventoryMap = async () => {
1470
+ const ret = {};
1471
+ if (!outboundItems.length) {
1472
+ return ret;
1473
+ }
1474
+ const variantIds = outboundItems.map((item) => item?.variant_id).filter(Boolean);
1475
+ const variants = (await sdk.admin.productVariant.list({
1476
+ id: variantIds,
1477
+ fields: "*inventory.location_levels"
1478
+ })).variants;
1479
+ variants.forEach((variant) => {
1480
+ ret[variant.id] = variant.inventory?.[0]?.location_levels || [];
1481
+ });
1482
+ return ret;
1483
+ };
1484
+ getInventoryMap().then((map) => {
1485
+ setInventoryMap(map);
1486
+ });
1487
+ }, [outboundItems]);
1488
+ return /* @__PURE__ */ jsxs4("div", { children: [
1489
+ /* @__PURE__ */ jsxs4("div", { className: "mt-8 flex items-center justify-between", children: [
1490
+ /* @__PURE__ */ jsx8(Heading2, { level: "h2", children: t("orders.returns.outbound") }),
1491
+ /* @__PURE__ */ jsxs4(StackedFocusModal, { id: "outbound-items", children: [
1492
+ /* @__PURE__ */ jsx8(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx8("a", { className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400", children: t("actions.addItems") }) }),
1493
+ /* @__PURE__ */ jsxs4(StackedFocusModal.Content, { children: [
1494
+ /* @__PURE__ */ jsx8(StackedFocusModal.Header, {}),
1495
+ /* @__PURE__ */ jsx8(
1496
+ AddExchangeOutboundItemsTable,
1497
+ {
1498
+ selectedItems: outboundItems.map((i) => i.variant_id),
1499
+ currencyCode: order.currency_code,
1500
+ onSelectionChange: (finalSelection) => {
1501
+ const alreadySelected = outboundItems.map((i) => i.variant_id);
1502
+ itemsToAdd2 = finalSelection.filter(
1503
+ (selection) => !alreadySelected.includes(selection)
1504
+ );
1505
+ itemsToRemove2 = alreadySelected.filter(
1506
+ (selection) => !finalSelection.includes(selection)
1507
+ );
1508
+ }
1509
+ }
1510
+ ),
1511
+ /* @__PURE__ */ jsx8(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsx8("div", { className: "flex w-full items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-end gap-x-2", children: [
1512
+ /* @__PURE__ */ jsx8(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx8(Button2, { type: "button", variant: "secondary", size: "small", children: t("actions.cancel") }) }),
1513
+ /* @__PURE__ */ jsx8(
1514
+ Button2,
1515
+ {
1516
+ type: "submit",
1517
+ variant: "primary",
1518
+ size: "small",
1519
+ role: "button",
1520
+ onClick: async () => await onItemsSelected(),
1521
+ children: t("actions.save")
1522
+ },
1523
+ "submit-button"
1524
+ )
1525
+ ] }) }) })
1526
+ ] })
1527
+ ] })
1528
+ ] }),
1529
+ showOutboundItemsPlaceholder && /* @__PURE__ */ jsx8(ItemPlaceholder, {}),
1530
+ outboundItems.map(
1531
+ (item, index) => variantOutboundMap.get(item.variant_id) && /* @__PURE__ */ jsx8(
1532
+ ExchangeOutboundItem,
1533
+ {
1534
+ previewItem: variantOutboundMap.get(item.variant_id),
1535
+ currencyCode: order.currency_code,
1536
+ form,
1537
+ onRemove: () => {
1538
+ const actionId = previewOutboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "ITEM_ADD")?.id;
1539
+ if (actionId) {
1540
+ removeOutboundItem(actionId, {
1541
+ onError: (error) => {
1542
+ toast2.error(error.message);
1543
+ }
1544
+ });
1545
+ }
1546
+ },
1547
+ onUpdate: (payload) => {
1548
+ const actionId = previewOutboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "ITEM_ADD")?.id;
1549
+ if (actionId) {
1550
+ updateOutboundItem(
1551
+ { ...payload, actionId },
1552
+ {
1553
+ onError: (error) => {
1554
+ toast2.error(error.message);
1555
+ }
1556
+ }
1557
+ );
1558
+ }
1559
+ },
1560
+ index
1561
+ },
1562
+ item.id
1563
+ )
1564
+ ),
1565
+ !showOutboundItemsPlaceholder && /* @__PURE__ */ jsx8("div", { className: "mt-8 flex flex-col gap-y-4", children: /* @__PURE__ */ jsxs4("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
1566
+ /* @__PURE__ */ jsxs4("div", { children: [
1567
+ /* @__PURE__ */ jsx8(Form.Label, { children: t("orders.exchanges.outboundShipping") }),
1568
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.exchanges.outboundShippingHint") })
1569
+ ] }),
1570
+ /* @__PURE__ */ jsx8(
1571
+ Form.Field,
1572
+ {
1573
+ control: form.control,
1574
+ name: "outbound_option_id",
1575
+ render: ({ field: { value, onChange, ...field } }) => {
1576
+ return /* @__PURE__ */ jsx8(Form.Item, { children: /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(
1577
+ Combobox,
1578
+ {
1579
+ allowClear: true,
1580
+ noResultsPlaceholder: /* @__PURE__ */ jsx8(OutboundShippingPlaceholder, {}),
1581
+ value: value ?? void 0,
1582
+ onChange: (val) => {
1583
+ onChange(val);
1584
+ onShippingOptionChange(val);
1585
+ },
1586
+ ...field,
1587
+ options: outboundShippingOptions.map((so) => ({
1588
+ label: `${so.name} (${getFormattedShippingOptionLocationName(so)})`,
1589
+ value: so.id
1590
+ })),
1591
+ disabled: !outboundShippingOptions.length
1592
+ }
1593
+ ) }) });
1594
+ }
1595
+ }
1596
+ )
1597
+ ] }) }),
1598
+ showLevelsWarning && /* @__PURE__ */ jsxs4(Alert2, { variant: "warning", dismissible: true, className: "mt-4 p-5", children: [
1599
+ /* @__PURE__ */ jsx8("div", { className: "text-ui-fg-subtle txt-small pb-2 font-medium leading-[20px]", children: t("orders.returns.noInventoryLevel") }),
1600
+ /* @__PURE__ */ jsx8(Text4, { className: "text-ui-fg-subtle txt-small leading-normal", children: t("orders.returns.noInventoryLevelDesc") })
1601
+ ] })
1602
+ ] });
1603
+ };
1604
+
1605
+ // src/pages/orders/order-create-exchange/components/exchange-create-form/exchange-create-form.tsx
1606
+ import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1607
+ var IS_CANCELING = false;
1608
+ var ExchangeCreateForm = ({
1609
+ order,
1610
+ preview,
1611
+ exchange,
1612
+ orderReturn
1613
+ }) => {
1614
+ const { t } = useTranslation11();
1615
+ const { handleSuccess } = useRouteModal();
1616
+ const [isInboundShippingPriceEdit, setIsInboundShippingPriceEdit] = useState5(false);
1617
+ const [isOutboundShippingPriceEdit, setIsOutboundShippingPriceEdit] = useState5(false);
1618
+ const [customInboundShippingAmount, setCustomInboundShippingAmount] = useState5({
1619
+ value: "0",
1620
+ float: 0
1621
+ });
1622
+ const [customOutboundShippingAmount, setCustomOutboundShippingAmount] = useState5({
1623
+ value: "0",
1624
+ float: 0
1625
+ });
1626
+ const { mutateAsync: confirmExchangeRequest, isPending: isConfirming } = useExchangeConfirmRequest(exchange.id, order.id);
1627
+ const { mutateAsync: cancelExchangeRequest, isPending: isCanceling } = useCancelExchangeRequest(exchange.id, order.id);
1628
+ const {
1629
+ mutateAsync: updateInboundShipping,
1630
+ isPending: isUpdatingOutboundShipping
1631
+ } = useUpdateExchangeInboundShipping(exchange.id, order.id);
1632
+ const {
1633
+ mutateAsync: updateOutboundShipping,
1634
+ isPending: isUpdatingInboundShipping
1635
+ } = useUpdateExchangeOutboundShipping(exchange.id, order.id);
1636
+ const isRequestLoading = isConfirming || isCanceling || isUpdatingInboundShipping || isUpdatingOutboundShipping;
1637
+ const previewItems = useMemo6(
1638
+ () => preview?.items?.filter(
1639
+ (i) => !!i.actions?.find((a) => a.exchange_id === exchange.id)
1640
+ ),
1641
+ [preview.items]
1642
+ );
1643
+ const inboundPreviewItems = previewItems.filter(
1644
+ (item) => !!item.actions?.find((a) => a.action === "RETURN_ITEM")
1645
+ );
1646
+ const outboundPreviewItems = previewItems.filter(
1647
+ (item) => !!item.actions?.find((a) => a.action === "ITEM_ADD")
1648
+ );
1649
+ const form = useForm({
1650
+ defaultValues: () => {
1651
+ const inboundShippingMethod = preview.shipping_methods.find((s) => {
1652
+ return !!s.actions?.find(
1653
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1654
+ );
1655
+ });
1656
+ const outboundShippingMethod = preview.shipping_methods.find((s) => {
1657
+ return !!s.actions?.find(
1658
+ (a) => a.action === "SHIPPING_ADD" && !a.return_id
1659
+ );
1660
+ });
1661
+ return Promise.resolve({
1662
+ inbound_items: inboundPreviewItems.map((i) => {
1663
+ const inboundAction = i.actions?.find(
1664
+ (a) => a.action === "RETURN_ITEM"
1665
+ );
1666
+ return {
1667
+ item_id: i.id,
1668
+ variant_id: i.variant_id,
1669
+ quantity: i.detail.return_requested_quantity,
1670
+ note: inboundAction?.internal_note,
1671
+ reason_id: inboundAction?.details?.reason_id
1672
+ };
1673
+ }),
1674
+ outbound_items: outboundPreviewItems.map((i) => ({
1675
+ item_id: i.id,
1676
+ variant_id: i.variant_id,
1677
+ quantity: i.detail.quantity
1678
+ })),
1679
+ inbound_option_id: inboundShippingMethod ? inboundShippingMethod.shipping_option_id : "",
1680
+ outbound_option_id: outboundShippingMethod ? outboundShippingMethod.shipping_option_id : "",
1681
+ location_id: orderReturn?.location_id,
1682
+ send_notification: false
1683
+ });
1684
+ },
1685
+ resolver: zodResolver(ExchangeCreateSchema)
1686
+ });
1687
+ const inboundShipping = preview.shipping_methods.find((s) => {
1688
+ return !!s.actions?.find(
1689
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1690
+ );
1691
+ });
1692
+ const outboundShipping = preview.shipping_methods.find((s) => {
1693
+ return !!s.actions?.find(
1694
+ (a) => a.action === "SHIPPING_ADD" && !a.return_id
1695
+ );
1696
+ });
1697
+ useEffect3(() => {
1698
+ if (inboundShipping) {
1699
+ setCustomInboundShippingAmount(inboundShipping.total);
1700
+ }
1701
+ }, [inboundShipping]);
1702
+ useEffect3(() => {
1703
+ if (outboundShipping) {
1704
+ setCustomOutboundShippingAmount(outboundShipping.total);
1705
+ }
1706
+ }, [outboundShipping]);
1707
+ const inboundShippingOptionId = form.watch("inbound_option_id");
1708
+ const outboundShippingOptionId = form.watch("outbound_option_id");
1709
+ const prompt = usePrompt();
1710
+ const handleSubmit = form.handleSubmit(async (data) => {
1711
+ try {
1712
+ const res = await prompt({
1713
+ title: t("general.areYouSure"),
1714
+ description: t("orders.exchanges.confirmText"),
1715
+ confirmText: t("actions.continue"),
1716
+ cancelText: t("actions.cancel"),
1717
+ variant: "confirmation"
1718
+ });
1719
+ if (!res) {
1720
+ return;
1721
+ }
1722
+ await confirmExchangeRequest({
1723
+ no_notification: !data.send_notification
1724
+ });
1725
+ handleSuccess();
1726
+ } catch (e) {
1727
+ toast3.error(t("general.error"), {
1728
+ description: e.message
1729
+ });
1730
+ }
1731
+ });
1732
+ useEffect3(() => {
1733
+ if (isInboundShippingPriceEdit) {
1734
+ document.getElementById("js-inbound-shipping-input")?.focus();
1735
+ }
1736
+ }, [isInboundShippingPriceEdit]);
1737
+ useEffect3(() => {
1738
+ if (isOutboundShippingPriceEdit) {
1739
+ document.getElementById("js-outbound-shipping-input")?.focus();
1740
+ }
1741
+ }, [isOutboundShippingPriceEdit]);
1742
+ useEffect3(() => {
1743
+ return () => {
1744
+ if (IS_CANCELING) {
1745
+ cancelExchangeRequest(void 0, {
1746
+ onSuccess: () => {
1747
+ toast3.success(
1748
+ t("orders.exchanges.actions.cancelExchange.successToast")
1749
+ );
1750
+ },
1751
+ onError: (error) => {
1752
+ toast3.error(error.message);
1753
+ }
1754
+ });
1755
+ IS_CANCELING = false;
1756
+ }
1757
+ };
1758
+ }, []);
1759
+ const inboundShippingTotal = useMemo6(() => {
1760
+ const method = preview.shipping_methods.find(
1761
+ (sm) => !!sm.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
1762
+ );
1763
+ return method?.total || 0;
1764
+ }, [preview.shipping_methods]);
1765
+ const outboundShippingTotal = useMemo6(() => {
1766
+ const method = preview.shipping_methods.find(
1767
+ (sm) => !!sm.actions?.find((a) => a.action === "SHIPPING_ADD" && !a.return_id)
1768
+ );
1769
+ return method?.total || 0;
1770
+ }, [preview.shipping_methods]);
1771
+ return /* @__PURE__ */ jsx9(RouteFocusModal.Form, { form, "data-testid": "order-create-exchange-form", children: /* @__PURE__ */ jsxs5(
1772
+ KeyboundForm,
1773
+ {
1774
+ onSubmit: handleSubmit,
1775
+ className: "flex h-full flex-col",
1776
+ "data-testid": "order-create-exchange-form",
1777
+ children: [
1778
+ /* @__PURE__ */ jsx9(RouteFocusModal.Header, { "data-testid": "order-create-exchange-header" }),
1779
+ /* @__PURE__ */ jsx9(
1780
+ RouteFocusModal.Body,
1781
+ {
1782
+ className: "flex size-full justify-center overflow-y-auto",
1783
+ "data-testid": "order-create-exchange-body",
1784
+ children: /* @__PURE__ */ jsxs5(
1785
+ "div",
1786
+ {
1787
+ className: "mt-16 w-[720px] max-w-[100%] px-4 md:p-0",
1788
+ "data-testid": "order-create-exchange-form-content",
1789
+ children: [
1790
+ /* @__PURE__ */ jsx9(Heading3, { level: "h1", "data-testid": "order-create-exchange-heading", children: t("orders.exchanges.create") }),
1791
+ /* @__PURE__ */ jsx9(
1792
+ ExchangeInboundSection,
1793
+ {
1794
+ form,
1795
+ preview,
1796
+ order,
1797
+ exchange,
1798
+ orderReturn
1799
+ }
1800
+ ),
1801
+ /* @__PURE__ */ jsx9(
1802
+ ExchangeOutboundSection,
1803
+ {
1804
+ form,
1805
+ preview,
1806
+ order,
1807
+ exchange
1808
+ }
1809
+ ),
1810
+ /* @__PURE__ */ jsxs5(
1811
+ "div",
1812
+ {
1813
+ className: "mt-8 border-y border-dotted py-4",
1814
+ "data-testid": "order-create-exchange-totals",
1815
+ children: [
1816
+ /* @__PURE__ */ jsxs5(
1817
+ "div",
1818
+ {
1819
+ className: "mb-2 flex items-center justify-between",
1820
+ "data-testid": "order-create-exchange-inbound-total",
1821
+ children: [
1822
+ /* @__PURE__ */ jsx9(
1823
+ "span",
1824
+ {
1825
+ className: "txt-small text-ui-fg-subtle",
1826
+ "data-testid": "order-create-exchange-form-inbound-total-label",
1827
+ children: t("orders.returns.inboundTotal")
1828
+ }
1829
+ ),
1830
+ /* @__PURE__ */ jsx9(
1831
+ "span",
1832
+ {
1833
+ className: "txt-small text-ui-fg-subtle",
1834
+ "data-testid": "order-create-exchange-form-inbound-total-value",
1835
+ children: getStylizedAmount(
1836
+ inboundPreviewItems.reduce((acc, item) => {
1837
+ const action = item.actions?.find(
1838
+ (act) => act.action === "RETURN_ITEM"
1839
+ );
1840
+ acc = acc + (action?.amount || 0);
1841
+ return acc;
1842
+ }, 0) * -1,
1843
+ order.currency_code
1844
+ )
1845
+ }
1846
+ )
1847
+ ]
1848
+ }
1849
+ ),
1850
+ /* @__PURE__ */ jsxs5(
1851
+ "div",
1852
+ {
1853
+ className: "mb-2 flex items-center justify-between",
1854
+ "data-testid": "order-create-exchange-outbound-total",
1855
+ children: [
1856
+ /* @__PURE__ */ jsx9(
1857
+ "span",
1858
+ {
1859
+ className: "txt-small text-ui-fg-subtle",
1860
+ "data-testid": "order-create-exchange-form-outbound-total-label",
1861
+ children: t("orders.exchanges.outboundTotal")
1862
+ }
1863
+ ),
1864
+ /* @__PURE__ */ jsx9(
1865
+ "span",
1866
+ {
1867
+ className: "txt-small text-ui-fg-subtle",
1868
+ "data-testid": "order-create-exchange-form-outbound-total-value",
1869
+ children: getStylizedAmount(
1870
+ outboundPreviewItems.reduce((acc, item) => {
1871
+ const action = item.actions?.find(
1872
+ (act) => act.action === "ITEM_ADD"
1873
+ );
1874
+ acc = acc + (action?.amount || 0);
1875
+ return acc;
1876
+ }, 0),
1877
+ order.currency_code
1878
+ )
1879
+ }
1880
+ )
1881
+ ]
1882
+ }
1883
+ ),
1884
+ /* @__PURE__ */ jsxs5("div", { className: "mb-2 flex items-center justify-between", children: [
1885
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.inboundShipping") }),
1886
+ /* @__PURE__ */ jsxs5("span", { className: "txt-small text-ui-fg-subtle flex items-center", children: [
1887
+ !isInboundShippingPriceEdit && /* @__PURE__ */ jsx9(
1888
+ IconButton2,
1889
+ {
1890
+ onClick: () => setIsInboundShippingPriceEdit(true),
1891
+ variant: "transparent",
1892
+ className: "text-ui-fg-muted",
1893
+ disabled: !inboundPreviewItems?.length || !inboundShippingOptionId,
1894
+ children: /* @__PURE__ */ jsx9(PencilSquare, {})
1895
+ }
1896
+ ),
1897
+ isInboundShippingPriceEdit ? /* @__PURE__ */ jsx9(
1898
+ CurrencyInput,
1899
+ {
1900
+ id: "js-inbound-shipping-input",
1901
+ onBlur: () => {
1902
+ let actionId;
1903
+ preview.shipping_methods.forEach((s) => {
1904
+ if (s.actions) {
1905
+ for (const a of s.actions) {
1906
+ if (a.action === "SHIPPING_ADD" && !!a.return_id) {
1907
+ actionId = a.id;
1908
+ }
1909
+ }
1910
+ }
1911
+ });
1912
+ const customPrice = customInboundShippingAmount.float;
1913
+ if (actionId) {
1914
+ updateInboundShipping(
1915
+ {
1916
+ actionId,
1917
+ custom_amount: customPrice
1918
+ },
1919
+ {
1920
+ onError: (error) => {
1921
+ toast3.error(error.message);
1922
+ }
1923
+ }
1924
+ );
1925
+ }
1926
+ setIsInboundShippingPriceEdit(false);
1927
+ },
1928
+ symbol: currencies[order.currency_code.toUpperCase()].symbol_native,
1929
+ code: order.currency_code,
1930
+ onValueChange: (_value, _name, values) => setCustomInboundShippingAmount({
1931
+ value: values?.value ?? "",
1932
+ float: values?.float ?? null
1933
+ }),
1934
+ value: customInboundShippingAmount.value,
1935
+ disabled: !inboundPreviewItems?.length
1936
+ }
1937
+ ) : getStylizedAmount(inboundShippingTotal, order.currency_code)
1938
+ ] })
1939
+ ] }),
1940
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between", children: [
1941
+ /* @__PURE__ */ jsx9("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.exchanges.outboundShipping") }),
1942
+ /* @__PURE__ */ jsxs5("span", { className: "txt-small text-ui-fg-subtle flex items-center", children: [
1943
+ !isOutboundShippingPriceEdit && /* @__PURE__ */ jsx9(
1944
+ IconButton2,
1945
+ {
1946
+ onClick: () => setIsOutboundShippingPriceEdit(true),
1947
+ variant: "transparent",
1948
+ className: "text-ui-fg-muted",
1949
+ disabled: !outboundPreviewItems?.length || !outboundShippingOptionId,
1950
+ children: /* @__PURE__ */ jsx9(PencilSquare, {})
1951
+ }
1952
+ ),
1953
+ isOutboundShippingPriceEdit ? /* @__PURE__ */ jsx9(
1954
+ CurrencyInput,
1955
+ {
1956
+ id: "js-outbound-shipping-input",
1957
+ onBlur: () => {
1958
+ let actionId;
1959
+ preview.shipping_methods.forEach((s) => {
1960
+ if (s.actions) {
1961
+ for (const a of s.actions) {
1962
+ if (a.action === "SHIPPING_ADD" && !a.return_id) {
1963
+ actionId = a.id;
1964
+ }
1965
+ }
1966
+ }
1967
+ });
1968
+ const customPrice = customOutboundShippingAmount.float;
1969
+ if (actionId) {
1970
+ updateOutboundShipping(
1971
+ {
1972
+ actionId,
1973
+ custom_amount: customPrice
1974
+ },
1975
+ {
1976
+ onError: (error) => {
1977
+ toast3.error(error.message);
1978
+ }
1979
+ }
1980
+ );
1981
+ }
1982
+ setIsOutboundShippingPriceEdit(false);
1983
+ },
1984
+ symbol: currencies[order.currency_code.toUpperCase()].symbol_native,
1985
+ code: order.currency_code,
1986
+ onValueChange: (_value, _name, values) => setCustomOutboundShippingAmount({
1987
+ value: values?.value ?? "",
1988
+ float: values?.float ?? null
1989
+ }),
1990
+ value: customOutboundShippingAmount.value,
1991
+ disabled: !outboundPreviewItems?.length
1992
+ }
1993
+ ) : getStylizedAmount(
1994
+ outboundShippingTotal,
1995
+ order.currency_code
1996
+ )
1997
+ ] })
1998
+ ] }),
1999
+ /* @__PURE__ */ jsxs5(
2000
+ "div",
2001
+ {
2002
+ className: "mt-4 flex items-center justify-between border-t border-dotted pt-4",
2003
+ "data-testid": "order-create-exchange-refund-amount",
2004
+ children: [
2005
+ /* @__PURE__ */ jsx9(
2006
+ "span",
2007
+ {
2008
+ className: "txt-small font-medium",
2009
+ "data-testid": "order-create-exchange-form-refund-amount-label",
2010
+ children: t("orders.exchanges.refundAmount")
2011
+ }
2012
+ ),
2013
+ /* @__PURE__ */ jsx9(
2014
+ "span",
2015
+ {
2016
+ className: "txt-small font-medium",
2017
+ "data-testid": "order-create-exchange-form-refund-amount-value",
2018
+ children: getStylizedAmount(
2019
+ preview.summary.pending_difference,
2020
+ order.currency_code
2021
+ )
2022
+ }
2023
+ )
2024
+ ]
2025
+ }
2026
+ )
2027
+ ]
2028
+ }
2029
+ ),
2030
+ /* @__PURE__ */ jsx9(
2031
+ "div",
2032
+ {
2033
+ className: "bg-ui-bg-field mt-8 rounded-lg border py-2 pl-2 pr-4",
2034
+ "data-testid": "order-create-exchange-notification",
2035
+ children: /* @__PURE__ */ jsx9(
2036
+ Form.Field,
2037
+ {
2038
+ control: form.control,
2039
+ name: "send_notification",
2040
+ render: ({ field: { onChange, value, ...field } }) => {
2041
+ return /* @__PURE__ */ jsxs5(Form.Item, { "data-testid": "order-create-exchange-notification-item", children: [
2042
+ /* @__PURE__ */ jsxs5(
2043
+ "div",
2044
+ {
2045
+ className: "flex items-center",
2046
+ "data-testid": "order-create-exchange-form-notification-control",
2047
+ children: [
2048
+ /* @__PURE__ */ jsx9(
2049
+ Form.Control,
2050
+ {
2051
+ className: "mr-4 self-start",
2052
+ "data-testid": "order-create-exchange-notification-control",
2053
+ children: /* @__PURE__ */ jsx9(
2054
+ Switch,
2055
+ {
2056
+ dir: "ltr",
2057
+ className: "mt-[2px] rtl:rotate-180",
2058
+ checked: !!value,
2059
+ onCheckedChange: onChange,
2060
+ ...field,
2061
+ "data-testid": "order-create-exchange-notification-switch"
2062
+ }
2063
+ )
2064
+ }
2065
+ ),
2066
+ /* @__PURE__ */ jsxs5("div", { className: "block", children: [
2067
+ /* @__PURE__ */ jsx9(Form.Label, { "data-testid": "order-create-exchange-notification-label", children: t("orders.returns.sendNotification") }),
2068
+ /* @__PURE__ */ jsx9(
2069
+ Form.Hint,
2070
+ {
2071
+ className: "!mt-1",
2072
+ "data-testid": "order-create-exchange-notification-hint",
2073
+ children: t("orders.returns.sendNotificationHint")
2074
+ }
2075
+ )
2076
+ ] })
2077
+ ]
2078
+ }
2079
+ ),
2080
+ /* @__PURE__ */ jsx9(Form.ErrorMessage, { "data-testid": "order-create-exchange-notification-error" })
2081
+ ] });
2082
+ }
2083
+ }
2084
+ )
2085
+ }
2086
+ ),
2087
+ /* @__PURE__ */ jsx9("div", { className: "p-8" })
2088
+ ]
2089
+ }
2090
+ )
2091
+ }
2092
+ ),
2093
+ /* @__PURE__ */ jsx9(RouteFocusModal.Footer, { "data-testid": "order-create-exchange-footer", children: /* @__PURE__ */ jsx9(
2094
+ "div",
2095
+ {
2096
+ className: "flex w-full items-center justify-end gap-x-4",
2097
+ "data-testid": "order-create-exchange-form-footer-actions",
2098
+ children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-end gap-x-2", children: [
2099
+ /* @__PURE__ */ jsx9(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx9(
2100
+ Button3,
2101
+ {
2102
+ type: "button",
2103
+ onClick: () => IS_CANCELING = true,
2104
+ variant: "secondary",
2105
+ size: "small",
2106
+ "data-testid": "order-create-exchange-cancel-button",
2107
+ children: t("orders.exchanges.cancel.title")
2108
+ }
2109
+ ) }),
2110
+ /* @__PURE__ */ jsx9(
2111
+ Button3,
2112
+ {
2113
+ type: "submit",
2114
+ variant: "primary",
2115
+ size: "small",
2116
+ isLoading: isRequestLoading,
2117
+ "data-testid": "order-create-exchange-confirm-button",
2118
+ children: t("orders.exchanges.confirm")
2119
+ },
2120
+ "submit-button"
2121
+ )
2122
+ ] })
2123
+ }
2124
+ ) })
2125
+ ]
2126
+ }
2127
+ ) });
2128
+ };
2129
+
2130
+ // src/pages/orders/order-create-exchange/exchange-create.tsx
2131
+ import { jsx as jsx10 } from "react/jsx-runtime";
2132
+ var IS_REQUEST_RUNNING = false;
2133
+ var ExchangeCreate = () => {
2134
+ const { id } = useParams();
2135
+ const navigate = useNavigate();
2136
+ const { t } = useTranslation12();
2137
+ const { order } = useOrder(id, {
2138
+ fields: DEFAULT_FIELDS
2139
+ });
2140
+ const { order: preview } = useOrderPreview(id);
2141
+ const [activeExchangeId, setActiveExchangeId] = useState6();
2142
+ const { mutateAsync: createExchange } = useCreateExchange(order.id);
2143
+ const { exchange } = useExchange(activeExchangeId, void 0, {
2144
+ enabled: !!activeExchangeId
2145
+ });
2146
+ const { return: orderReturn } = useReturn(exchange?.return_id, void 0, {
2147
+ enabled: !!exchange?.return_id
2148
+ });
2149
+ useEffect4(() => {
2150
+ async function run() {
2151
+ if (IS_REQUEST_RUNNING || !preview) {
2152
+ return;
2153
+ }
2154
+ if (preview.order_change) {
2155
+ if (preview.order_change.change_type === "exchange") {
2156
+ setActiveExchangeId(preview.order_change.exchange_id);
2157
+ } else {
2158
+ navigate(`/orders/${preview.id}`, { replace: true });
2159
+ toast4.error(t("orders.exchanges.activeChangeError"));
2160
+ }
2161
+ return;
2162
+ }
2163
+ IS_REQUEST_RUNNING = true;
2164
+ try {
2165
+ const { exchange: createdExchange } = await createExchange({
2166
+ order_id: preview.id
2167
+ });
2168
+ setActiveExchangeId(createdExchange.id);
2169
+ } catch (e) {
2170
+ toast4.error(e.message);
2171
+ navigate(`/orders/${preview.id}`, { replace: true });
2172
+ } finally {
2173
+ IS_REQUEST_RUNNING = false;
2174
+ }
2175
+ }
2176
+ run();
2177
+ }, [preview]);
2178
+ return /* @__PURE__ */ jsx10(RouteFocusModal, { "data-testid": "order-create-exchange-modal", children: exchange && preview && order && /* @__PURE__ */ jsx10(
2179
+ ExchangeCreateForm,
2180
+ {
2181
+ order,
2182
+ exchange,
2183
+ preview,
2184
+ orderReturn
2185
+ }
2186
+ ) });
2187
+ };
2188
+ export {
2189
+ ExchangeCreate as Component
2190
+ };