@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,2203 @@
1
+ import {
2
+ useAddClaimInboundItems,
3
+ useAddClaimInboundShipping,
4
+ useAddClaimOutboundItems,
5
+ useAddClaimOutboundShipping,
6
+ useCancelClaimRequest,
7
+ useClaim,
8
+ useClaimConfirmRequest,
9
+ useCreateClaim,
10
+ useDeleteClaimInboundShipping,
11
+ useDeleteClaimOutboundShipping,
12
+ useRemoveClaimInboundItem,
13
+ useRemoveClaimOutboundItem,
14
+ useUpdateClaimInboundItem,
15
+ useUpdateClaimInboundShipping,
16
+ useUpdateClaimOutboundItems,
17
+ useUpdateClaimOutboundShipping
18
+ } from "./chunk-LZALOVO3.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-claim/claim-create.tsx
138
+ import { toast as toast3 } from "@medusajs/ui";
139
+ import { useEffect as useEffect3, useState as useState5 } from "react";
140
+ import { useTranslation as useTranslation11 } from "react-i18next";
141
+ import { useNavigate, useParams } from "react-router-dom";
142
+
143
+ // src/pages/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx
144
+ import { zodResolver } from "@hookform/resolvers/zod";
145
+ import { PencilSquare } from "@medusajs/icons";
146
+ import {
147
+ Alert as Alert2,
148
+ Button as Button2,
149
+ CurrencyInput,
150
+ Heading as Heading2,
151
+ IconButton as IconButton2,
152
+ Switch,
153
+ Text as Text4,
154
+ toast as toast2,
155
+ usePrompt
156
+ } from "@medusajs/ui";
157
+ import { useEffect as useEffect2, useMemo as useMemo5, useState as useState4 } from "react";
158
+ import { useFieldArray as useFieldArray2, useForm } from "react-hook-form";
159
+ import { useTranslation as useTranslation10 } from "react-i18next";
160
+
161
+ // src/pages/orders/order-create-claim/components/add-claim-items-table/add-claim-items-table.tsx
162
+ import { useMemo as useMemo2, useState } from "react";
163
+ import { useTranslation as useTranslation3 } from "react-i18next";
164
+
165
+ // src/pages/orders/order-create-claim/components/add-claim-items-table/use-claim-item-table-columns.tsx
166
+ import { useMemo } from "react";
167
+ import { Checkbox } from "@medusajs/ui";
168
+ import { createColumnHelper } from "@tanstack/react-table";
169
+ import { useTranslation } from "react-i18next";
170
+ import { jsx } from "react/jsx-runtime";
171
+ var columnHelper = createColumnHelper();
172
+ var useClaimItemTableColumns = (currencyCode) => {
173
+ const { t } = useTranslation();
174
+ return useMemo(
175
+ () => [
176
+ columnHelper.display({
177
+ id: "select",
178
+ header: ({ table }) => {
179
+ return /* @__PURE__ */ jsx(
180
+ Checkbox,
181
+ {
182
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
183
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
184
+ }
185
+ );
186
+ },
187
+ cell: ({ row }) => {
188
+ const isSelectable = row.getCanSelect();
189
+ return /* @__PURE__ */ jsx(
190
+ Checkbox,
191
+ {
192
+ disabled: !isSelectable,
193
+ checked: row.getIsSelected(),
194
+ onCheckedChange: (value) => row.toggleSelected(!!value),
195
+ onClick: (e) => {
196
+ e.stopPropagation();
197
+ }
198
+ }
199
+ );
200
+ }
201
+ }),
202
+ columnHelper.display({
203
+ id: "product",
204
+ header: () => /* @__PURE__ */ jsx(ProductHeader, {}),
205
+ cell: ({ row }) => /* @__PURE__ */ jsx(
206
+ ProductCell,
207
+ {
208
+ product: {
209
+ thumbnail: row.original.thumbnail,
210
+ title: row.original.product_title
211
+ }
212
+ }
213
+ )
214
+ }),
215
+ columnHelper.accessor("variant.sku", {
216
+ header: t("fields.sku"),
217
+ cell: ({ getValue }) => {
218
+ return getValue() || "-";
219
+ }
220
+ }),
221
+ columnHelper.accessor("variant.title", {
222
+ header: t("fields.variant")
223
+ }),
224
+ columnHelper.accessor("quantity", {
225
+ header: () => /* @__PURE__ */ jsx("div", { className: "flex size-full items-center overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t("fields.quantity") }) }),
226
+ cell: ({ row }) => {
227
+ return getReturnableQuantity(row.original);
228
+ }
229
+ }),
230
+ columnHelper.accessor("refundable_total", {
231
+ 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") }) }),
232
+ cell: ({ getValue }) => {
233
+ const amount = getValue() || 0;
234
+ const stylized = getStylizedAmount(amount, currencyCode);
235
+ return /* @__PURE__ */ jsx("div", { className: "flex size-full items-center justify-end overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: stylized }) });
236
+ }
237
+ })
238
+ ],
239
+ [t, currencyCode]
240
+ );
241
+ };
242
+
243
+ // src/pages/orders/order-create-claim/components/add-claim-items-table/use-claim-item-table-filters.tsx
244
+ import { useTranslation as useTranslation2 } from "react-i18next";
245
+ var useClaimItemTableFilters = () => {
246
+ const { t } = useTranslation2();
247
+ const filters = [
248
+ {
249
+ key: "returnable_quantity",
250
+ label: t("orders.returns.returnableQuantityLabel"),
251
+ type: "number"
252
+ },
253
+ {
254
+ key: "refundable_amount",
255
+ label: t("orders.returns.refundableAmountLabel"),
256
+ type: "number"
257
+ },
258
+ {
259
+ key: "created_at",
260
+ label: t("fields.createdAt"),
261
+ type: "date"
262
+ },
263
+ {
264
+ key: "updated_at",
265
+ label: t("fields.updatedAt"),
266
+ type: "date"
267
+ }
268
+ ];
269
+ return filters;
270
+ };
271
+
272
+ // src/pages/orders/order-create-claim/components/add-claim-items-table/use-claim-item-table-query.tsx
273
+ var useClaimItemTableQuery = ({
274
+ pageSize = 50,
275
+ prefix
276
+ }) => {
277
+ const raw = useQueryParams(
278
+ [
279
+ "q",
280
+ "offset",
281
+ "order",
282
+ "created_at",
283
+ "updated_at",
284
+ "returnable_quantity",
285
+ "refundable_amount"
286
+ ],
287
+ prefix
288
+ );
289
+ const {
290
+ offset,
291
+ created_at,
292
+ updated_at,
293
+ refundable_amount,
294
+ returnable_quantity,
295
+ ...rest
296
+ } = raw;
297
+ const searchParams = {
298
+ ...rest,
299
+ limit: pageSize,
300
+ offset: offset ? Number(offset) : 0,
301
+ created_at: created_at ? JSON.parse(created_at) : void 0,
302
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0,
303
+ refundable_amount: refundable_amount ? JSON.parse(refundable_amount) : void 0,
304
+ returnable_quantity: returnable_quantity ? JSON.parse(returnable_quantity) : void 0
305
+ };
306
+ return { searchParams, raw };
307
+ };
308
+
309
+ // src/pages/orders/order-create-claim/components/add-claim-items-table/add-claim-items-table.tsx
310
+ import { jsx as jsx2 } from "react/jsx-runtime";
311
+ var PAGE_SIZE = 50;
312
+ var PREFIX = "rit";
313
+ var AddClaimItemsTable = ({
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 } = useClaimItemTableQuery({
332
+ pageSize: PAGE_SIZE,
333
+ prefix: PREFIX
334
+ });
335
+ const queriedItems = useMemo2(() => {
336
+ const {
337
+ order,
338
+ offset,
339
+ limit,
340
+ q,
341
+ created_at,
342
+ updated_at,
343
+ refundable_amount,
344
+ returnable_quantity
345
+ } = searchParams;
346
+ let results = items;
347
+ if (q) {
348
+ results = results.filter((i) => {
349
+ return i.product_title?.toLowerCase().includes(q.toLowerCase()) || i.variant_title?.toLowerCase().includes(q.toLowerCase()) || i.variant_sku?.toLowerCase().includes(q.toLowerCase());
350
+ });
351
+ }
352
+ if (order) {
353
+ const direction = order[0] === "-" ? "desc" : "asc";
354
+ const field = order.replace("-", "");
355
+ results = sortItems(results, field, direction);
356
+ }
357
+ if (created_at) {
358
+ results = filterByDate(results, created_at, "created_at");
359
+ }
360
+ if (updated_at) {
361
+ results = filterByDate(results, updated_at, "updated_at");
362
+ }
363
+ if (returnable_quantity) {
364
+ results = filterByNumber(
365
+ results,
366
+ returnable_quantity,
367
+ "returnable_quantity",
368
+ currencyCode
369
+ );
370
+ }
371
+ if (refundable_amount) {
372
+ results = filterByNumber(
373
+ results,
374
+ refundable_amount,
375
+ "refundable_amount",
376
+ currencyCode
377
+ );
378
+ }
379
+ return results.slice(offset, offset + limit);
380
+ }, [items, currencyCode, searchParams]);
381
+ const columns = useClaimItemTableColumns(currencyCode);
382
+ const filters = useClaimItemTableFilters();
383
+ const { table } = useDataTable({
384
+ data: queriedItems,
385
+ columns,
386
+ count: queriedItems.length,
387
+ enablePagination: true,
388
+ getRowId: (row) => row.id,
389
+ pageSize: PAGE_SIZE,
390
+ enableRowSelection: (row) => {
391
+ return getReturnableQuantity(row.original) > 0;
392
+ },
393
+ rowSelection: {
394
+ state: rowSelection,
395
+ updater
396
+ }
397
+ });
398
+ return /* @__PURE__ */ jsx2("div", { className: "flex size-full flex-col overflow-hidden", children: /* @__PURE__ */ jsx2(
399
+ _DataTable,
400
+ {
401
+ table,
402
+ columns,
403
+ pageSize: PAGE_SIZE,
404
+ count: queriedItems.length,
405
+ filters,
406
+ pagination: true,
407
+ layout: "fill",
408
+ search: true,
409
+ orderBy: [
410
+ { key: "product_title", label: t("fields.product") },
411
+ { key: "variant_title", label: t("fields.variant") },
412
+ { key: "sku", label: t("fields.sku") },
413
+ {
414
+ key: "returnable_quantity",
415
+ label: t("orders.fields.returnableQuantity")
416
+ },
417
+ {
418
+ key: "refundable_amount",
419
+ label: t("orders.fields.refundableAmount")
420
+ }
421
+ ],
422
+ prefix: PREFIX,
423
+ queryObject: raw
424
+ }
425
+ ) });
426
+ };
427
+ var sortItems = (items, field, direction) => {
428
+ return items.sort((a, b) => {
429
+ let aValue;
430
+ let bValue;
431
+ if (field === "product_title") {
432
+ aValue = a.product_title;
433
+ bValue = b.product_title;
434
+ } else if (field === "variant_title") {
435
+ aValue = a.variant_title;
436
+ bValue = b.variant_title;
437
+ } else if (field === "sku") {
438
+ aValue = a.variant_sku;
439
+ bValue = b.variant_sku;
440
+ } else if (field === "returnable_quantity") {
441
+ aValue = a.quantity - (a.returned_quantity || 0);
442
+ bValue = b.quantity - (b.returned_quantity || 0);
443
+ } else if (field === "refundable_amount") {
444
+ aValue = a.refundable || 0;
445
+ bValue = b.refundable || 0;
446
+ }
447
+ if (aValue < bValue) {
448
+ return direction === "asc" ? -1 : 1;
449
+ }
450
+ if (aValue > bValue) {
451
+ return direction === "asc" ? 1 : -1;
452
+ }
453
+ return 0;
454
+ });
455
+ };
456
+ var filterByDate = (items, date, field) => {
457
+ const { gt, gte, lt, lte } = date;
458
+ return items.filter((i) => {
459
+ const itemDate = new Date(i[field]);
460
+ let isValid = true;
461
+ if (gt) {
462
+ isValid = isValid && itemDate > new Date(gt);
463
+ }
464
+ if (gte) {
465
+ isValid = isValid && itemDate >= new Date(gte);
466
+ }
467
+ if (lt) {
468
+ isValid = isValid && itemDate < new Date(lt);
469
+ }
470
+ if (lte) {
471
+ isValid = isValid && itemDate <= new Date(lte);
472
+ }
473
+ return isValid;
474
+ });
475
+ };
476
+ var defaultOperators = {
477
+ eq: void 0,
478
+ gt: void 0,
479
+ gte: void 0,
480
+ lt: void 0,
481
+ lte: void 0
482
+ };
483
+ var filterByNumber = (items, value, field, currency_code) => {
484
+ const { eq, gt, lt, gte, lte } = typeof value === "object" ? { ...defaultOperators, ...value } : { ...defaultOperators, eq: value };
485
+ return items.filter((i) => {
486
+ const returnableQuantity = i.quantity - (i.returned_quantity || 0);
487
+ const refundableAmount = getStylizedAmount(i.refundable || 0, currency_code);
488
+ const itemValue = field === "returnable_quantity" ? returnableQuantity : refundableAmount;
489
+ if (eq) {
490
+ return itemValue === eq;
491
+ }
492
+ let isValid = true;
493
+ if (gt) {
494
+ isValid = isValid && itemValue > gt;
495
+ }
496
+ if (gte) {
497
+ isValid = isValid && itemValue >= gte;
498
+ }
499
+ if (lt) {
500
+ isValid = isValid && itemValue < lt;
501
+ }
502
+ if (lte) {
503
+ isValid = isValid && itemValue <= lte;
504
+ }
505
+ return isValid;
506
+ });
507
+ };
508
+
509
+ // src/pages/orders/order-create-claim/components/claim-create-form/claim-inbound-item.tsx
510
+ import { ChatBubble, DocumentText, XCircle, XMark } from "@medusajs/icons";
511
+ import { IconButton, Input, Text } from "@medusajs/ui";
512
+ import { useTranslation as useTranslation4 } from "react-i18next";
513
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
514
+ function ClaimInboundItem({
515
+ item,
516
+ previewItem,
517
+ currencyCode,
518
+ form,
519
+ onRemove,
520
+ onUpdate,
521
+ index
522
+ }) {
523
+ const { t } = useTranslation4();
524
+ const { return_reasons = [] } = useReturnReasons({ fields: "+label" });
525
+ const formItem = form.watch(`inbound_items.${index}`);
526
+ const showReturnReason = typeof formItem.reason_id === "string";
527
+ const showNote = typeof formItem.note === "string";
528
+ return /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl ", children: [
529
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-x-2 gap-y-2 border-b p-3 text-sm md:flex-row", children: [
530
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center gap-x-3", children: [
531
+ /* @__PURE__ */ jsx3(Thumbnail, { src: item.thumbnail }),
532
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
533
+ /* @__PURE__ */ jsxs("div", { children: [
534
+ /* @__PURE__ */ jsxs(Text, { className: "txt-small", as: "span", weight: "plus", children: [
535
+ item.title,
536
+ " "
537
+ ] }),
538
+ item.variant_sku && /* @__PURE__ */ jsxs("span", { children: [
539
+ "(",
540
+ item.variant_sku,
541
+ ")"
542
+ ] })
543
+ ] }),
544
+ /* @__PURE__ */ jsx3(Text, { as: "div", className: "text-ui-fg-subtle txt-small", children: item.product_title })
545
+ ] })
546
+ ] }),
547
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 justify-between", children: [
548
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-grow items-center gap-2", children: [
549
+ /* @__PURE__ */ jsx3(
550
+ Form.Field,
551
+ {
552
+ control: form.control,
553
+ name: `inbound_items.${index}.quantity`,
554
+ render: ({ field }) => {
555
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
556
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
557
+ Input,
558
+ {
559
+ ...field,
560
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
561
+ min: 1,
562
+ max: item.quantity,
563
+ type: "number",
564
+ onBlur: (e) => {
565
+ const val = e.target.value;
566
+ const payload = val === "" ? null : Number(val);
567
+ field.onChange(payload);
568
+ if (payload) {
569
+ onUpdate({ quantity: payload });
570
+ }
571
+ }
572
+ }
573
+ ) }),
574
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
575
+ ] });
576
+ }
577
+ }
578
+ ),
579
+ /* @__PURE__ */ jsx3(Text, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
580
+ ] }),
581
+ /* @__PURE__ */ jsx3("div", { className: "text-ui-fg-subtle txt-small mr-2 flex flex-shrink-0", children: /* @__PURE__ */ jsx3(
582
+ MoneyAmountCell,
583
+ {
584
+ currencyCode,
585
+ amount: previewItem.return_requested_total
586
+ }
587
+ ) }),
588
+ /* @__PURE__ */ jsx3(
589
+ ActionMenu,
590
+ {
591
+ groups: [
592
+ {
593
+ actions: [
594
+ !showReturnReason && {
595
+ label: t("actions.addReason"),
596
+ onClick: () => form.setValue(`inbound_items.${index}.reason_id`, ""),
597
+ icon: /* @__PURE__ */ jsx3(ChatBubble, {})
598
+ },
599
+ !showNote && {
600
+ label: t("actions.addNote"),
601
+ onClick: () => form.setValue(`inbound_items.${index}.note`, ""),
602
+ icon: /* @__PURE__ */ jsx3(DocumentText, {})
603
+ },
604
+ {
605
+ label: t("actions.remove"),
606
+ onClick: onRemove,
607
+ icon: /* @__PURE__ */ jsx3(XCircle, {})
608
+ }
609
+ ].filter(Boolean)
610
+ }
611
+ ]
612
+ }
613
+ )
614
+ ] })
615
+ ] }),
616
+ /* @__PURE__ */ jsxs(Fragment, { children: [
617
+ showReturnReason && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
618
+ /* @__PURE__ */ jsxs("div", { children: [
619
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.reason") }),
620
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.reasonHint") })
621
+ ] }),
622
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
623
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
624
+ Form.Field,
625
+ {
626
+ control: form.control,
627
+ name: `inbound_items.${index}.reason_id`,
628
+ render: ({ field: { ref, value, onChange, ...field } }) => {
629
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
630
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
631
+ Combobox,
632
+ {
633
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
634
+ value,
635
+ onChange: (v) => {
636
+ onUpdate({ reason_id: v });
637
+ onChange(v);
638
+ },
639
+ ...field,
640
+ options: return_reasons.map((reason) => ({
641
+ label: reason.label,
642
+ value: reason.id
643
+ }))
644
+ }
645
+ ) }),
646
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
647
+ ] });
648
+ }
649
+ }
650
+ ) }),
651
+ /* @__PURE__ */ jsx3(
652
+ IconButton,
653
+ {
654
+ type: "button",
655
+ className: "flex-shrink",
656
+ variant: "transparent",
657
+ onClick: () => {
658
+ form.setValue(`inbound_items.${index}.reason_id`, null);
659
+ onUpdate({ reason_id: null });
660
+ },
661
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
662
+ }
663
+ )
664
+ ] })
665
+ ] }),
666
+ showNote && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
667
+ /* @__PURE__ */ jsxs("div", { children: [
668
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.note") }),
669
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.noteHint") })
670
+ ] }),
671
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
672
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
673
+ Form.Field,
674
+ {
675
+ control: form.control,
676
+ name: `inbound_items.${index}.note`,
677
+ render: ({ field: { ref, ...field } }) => {
678
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
679
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
680
+ Input,
681
+ {
682
+ ...field,
683
+ onBlur: () => {
684
+ field.onChange(field.value);
685
+ onUpdate({ internal_note: field.value });
686
+ },
687
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover"
688
+ }
689
+ ) }),
690
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
691
+ ] });
692
+ }
693
+ }
694
+ ) }),
695
+ /* @__PURE__ */ jsx3(
696
+ IconButton,
697
+ {
698
+ type: "button",
699
+ className: "flex-shrink",
700
+ variant: "transparent",
701
+ onClick: () => {
702
+ form.setValue(`inbound_items.${index}.note`, null);
703
+ onUpdate({ internal_note: null });
704
+ },
705
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
706
+ }
707
+ )
708
+ ] })
709
+ ] })
710
+ ] })
711
+ ] });
712
+ }
713
+
714
+ // src/pages/orders/order-create-claim/components/claim-create-form/schema.ts
715
+ import { z } from "zod";
716
+ var ClaimCreateSchema = z.object({
717
+ inbound_items: z.array(
718
+ z.object({
719
+ item_id: z.string(),
720
+ quantity: z.number(),
721
+ reason_id: z.string().nullish(),
722
+ note: z.string().nullish()
723
+ })
724
+ ),
725
+ outbound_items: z.array(
726
+ z.object({
727
+ item_id: z.string(),
728
+ // TODO: variant id?
729
+ quantity: z.number()
730
+ })
731
+ ),
732
+ location_id: z.string().optional(),
733
+ inbound_option_id: z.string().nullish(),
734
+ outbound_option_id: z.string().nullish(),
735
+ send_notification: z.boolean().optional()
736
+ });
737
+
738
+ // src/pages/orders/order-create-claim/components/claim-create-form/claim-outbound-section.tsx
739
+ import { Alert, Button, Heading, Text as Text3, toast } from "@medusajs/ui";
740
+ import { useEffect, useMemo as useMemo4, useState as useState3 } from "react";
741
+ import { useFieldArray } from "react-hook-form";
742
+ import { useTranslation as useTranslation9 } from "react-i18next";
743
+
744
+ // src/pages/orders/order-create-claim/components/add-claim-outbound-items-table/add-claim-outbound-items-table.tsx
745
+ import { useState as useState2 } from "react";
746
+ import { useTranslation as useTranslation7 } from "react-i18next";
747
+
748
+ // src/pages/orders/order-create-claim/components/add-claim-outbound-items-table/use-claim-outbound-item-table-columns.tsx
749
+ import { Checkbox as Checkbox2 } from "@medusajs/ui";
750
+ import { createColumnHelper as createColumnHelper2 } from "@tanstack/react-table";
751
+ import { useMemo as useMemo3 } from "react";
752
+ import { useTranslation as useTranslation5 } from "react-i18next";
753
+ import { jsx as jsx4 } from "react/jsx-runtime";
754
+ var columnHelper2 = createColumnHelper2();
755
+ var useClaimOutboundItemTableColumns = (currencyCode) => {
756
+ const { t } = useTranslation5();
757
+ return useMemo3(
758
+ () => [
759
+ columnHelper2.display({
760
+ id: "select",
761
+ header: ({ table }) => {
762
+ return /* @__PURE__ */ jsx4(
763
+ Checkbox2,
764
+ {
765
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
766
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
767
+ }
768
+ );
769
+ },
770
+ cell: ({ row }) => {
771
+ const isSelectable = row.getCanSelect();
772
+ return /* @__PURE__ */ jsx4(
773
+ Checkbox2,
774
+ {
775
+ disabled: !isSelectable,
776
+ checked: row.getIsSelected(),
777
+ onCheckedChange: (value) => row.toggleSelected(!!value),
778
+ onClick: (e) => {
779
+ e.stopPropagation();
780
+ }
781
+ }
782
+ );
783
+ }
784
+ }),
785
+ columnHelper2.display({
786
+ id: "product",
787
+ header: () => /* @__PURE__ */ jsx4(ProductHeader, {}),
788
+ cell: ({ row }) => {
789
+ return /* @__PURE__ */ jsx4(ProductCell, { product: row.original.product });
790
+ }
791
+ }),
792
+ columnHelper2.accessor("sku", {
793
+ header: t("fields.sku"),
794
+ cell: ({ getValue }) => {
795
+ return getValue() || "-";
796
+ }
797
+ }),
798
+ columnHelper2.accessor("title", {
799
+ header: t("fields.title")
800
+ })
801
+ ],
802
+ [t, currencyCode]
803
+ );
804
+ };
805
+
806
+ // src/pages/orders/order-create-claim/components/add-claim-outbound-items-table/use-claim-outbound-item-table-filters.tsx
807
+ import { useTranslation as useTranslation6 } from "react-i18next";
808
+ var useClaimOutboundItemTableFilters = () => {
809
+ const { t } = useTranslation6();
810
+ const filters = [
811
+ {
812
+ key: "created_at",
813
+ label: t("fields.createdAt"),
814
+ type: "date"
815
+ },
816
+ {
817
+ key: "updated_at",
818
+ label: t("fields.updatedAt"),
819
+ type: "date"
820
+ }
821
+ ];
822
+ return filters;
823
+ };
824
+
825
+ // src/pages/orders/order-create-claim/components/add-claim-outbound-items-table/use-claim-outbound-item-table-query.tsx
826
+ var useClaimOutboundItemTableQuery = ({
827
+ pageSize = 50,
828
+ prefix
829
+ }) => {
830
+ const raw = useQueryParams(
831
+ ["q", "offset", "order", "created_at", "updated_at"],
832
+ prefix
833
+ );
834
+ const { offset, created_at, updated_at, ...rest } = raw;
835
+ const searchParams = {
836
+ ...rest,
837
+ limit: pageSize,
838
+ offset: offset ? Number(offset) : 0,
839
+ created_at: created_at ? JSON.parse(created_at) : void 0,
840
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0
841
+ };
842
+ return { searchParams, raw };
843
+ };
844
+
845
+ // src/pages/orders/order-create-claim/components/add-claim-outbound-items-table/add-claim-outbound-items-table.tsx
846
+ import { jsx as jsx5 } from "react/jsx-runtime";
847
+ var PAGE_SIZE2 = 50;
848
+ var PREFIX2 = "rit";
849
+ var AddClaimOutboundItemsTable = ({
850
+ onSelectionChange,
851
+ selectedItems,
852
+ currencyCode
853
+ }) => {
854
+ const { t } = useTranslation7();
855
+ const [rowSelection, setRowSelection] = useState2(
856
+ selectedItems.reduce((acc, id) => {
857
+ acc[id] = true;
858
+ return acc;
859
+ }, {})
860
+ );
861
+ const updater = (fn) => {
862
+ const newState = typeof fn === "function" ? fn(rowSelection) : fn;
863
+ setRowSelection(newState);
864
+ onSelectionChange(Object.keys(newState));
865
+ };
866
+ const { searchParams, raw } = useClaimOutboundItemTableQuery({
867
+ pageSize: PAGE_SIZE2,
868
+ prefix: PREFIX2
869
+ });
870
+ const { variants = [], count } = useVariants({
871
+ ...searchParams,
872
+ fields: "*inventory_items.inventory.location_levels,+inventory_quantity"
873
+ });
874
+ const columns = useClaimOutboundItemTableColumns(currencyCode);
875
+ const filters = useClaimOutboundItemTableFilters();
876
+ const { table } = useDataTable({
877
+ data: variants,
878
+ columns,
879
+ count,
880
+ enablePagination: true,
881
+ getRowId: (row) => row.id,
882
+ pageSize: PAGE_SIZE2,
883
+ enableRowSelection: (_row) => {
884
+ return true;
885
+ },
886
+ rowSelection: {
887
+ state: rowSelection,
888
+ updater
889
+ },
890
+ prefix: PREFIX2
891
+ });
892
+ return /* @__PURE__ */ jsx5("div", { className: "flex size-full flex-col overflow-hidden", children: /* @__PURE__ */ jsx5(
893
+ _DataTable,
894
+ {
895
+ table,
896
+ columns,
897
+ pageSize: PAGE_SIZE2,
898
+ count,
899
+ filters,
900
+ pagination: true,
901
+ layout: "fill",
902
+ search: true,
903
+ orderBy: [
904
+ { key: "product_id", label: t("fields.product") },
905
+ { key: "title", label: t("fields.title") },
906
+ { key: "sku", label: t("fields.sku") }
907
+ ],
908
+ prefix: PREFIX2,
909
+ queryObject: raw
910
+ }
911
+ ) });
912
+ };
913
+
914
+ // src/pages/orders/order-create-claim/components/claim-create-form/claim-outbound-item.tsx
915
+ import { XCircle as XCircle2 } from "@medusajs/icons";
916
+ import { Input as Input2, Text as Text2 } from "@medusajs/ui";
917
+ import { useTranslation as useTranslation8 } from "react-i18next";
918
+ import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
919
+ function ClaimOutboundItem({
920
+ previewItem,
921
+ currencyCode,
922
+ form,
923
+ onRemove,
924
+ onUpdate,
925
+ index
926
+ }) {
927
+ const { t } = useTranslation8();
928
+ return /* @__PURE__ */ jsx6("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl ", children: /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-x-2 gap-y-2 border-b p-3 text-sm md:flex-row", children: [
929
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-1 items-center gap-x-3", children: [
930
+ /* @__PURE__ */ jsx6(Thumbnail, { src: previewItem.thumbnail }),
931
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
932
+ /* @__PURE__ */ jsxs2("div", { children: [
933
+ /* @__PURE__ */ jsxs2(Text2, { className: "txt-small", as: "span", weight: "plus", children: [
934
+ previewItem.title,
935
+ " "
936
+ ] }),
937
+ previewItem.variant_sku && /* @__PURE__ */ jsxs2("span", { children: [
938
+ "(",
939
+ previewItem.variant_sku,
940
+ ")"
941
+ ] })
942
+ ] }),
943
+ /* @__PURE__ */ jsx6(Text2, { as: "div", className: "text-ui-fg-subtle txt-small", children: previewItem.subtitle })
944
+ ] })
945
+ ] }),
946
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-1 justify-between", children: [
947
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-grow items-center gap-2", children: [
948
+ /* @__PURE__ */ jsx6(
949
+ Form.Field,
950
+ {
951
+ control: form.control,
952
+ name: `outbound_items.${index}.quantity`,
953
+ render: ({ field }) => {
954
+ return /* @__PURE__ */ jsxs2(Form.Item, { children: [
955
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(
956
+ Input2,
957
+ {
958
+ ...field,
959
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
960
+ min: 1,
961
+ type: "number",
962
+ onBlur: (e) => {
963
+ const val = e.target.value;
964
+ const payload = val === "" ? null : Number(val);
965
+ field.onChange(payload);
966
+ if (payload) {
967
+ onUpdate({ quantity: payload });
968
+ }
969
+ }
970
+ }
971
+ ) }),
972
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
973
+ ] });
974
+ }
975
+ }
976
+ ),
977
+ /* @__PURE__ */ jsx6(Text2, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
978
+ ] }),
979
+ /* @__PURE__ */ jsx6("div", { className: "text-ui-fg-subtle txt-small mr-2 flex flex-shrink-0", children: /* @__PURE__ */ jsx6(
980
+ MoneyAmountCell,
981
+ {
982
+ currencyCode,
983
+ amount: previewItem.total
984
+ }
985
+ ) }),
986
+ /* @__PURE__ */ jsx6(
987
+ ActionMenu,
988
+ {
989
+ groups: [
990
+ {
991
+ actions: [
992
+ {
993
+ label: t("actions.remove"),
994
+ onClick: onRemove,
995
+ icon: /* @__PURE__ */ jsx6(XCircle2, {})
996
+ }
997
+ ].filter(Boolean)
998
+ }
999
+ ]
1000
+ }
1001
+ )
1002
+ ] })
1003
+ ] }) });
1004
+ }
1005
+
1006
+ // src/pages/orders/order-create-claim/components/claim-create-form/claim-outbound-section.tsx
1007
+ import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
1008
+ var itemsToAdd = [];
1009
+ var itemsToRemove = [];
1010
+ var ClaimOutboundSection = ({
1011
+ order,
1012
+ preview,
1013
+ claim,
1014
+ form
1015
+ }) => {
1016
+ const { t } = useTranslation9();
1017
+ const { setIsOpen } = useStackedModal();
1018
+ const [inventoryMap, setInventoryMap] = useState3({});
1019
+ const { shipping_options = [] } = useOrderShippingOptions(order.id);
1020
+ const outboundShippingOptions = shipping_options.filter(
1021
+ (so) => !so.rules?.find((r) => r.attribute === "is_return" && r.value === "true")
1022
+ );
1023
+ const { mutateAsync: addOutboundShipping } = useAddClaimOutboundShipping(
1024
+ claim.id,
1025
+ order.id
1026
+ );
1027
+ const { mutateAsync: deleteOutboundShipping } = useDeleteClaimOutboundShipping(claim.id, order.id);
1028
+ const { mutateAsync: addOutboundItem } = useAddClaimOutboundItems(
1029
+ claim.id,
1030
+ order.id
1031
+ );
1032
+ const { mutateAsync: updateOutboundItem } = useUpdateClaimOutboundItems(
1033
+ claim.id,
1034
+ order.id
1035
+ );
1036
+ const { mutateAsync: removeOutboundItem } = useRemoveClaimOutboundItem(
1037
+ claim.id,
1038
+ order.id
1039
+ );
1040
+ const previewOutboundItems = useMemo4(
1041
+ () => preview?.items?.filter(
1042
+ (i) => !!i.actions?.find(
1043
+ (a) => a.claim_id === claim.id && a.action === "ITEM_ADD"
1044
+ )
1045
+ ),
1046
+ [preview.items]
1047
+ );
1048
+ const variantItemMap = useMemo4(
1049
+ () => new Map(order?.items?.map((i) => [i.variant_id, i])),
1050
+ [order.items]
1051
+ );
1052
+ const {
1053
+ fields: outboundItems,
1054
+ append,
1055
+ remove,
1056
+ update
1057
+ } = useFieldArray({
1058
+ name: "outbound_items",
1059
+ control: form.control
1060
+ });
1061
+ const variantOutboundMap = useMemo4(
1062
+ () => new Map(previewOutboundItems.map((i) => [i.variant_id, i])),
1063
+ [previewOutboundItems, outboundItems]
1064
+ );
1065
+ useEffect(() => {
1066
+ const existingItemsMap = {};
1067
+ previewOutboundItems.forEach((i) => {
1068
+ const ind = outboundItems.findIndex((field) => field.item_id === i.id);
1069
+ existingItemsMap[i.id] = true;
1070
+ if (ind > -1) {
1071
+ if (outboundItems[ind].quantity !== i.detail.quantity) {
1072
+ update(ind, {
1073
+ ...outboundItems[ind],
1074
+ quantity: i.detail.quantity
1075
+ });
1076
+ }
1077
+ } else {
1078
+ append(
1079
+ {
1080
+ item_id: i.id,
1081
+ quantity: i.detail.quantity,
1082
+ variant_id: i.variant_id
1083
+ },
1084
+ { shouldFocus: false }
1085
+ );
1086
+ }
1087
+ });
1088
+ outboundItems.forEach((i, ind) => {
1089
+ if (!(i.item_id in existingItemsMap)) {
1090
+ remove(ind);
1091
+ }
1092
+ });
1093
+ }, [previewOutboundItems]);
1094
+ const locationId = form.watch("location_id");
1095
+ const showOutboundItemsPlaceholder = !outboundItems.length;
1096
+ const onItemsSelected = async () => {
1097
+ itemsToAdd.length && await addOutboundItem(
1098
+ {
1099
+ items: itemsToAdd.map((variantId) => ({
1100
+ variant_id: variantId,
1101
+ quantity: 1
1102
+ }))
1103
+ },
1104
+ {
1105
+ onError: (error) => {
1106
+ toast.error(error.message);
1107
+ }
1108
+ }
1109
+ );
1110
+ for (const itemToRemove of itemsToRemove) {
1111
+ const action = previewOutboundItems.find((i) => i.variant_id === itemToRemove)?.actions?.find((a) => a.action === "ITEM_ADD");
1112
+ if (action?.id) {
1113
+ await removeOutboundItem(action?.id, {
1114
+ onError: (error) => {
1115
+ toast.error(error.message);
1116
+ }
1117
+ });
1118
+ }
1119
+ }
1120
+ setIsOpen("outbound-items", false);
1121
+ };
1122
+ const onShippingOptionChange = async (selectedOptionId) => {
1123
+ const outboundShippingMethods = preview.shipping_methods.filter((s) => {
1124
+ const action = s.actions?.find(
1125
+ (a) => a.action === "SHIPPING_ADD" && !a.return_id
1126
+ );
1127
+ return action && !!!action?.return_id;
1128
+ });
1129
+ const promises = outboundShippingMethods.filter(Boolean).map((outboundShippingMethod) => {
1130
+ const action = outboundShippingMethod.actions?.find(
1131
+ (a) => a.action === "SHIPPING_ADD" && !a.return_id
1132
+ );
1133
+ if (action) {
1134
+ return deleteOutboundShipping(action.id);
1135
+ }
1136
+ });
1137
+ await Promise.all(promises);
1138
+ if (selectedOptionId) {
1139
+ await addOutboundShipping(
1140
+ { shipping_option_id: selectedOptionId },
1141
+ {
1142
+ onError: (error) => {
1143
+ toast.error(error.message);
1144
+ }
1145
+ }
1146
+ );
1147
+ }
1148
+ };
1149
+ const showLevelsWarning = useMemo4(() => {
1150
+ if (!locationId) {
1151
+ return false;
1152
+ }
1153
+ const allItemsHaveLocation = outboundItems.map((i) => {
1154
+ const item = variantItemMap.get(i.variant_id);
1155
+ if (!item?.variant_id || !item?.variant) {
1156
+ return true;
1157
+ }
1158
+ if (!item.variant?.manage_inventory) {
1159
+ return true;
1160
+ }
1161
+ return inventoryMap[item.variant_id]?.find(
1162
+ (l) => l.location_id === locationId
1163
+ );
1164
+ }).every(Boolean);
1165
+ return !allItemsHaveLocation;
1166
+ }, [outboundItems, inventoryMap, locationId]);
1167
+ useEffect(() => {
1168
+ const getInventoryMap = async () => {
1169
+ const ret = {};
1170
+ if (!outboundItems.length) {
1171
+ return ret;
1172
+ }
1173
+ const variantIds = outboundItems.map((item) => item?.variant_id).filter(Boolean);
1174
+ const variants = (await sdk.admin.productVariant.list({
1175
+ id: variantIds,
1176
+ fields: "*inventory.location_levels"
1177
+ })).variants;
1178
+ variants.forEach((variant) => {
1179
+ ret[variant.id] = variant.inventory?.[0]?.location_levels || [];
1180
+ });
1181
+ return ret;
1182
+ };
1183
+ getInventoryMap().then((map) => {
1184
+ setInventoryMap(map);
1185
+ });
1186
+ }, [outboundItems]);
1187
+ return /* @__PURE__ */ jsxs3("div", { children: [
1188
+ /* @__PURE__ */ jsxs3("div", { className: "mt-8 flex items-center justify-between", children: [
1189
+ /* @__PURE__ */ jsx7(Heading, { level: "h2", children: t("orders.returns.outbound") }),
1190
+ /* @__PURE__ */ jsxs3(StackedFocusModal, { id: "outbound-items", children: [
1191
+ /* @__PURE__ */ jsx7(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx7("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") }) }),
1192
+ /* @__PURE__ */ jsxs3(StackedFocusModal.Content, { children: [
1193
+ /* @__PURE__ */ jsx7(StackedFocusModal.Header, {}),
1194
+ /* @__PURE__ */ jsx7(
1195
+ AddClaimOutboundItemsTable,
1196
+ {
1197
+ selectedItems: outboundItems.map((i) => i.variant_id),
1198
+ currencyCode: order.currency_code,
1199
+ onSelectionChange: (finalSelection) => {
1200
+ const alreadySelected = outboundItems.map((i) => i.variant_id);
1201
+ itemsToAdd = finalSelection.filter(
1202
+ (selection) => !alreadySelected.includes(selection)
1203
+ );
1204
+ itemsToRemove = alreadySelected.filter(
1205
+ (selection) => !finalSelection.includes(selection)
1206
+ );
1207
+ }
1208
+ }
1209
+ ),
1210
+ /* @__PURE__ */ jsx7(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsx7("div", { className: "flex w-full items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-x-2", children: [
1211
+ /* @__PURE__ */ jsx7(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx7(Button, { type: "button", variant: "secondary", size: "small", children: t("actions.cancel") }) }),
1212
+ /* @__PURE__ */ jsx7(
1213
+ Button,
1214
+ {
1215
+ type: "submit",
1216
+ variant: "primary",
1217
+ size: "small",
1218
+ role: "button",
1219
+ onClick: async () => await onItemsSelected(),
1220
+ children: t("actions.save")
1221
+ },
1222
+ "submit-button"
1223
+ )
1224
+ ] }) }) })
1225
+ ] })
1226
+ ] })
1227
+ ] }),
1228
+ showOutboundItemsPlaceholder && /* @__PURE__ */ jsx7(ItemPlaceholder, {}),
1229
+ outboundItems.map(
1230
+ (item, index) => variantOutboundMap.get(item.variant_id) && /* @__PURE__ */ jsx7(
1231
+ ClaimOutboundItem,
1232
+ {
1233
+ previewItem: variantOutboundMap.get(item.variant_id),
1234
+ currencyCode: order.currency_code,
1235
+ form,
1236
+ onRemove: () => {
1237
+ const actionId = previewOutboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "ITEM_ADD")?.id;
1238
+ if (actionId) {
1239
+ removeOutboundItem(actionId, {
1240
+ onError: (error) => {
1241
+ toast.error(error.message);
1242
+ }
1243
+ });
1244
+ }
1245
+ },
1246
+ onUpdate: (payload) => {
1247
+ const actionId = previewOutboundItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "ITEM_ADD")?.id;
1248
+ if (actionId) {
1249
+ updateOutboundItem(
1250
+ { ...payload, actionId },
1251
+ {
1252
+ onError: (error) => {
1253
+ toast.error(error.message);
1254
+ }
1255
+ }
1256
+ );
1257
+ }
1258
+ },
1259
+ index
1260
+ },
1261
+ item.id
1262
+ )
1263
+ ),
1264
+ !showOutboundItemsPlaceholder && /* @__PURE__ */ jsx7("div", { className: "mt-8 flex flex-col gap-y-4", children: /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
1265
+ /* @__PURE__ */ jsxs3("div", { children: [
1266
+ /* @__PURE__ */ jsx7(Form.Label, { children: t("orders.claims.outboundShipping") }),
1267
+ /* @__PURE__ */ jsx7(Form.Hint, { className: "!mt-1", children: t("orders.claims.outboundShippingHint") })
1268
+ ] }),
1269
+ /* @__PURE__ */ jsx7(
1270
+ Form.Field,
1271
+ {
1272
+ control: form.control,
1273
+ name: "outbound_option_id",
1274
+ render: ({ field: { value, onChange, ...field } }) => {
1275
+ return /* @__PURE__ */ jsx7(Form.Item, { children: /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(
1276
+ Combobox,
1277
+ {
1278
+ allowClear: true,
1279
+ value: value ?? void 0,
1280
+ onChange: (val) => {
1281
+ onChange(val);
1282
+ onShippingOptionChange(val);
1283
+ },
1284
+ ...field,
1285
+ options: outboundShippingOptions.map((so) => ({
1286
+ label: `${so.name} (${getFormattedShippingOptionLocationName(so)})`,
1287
+ value: so.id
1288
+ })),
1289
+ disabled: !outboundShippingOptions.length,
1290
+ noResultsPlaceholder: /* @__PURE__ */ jsx7(OutboundShippingPlaceholder, {})
1291
+ }
1292
+ ) }) });
1293
+ }
1294
+ }
1295
+ )
1296
+ ] }) }),
1297
+ showLevelsWarning && /* @__PURE__ */ jsxs3(Alert, { variant: "warning", dismissible: true, className: "mt-4 p-5", children: [
1298
+ /* @__PURE__ */ jsx7("div", { className: "text-ui-fg-subtle txt-small pb-2 font-medium leading-[20px]", children: t("orders.returns.noInventoryLevel") }),
1299
+ /* @__PURE__ */ jsx7(Text3, { className: "text-ui-fg-subtle txt-small leading-normal", children: t("orders.returns.noInventoryLevelDesc") })
1300
+ ] })
1301
+ ] });
1302
+ };
1303
+
1304
+ // src/pages/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx
1305
+ import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1306
+ var itemsToAdd2 = [];
1307
+ var itemsToRemove2 = [];
1308
+ var IS_CANCELING = false;
1309
+ var ClaimCreateForm = ({
1310
+ order,
1311
+ preview,
1312
+ claim,
1313
+ orderReturn
1314
+ }) => {
1315
+ const { t } = useTranslation10();
1316
+ const { handleSuccess } = useRouteModal();
1317
+ const { setIsOpen } = useStackedModal();
1318
+ const [isShippingInboundPriceEdit, setIsShippingInboundPriceEdit] = useState4(false);
1319
+ const [isShippingOutboundPriceEdit, setIsShippingOutboundPriceEdit] = useState4(false);
1320
+ const [customInboundShippingAmount, setCustomInboundShippingAmount] = useState4({
1321
+ value: "0",
1322
+ float: 0
1323
+ });
1324
+ const [customOutboundShippingAmount, setCustomOutboundShippingAmount] = useState4({
1325
+ value: "0",
1326
+ float: 0
1327
+ });
1328
+ const [inventoryMap, setInventoryMap] = useState4({});
1329
+ const { mutateAsync: confirmClaimRequest, isPending: isConfirming } = useClaimConfirmRequest(claim.id, order.id);
1330
+ const { mutateAsync: cancelClaimRequest, isPending: isCanceling } = useCancelClaimRequest(claim.id, order.id);
1331
+ const { mutateAsync: updateReturn, isPending: isUpdating } = useUpdateReturn(
1332
+ preview?.order_change?.return_id,
1333
+ order.id
1334
+ );
1335
+ const {
1336
+ mutateAsync: addInboundShipping,
1337
+ isPending: isAddingInboundShipping
1338
+ } = useAddClaimInboundShipping(claim.id, order.id);
1339
+ const {
1340
+ mutateAsync: updateInboundShipping,
1341
+ isPending: isUpdatingInboundShipping
1342
+ } = useUpdateClaimInboundShipping(claim.id, order.id);
1343
+ const {
1344
+ mutateAsync: updateOutboundShipping,
1345
+ isPending: isUpdatingOutboundShipping
1346
+ } = useUpdateClaimOutboundShipping(claim.id, order.id);
1347
+ const {
1348
+ mutateAsync: deleteInboundShipping,
1349
+ isPending: isDeletingInboundShipping
1350
+ } = useDeleteClaimInboundShipping(claim.id, order.id);
1351
+ const { mutateAsync: addInboundItem, isPending: isAddingInboundItem } = useAddClaimInboundItems(claim.id, order.id);
1352
+ const { mutateAsync: updateInboundItem, isPending: isUpdatingInboundItem } = useUpdateClaimInboundItem(claim.id, order.id);
1353
+ const { mutateAsync: removeInboundItem, isPending: isRemovingInboundItem } = useRemoveClaimInboundItem(claim.id, order.id);
1354
+ const isRequestLoading = isConfirming || isCanceling || isAddingInboundShipping || isUpdatingInboundShipping || isDeletingInboundShipping || isUpdatingOutboundShipping || isAddingInboundItem || isRemovingInboundItem || isUpdatingInboundItem || isUpdating;
1355
+ const previewItems = useMemo5(
1356
+ () => preview?.items?.filter(
1357
+ (i) => !!i.actions?.find((a) => a.claim_id === claim.id)
1358
+ ),
1359
+ [preview.items]
1360
+ );
1361
+ const inboundPreviewItems = previewItems.filter(
1362
+ (item) => !!item.actions?.find((a) => a.action === "RETURN_ITEM")
1363
+ );
1364
+ const outboundPreviewItems = previewItems.filter(
1365
+ (item) => !!item.actions?.find((a) => a.action === "ITEM_ADD")
1366
+ );
1367
+ const itemsMap = useMemo5(
1368
+ () => new Map(order?.items?.map((i) => [i.id, i])),
1369
+ [order.items]
1370
+ );
1371
+ const form = useForm({
1372
+ defaultValues: () => {
1373
+ const inboundShippingMethod = preview.shipping_methods.find((s) => {
1374
+ return !!s.actions?.find(
1375
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1376
+ );
1377
+ });
1378
+ const outboundShippingMethod = preview.shipping_methods.find((s) => {
1379
+ return !!s.actions?.find(
1380
+ (a) => a.action === "SHIPPING_ADD" && !a.return_id
1381
+ );
1382
+ });
1383
+ return Promise.resolve({
1384
+ inbound_items: inboundPreviewItems.map((i) => {
1385
+ const inboundAction = i.actions?.find(
1386
+ (a) => a.action === "RETURN_ITEM"
1387
+ );
1388
+ return {
1389
+ item_id: i.id,
1390
+ variant_id: i.variant_id,
1391
+ quantity: i.detail.return_requested_quantity,
1392
+ note: inboundAction?.internal_note,
1393
+ reason_id: inboundAction?.details?.reason_id
1394
+ };
1395
+ }),
1396
+ outbound_items: outboundPreviewItems.map((i) => ({
1397
+ item_id: i.id,
1398
+ variant_id: i.variant_id,
1399
+ quantity: i.detail.quantity
1400
+ })),
1401
+ inbound_option_id: inboundShippingMethod ? inboundShippingMethod.shipping_option_id : "",
1402
+ outbound_option_id: outboundShippingMethod ? outboundShippingMethod.shipping_option_id : "",
1403
+ location_id: orderReturn?.location_id,
1404
+ send_notification: false
1405
+ });
1406
+ },
1407
+ resolver: zodResolver(ClaimCreateSchema)
1408
+ });
1409
+ const locationId = form.watch("location_id");
1410
+ const { stock_locations = [] } = useStockLocations({ limit: 999 });
1411
+ const { shipping_options = [] } = useShippingOptions(
1412
+ {
1413
+ limit: 999,
1414
+ fields: "*prices,+service_zone.fulfillment_set.location.id",
1415
+ stock_location_id: locationId
1416
+ },
1417
+ {
1418
+ enabled: !!locationId
1419
+ }
1420
+ );
1421
+ const inboundShippingOptions = shipping_options.filter(
1422
+ (shippingOption) => !!shippingOption.rules.find(
1423
+ (r) => r.attribute === "is_return" && r.value === "true"
1424
+ )
1425
+ );
1426
+ const inboundShipping = preview.shipping_methods.find((s) => {
1427
+ return !!s.actions?.find(
1428
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1429
+ );
1430
+ });
1431
+ const outboundShipping = preview.shipping_methods.find((s) => {
1432
+ return !!s.actions?.find(
1433
+ (a) => a.action === "SHIPPING_ADD" && !a.return_id
1434
+ );
1435
+ });
1436
+ useEffect2(() => {
1437
+ if (inboundShipping) {
1438
+ setCustomInboundShippingAmount({
1439
+ value: inboundShipping.total.toFixed(
1440
+ currencies[order.currency_code.toUpperCase()].decimal_digits
1441
+ ),
1442
+ float: inboundShipping.total
1443
+ });
1444
+ }
1445
+ }, [inboundShipping]);
1446
+ useEffect2(() => {
1447
+ if (outboundShipping) {
1448
+ setCustomOutboundShippingAmount({
1449
+ value: outboundShipping.total.toFixed(
1450
+ currencies[order.currency_code.toUpperCase()].decimal_digits
1451
+ ),
1452
+ float: outboundShipping.total
1453
+ });
1454
+ }
1455
+ }, [outboundShipping]);
1456
+ const {
1457
+ fields: inboundItems,
1458
+ append,
1459
+ remove,
1460
+ update
1461
+ } = useFieldArray2({
1462
+ name: "inbound_items",
1463
+ control: form.control
1464
+ });
1465
+ const previewItemsMap = useMemo5(
1466
+ () => new Map(previewItems.map((i) => [i.id, i])),
1467
+ [previewItems, inboundItems]
1468
+ );
1469
+ useEffect2(() => {
1470
+ const existingItemsMap = {};
1471
+ inboundPreviewItems.forEach((i) => {
1472
+ const ind = inboundItems.findIndex((field) => field.item_id === i.id);
1473
+ existingItemsMap[i.id] = true;
1474
+ if (ind > -1) {
1475
+ if (inboundItems[ind].quantity !== i.detail.return_requested_quantity) {
1476
+ const returnItemAction = i.actions?.find(
1477
+ (a) => a.action === "RETURN_ITEM"
1478
+ );
1479
+ update(ind, {
1480
+ ...inboundItems[ind],
1481
+ quantity: i.detail.return_requested_quantity,
1482
+ note: returnItemAction?.internal_note,
1483
+ reason_id: returnItemAction?.details?.reason_id
1484
+ });
1485
+ }
1486
+ } else {
1487
+ append(
1488
+ { item_id: i.id, quantity: i.detail.return_requested_quantity },
1489
+ { shouldFocus: false }
1490
+ );
1491
+ }
1492
+ });
1493
+ inboundItems.forEach((i, ind) => {
1494
+ if (!(i.item_id in existingItemsMap)) {
1495
+ remove(ind);
1496
+ }
1497
+ });
1498
+ }, [previewItems]);
1499
+ useEffect2(() => {
1500
+ const inboundShipping2 = preview.shipping_methods.find(
1501
+ (s) => !!s.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
1502
+ );
1503
+ if (inboundShipping2) {
1504
+ form.setValue("inbound_option_id", inboundShipping2.shipping_option_id);
1505
+ } else {
1506
+ form.setValue("inbound_option_id", null);
1507
+ }
1508
+ const outboundShipping2 = preview.shipping_methods.find(
1509
+ (s) => !!s.actions?.find((a) => a.action === "SHIPPING_ADD" && !a.return_id)
1510
+ );
1511
+ if (outboundShipping2) {
1512
+ form.setValue("outbound_option_id", outboundShipping2.shipping_option_id);
1513
+ } else {
1514
+ form.setValue("outbound_option_id", null);
1515
+ }
1516
+ }, [preview.shipping_methods]);
1517
+ useEffect2(() => {
1518
+ form.setValue("location_id", orderReturn?.location_id);
1519
+ }, [orderReturn]);
1520
+ const showInboundItemsPlaceholder = !inboundPreviewItems.length;
1521
+ const showOutboundItemsPlaceholder = !outboundPreviewItems.length;
1522
+ const inboundShippingOptionId = form.watch("inbound_option_id");
1523
+ const outboundShippingOptionId = form.watch("outbound_option_id");
1524
+ const prompt = usePrompt();
1525
+ const handleSubmit = form.handleSubmit(async (data) => {
1526
+ const res = await prompt({
1527
+ title: t("general.areYouSure"),
1528
+ description: t("orders.claims.confirmText"),
1529
+ confirmText: t("actions.continue"),
1530
+ cancelText: t("actions.cancel"),
1531
+ variant: "confirmation"
1532
+ });
1533
+ if (!res) {
1534
+ return;
1535
+ }
1536
+ await confirmClaimRequest(
1537
+ { no_notification: !data.send_notification },
1538
+ {
1539
+ onSuccess: () => {
1540
+ toast2.success(t("orders.claims.toast.confirmedSuccessfully"));
1541
+ handleSuccess();
1542
+ },
1543
+ onError: (error) => {
1544
+ toast2.error(error.message);
1545
+ }
1546
+ }
1547
+ );
1548
+ });
1549
+ const onItemsSelected = async () => {
1550
+ itemsToAdd2.length && await addInboundItem(
1551
+ {
1552
+ items: itemsToAdd2.map((id) => ({
1553
+ id,
1554
+ quantity: 1
1555
+ }))
1556
+ },
1557
+ {
1558
+ onError: (error) => {
1559
+ toast2.error(error.message);
1560
+ }
1561
+ }
1562
+ );
1563
+ for (const itemToRemove of itemsToRemove2) {
1564
+ const actionId = previewItems.find((i) => i.id === itemToRemove)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
1565
+ if (actionId) {
1566
+ await removeInboundItem(actionId, {
1567
+ onError: (error) => {
1568
+ toast2.error(error.message);
1569
+ }
1570
+ });
1571
+ }
1572
+ }
1573
+ setIsOpen("inbound-items", false);
1574
+ };
1575
+ const onLocationChange = async (selectedLocationId) => {
1576
+ await updateReturn({ location_id: selectedLocationId });
1577
+ };
1578
+ const onShippingOptionChange = async (selectedOptionId) => {
1579
+ const inboundShippingMethods = preview.shipping_methods.filter((s) => {
1580
+ const action = s.actions?.find(
1581
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1582
+ );
1583
+ return action && !!action?.return_id;
1584
+ });
1585
+ const promises = inboundShippingMethods.filter(Boolean).map((inboundShippingMethod) => {
1586
+ const action = inboundShippingMethod.actions?.find(
1587
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1588
+ );
1589
+ if (action) {
1590
+ return deleteInboundShipping(action.id);
1591
+ }
1592
+ });
1593
+ await Promise.all(promises);
1594
+ if (selectedOptionId) {
1595
+ await addInboundShipping(
1596
+ { shipping_option_id: selectedOptionId },
1597
+ {
1598
+ onError: (error) => {
1599
+ toast2.error(error.message);
1600
+ }
1601
+ }
1602
+ );
1603
+ }
1604
+ };
1605
+ useEffect2(() => {
1606
+ if (isShippingInboundPriceEdit) {
1607
+ document.getElementById("js-shipping-inbound-input")?.focus();
1608
+ }
1609
+ }, [isShippingInboundPriceEdit]);
1610
+ useEffect2(() => {
1611
+ if (isShippingOutboundPriceEdit) {
1612
+ document.getElementById("js-shipping-outbound-input")?.focus();
1613
+ }
1614
+ }, [isShippingOutboundPriceEdit]);
1615
+ const showLevelsWarning = useMemo5(() => {
1616
+ if (!locationId) {
1617
+ return false;
1618
+ }
1619
+ const allItemsHaveLocation = inboundItems.map((_i) => {
1620
+ const item = itemsMap.get(_i.item_id);
1621
+ if (!item?.variant_id || !item?.variant) {
1622
+ return true;
1623
+ }
1624
+ if (!item.variant?.manage_inventory) {
1625
+ return true;
1626
+ }
1627
+ return inventoryMap[item.variant_id]?.find(
1628
+ (l) => l.location_id === locationId
1629
+ );
1630
+ }).every(Boolean);
1631
+ return !allItemsHaveLocation;
1632
+ }, [inboundItems, inventoryMap, locationId]);
1633
+ useEffect2(() => {
1634
+ const getInventoryMap = async () => {
1635
+ const ret = {};
1636
+ if (!inboundItems.length) {
1637
+ return ret;
1638
+ }
1639
+ const variantIds = inboundItems.map((item) => item?.variant_id).filter(Boolean);
1640
+ const variants = (await sdk.admin.productVariant.list({
1641
+ id: variantIds,
1642
+ fields: "*inventory.location_levels"
1643
+ })).variants;
1644
+ variants.forEach((variant) => {
1645
+ ret[variant.id] = variant.inventory?.[0]?.location_levels || [];
1646
+ });
1647
+ return ret;
1648
+ };
1649
+ getInventoryMap().then((map) => {
1650
+ setInventoryMap(map);
1651
+ });
1652
+ }, [inboundItems]);
1653
+ useEffect2(() => {
1654
+ return () => {
1655
+ if (IS_CANCELING) {
1656
+ cancelClaimRequest(void 0, {
1657
+ onSuccess: () => {
1658
+ toast2.success(t("orders.claims.actions.cancelClaim.successToast"));
1659
+ },
1660
+ onError: (error) => {
1661
+ toast2.error(error.message);
1662
+ }
1663
+ });
1664
+ IS_CANCELING = false;
1665
+ }
1666
+ };
1667
+ }, []);
1668
+ const inboundShippingTotal = useMemo5(() => {
1669
+ const method = preview.shipping_methods.find(
1670
+ (sm) => !!sm.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
1671
+ );
1672
+ return method?.total || 0;
1673
+ }, [preview.shipping_methods]);
1674
+ const outboundShippingTotal = useMemo5(() => {
1675
+ const method = preview.shipping_methods.find(
1676
+ (sm) => !!sm.actions?.find((a) => a.action === "SHIPPING_ADD" && !a.return_id)
1677
+ );
1678
+ return method?.total || 0;
1679
+ }, [preview.shipping_methods]);
1680
+ return /* @__PURE__ */ jsx8(RouteFocusModal.Form, { form, "data-testid": "order-create-claim-form", children: /* @__PURE__ */ jsxs4(KeyboundForm, { onSubmit: handleSubmit, className: "flex h-full flex-col", children: [
1681
+ /* @__PURE__ */ jsx8(RouteFocusModal.Header, { "data-testid": "order-create-claim-header" }),
1682
+ /* @__PURE__ */ jsx8(
1683
+ RouteFocusModal.Body,
1684
+ {
1685
+ className: "flex size-full justify-center overflow-y-auto",
1686
+ "data-testid": "order-create-claim-body",
1687
+ children: /* @__PURE__ */ jsxs4("div", { className: "mt-16 w-[720px] max-w-[100%] px-4 md:p-0", children: [
1688
+ /* @__PURE__ */ jsx8(Heading2, { level: "h1", "data-testid": "order-create-claim-heading", children: t("orders.claims.create") }),
1689
+ /* @__PURE__ */ jsxs4("div", { className: "mt-8 flex items-center justify-between", children: [
1690
+ /* @__PURE__ */ jsx8(Heading2, { level: "h2", children: t("orders.returns.inbound") }),
1691
+ /* @__PURE__ */ jsxs4(StackedFocusModal, { id: "inbound-items", children: [
1692
+ /* @__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") }) }),
1693
+ /* @__PURE__ */ jsxs4(StackedFocusModal.Content, { children: [
1694
+ /* @__PURE__ */ jsx8(StackedFocusModal.Header, {}),
1695
+ /* @__PURE__ */ jsx8(
1696
+ AddClaimItemsTable,
1697
+ {
1698
+ items: order.items,
1699
+ selectedItems: inboundItems.map((i) => i.item_id),
1700
+ currencyCode: order.currency_code,
1701
+ onSelectionChange: (finalSelection) => {
1702
+ const alreadySelected = inboundItems.map(
1703
+ (i) => i.item_id
1704
+ );
1705
+ itemsToAdd2 = finalSelection.filter(
1706
+ (selection) => !alreadySelected.includes(selection)
1707
+ );
1708
+ itemsToRemove2 = alreadySelected.filter(
1709
+ (selection) => !finalSelection.includes(selection)
1710
+ );
1711
+ }
1712
+ }
1713
+ ),
1714
+ /* @__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: [
1715
+ /* @__PURE__ */ jsx8(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx8(
1716
+ Button2,
1717
+ {
1718
+ type: "button",
1719
+ variant: "secondary",
1720
+ size: "small",
1721
+ children: t("actions.cancel")
1722
+ }
1723
+ ) }),
1724
+ /* @__PURE__ */ jsx8(
1725
+ Button2,
1726
+ {
1727
+ type: "submit",
1728
+ variant: "primary",
1729
+ size: "small",
1730
+ role: "button",
1731
+ onClick: async () => await onItemsSelected(),
1732
+ children: t("actions.save")
1733
+ },
1734
+ "submit-button"
1735
+ )
1736
+ ] }) }) })
1737
+ ] })
1738
+ ] })
1739
+ ] }),
1740
+ showInboundItemsPlaceholder && /* @__PURE__ */ jsx8(ItemPlaceholder, {}),
1741
+ inboundItems.map(
1742
+ (item, index) => previewItemsMap.get(item.item_id) && itemsMap.get(item.item_id) && /* @__PURE__ */ jsx8(
1743
+ ClaimInboundItem,
1744
+ {
1745
+ item: itemsMap.get(item.item_id),
1746
+ previewItem: previewItemsMap.get(item.item_id),
1747
+ currencyCode: order.currency_code,
1748
+ form,
1749
+ onRemove: () => {
1750
+ const actionId = previewItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
1751
+ if (actionId) {
1752
+ removeInboundItem(actionId, {
1753
+ onError: (error) => {
1754
+ toast2.error(error.message);
1755
+ }
1756
+ });
1757
+ }
1758
+ },
1759
+ onUpdate: (payload) => {
1760
+ const action = previewItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM");
1761
+ if (action) {
1762
+ updateInboundItem(
1763
+ { ...payload, actionId: action.id },
1764
+ {
1765
+ onError: (error) => {
1766
+ if (action.details?.quantity && payload.quantity) {
1767
+ form.setValue(
1768
+ `inbound_items.${index}.quantity`,
1769
+ action.details?.quantity
1770
+ );
1771
+ }
1772
+ toast2.error(error.message);
1773
+ }
1774
+ }
1775
+ );
1776
+ }
1777
+ },
1778
+ index
1779
+ },
1780
+ item.id
1781
+ )
1782
+ ),
1783
+ !showInboundItemsPlaceholder && /* @__PURE__ */ jsxs4("div", { className: "mt-8 flex flex-col gap-y-4", children: [
1784
+ /* @__PURE__ */ jsxs4("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
1785
+ /* @__PURE__ */ jsxs4("div", { children: [
1786
+ /* @__PURE__ */ jsx8(Form.Label, { children: t("orders.returns.location") }),
1787
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.returns.locationHint") })
1788
+ ] }),
1789
+ /* @__PURE__ */ jsx8(
1790
+ Form.Field,
1791
+ {
1792
+ control: form.control,
1793
+ name: "location_id",
1794
+ render: ({ field: { value, onChange, ...field } }) => {
1795
+ return /* @__PURE__ */ jsx8(Form.Item, { children: /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(
1796
+ Combobox,
1797
+ {
1798
+ ...field,
1799
+ value: value ?? void 0,
1800
+ onChange: (v) => {
1801
+ onChange(v);
1802
+ onLocationChange(v);
1803
+ },
1804
+ options: (stock_locations ?? []).map(
1805
+ (stockLocation) => ({
1806
+ label: stockLocation.name,
1807
+ value: stockLocation.id
1808
+ })
1809
+ )
1810
+ }
1811
+ ) }) });
1812
+ }
1813
+ }
1814
+ )
1815
+ ] }),
1816
+ /* @__PURE__ */ jsxs4("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
1817
+ /* @__PURE__ */ jsxs4("div", { children: [
1818
+ /* @__PURE__ */ jsxs4(Form.Label, { children: [
1819
+ t("orders.returns.inboundShipping"),
1820
+ /* @__PURE__ */ jsxs4(
1821
+ Text4,
1822
+ {
1823
+ size: "small",
1824
+ leading: "compact",
1825
+ className: "text-ui-fg-muted ml-1 inline",
1826
+ children: [
1827
+ "(",
1828
+ t("fields.optional"),
1829
+ ")"
1830
+ ]
1831
+ }
1832
+ )
1833
+ ] }),
1834
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.returns.inboundShippingHint") })
1835
+ ] }),
1836
+ /* @__PURE__ */ jsx8(
1837
+ Form.Field,
1838
+ {
1839
+ control: form.control,
1840
+ name: "inbound_option_id",
1841
+ render: ({ field: { value, onChange, ...field } }) => {
1842
+ return /* @__PURE__ */ jsx8(Form.Item, { children: /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(
1843
+ Combobox,
1844
+ {
1845
+ allowClear: true,
1846
+ value: value ?? void 0,
1847
+ onChange: (val) => {
1848
+ onChange(val);
1849
+ onShippingOptionChange(val);
1850
+ },
1851
+ ...field,
1852
+ options: inboundShippingOptions.map((so) => ({
1853
+ label: so.name,
1854
+ value: so.id
1855
+ })),
1856
+ disabled: !locationId,
1857
+ noResultsPlaceholder: /* @__PURE__ */ jsx8(ReturnShippingPlaceholder, {})
1858
+ }
1859
+ ) }) });
1860
+ }
1861
+ }
1862
+ )
1863
+ ] })
1864
+ ] }),
1865
+ showLevelsWarning && /* @__PURE__ */ jsxs4(Alert2, { variant: "warning", dismissible: true, className: "mt-4 p-5", children: [
1866
+ /* @__PURE__ */ jsx8("div", { className: "text-ui-fg-subtle txt-small pb-2 font-medium leading-[20px]", children: t("orders.returns.noInventoryLevel") }),
1867
+ /* @__PURE__ */ jsx8(Text4, { className: "text-ui-fg-subtle txt-small leading-normal", children: t("orders.returns.noInventoryLevelDesc") })
1868
+ ] }),
1869
+ /* @__PURE__ */ jsx8(
1870
+ ClaimOutboundSection,
1871
+ {
1872
+ form,
1873
+ preview,
1874
+ order,
1875
+ claim
1876
+ }
1877
+ ),
1878
+ /* @__PURE__ */ jsxs4(
1879
+ "div",
1880
+ {
1881
+ className: "mt-8 border-y border-dotted py-4",
1882
+ "data-testid": "order-create-claim-totals",
1883
+ children: [
1884
+ /* @__PURE__ */ jsxs4(
1885
+ "div",
1886
+ {
1887
+ className: "mb-2 flex items-center justify-between",
1888
+ "data-testid": "order-create-claim-inbound-total",
1889
+ children: [
1890
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.inboundTotal") }),
1891
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(
1892
+ inboundPreviewItems.reduce((acc, item) => {
1893
+ const action = item.actions?.find(
1894
+ (act) => act.action === "RETURN_ITEM"
1895
+ );
1896
+ acc = acc + (action?.amount || 0);
1897
+ return acc;
1898
+ }, 0) * -1,
1899
+ order.currency_code
1900
+ ) })
1901
+ ]
1902
+ }
1903
+ ),
1904
+ /* @__PURE__ */ jsxs4(
1905
+ "div",
1906
+ {
1907
+ className: "mb-2 flex items-center justify-between",
1908
+ "data-testid": "order-create-claim-outbound-total",
1909
+ children: [
1910
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.claims.outboundTotal") }),
1911
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(
1912
+ outboundPreviewItems.reduce((acc, item) => {
1913
+ const action = item.actions?.find(
1914
+ (act) => act.action === "ITEM_ADD"
1915
+ );
1916
+ acc = acc + (action?.amount || 0);
1917
+ return acc;
1918
+ }, 0),
1919
+ order.currency_code
1920
+ ) })
1921
+ ]
1922
+ }
1923
+ ),
1924
+ /* @__PURE__ */ jsxs4("div", { className: "mb-2 flex items-center justify-between", children: [
1925
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.inboundShipping") }),
1926
+ /* @__PURE__ */ jsxs4("span", { className: "txt-small text-ui-fg-subtle flex items-center", children: [
1927
+ !isShippingInboundPriceEdit && /* @__PURE__ */ jsx8(
1928
+ IconButton2,
1929
+ {
1930
+ onClick: () => setIsShippingInboundPriceEdit(true),
1931
+ variant: "transparent",
1932
+ className: "text-ui-fg-muted",
1933
+ disabled: showInboundItemsPlaceholder || !inboundShippingOptionId,
1934
+ children: /* @__PURE__ */ jsx8(PencilSquare, {})
1935
+ }
1936
+ ),
1937
+ isShippingInboundPriceEdit ? /* @__PURE__ */ jsx8(
1938
+ CurrencyInput,
1939
+ {
1940
+ id: "js-shipping-inbound-input",
1941
+ onBlur: () => {
1942
+ let actionId;
1943
+ preview.shipping_methods.forEach((s) => {
1944
+ if (s.actions) {
1945
+ for (const a of s.actions) {
1946
+ if (a.action === "SHIPPING_ADD" && !!a.return_id) {
1947
+ actionId = a.id;
1948
+ }
1949
+ }
1950
+ }
1951
+ });
1952
+ const customPrice = customInboundShippingAmount.float;
1953
+ if (actionId) {
1954
+ updateInboundShipping(
1955
+ {
1956
+ actionId,
1957
+ custom_amount: customPrice
1958
+ },
1959
+ {
1960
+ onError: (error) => {
1961
+ toast2.error(error.message);
1962
+ }
1963
+ }
1964
+ );
1965
+ }
1966
+ setIsShippingInboundPriceEdit(false);
1967
+ },
1968
+ symbol: currencies[order.currency_code.toUpperCase()].symbol_native,
1969
+ code: order.currency_code,
1970
+ onValueChange: (_value, _name, values) => {
1971
+ setCustomInboundShippingAmount({
1972
+ value: values?.value ?? "",
1973
+ float: values?.float ?? null
1974
+ });
1975
+ },
1976
+ value: customInboundShippingAmount.value,
1977
+ disabled: showInboundItemsPlaceholder
1978
+ }
1979
+ ) : getStylizedAmount(inboundShippingTotal, order.currency_code)
1980
+ ] })
1981
+ ] }),
1982
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between", children: [
1983
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.claims.outboundShipping") }),
1984
+ /* @__PURE__ */ jsxs4("span", { className: "txt-small text-ui-fg-subtle flex items-center", children: [
1985
+ !isShippingOutboundPriceEdit && /* @__PURE__ */ jsx8(
1986
+ IconButton2,
1987
+ {
1988
+ onClick: () => setIsShippingOutboundPriceEdit(true),
1989
+ variant: "transparent",
1990
+ className: "text-ui-fg-muted",
1991
+ disabled: showOutboundItemsPlaceholder || !outboundShippingOptionId,
1992
+ children: /* @__PURE__ */ jsx8(PencilSquare, {})
1993
+ }
1994
+ ),
1995
+ isShippingOutboundPriceEdit ? /* @__PURE__ */ jsx8(
1996
+ CurrencyInput,
1997
+ {
1998
+ id: "js-shipping-outbound-input",
1999
+ onBlur: () => {
2000
+ let actionId;
2001
+ preview.shipping_methods.forEach((s) => {
2002
+ if (s.actions) {
2003
+ for (const a of s.actions) {
2004
+ if (a.action === "SHIPPING_ADD" && !a.return_id) {
2005
+ actionId = a.id;
2006
+ }
2007
+ }
2008
+ }
2009
+ });
2010
+ const customPrice = customOutboundShippingAmount.float;
2011
+ if (actionId) {
2012
+ updateOutboundShipping(
2013
+ {
2014
+ actionId,
2015
+ custom_amount: customPrice
2016
+ },
2017
+ {
2018
+ onError: (error) => {
2019
+ toast2.error(error.message);
2020
+ }
2021
+ }
2022
+ );
2023
+ }
2024
+ setIsShippingOutboundPriceEdit(false);
2025
+ },
2026
+ symbol: currencies[order.currency_code.toUpperCase()].symbol_native,
2027
+ code: order.currency_code,
2028
+ onValueChange: (_value, _name, values) => {
2029
+ setCustomOutboundShippingAmount({
2030
+ value: values?.value ?? "",
2031
+ float: values?.float ?? null
2032
+ });
2033
+ },
2034
+ value: customOutboundShippingAmount.value,
2035
+ disabled: showOutboundItemsPlaceholder
2036
+ }
2037
+ ) : getStylizedAmount(
2038
+ outboundShippingTotal,
2039
+ order.currency_code
2040
+ )
2041
+ ] })
2042
+ ] }),
2043
+ /* @__PURE__ */ jsxs4(
2044
+ "div",
2045
+ {
2046
+ className: "mt-4 flex items-center justify-between border-t border-dotted pt-4",
2047
+ "data-testid": "order-create-claim-refund-amount",
2048
+ children: [
2049
+ /* @__PURE__ */ jsx8("span", { className: "txt-small font-medium", children: t("orders.claims.refundAmount") }),
2050
+ /* @__PURE__ */ jsx8("span", { className: "txt-small font-medium", children: getStylizedAmount(
2051
+ preview.summary.pending_difference,
2052
+ order.currency_code
2053
+ ) })
2054
+ ]
2055
+ }
2056
+ )
2057
+ ]
2058
+ }
2059
+ ),
2060
+ /* @__PURE__ */ jsx8(
2061
+ "div",
2062
+ {
2063
+ className: "bg-ui-bg-field mt-8 rounded-lg border py-2 pl-2 pr-4",
2064
+ "data-testid": "order-create-claim-notification",
2065
+ children: /* @__PURE__ */ jsx8(
2066
+ Form.Field,
2067
+ {
2068
+ control: form.control,
2069
+ name: "send_notification",
2070
+ render: ({ field: { onChange, value, ...field } }) => {
2071
+ return /* @__PURE__ */ jsxs4(Form.Item, { "data-testid": "order-create-claim-notification-item", children: [
2072
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center", children: [
2073
+ /* @__PURE__ */ jsx8(
2074
+ Form.Control,
2075
+ {
2076
+ className: "mr-4 self-start",
2077
+ "data-testid": "order-create-claim-notification-control",
2078
+ children: /* @__PURE__ */ jsx8(
2079
+ Switch,
2080
+ {
2081
+ dir: "ltr",
2082
+ className: "mt-[2px] rtl:rotate-180",
2083
+ checked: !!value,
2084
+ onCheckedChange: onChange,
2085
+ ...field,
2086
+ "data-testid": "order-create-claim-notification-switch"
2087
+ }
2088
+ )
2089
+ }
2090
+ ),
2091
+ /* @__PURE__ */ jsxs4("div", { className: "block", children: [
2092
+ /* @__PURE__ */ jsx8(Form.Label, { "data-testid": "order-create-claim-notification-label", children: t("orders.returns.sendNotification") }),
2093
+ /* @__PURE__ */ jsx8(
2094
+ Form.Hint,
2095
+ {
2096
+ className: "!mt-1",
2097
+ "data-testid": "order-create-claim-notification-hint",
2098
+ children: t("orders.returns.sendNotificationHint")
2099
+ }
2100
+ )
2101
+ ] })
2102
+ ] }),
2103
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, { "data-testid": "order-create-claim-notification-error" })
2104
+ ] });
2105
+ }
2106
+ }
2107
+ )
2108
+ }
2109
+ ),
2110
+ /* @__PURE__ */ jsx8("div", { className: "p-8" })
2111
+ ] })
2112
+ }
2113
+ ),
2114
+ /* @__PURE__ */ jsx8(RouteFocusModal.Footer, { "data-testid": "order-create-claim-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: [
2115
+ /* @__PURE__ */ jsx8(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx8(
2116
+ Button2,
2117
+ {
2118
+ type: "button",
2119
+ onClick: () => IS_CANCELING = true,
2120
+ variant: "secondary",
2121
+ size: "small",
2122
+ "data-testid": "order-create-claim-cancel-button",
2123
+ children: t("orders.claims.cancel.title")
2124
+ }
2125
+ ) }),
2126
+ /* @__PURE__ */ jsx8(
2127
+ Button2,
2128
+ {
2129
+ type: "submit",
2130
+ variant: "primary",
2131
+ size: "small",
2132
+ isLoading: isRequestLoading,
2133
+ "data-testid": "order-create-claim-confirm-button",
2134
+ children: t("orders.claims.confirm")
2135
+ },
2136
+ "submit-button"
2137
+ )
2138
+ ] }) }) })
2139
+ ] }) });
2140
+ };
2141
+
2142
+ // src/pages/orders/order-create-claim/claim-create.tsx
2143
+ import { jsx as jsx9 } from "react/jsx-runtime";
2144
+ var IS_REQUEST_RUNNING = false;
2145
+ var ClaimCreate = () => {
2146
+ const { id } = useParams();
2147
+ const navigate = useNavigate();
2148
+ const { t } = useTranslation11();
2149
+ const { order } = useOrder(id, {
2150
+ fields: DEFAULT_FIELDS
2151
+ });
2152
+ const { order: preview } = useOrderPreview(id);
2153
+ const [activeClaimId, setActiveClaimId] = useState5();
2154
+ const { mutateAsync: createClaim } = useCreateClaim(order.id);
2155
+ const { claim } = useClaim(activeClaimId, void 0, {
2156
+ enabled: !!activeClaimId
2157
+ });
2158
+ const { return: orderReturn } = useReturn(claim?.return_id, void 0, {
2159
+ enabled: !!claim?.return_id
2160
+ });
2161
+ useEffect3(() => {
2162
+ async function run() {
2163
+ if (IS_REQUEST_RUNNING || !preview) {
2164
+ return;
2165
+ }
2166
+ if (preview.order_change) {
2167
+ if (preview.order_change.change_type === "claim") {
2168
+ setActiveClaimId(preview.order_change.claim_id);
2169
+ } else {
2170
+ navigate(`/orders/${preview.id}`, { replace: true });
2171
+ toast3.error(t("orders.claims.activeChangeError"));
2172
+ }
2173
+ return;
2174
+ }
2175
+ IS_REQUEST_RUNNING = true;
2176
+ try {
2177
+ const { claim: createdClaim } = await createClaim({
2178
+ order_id: preview.id,
2179
+ type: "replace"
2180
+ });
2181
+ setActiveClaimId(createdClaim.id);
2182
+ } catch (e) {
2183
+ toast3.error(e.message);
2184
+ navigate(`/orders/${preview.id}`, { replace: true });
2185
+ } finally {
2186
+ IS_REQUEST_RUNNING = false;
2187
+ }
2188
+ }
2189
+ run();
2190
+ }, [preview]);
2191
+ return /* @__PURE__ */ jsx9(RouteFocusModal, { "data-testid": "order-create-claim-modal", children: claim && preview && order && /* @__PURE__ */ jsx9(
2192
+ ClaimCreateForm,
2193
+ {
2194
+ order,
2195
+ claim,
2196
+ preview,
2197
+ orderReturn
2198
+ }
2199
+ ) });
2200
+ };
2201
+ export {
2202
+ ClaimCreate as Component
2203
+ };