@mercurjs/admin 2.0.0-canary.100

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