@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,3892 @@
1
+ import {
2
+ By
3
+ } from "./chunk-OT5X3VOQ.js";
4
+ import {
5
+ DisplayIdCell,
6
+ DisplayIdHeader,
7
+ TotalCell,
8
+ TotalHeader
9
+ } from "./chunk-NOWUEJ74.js";
10
+ import {
11
+ formatPercentage
12
+ } from "./chunk-QDPLZDMX.js";
13
+ import {
14
+ useCancelExchange,
15
+ useCancelExchangeRequest,
16
+ useExchanges
17
+ } from "./chunk-PWMB7ITO.js";
18
+ import {
19
+ useCancelOrderEdit,
20
+ useConfirmOrderEdit
21
+ } from "./chunk-7ITJ4725.js";
22
+ import {
23
+ formatProvider
24
+ } from "./chunk-VW56KWO2.js";
25
+ import {
26
+ formatCurrency
27
+ } from "./chunk-XSX255FK.js";
28
+ import {
29
+ FulfillmentStatusCell,
30
+ FulfillmentStatusHeader,
31
+ PaymentStatusCell,
32
+ PaymentStatusHeader,
33
+ getCanceledOrderStatus,
34
+ getOrderFulfillmentStatus,
35
+ getOrderPaymentStatus
36
+ } from "./chunk-TZSOL34K.js";
37
+ import {
38
+ DateCell,
39
+ DateHeader
40
+ } from "./chunk-25LYVP3C.js";
41
+ import {
42
+ getPaymentsFromOrder,
43
+ getReservationsLimitCount
44
+ } from "./chunk-3KOTDGC2.js";
45
+ import {
46
+ useCancelClaim,
47
+ useCancelClaimRequest,
48
+ useClaims
49
+ } from "./chunk-5HZT54X7.js";
50
+ import {
51
+ getReturnableQuantity
52
+ } from "./chunk-UM7ZR3VU.js";
53
+ import {
54
+ DEFAULT_FIELDS
55
+ } from "./chunk-Y2M536WR.js";
56
+ import {
57
+ useCancelReturn,
58
+ useCancelReturnRequest,
59
+ useReturns
60
+ } from "./chunk-PJTR2MBS.js";
61
+ import {
62
+ TextCell,
63
+ TextHeader
64
+ } from "./chunk-JHIMVLB2.js";
65
+ import {
66
+ getLocaleAmount,
67
+ getStylizedAmount,
68
+ isAmountLessThenRoundingError
69
+ } from "./chunk-PXYDR7WQ.js";
70
+ import {
71
+ getFormattedAddress,
72
+ isSameAddress
73
+ } from "./chunk-W6Y3PPU5.js";
74
+ import {
75
+ TwoColumnPage
76
+ } from "./chunk-V5J73NPW.js";
77
+ import {
78
+ Thumbnail
79
+ } from "./chunk-WIYFXWRI.js";
80
+ import {
81
+ _DataTable,
82
+ useDataTable
83
+ } from "./chunk-ULJ3OMWU.js";
84
+ import {
85
+ Skeleton,
86
+ TwoColumnPageSkeleton
87
+ } from "./chunk-INNFZYX2.js";
88
+ import {
89
+ ActionMenu
90
+ } from "./chunk-BDGZ4EQO.js";
91
+ import {
92
+ useDate
93
+ } from "./chunk-UZWFZMOX.js";
94
+ import {
95
+ useCapturePayment,
96
+ useMarkPaymentCollectionAsPaid
97
+ } from "./chunk-YAMNPEPW.js";
98
+ import {
99
+ useOrderGroupByOrderId
100
+ } from "./chunk-PYF5EER5.js";
101
+ import {
102
+ useCustomer
103
+ } from "./chunk-FIVW6L2I.js";
104
+ import {
105
+ useCancelOrder,
106
+ useCancelOrderFulfillment,
107
+ useCancelOrderTransfer,
108
+ useMarkOrderFulfillmentAsDelivered,
109
+ useOrder,
110
+ useOrderChanges,
111
+ useOrderLineItems,
112
+ useOrderPreview
113
+ } from "./chunk-QVLL4MKH.js";
114
+ import {
115
+ useReservationItems
116
+ } from "./chunk-I5LLMPI2.js";
117
+ import {
118
+ useStockLocation
119
+ } from "./chunk-VXW3BCN2.js";
120
+
121
+ // src/pages/orders/order-detail/order-detail.tsx
122
+ import { Children } from "react";
123
+ import { useLoaderData, useParams as useParams2 } from "react-router-dom";
124
+
125
+ // src/pages/orders/order-detail/components/active-order-claim-section/active-order-claim-section.tsx
126
+ import { ExclamationCircle } from "@medusajs/icons";
127
+ import { Button, Container, Heading, Text, toast } from "@medusajs/ui";
128
+ import { useTranslation } from "react-i18next";
129
+ import { useNavigate } from "react-router-dom";
130
+ import { jsx, jsxs } from "react/jsx-runtime";
131
+ var ActiveOrderClaimSection = ({
132
+ orderPreview
133
+ }) => {
134
+ const { t } = useTranslation();
135
+ const claimId = orderPreview?.order_change?.claim_id;
136
+ const { mutateAsync: cancelClaim } = useCancelClaimRequest(
137
+ claimId,
138
+ orderPreview.id
139
+ );
140
+ const navigate = useNavigate();
141
+ const onContinueClaim = async () => {
142
+ navigate(`/orders/${orderPreview.id}/claims`);
143
+ };
144
+ const onCancelClaim = async () => {
145
+ await cancelClaim(void 0, {
146
+ onSuccess: () => {
147
+ toast.success(t("orders.claims.toast.canceledSuccessfully"));
148
+ },
149
+ onError: (error) => {
150
+ toast.error(error.message);
151
+ }
152
+ });
153
+ };
154
+ if (!claimId) {
155
+ return;
156
+ }
157
+ return /* @__PURE__ */ jsx(
158
+ "div",
159
+ {
160
+ style: {
161
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
162
+ },
163
+ className: "-m-4 mb-1 border-b border-l p-4",
164
+ "data-testid": "active-order-claim-section",
165
+ children: /* @__PURE__ */ jsx(Container, { className: "flex items-center justify-between p-0", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-row justify-between", children: [
166
+ /* @__PURE__ */ jsxs("div", { children: [
167
+ /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", "data-testid": "active-order-claim-header", children: [
168
+ /* @__PURE__ */ jsx(ExclamationCircle, { className: "text-ui-fg-subtle" }),
169
+ /* @__PURE__ */ jsx(Heading, { level: "h2", "data-testid": "active-order-claim-heading", children: t("orders.claims.panel.title") })
170
+ ] }),
171
+ /* @__PURE__ */ jsx("div", { className: "gap-2 px-6 pb-4", "data-testid": "active-order-claim-description", children: /* @__PURE__ */ jsx(Text, { children: t("orders.claims.panel.description") }) })
172
+ ] }),
173
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", "data-testid": "active-order-claim-actions", children: [
174
+ /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", onClick: onCancelClaim, "data-testid": "active-order-claim-cancel-button", children: t("orders.claims.cancel.title") }),
175
+ /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", onClick: onContinueClaim, "data-testid": "active-order-claim-continue-button", children: t("actions.continue") })
176
+ ] })
177
+ ] }) })
178
+ }
179
+ );
180
+ };
181
+
182
+ // src/pages/orders/order-detail/components/active-order-exchange-section/active-order-exchange-section.tsx
183
+ import { ArrowPath } from "@medusajs/icons";
184
+ import { Button as Button2, Container as Container2, Heading as Heading2, Text as Text2, toast as toast2 } from "@medusajs/ui";
185
+ import { useTranslation as useTranslation2 } from "react-i18next";
186
+ import { useNavigate as useNavigate2 } from "react-router-dom";
187
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
188
+ var ActiveOrderExchangeSection = ({
189
+ orderPreview
190
+ }) => {
191
+ const { t } = useTranslation2();
192
+ const exchangeId = orderPreview?.order_change?.exchange_id;
193
+ const { mutateAsync: cancelExchange } = useCancelExchangeRequest(
194
+ exchangeId,
195
+ orderPreview.id
196
+ );
197
+ const navigate = useNavigate2();
198
+ const onContinueExchange = async () => {
199
+ navigate(`/orders/${orderPreview.id}/exchanges`);
200
+ };
201
+ const onCancelExchange = async () => {
202
+ await cancelExchange(void 0, {
203
+ onSuccess: () => {
204
+ toast2.success(t("orders.exchanges.toast.canceledSuccessfully"));
205
+ },
206
+ onError: (error) => {
207
+ toast2.error(error.message);
208
+ }
209
+ });
210
+ };
211
+ if (!exchangeId) {
212
+ return;
213
+ }
214
+ return /* @__PURE__ */ jsx2(
215
+ "div",
216
+ {
217
+ style: {
218
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
219
+ },
220
+ className: "-m-4 mb-1 border-b border-l p-4",
221
+ "data-testid": "active-order-exchange-section",
222
+ children: /* @__PURE__ */ jsx2(Container2, { className: "flex items-center justify-between p-0", children: /* @__PURE__ */ jsxs2("div", { className: "flex w-full flex-row justify-between", children: [
223
+ /* @__PURE__ */ jsxs2("div", { children: [
224
+ /* @__PURE__ */ jsxs2("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", "data-testid": "active-order-exchange-header", children: [
225
+ /* @__PURE__ */ jsx2(ArrowPath, { className: "text-ui-fg-subtle" }),
226
+ /* @__PURE__ */ jsx2(Heading2, { level: "h2", "data-testid": "active-order-exchange-heading", children: t("orders.exchanges.panel.title") })
227
+ ] }),
228
+ /* @__PURE__ */ jsx2("div", { className: "gap-2 px-6 pb-4", "data-testid": "active-order-exchange-description", children: /* @__PURE__ */ jsx2(Text2, { children: t("orders.exchanges.panel.description") }) })
229
+ ] }),
230
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", "data-testid": "active-order-exchange-actions", children: [
231
+ /* @__PURE__ */ jsx2(Button2, { size: "small", variant: "secondary", onClick: onCancelExchange, "data-testid": "active-order-exchange-cancel-button", children: t("orders.exchanges.cancel.title") }),
232
+ /* @__PURE__ */ jsx2(
233
+ Button2,
234
+ {
235
+ size: "small",
236
+ variant: "secondary",
237
+ onClick: onContinueExchange,
238
+ "data-testid": "active-order-exchange-continue-button",
239
+ children: t("actions.continue")
240
+ }
241
+ )
242
+ ] })
243
+ ] }) })
244
+ }
245
+ );
246
+ };
247
+
248
+ // src/pages/orders/order-detail/components/active-order-return-section/active-order-return-section.tsx
249
+ import { ArrowUturnLeft } from "@medusajs/icons";
250
+ import { Button as Button3, Container as Container3, Heading as Heading3, Text as Text3, toast as toast3 } from "@medusajs/ui";
251
+ import { useTranslation as useTranslation3 } from "react-i18next";
252
+ import { useNavigate as useNavigate3 } from "react-router-dom";
253
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
254
+ var ActiveOrderReturnSection = ({
255
+ orderPreview
256
+ }) => {
257
+ const { t } = useTranslation3();
258
+ const orderChange = orderPreview?.order_change;
259
+ const returnId = orderChange?.return_id;
260
+ const isReturnRequest = orderChange?.change_type === "return_request" && !!orderChange.return_id;
261
+ const { mutateAsync: cancelReturn } = useCancelReturnRequest(
262
+ returnId,
263
+ orderPreview.id
264
+ );
265
+ const navigate = useNavigate3();
266
+ const onContinueReturn = async () => {
267
+ navigate(`/orders/${orderPreview.id}/returns`);
268
+ };
269
+ const onCancelReturn = async () => {
270
+ await cancelReturn(void 0, {
271
+ onSuccess: () => {
272
+ toast3.success(t("orders.returns.toast.canceledSuccessfully"));
273
+ },
274
+ onError: (error) => {
275
+ toast3.error(error.message);
276
+ }
277
+ });
278
+ };
279
+ if (!returnId || !isReturnRequest) {
280
+ return;
281
+ }
282
+ return /* @__PURE__ */ jsx3(
283
+ "div",
284
+ {
285
+ style: {
286
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
287
+ },
288
+ className: "-m-4 mb-1 border-b border-l p-4",
289
+ "data-testid": "active-order-return-section",
290
+ children: /* @__PURE__ */ jsx3(Container3, { className: "flex items-center justify-between p-0", children: /* @__PURE__ */ jsxs3("div", { className: "flex w-full flex-row justify-between", children: [
291
+ /* @__PURE__ */ jsxs3("div", { children: [
292
+ /* @__PURE__ */ jsxs3("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", "data-testid": "active-order-return-header", children: [
293
+ /* @__PURE__ */ jsx3(ArrowUturnLeft, { className: "text-ui-fg-subtle" }),
294
+ /* @__PURE__ */ jsx3(Heading3, { level: "h2", "data-testid": "active-order-return-heading", children: t("orders.returns.panel.title") })
295
+ ] }),
296
+ /* @__PURE__ */ jsx3("div", { className: "gap-2 px-6 pb-4", "data-testid": "active-order-return-description", children: /* @__PURE__ */ jsx3(Text3, { children: t("orders.returns.panel.description") }) })
297
+ ] }),
298
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", "data-testid": "active-order-return-actions", children: [
299
+ /* @__PURE__ */ jsx3(Button3, { size: "small", variant: "secondary", onClick: onCancelReturn, "data-testid": "active-order-return-cancel-button", children: t("orders.returns.cancel.title") }),
300
+ /* @__PURE__ */ jsx3(Button3, { size: "small", variant: "secondary", onClick: onContinueReturn, "data-testid": "active-order-return-continue-button", children: t("actions.continue") })
301
+ ] })
302
+ ] }) })
303
+ }
304
+ );
305
+ };
306
+
307
+ // src/pages/orders/order-detail/components/order-active-edit-section/order-active-edit-section.tsx
308
+ import { Button as Button4, Container as Container4, Copy, Heading as Heading4, toast as toast4 } from "@medusajs/ui";
309
+ import { useTranslation as useTranslation4 } from "react-i18next";
310
+ import { ExclamationCircleSolid } from "@medusajs/icons";
311
+ import { useMemo } from "react";
312
+ import { useNavigate as useNavigate4 } from "react-router-dom";
313
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
314
+ function EditItem({
315
+ item,
316
+ quantity
317
+ }) {
318
+ return /* @__PURE__ */ jsx4("div", { className: "text-ui-fg-subtle items-center gap-x-2", children: /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-2", children: [
319
+ /* @__PURE__ */ jsxs4("div", { className: "w-fit min-w-[27px]", children: [
320
+ /* @__PURE__ */ jsx4("span", { className: "txt-small tabular-nums", children: quantity }),
321
+ "x"
322
+ ] }),
323
+ /* @__PURE__ */ jsx4(Thumbnail, { src: item.thumbnail }),
324
+ /* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle font-medium", children: item.title }),
325
+ item.variant_sku && " \xB7 ",
326
+ item.variant_sku && /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
327
+ /* @__PURE__ */ jsx4("span", { className: "txt-small", children: item.variant_sku }),
328
+ /* @__PURE__ */ jsx4(Copy, { content: item.variant_sku, className: "text-ui-fg-muted" })
329
+ ] })
330
+ ] }) }, item.id);
331
+ }
332
+ var OrderActiveEditSection = ({
333
+ order
334
+ }) => {
335
+ const { t } = useTranslation4();
336
+ const navigate = useNavigate4();
337
+ const { order: orderPreview } = useOrderPreview(order.id);
338
+ const { mutateAsync: cancelOrderEdit } = useCancelOrderEdit(order.id);
339
+ const { mutateAsync: confirmOrderEdit } = useConfirmOrderEdit(order.id);
340
+ const isPending = orderPreview.order_change?.status === "pending";
341
+ const [addedItems, removedItems] = useMemo(() => {
342
+ const added = [];
343
+ const removed = [];
344
+ const orderLookupMap = new Map(order.items.map((i) => [i.id, i]));
345
+ (orderPreview?.items || []).forEach((currentItem) => {
346
+ const originalItem = orderLookupMap.get(currentItem.id);
347
+ if (!originalItem) {
348
+ added.push({ item: currentItem, quantity: currentItem.quantity });
349
+ return;
350
+ }
351
+ if (originalItem.quantity > currentItem.quantity) {
352
+ removed.push({
353
+ item: currentItem,
354
+ quantity: originalItem.quantity - currentItem.quantity
355
+ });
356
+ }
357
+ if (originalItem.quantity < currentItem.quantity) {
358
+ added.push({
359
+ item: currentItem,
360
+ quantity: currentItem.quantity - originalItem.quantity
361
+ });
362
+ }
363
+ });
364
+ return [added, removed];
365
+ }, [orderPreview]);
366
+ const onConfirmOrderEdit = async () => {
367
+ try {
368
+ await confirmOrderEdit();
369
+ toast4.success(t("orders.edits.toast.confirmedSuccessfully"));
370
+ } catch (e) {
371
+ toast4.error(e.message);
372
+ }
373
+ };
374
+ const onCancelOrderEdit = async () => {
375
+ try {
376
+ await cancelOrderEdit();
377
+ toast4.success(t("orders.edits.toast.canceledSuccessfully"));
378
+ } catch (e) {
379
+ toast4.error(e.message);
380
+ }
381
+ };
382
+ if (!orderPreview || orderPreview.order_change?.change_type !== "edit") {
383
+ return null;
384
+ }
385
+ return /* @__PURE__ */ jsx4(
386
+ "div",
387
+ {
388
+ style: {
389
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
390
+ },
391
+ className: "-m-4 mb-1 border-b border-l p-4",
392
+ "data-testid": "order-active-edit-section",
393
+ children: /* @__PURE__ */ jsx4(Container4, { className: "flex items-center justify-between p-0", children: /* @__PURE__ */ jsxs4("div", { className: "flex w-full flex-col divide-y divide-dashed", children: [
394
+ /* @__PURE__ */ jsxs4(
395
+ "div",
396
+ {
397
+ className: "flex items-center gap-2 px-6 py-4",
398
+ "data-testid": "order-active-edit-header",
399
+ children: [
400
+ /* @__PURE__ */ jsx4(ExclamationCircleSolid, { className: "text-blue-500" }),
401
+ /* @__PURE__ */ jsx4(Heading4, { level: "h2", "data-testid": "order-active-edit-heading", children: t(
402
+ isPending ? "orders.edits.panel.titlePending" : "orders.edits.panel.title"
403
+ ) })
404
+ ]
405
+ }
406
+ ),
407
+ !!addedItems.length && /* @__PURE__ */ jsxs4("div", { className: "txt-small text-ui-fg-subtle flex flex-row px-6 py-4", children: [
408
+ /* @__PURE__ */ jsx4("span", { className: "flex-1 font-medium", children: t("labels.added") }),
409
+ /* @__PURE__ */ jsx4("div", { className: "flex flex-1 flex-col gap-y-2", children: addedItems.map(({ item, quantity }) => /* @__PURE__ */ jsx4(EditItem, { item, quantity }, item.id)) })
410
+ ] }),
411
+ !!removedItems.length && /* @__PURE__ */ jsxs4("div", { className: "txt-small text-ui-fg-subtle flex flex-row px-6 py-4", children: [
412
+ /* @__PURE__ */ jsx4("span", { className: "flex-1 font-medium", children: t("labels.removed") }),
413
+ /* @__PURE__ */ jsx4("div", { className: "flex flex-1 flex-col gap-y-2", children: removedItems.map(({ item, quantity }) => /* @__PURE__ */ jsx4(EditItem, { item, quantity }, item.id)) })
414
+ ] }),
415
+ /* @__PURE__ */ jsxs4(
416
+ "div",
417
+ {
418
+ className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4",
419
+ "data-testid": "order-active-edit-actions",
420
+ children: [
421
+ isPending ? /* @__PURE__ */ jsx4(
422
+ Button4,
423
+ {
424
+ size: "small",
425
+ variant: "secondary",
426
+ onClick: () => navigate(`/orders/${order.id}/edits`),
427
+ "data-testid": "order-active-edit-continue-button",
428
+ children: t("actions.continueEdit")
429
+ }
430
+ ) : /* @__PURE__ */ jsx4(
431
+ Button4,
432
+ {
433
+ size: "small",
434
+ variant: "secondary",
435
+ onClick: onConfirmOrderEdit,
436
+ "data-testid": "order-active-edit-confirm-button",
437
+ children: t("actions.forceConfirm")
438
+ }
439
+ ),
440
+ /* @__PURE__ */ jsx4(
441
+ Button4,
442
+ {
443
+ size: "small",
444
+ variant: "secondary",
445
+ onClick: onCancelOrderEdit,
446
+ "data-testid": "order-active-edit-cancel-button",
447
+ children: t("actions.cancel")
448
+ }
449
+ )
450
+ ]
451
+ }
452
+ )
453
+ ] }) })
454
+ }
455
+ );
456
+ };
457
+
458
+ // src/pages/orders/order-detail/components/order-activity-section/order-activity-section.tsx
459
+ import { Container as Container5, Heading as Heading5 } from "@medusajs/ui";
460
+ import { useTranslation as useTranslation8 } from "react-i18next";
461
+
462
+ // src/pages/orders/order-detail/components/order-activity-section/order-timeline.tsx
463
+ import { Button as Button5, Text as Text6, Tooltip, clx, toast as toast5, usePrompt } from "@medusajs/ui";
464
+ import { Collapsible as RadixCollapsible } from "radix-ui";
465
+ import { useMemo as useMemo2, useState as useState3 } from "react";
466
+ import { useTranslation as useTranslation7 } from "react-i18next";
467
+
468
+ // src/pages/orders/order-detail/components/order-activity-section/activity-items.tsx
469
+ import { Popover, Text as Text4 } from "@medusajs/ui";
470
+ import { useState } from "react";
471
+ import { useTranslation as useTranslation5 } from "react-i18next";
472
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
473
+ function ActivityItems(props) {
474
+ const { t } = useTranslation5();
475
+ const [open, setOpen] = useState(false);
476
+ const itemsToSend = props.itemsToSend;
477
+ const itemsToReturn = props.itemsToReturn;
478
+ const itemsMap = props.itemsMap;
479
+ const title = props.title;
480
+ const handleMouseEnter = () => {
481
+ setOpen(true);
482
+ };
483
+ const handleMouseLeave = () => {
484
+ setOpen(false);
485
+ };
486
+ if (!itemsToSend?.length && !itemsToReturn?.length) {
487
+ return;
488
+ }
489
+ return /* @__PURE__ */ jsxs5(Popover, { open, children: [
490
+ /* @__PURE__ */ jsx5(
491
+ Popover.Trigger,
492
+ {
493
+ onMouseEnter: handleMouseEnter,
494
+ onMouseLeave: handleMouseLeave,
495
+ autoFocus: false,
496
+ className: "focus-visible:outline-none",
497
+ children: /* @__PURE__ */ jsx5(Text4, { size: "small", leading: "compact", weight: "plus", children: title })
498
+ }
499
+ ),
500
+ /* @__PURE__ */ jsx5(
501
+ Popover.Content,
502
+ {
503
+ align: "center",
504
+ side: "top",
505
+ className: "bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",
506
+ children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col", children: [
507
+ !!itemsToSend?.length && /* @__PURE__ */ jsxs5("div", { className: "p-3", children: [
508
+ /* @__PURE__ */ jsx5("div", { className: "txt-compact-small-plus mb-1", children: t("orders.activity.events.common.toSend") }),
509
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-col", children: [
510
+ itemsToSend?.map((item) => {
511
+ const originalItem = itemsMap?.get(item.item_id);
512
+ return /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-x-3", children: [
513
+ /* @__PURE__ */ jsxs5(Text4, { size: "small", className: "text-ui-fg-subtle", children: [
514
+ item.quantity,
515
+ "x"
516
+ ] }),
517
+ /* @__PURE__ */ jsx5(Thumbnail, { src: originalItem?.thumbnail }),
518
+ /* @__PURE__ */ jsx5(Text4, { className: "txt-compact-small text-ui-fg-subtle truncate", children: `${originalItem?.variant_title} \xB7 ${originalItem?.product_title}` })
519
+ ] }, item.id);
520
+ }),
521
+ /* @__PURE__ */ jsx5("div", { className: "flex flex-1 flex-row items-center gap-2" })
522
+ ] })
523
+ ] }),
524
+ !!itemsToReturn?.length && /* @__PURE__ */ jsxs5("div", { className: "border-t-2 border-dotted p-3", children: [
525
+ /* @__PURE__ */ jsx5("div", { className: "txt-compact-small-plus mb-1", children: t("orders.activity.events.common.toReturn") }),
526
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-col", children: [
527
+ itemsToReturn?.map((item) => {
528
+ const originalItem = itemsMap?.get(item.item_id);
529
+ return /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-x-3", children: [
530
+ /* @__PURE__ */ jsxs5(Text4, { size: "small", className: "text-ui-fg-subtle", children: [
531
+ item.quantity,
532
+ "x"
533
+ ] }),
534
+ /* @__PURE__ */ jsx5(Thumbnail, { src: originalItem?.thumbnail }),
535
+ /* @__PURE__ */ jsx5(Text4, { className: "txt-compact-small text-ui-fg-subtle truncate", children: `${originalItem?.variant_title} \xB7 ${originalItem?.product_title}` })
536
+ ] }, item.id);
537
+ }),
538
+ /* @__PURE__ */ jsx5("div", { className: "flex flex-1 flex-row items-center gap-2" })
539
+ ] })
540
+ ] })
541
+ ] })
542
+ }
543
+ )
544
+ ] });
545
+ }
546
+ var activity_items_default = ActivityItems;
547
+
548
+ // src/pages/orders/order-detail/components/order-activity-section/change-details-tooltip.tsx
549
+ import { Popover as Popover2, Text as Text5 } from "@medusajs/ui";
550
+ import { useState as useState2 } from "react";
551
+ import { useTranslation as useTranslation6 } from "react-i18next";
552
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
553
+ function ChangeDetailsTooltip(props) {
554
+ const { t } = useTranslation6();
555
+ const [open, setOpen] = useState2(false);
556
+ const previous = props.previous;
557
+ const next = props.next;
558
+ const title = props.title;
559
+ const handleMouseEnter = () => {
560
+ setOpen(true);
561
+ };
562
+ const handleMouseLeave = () => {
563
+ setOpen(false);
564
+ };
565
+ if (!previous && !next) {
566
+ return null;
567
+ }
568
+ return /* @__PURE__ */ jsxs6(Popover2, { open, children: [
569
+ /* @__PURE__ */ jsx6(
570
+ Popover2.Trigger,
571
+ {
572
+ onMouseEnter: handleMouseEnter,
573
+ onMouseLeave: handleMouseLeave,
574
+ autoFocus: false,
575
+ className: "focus-visible:outline-none",
576
+ children: /* @__PURE__ */ jsx6(Text5, { size: "small", leading: "compact", weight: "plus", children: title })
577
+ }
578
+ ),
579
+ /* @__PURE__ */ jsx6(
580
+ Popover2.Content,
581
+ {
582
+ align: "center",
583
+ side: "top",
584
+ className: "bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",
585
+ children: /* @__PURE__ */ jsxs6("div", { className: "flex flex-col", children: [
586
+ !!previous && /* @__PURE__ */ jsxs6("div", { className: "p-3", children: [
587
+ /* @__PURE__ */ jsx6("div", { className: "txt-compact-small-plus mb-1", children: t("labels.from") }),
588
+ /* @__PURE__ */ jsx6("p", { className: "txt-compact-small text-ui-fg-subtle", children: previous })
589
+ ] }),
590
+ !!next && /* @__PURE__ */ jsxs6("div", { className: "border-t-2 border-dotted p-3", children: [
591
+ /* @__PURE__ */ jsx6("div", { className: "txt-compact-small-plus mb-1", children: t("labels.to") }),
592
+ /* @__PURE__ */ jsx6("p", { className: "txt-compact-small text-ui-fg-subtle", children: next })
593
+ ] })
594
+ ] })
595
+ }
596
+ )
597
+ ] });
598
+ }
599
+ var change_details_tooltip_default = ChangeDetailsTooltip;
600
+
601
+ // src/pages/orders/order-detail/components/order-activity-section/order-timeline.tsx
602
+ import { Fragment, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
603
+ var NON_RMA_CHANGE_TYPES = ["transfer", "update_order"];
604
+ var OrderTimeline = ({ order }) => {
605
+ const items = useActivityItems(order);
606
+ if (items.length <= 3) {
607
+ return /* @__PURE__ */ jsx7("div", { className: "flex flex-col gap-y-0.5", "data-testid": "order-timeline", children: items.map((item, index) => {
608
+ return /* @__PURE__ */ jsx7(
609
+ OrderActivityItem,
610
+ {
611
+ title: item.title,
612
+ timestamp: item.timestamp,
613
+ isFirst: index === items.length - 1,
614
+ itemsToSend: item.itemsToSend,
615
+ itemsToReturn: item.itemsToReturn,
616
+ itemsMap: item.itemsMap,
617
+ children: item.children
618
+ },
619
+ index
620
+ );
621
+ }) });
622
+ }
623
+ const lastItems = items.slice(0, 2);
624
+ const collapsibleItems = items.slice(2, items.length - 1);
625
+ const firstItem = items[items.length - 1];
626
+ return /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-y-0.5", "data-testid": "order-timeline", children: [
627
+ lastItems.map((item, index) => {
628
+ return /* @__PURE__ */ jsx7(
629
+ OrderActivityItem,
630
+ {
631
+ title: item.title,
632
+ timestamp: item.timestamp,
633
+ itemsToSend: item.itemsToSend,
634
+ itemsToReturn: item.itemsToReturn,
635
+ itemsMap: item.itemsMap,
636
+ children: item.children
637
+ },
638
+ index
639
+ );
640
+ }),
641
+ /* @__PURE__ */ jsx7(OrderActivityCollapsible, { activities: collapsibleItems }),
642
+ /* @__PURE__ */ jsx7(
643
+ OrderActivityItem,
644
+ {
645
+ title: firstItem.title,
646
+ timestamp: firstItem.timestamp,
647
+ isFirst: true,
648
+ itemsToSend: firstItem.itemsToSend,
649
+ itemsToReturn: firstItem.itemsToReturn,
650
+ itemsMap: firstItem.itemsMap,
651
+ children: firstItem.children
652
+ }
653
+ )
654
+ ] });
655
+ };
656
+ var useActivityItems = (order) => {
657
+ const { t } = useTranslation7();
658
+ const { order_changes: orderChanges = [] } = useOrderChanges(order.id, {
659
+ change_type: [
660
+ "edit",
661
+ "claim",
662
+ "exchange",
663
+ "return",
664
+ "transfer",
665
+ "update_order"
666
+ ]
667
+ });
668
+ const rmaChanges = orderChanges.filter(
669
+ (oc) => !NON_RMA_CHANGE_TYPES.includes(oc.change_type)
670
+ );
671
+ const missingLineItemIds = getMissingLineItemIds(order, rmaChanges);
672
+ const { order_items: removedLineItems = [] } = useOrderLineItems(
673
+ order.id,
674
+ {
675
+ fields: "+quantity",
676
+ item_id: missingLineItemIds
677
+ },
678
+ {
679
+ enabled: !!rmaChanges.length
680
+ }
681
+ );
682
+ const itemsMap = useMemo2(() => {
683
+ const _itemsMap = new Map(order?.items?.map((i) => [i.id, i]));
684
+ for (const id of missingLineItemIds) {
685
+ const i = removedLineItems.find((i2) => i2.item.id === id);
686
+ if (i) {
687
+ _itemsMap.set(id, { ...i.item, quantity: i.quantity });
688
+ }
689
+ }
690
+ return _itemsMap;
691
+ }, [order.items, removedLineItems, missingLineItemIds]);
692
+ const { returns = [] } = useReturns({
693
+ order_id: order.id,
694
+ fields: "+received_at,*items"
695
+ });
696
+ const { claims = [] } = useClaims({
697
+ order_id: order.id,
698
+ fields: "*additional_items"
699
+ });
700
+ const { exchanges = [] } = useExchanges({
701
+ order_id: order.id,
702
+ fields: "*additional_items"
703
+ });
704
+ const payments = getPaymentsFromOrder(order);
705
+ const notes = [];
706
+ const isLoading = false;
707
+ return useMemo2(() => {
708
+ if (isLoading) {
709
+ return [];
710
+ }
711
+ const items = [];
712
+ for (const payment of payments) {
713
+ const amount = payment.amount;
714
+ items.push({
715
+ title: t("orders.activity.events.payment.awaiting"),
716
+ timestamp: payment.created_at,
717
+ children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
718
+ });
719
+ if (payment.canceled_at) {
720
+ items.push({
721
+ title: t("orders.activity.events.payment.canceled"),
722
+ timestamp: payment.canceled_at,
723
+ children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
724
+ });
725
+ }
726
+ if (payment.captured_at) {
727
+ items.push({
728
+ title: t("orders.activity.events.payment.captured"),
729
+ timestamp: payment.captured_at,
730
+ children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
731
+ });
732
+ }
733
+ for (const refund of payment.refunds || []) {
734
+ items.push({
735
+ title: t("orders.activity.events.payment.refunded"),
736
+ timestamp: refund.created_at,
737
+ children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(
738
+ refund.amount,
739
+ payment.currency_code
740
+ ) })
741
+ });
742
+ }
743
+ }
744
+ for (const fulfillment of order.fulfillments || []) {
745
+ items.push({
746
+ title: t("orders.activity.events.fulfillment.created"),
747
+ timestamp: fulfillment.created_at,
748
+ children: /* @__PURE__ */ jsx7(
749
+ FulfillmentCreatedBody,
750
+ {
751
+ fulfillment,
752
+ itemsMap
753
+ }
754
+ )
755
+ });
756
+ if (fulfillment.delivered_at) {
757
+ items.push({
758
+ title: t("orders.activity.events.fulfillment.delivered"),
759
+ timestamp: fulfillment.delivered_at,
760
+ children: /* @__PURE__ */ jsx7(
761
+ FulfillmentCreatedBody,
762
+ {
763
+ fulfillment,
764
+ itemsMap
765
+ }
766
+ )
767
+ });
768
+ }
769
+ if (fulfillment.shipped_at) {
770
+ items.push({
771
+ title: t("orders.activity.events.fulfillment.shipped"),
772
+ timestamp: fulfillment.shipped_at,
773
+ children: /* @__PURE__ */ jsx7(
774
+ FulfillmentCreatedBody,
775
+ {
776
+ fulfillment,
777
+ isShipment: true,
778
+ itemsMap
779
+ }
780
+ )
781
+ });
782
+ }
783
+ if (fulfillment.canceled_at) {
784
+ items.push({
785
+ title: t("orders.activity.events.fulfillment.canceled"),
786
+ timestamp: fulfillment.canceled_at
787
+ });
788
+ }
789
+ }
790
+ const returnMap = /* @__PURE__ */ new Map();
791
+ for (const ret of returns) {
792
+ returnMap.set(ret.id, ret);
793
+ if (ret.claim_id || ret.exchange_id) {
794
+ continue;
795
+ }
796
+ items.push({
797
+ title: t("orders.activity.events.return.created", {
798
+ returnId: ret.id.slice(-7)
799
+ }),
800
+ timestamp: ret.created_at,
801
+ itemsToReturn: ret?.items,
802
+ itemsMap,
803
+ children: /* @__PURE__ */ jsx7(ReturnBody, { orderReturn: ret, isCreated: !ret.canceled_at })
804
+ });
805
+ if (ret.canceled_at) {
806
+ items.push({
807
+ title: t("orders.activity.events.return.canceled", {
808
+ returnId: ret.id.slice(-7)
809
+ }),
810
+ timestamp: ret.canceled_at
811
+ });
812
+ }
813
+ if (ret.status === "received" || ret.status === "partially_received") {
814
+ items.push({
815
+ title: t("orders.activity.events.return.received", {
816
+ returnId: ret.id.slice(-7)
817
+ }),
818
+ timestamp: ret.received_at,
819
+ itemsToReturn: ret?.items,
820
+ itemsMap,
821
+ children: /* @__PURE__ */ jsx7(ReturnBody, { orderReturn: ret, isReceived: true })
822
+ });
823
+ }
824
+ }
825
+ for (const claim of claims) {
826
+ const claimReturn = returnMap.get(claim.return_id);
827
+ items.push({
828
+ title: t(
829
+ claim.canceled_at ? "orders.activity.events.claim.canceled" : "orders.activity.events.claim.created",
830
+ {
831
+ claimId: claim.id.slice(-7)
832
+ }
833
+ ),
834
+ timestamp: claim.canceled_at || claim.created_at,
835
+ itemsToSend: claim.additional_items,
836
+ itemsToReturn: claimReturn?.items,
837
+ itemsMap,
838
+ children: /* @__PURE__ */ jsx7(ClaimBody, { claim, claimReturn })
839
+ });
840
+ }
841
+ for (const exchange of exchanges) {
842
+ const exchangeReturn = returnMap.get(exchange.return_id);
843
+ items.push({
844
+ title: t(
845
+ exchange.canceled_at ? "orders.activity.events.exchange.canceled" : "orders.activity.events.exchange.created",
846
+ {
847
+ exchangeId: exchange.id.slice(-7)
848
+ }
849
+ ),
850
+ timestamp: exchange.canceled_at || exchange.created_at,
851
+ itemsToSend: exchange.additional_items,
852
+ itemsToReturn: exchangeReturn?.items,
853
+ itemsMap,
854
+ children: /* @__PURE__ */ jsx7(ExchangeBody, { exchange, exchangeReturn })
855
+ });
856
+ }
857
+ for (const edit of orderChanges.filter((oc) => oc.change_type === "edit")) {
858
+ const isConfirmed = edit.status === "confirmed";
859
+ const isPending = edit.status === "pending";
860
+ if (isPending) {
861
+ continue;
862
+ }
863
+ items.push({
864
+ title: t(`orders.activity.events.edit.${edit.status}`, {
865
+ editId: edit.id.slice(-7)
866
+ }),
867
+ timestamp: edit.status === "requested" ? edit.requested_at : edit.status === "confirmed" ? edit.confirmed_at : edit.status === "declined" ? edit.declined_at : edit.status === "canceled" ? edit.canceled_at : edit.created_at,
868
+ children: isConfirmed ? /* @__PURE__ */ jsx7(OrderEditBody, { edit }) : null
869
+ });
870
+ }
871
+ for (const transfer of orderChanges.filter(
872
+ (oc) => oc.change_type === "transfer"
873
+ )) {
874
+ if (transfer.requested_at) {
875
+ items.push({
876
+ title: t(`orders.activity.events.transfer.requested`, {
877
+ transferId: transfer.id.slice(-7)
878
+ }),
879
+ timestamp: transfer.requested_at,
880
+ children: /* @__PURE__ */ jsx7(TransferOrderRequestBody, { transfer })
881
+ });
882
+ }
883
+ if (transfer.confirmed_at) {
884
+ items.push({
885
+ title: t(`orders.activity.events.transfer.confirmed`, {
886
+ transferId: transfer.id.slice(-7)
887
+ }),
888
+ timestamp: transfer.confirmed_at
889
+ });
890
+ }
891
+ if (transfer.declined_at) {
892
+ items.push({
893
+ title: t(`orders.activity.events.transfer.declined`, {
894
+ transferId: transfer.id.slice(-7)
895
+ }),
896
+ timestamp: transfer.declined_at
897
+ });
898
+ }
899
+ }
900
+ for (const update of orderChanges.filter(
901
+ (oc) => oc.change_type === "update_order"
902
+ )) {
903
+ const updateType = update.actions[0]?.details?.type;
904
+ if (updateType === "shipping_address") {
905
+ items.push({
906
+ title: /* @__PURE__ */ jsx7(
907
+ change_details_tooltip_default,
908
+ {
909
+ title: t(`orders.activity.events.update_order.shipping_address`),
910
+ previous: getFormattedAddress({
911
+ address: update.actions[0].details.old
912
+ }).join(", "),
913
+ next: getFormattedAddress({
914
+ address: update.actions[0].details.new
915
+ }).join(", ")
916
+ }
917
+ ),
918
+ timestamp: update.created_at,
919
+ children: /* @__PURE__ */ jsxs7("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
920
+ t("fields.by"),
921
+ " ",
922
+ /* @__PURE__ */ jsx7(By, { id: update.created_by })
923
+ ] })
924
+ });
925
+ }
926
+ if (updateType === "billing_address") {
927
+ items.push({
928
+ title: /* @__PURE__ */ jsx7(
929
+ change_details_tooltip_default,
930
+ {
931
+ title: t(`orders.activity.events.update_order.billing_address`),
932
+ previous: getFormattedAddress({
933
+ address: update.actions[0].details.old
934
+ }).join(", "),
935
+ next: getFormattedAddress({
936
+ address: update.actions[0].details.new
937
+ }).join(", ")
938
+ }
939
+ ),
940
+ timestamp: update.created_at,
941
+ children: /* @__PURE__ */ jsxs7("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
942
+ t("fields.by"),
943
+ " ",
944
+ /* @__PURE__ */ jsx7(By, { id: update.created_by })
945
+ ] })
946
+ });
947
+ }
948
+ if (updateType === "email") {
949
+ items.push({
950
+ title: /* @__PURE__ */ jsx7(
951
+ change_details_tooltip_default,
952
+ {
953
+ title: t(`orders.activity.events.update_order.email`),
954
+ previous: update.actions[0].details.old,
955
+ next: update.actions[0].details.new
956
+ }
957
+ ),
958
+ timestamp: update.created_at,
959
+ children: /* @__PURE__ */ jsxs7("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
960
+ t("fields.by"),
961
+ " ",
962
+ /* @__PURE__ */ jsx7(By, { id: update.created_by })
963
+ ] })
964
+ });
965
+ }
966
+ }
967
+ if (order.canceled_at) {
968
+ items.push({
969
+ title: t("orders.activity.events.canceled.title"),
970
+ timestamp: order.canceled_at
971
+ });
972
+ }
973
+ const sortedActivities = items.sort((a, b) => {
974
+ return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
975
+ });
976
+ const createdAt = {
977
+ title: t("orders.activity.events.placed.title"),
978
+ timestamp: order.created_at,
979
+ children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(order.total, order.currency_code) })
980
+ };
981
+ return [...sortedActivities, createdAt];
982
+ }, [
983
+ order,
984
+ payments,
985
+ returns,
986
+ exchanges,
987
+ orderChanges,
988
+ notes,
989
+ isLoading,
990
+ itemsMap
991
+ ]);
992
+ };
993
+ var OrderActivityItem = ({
994
+ title,
995
+ timestamp,
996
+ isFirst = false,
997
+ children,
998
+ itemsToSend,
999
+ itemsToReturn,
1000
+ itemsMap
1001
+ }) => {
1002
+ const { getFullDate, getRelativeDate } = useDate();
1003
+ return /* @__PURE__ */ jsxs7(
1004
+ "div",
1005
+ {
1006
+ className: "grid grid-cols-[20px_1fr] items-start gap-2",
1007
+ "data-testid": "order-activity-item",
1008
+ children: [
1009
+ /* @__PURE__ */ jsxs7(
1010
+ "div",
1011
+ {
1012
+ className: "flex size-full flex-col items-center gap-y-0.5",
1013
+ "data-testid": "order-activity-item-indicator",
1014
+ children: [
1015
+ /* @__PURE__ */ jsx7("div", { className: "flex size-5 items-center justify-center", children: /* @__PURE__ */ jsx7("div", { className: "bg-ui-bg-base shadow-borders-base flex size-2.5 items-center justify-center rounded-full", children: /* @__PURE__ */ jsx7("div", { className: "bg-ui-tag-neutral-icon size-1.5 rounded-full" }) }) }),
1016
+ !isFirst && /* @__PURE__ */ jsx7("div", { className: "bg-ui-border-base w-px flex-1" })
1017
+ ]
1018
+ }
1019
+ ),
1020
+ /* @__PURE__ */ jsxs7(
1021
+ "div",
1022
+ {
1023
+ className: clx({
1024
+ "pb-4": !isFirst
1025
+ }),
1026
+ "data-testid": "order-activity-item-content",
1027
+ children: [
1028
+ /* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between", children: [
1029
+ itemsToSend?.length || itemsToReturn?.length ? /* @__PURE__ */ jsx7(
1030
+ activity_items_default,
1031
+ {
1032
+ title,
1033
+ itemsToSend,
1034
+ itemsToReturn,
1035
+ itemsMap
1036
+ },
1037
+ title
1038
+ ) : /* @__PURE__ */ jsx7(
1039
+ Text6,
1040
+ {
1041
+ size: "small",
1042
+ leading: "compact",
1043
+ weight: "plus",
1044
+ "data-testid": "order-activity-item-title",
1045
+ children: title
1046
+ }
1047
+ ),
1048
+ timestamp && /* @__PURE__ */ jsx7(
1049
+ Tooltip,
1050
+ {
1051
+ content: getFullDate({ date: timestamp, includeTime: true }),
1052
+ children: /* @__PURE__ */ jsx7(
1053
+ Text6,
1054
+ {
1055
+ size: "small",
1056
+ leading: "compact",
1057
+ className: "text-ui-fg-subtle text-right",
1058
+ "data-testid": "order-activity-item-timestamp",
1059
+ children: getRelativeDate(timestamp)
1060
+ }
1061
+ )
1062
+ }
1063
+ )
1064
+ ] }),
1065
+ /* @__PURE__ */ jsx7("div", { children })
1066
+ ]
1067
+ }
1068
+ )
1069
+ ]
1070
+ }
1071
+ );
1072
+ };
1073
+ var OrderActivityCollapsible = ({
1074
+ activities
1075
+ }) => {
1076
+ const [open, setOpen] = useState3(false);
1077
+ const { t } = useTranslation7();
1078
+ if (!activities.length) {
1079
+ return null;
1080
+ }
1081
+ return /* @__PURE__ */ jsxs7(RadixCollapsible.Root, { open, onOpenChange: setOpen, children: [
1082
+ !open && /* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
1083
+ /* @__PURE__ */ jsx7("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsx7("div", { className: "border-ui-border-strong w-px flex-1 bg-[linear-gradient(var(--border-strong)_33%,rgba(255,255,255,0)_0%)] bg-[length:1px_3px] bg-right bg-repeat-y" }) }),
1084
+ /* @__PURE__ */ jsx7("div", { className: "pb-4", children: /* @__PURE__ */ jsx7(RadixCollapsible.Trigger, { className: "text-left", children: /* @__PURE__ */ jsx7(
1085
+ Text6,
1086
+ {
1087
+ size: "small",
1088
+ leading: "compact",
1089
+ weight: "plus",
1090
+ className: "text-ui-fg-muted",
1091
+ children: t("orders.activity.showMoreActivities", {
1092
+ count: activities.length
1093
+ })
1094
+ }
1095
+ ) }) })
1096
+ ] }),
1097
+ /* @__PURE__ */ jsx7(RadixCollapsible.Content, { children: /* @__PURE__ */ jsx7("div", { className: "flex flex-col gap-y-0.5", children: activities.map((item, index) => {
1098
+ return /* @__PURE__ */ jsx7(
1099
+ OrderActivityItem,
1100
+ {
1101
+ title: item.title,
1102
+ timestamp: item.timestamp,
1103
+ itemsToSend: item.itemsToSend,
1104
+ itemsToReturn: item.itemsToReturn,
1105
+ itemsMap: item.itemsMap,
1106
+ children: item.children
1107
+ },
1108
+ index
1109
+ );
1110
+ }) }) })
1111
+ ] });
1112
+ };
1113
+ var FulfillmentCreatedBody = ({
1114
+ fulfillment
1115
+ }) => {
1116
+ const { t } = useTranslation7();
1117
+ const numberOfItems = (fulfillment.items || []).reduce(
1118
+ (acc, item) => acc + item.quantity,
1119
+ 0
1120
+ );
1121
+ return /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.fulfillment.items", {
1122
+ count: numberOfItems
1123
+ }) }) });
1124
+ };
1125
+ var ReturnBody = ({
1126
+ orderReturn,
1127
+ isCreated,
1128
+ isReceived
1129
+ }) => {
1130
+ const prompt = usePrompt();
1131
+ const { t } = useTranslation7();
1132
+ const { mutateAsync: cancelReturnRequest } = useCancelReturn(
1133
+ orderReturn.id,
1134
+ orderReturn.order_id
1135
+ );
1136
+ const onCancel = async () => {
1137
+ const res = await prompt({
1138
+ title: t("orders.returns.cancel.title"),
1139
+ description: t("orders.returns.cancel.description"),
1140
+ confirmText: t("actions.confirm"),
1141
+ cancelText: t("actions.cancel")
1142
+ });
1143
+ if (!res) {
1144
+ return;
1145
+ }
1146
+ await cancelReturnRequest().catch((error) => {
1147
+ toast5.error(error.message);
1148
+ });
1149
+ };
1150
+ const numberOfItems = orderReturn.items.reduce((acc, item) => {
1151
+ return acc + (isReceived ? item.received_quantity : item.quantity);
1152
+ }, 0);
1153
+ return /* @__PURE__ */ jsxs7("div", { className: "flex items-start gap-1", children: [
1154
+ /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.return.items", {
1155
+ count: numberOfItems
1156
+ }) }),
1157
+ isCreated && /* @__PURE__ */ jsxs7(Fragment, { children: [
1158
+ /* @__PURE__ */ jsx7("div", { className: "mt-[2px] flex items-center leading-none", children: "\u22C5" }),
1159
+ /* @__PURE__ */ jsx7(
1160
+ Button5,
1161
+ {
1162
+ onClick: onCancel,
1163
+ className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
1164
+ variant: "transparent",
1165
+ size: "small",
1166
+ children: t("actions.cancel")
1167
+ }
1168
+ )
1169
+ ] })
1170
+ ] });
1171
+ };
1172
+ var ClaimBody = ({
1173
+ claim,
1174
+ claimReturn
1175
+ }) => {
1176
+ const prompt = usePrompt();
1177
+ const { t } = useTranslation7();
1178
+ const isCanceled = !!claim.created_at;
1179
+ const { mutateAsync: cancelClaim } = useCancelClaim(claim.id, claim.order_id);
1180
+ const onCancel = async () => {
1181
+ const res = await prompt({
1182
+ title: t("orders.claims.cancel.title"),
1183
+ description: t("orders.claims.cancel.description"),
1184
+ confirmText: t("actions.confirm"),
1185
+ cancelText: t("actions.cancel")
1186
+ });
1187
+ if (!res) {
1188
+ return;
1189
+ }
1190
+ await cancelClaim().catch((error) => {
1191
+ toast5.error(error.message);
1192
+ });
1193
+ };
1194
+ const outboundItems = (claim.additional_items || []).reduce(
1195
+ (acc, item) => acc + item.quantity,
1196
+ 0
1197
+ );
1198
+ const inboundItems = (claimReturn?.items || []).reduce(
1199
+ (acc, item) => acc + item.quantity,
1200
+ 0
1201
+ );
1202
+ return /* @__PURE__ */ jsxs7("div", { children: [
1203
+ outboundItems > 0 && /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.claim.itemsInbound", {
1204
+ count: outboundItems
1205
+ }) }),
1206
+ inboundItems > 0 && /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.claim.itemsOutbound", {
1207
+ count: inboundItems
1208
+ }) }),
1209
+ !isCanceled && /* @__PURE__ */ jsx7(
1210
+ Button5,
1211
+ {
1212
+ onClick: onCancel,
1213
+ className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
1214
+ variant: "transparent",
1215
+ size: "small",
1216
+ children: t("actions.cancel")
1217
+ }
1218
+ )
1219
+ ] });
1220
+ };
1221
+ var ExchangeBody = ({
1222
+ exchange,
1223
+ exchangeReturn
1224
+ }) => {
1225
+ const prompt = usePrompt();
1226
+ const { t } = useTranslation7();
1227
+ const isCanceled = !!exchange.canceled_at;
1228
+ const { mutateAsync: cancelExchange } = useCancelExchange(
1229
+ exchange.id,
1230
+ exchange.order_id
1231
+ );
1232
+ const onCancel = async () => {
1233
+ const res = await prompt({
1234
+ title: t("orders.exchanges.cancel.title"),
1235
+ description: t("orders.exchanges.cancel.description"),
1236
+ confirmText: t("actions.confirm"),
1237
+ cancelText: t("actions.cancel")
1238
+ });
1239
+ if (!res) {
1240
+ return;
1241
+ }
1242
+ await cancelExchange().catch((error) => {
1243
+ toast5.error(error.message);
1244
+ });
1245
+ };
1246
+ const outboundItems = (exchange.additional_items || []).reduce(
1247
+ (acc, item) => acc + item.quantity,
1248
+ 0
1249
+ );
1250
+ const inboundItems = (exchangeReturn?.items || []).reduce(
1251
+ (acc, item) => acc + item.quantity,
1252
+ 0
1253
+ );
1254
+ return /* @__PURE__ */ jsxs7("div", { children: [
1255
+ outboundItems > 0 && /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.exchange.itemsInbound", {
1256
+ count: outboundItems
1257
+ }) }),
1258
+ inboundItems > 0 && /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.exchange.itemsOutbound", {
1259
+ count: inboundItems
1260
+ }) }),
1261
+ !isCanceled && /* @__PURE__ */ jsx7(
1262
+ Button5,
1263
+ {
1264
+ onClick: onCancel,
1265
+ className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
1266
+ variant: "transparent",
1267
+ size: "small",
1268
+ children: t("actions.cancel")
1269
+ }
1270
+ )
1271
+ ] });
1272
+ };
1273
+ var OrderEditBody = ({ edit }) => {
1274
+ const { t } = useTranslation7();
1275
+ const [itemsAdded, itemsRemoved] = useMemo2(
1276
+ () => countItemsChange(edit.actions),
1277
+ [edit]
1278
+ );
1279
+ return /* @__PURE__ */ jsxs7("div", { children: [
1280
+ itemsAdded > 0 && /* @__PURE__ */ jsxs7(Text6, { size: "small", className: "text-ui-fg-subtle", children: [
1281
+ t("labels.added"),
1282
+ ": ",
1283
+ itemsAdded
1284
+ ] }),
1285
+ itemsRemoved > 0 && /* @__PURE__ */ jsxs7(Text6, { size: "small", className: "text-ui-fg-subtle", children: [
1286
+ t("labels.removed"),
1287
+ ": ",
1288
+ itemsRemoved
1289
+ ] })
1290
+ ] });
1291
+ };
1292
+ var TransferOrderRequestBody = ({
1293
+ transfer
1294
+ }) => {
1295
+ const prompt = usePrompt();
1296
+ const { t } = useTranslation7();
1297
+ const action = transfer.actions[0];
1298
+ const { customer } = useCustomer(action.reference_id);
1299
+ const isCompleted = !!transfer.confirmed_at;
1300
+ const { mutateAsync: cancelTransfer } = useCancelOrderTransfer(
1301
+ transfer.order_id
1302
+ );
1303
+ const handleDelete = async () => {
1304
+ const res = await prompt({
1305
+ title: t("general.areYouSure"),
1306
+ description: t("actions.cannotUndo"),
1307
+ confirmText: t("actions.delete"),
1308
+ cancelText: t("actions.cancel")
1309
+ });
1310
+ if (!res) {
1311
+ return;
1312
+ }
1313
+ await cancelTransfer().catch((error) => {
1314
+ toast5.error(error.message);
1315
+ });
1316
+ };
1317
+ return /* @__PURE__ */ jsxs7("div", { children: [
1318
+ /* @__PURE__ */ jsxs7(Text6, { size: "small", className: "text-ui-fg-subtle", children: [
1319
+ t("orders.activity.from"),
1320
+ ": ",
1321
+ action.details?.original_email
1322
+ ] }),
1323
+ /* @__PURE__ */ jsxs7(Text6, { size: "small", className: "text-ui-fg-subtle", children: [
1324
+ t("orders.activity.to"),
1325
+ ":",
1326
+ " ",
1327
+ customer?.first_name ? `${customer?.first_name} ${customer?.last_name}` : customer?.email
1328
+ ] }),
1329
+ !isCompleted && /* @__PURE__ */ jsx7(
1330
+ Button5,
1331
+ {
1332
+ onClick: handleDelete,
1333
+ className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
1334
+ variant: "transparent",
1335
+ size: "small",
1336
+ children: t("actions.cancel")
1337
+ }
1338
+ )
1339
+ ] });
1340
+ };
1341
+ function countItemsChange(actions) {
1342
+ let added = 0;
1343
+ let removed = 0;
1344
+ actions.forEach((action) => {
1345
+ if (action.action === "ITEM_ADD") {
1346
+ added += action.details.quantity;
1347
+ }
1348
+ if (action.action === "ITEM_UPDATE") {
1349
+ const quantityDiff = action.details.quantity_diff;
1350
+ if (quantityDiff > 0) {
1351
+ added += quantityDiff;
1352
+ } else {
1353
+ removed += Math.abs(quantityDiff);
1354
+ }
1355
+ }
1356
+ });
1357
+ return [added, removed];
1358
+ }
1359
+ function getMissingLineItemIds(order, changes) {
1360
+ if (!changes?.length) {
1361
+ return [];
1362
+ }
1363
+ const retIds = /* @__PURE__ */ new Set();
1364
+ const existingItemsMap = new Map(order.items.map((item) => [item.id, true]));
1365
+ changes.forEach((change) => {
1366
+ change.actions.forEach((action) => {
1367
+ if (!action.details?.reference_id) {
1368
+ return;
1369
+ }
1370
+ if (action.details.reference_id.startsWith("ordli_") && !existingItemsMap.has(action.details.reference_id)) {
1371
+ retIds.add(action.details.reference_id);
1372
+ }
1373
+ });
1374
+ });
1375
+ return Array.from(retIds);
1376
+ }
1377
+
1378
+ // src/pages/orders/order-detail/components/order-activity-section/order-activity-section.tsx
1379
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1380
+ var OrderActivitySection = ({ order }) => {
1381
+ const { t } = useTranslation8();
1382
+ return /* @__PURE__ */ jsxs8(Container5, { className: "flex flex-col gap-y-8 px-6 py-4", "data-testid": "order-activity-section", children: [
1383
+ /* @__PURE__ */ jsx8("div", { className: "flex flex-col gap-y-4", children: /* @__PURE__ */ jsx8("div", { className: "flex items-center justify-between", "data-testid": "order-activity-header", children: /* @__PURE__ */ jsx8(Heading5, { level: "h2", "data-testid": "order-activity-heading", children: t("orders.activity.header") }) }) }),
1384
+ /* @__PURE__ */ jsx8(OrderTimeline, { order })
1385
+ ] });
1386
+ };
1387
+
1388
+ // src/pages/orders/order-detail/components/order-customer-section/order-customer-section.tsx
1389
+ import { ArrowPath as ArrowPath2, CurrencyDollar, Envelope, FlyingBox } from "@medusajs/icons";
1390
+ import { Container as Container6, Heading as Heading6 } from "@medusajs/ui";
1391
+ import { useTranslation as useTranslation10 } from "react-i18next";
1392
+
1393
+ // src/components/common/customer-info/customer-info.tsx
1394
+ import { Avatar, Copy as Copy2, Text as Text7 } from "@medusajs/ui";
1395
+ import { useTranslation as useTranslation9 } from "react-i18next";
1396
+ import { Link } from "react-router-dom";
1397
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
1398
+ var ID = ({ data }) => {
1399
+ const { t } = useTranslation9();
1400
+ const id = data.customer_id;
1401
+ const name = getOrderCustomer(data);
1402
+ const email = data.email;
1403
+ const fallback = (name || email || "").charAt(0).toUpperCase();
1404
+ return /* @__PURE__ */ jsxs9("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1405
+ /* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", weight: "plus", children: t("fields.id") }),
1406
+ /* @__PURE__ */ jsx9(
1407
+ Link,
1408
+ {
1409
+ to: `/customers/${id}`,
1410
+ className: "focus:shadow-borders-focus rounded-[4px] outline-none transition-shadow",
1411
+ children: /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-x-2 overflow-hidden", children: [
1412
+ /* @__PURE__ */ jsx9(Avatar, { size: "2xsmall", fallback }),
1413
+ /* @__PURE__ */ jsx9(
1414
+ Text7,
1415
+ {
1416
+ size: "small",
1417
+ leading: "compact",
1418
+ className: "text-ui-fg-subtle hover:text-ui-fg-base transition-fg truncate",
1419
+ children: name || email
1420
+ }
1421
+ )
1422
+ ] })
1423
+ }
1424
+ )
1425
+ ] });
1426
+ };
1427
+ var Company = ({ data }) => {
1428
+ const { t } = useTranslation9();
1429
+ const company = data.shipping_address?.company || data.billing_address?.company;
1430
+ if (!company) {
1431
+ return null;
1432
+ }
1433
+ return /* @__PURE__ */ jsxs9("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1434
+ /* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", weight: "plus", children: t("fields.company") }),
1435
+ /* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", className: "truncate", children: company })
1436
+ ] });
1437
+ };
1438
+ var Contact = ({ data }) => {
1439
+ const { t } = useTranslation9();
1440
+ const phone = data.shipping_address?.phone || data.billing_address?.phone;
1441
+ const email = data.email || "";
1442
+ return /* @__PURE__ */ jsxs9("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1443
+ /* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", weight: "plus", children: t("orders.customer.contactLabel") }),
1444
+ /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-y-2", children: [
1445
+ /* @__PURE__ */ jsxs9("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
1446
+ /* @__PURE__ */ jsx9(
1447
+ Text7,
1448
+ {
1449
+ size: "small",
1450
+ leading: "compact",
1451
+ className: "text-pretty break-all",
1452
+ children: email
1453
+ }
1454
+ ),
1455
+ /* @__PURE__ */ jsx9("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx9(Copy2, { content: email, className: "text-ui-fg-muted" }) })
1456
+ ] }),
1457
+ phone && /* @__PURE__ */ jsxs9("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
1458
+ /* @__PURE__ */ jsx9(
1459
+ Text7,
1460
+ {
1461
+ size: "small",
1462
+ leading: "compact",
1463
+ className: "text-pretty break-all",
1464
+ children: phone
1465
+ }
1466
+ ),
1467
+ /* @__PURE__ */ jsx9("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx9(Copy2, { content: phone, className: "text-ui-fg-muted" }) })
1468
+ ] })
1469
+ ] })
1470
+ ] });
1471
+ };
1472
+ var AddressPrint = ({
1473
+ address,
1474
+ type
1475
+ }) => {
1476
+ const { t } = useTranslation9();
1477
+ return /* @__PURE__ */ jsxs9("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1478
+ /* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", weight: "plus", children: type === "shipping" ? t("addresses.shippingAddress.label") : t("addresses.billingAddress.label") }),
1479
+ address ? /* @__PURE__ */ jsxs9("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
1480
+ /* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", children: getFormattedAddress({ address }).map((line, i) => {
1481
+ return /* @__PURE__ */ jsxs9("span", { className: "break-words", children: [
1482
+ line,
1483
+ /* @__PURE__ */ jsx9("br", {})
1484
+ ] }, i);
1485
+ }) }),
1486
+ /* @__PURE__ */ jsx9("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx9(
1487
+ Copy2,
1488
+ {
1489
+ content: getFormattedAddress({ address }).join("\n"),
1490
+ className: "text-ui-fg-muted"
1491
+ }
1492
+ ) })
1493
+ ] }) : /* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", children: "-" })
1494
+ ] });
1495
+ };
1496
+ var Addresses = ({ data }) => {
1497
+ const { t } = useTranslation9();
1498
+ return /* @__PURE__ */ jsxs9("div", { className: "divide-y", children: [
1499
+ /* @__PURE__ */ jsx9(AddressPrint, { address: data.shipping_address, type: "shipping" }),
1500
+ !isSameAddress(data.shipping_address, data.billing_address) ? /* @__PURE__ */ jsx9(AddressPrint, { address: data.billing_address, type: "billing" }) : /* @__PURE__ */ jsxs9("div", { className: "grid grid-cols-2 items-center px-6 py-4", children: [
1501
+ /* @__PURE__ */ jsx9(
1502
+ Text7,
1503
+ {
1504
+ size: "small",
1505
+ leading: "compact",
1506
+ weight: "plus",
1507
+ className: "text-ui-fg-subtle",
1508
+ children: t("addresses.billingAddress.label")
1509
+ }
1510
+ ),
1511
+ /* @__PURE__ */ jsx9(Text7, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: t("addresses.billingAddress.sameAsShipping") })
1512
+ ] })
1513
+ ] });
1514
+ };
1515
+ var CustomerInfo = Object.assign(
1516
+ {},
1517
+ {
1518
+ ID,
1519
+ Company,
1520
+ Contact,
1521
+ Addresses
1522
+ }
1523
+ );
1524
+ var getOrderCustomer = (obj) => {
1525
+ const { first_name: sFirstName, last_name: sLastName } = obj.shipping_address || {};
1526
+ const { first_name: bFirstName, last_name: bLastName } = obj.billing_address || {};
1527
+ const { first_name: cFirstName, last_name: cLastName } = obj.customer || {};
1528
+ const customerName = [cFirstName, cLastName].filter(Boolean).join(" ");
1529
+ const shippingName = [sFirstName, sLastName].filter(Boolean).join(" ");
1530
+ const billingName = [bFirstName, bLastName].filter(Boolean).join(" ");
1531
+ const name = customerName || shippingName || billingName;
1532
+ return name;
1533
+ };
1534
+
1535
+ // src/pages/orders/order-detail/components/order-customer-section/order-customer-section.tsx
1536
+ import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
1537
+ var OrderCustomerSection = ({ order }) => {
1538
+ return /* @__PURE__ */ jsxs10(
1539
+ Container6,
1540
+ {
1541
+ className: "divide-y p-0",
1542
+ "data-testid": "order-customer-section",
1543
+ children: [
1544
+ /* @__PURE__ */ jsx10(Header, { order }),
1545
+ /* @__PURE__ */ jsx10(CustomerInfo.ID, { data: order }),
1546
+ /* @__PURE__ */ jsx10(CustomerInfo.Contact, { data: order }),
1547
+ /* @__PURE__ */ jsx10(CustomerInfo.Company, { data: order }),
1548
+ /* @__PURE__ */ jsx10(CustomerInfo.Addresses, { data: order })
1549
+ ]
1550
+ }
1551
+ );
1552
+ };
1553
+ var Header = ({ order }) => {
1554
+ const { t } = useTranslation10();
1555
+ return /* @__PURE__ */ jsxs10(
1556
+ "div",
1557
+ {
1558
+ className: "flex items-center justify-between px-6 py-4",
1559
+ "data-testid": "order-customer-header",
1560
+ children: [
1561
+ /* @__PURE__ */ jsx10(
1562
+ Heading6,
1563
+ {
1564
+ level: "h2",
1565
+ "data-testid": "order-customer-heading",
1566
+ children: t("fields.customer")
1567
+ }
1568
+ ),
1569
+ /* @__PURE__ */ jsx10(
1570
+ ActionMenu,
1571
+ {
1572
+ groups: [
1573
+ {
1574
+ actions: [
1575
+ {
1576
+ label: t("transferOwnership.label"),
1577
+ to: `transfer`,
1578
+ icon: /* @__PURE__ */ jsx10(ArrowPath2, {})
1579
+ }
1580
+ ]
1581
+ },
1582
+ {
1583
+ actions: [
1584
+ {
1585
+ label: t("addresses.shippingAddress.editLabel"),
1586
+ to: "shipping-address",
1587
+ icon: /* @__PURE__ */ jsx10(FlyingBox, {})
1588
+ },
1589
+ {
1590
+ label: t("addresses.billingAddress.editLabel"),
1591
+ to: "billing-address",
1592
+ icon: /* @__PURE__ */ jsx10(CurrencyDollar, {})
1593
+ }
1594
+ ]
1595
+ },
1596
+ {
1597
+ actions: [
1598
+ {
1599
+ label: t("email.editLabel"),
1600
+ to: `email`,
1601
+ icon: /* @__PURE__ */ jsx10(Envelope, {}),
1602
+ disabled: order.status === "canceled"
1603
+ }
1604
+ ]
1605
+ }
1606
+ ],
1607
+ "data-testid": "order-customer-action-menu"
1608
+ }
1609
+ )
1610
+ ]
1611
+ }
1612
+ );
1613
+ };
1614
+
1615
+ // src/pages/orders/order-detail/components/order-fulfillment-section/order-fulfillment-section.tsx
1616
+ import { Buildings, XCircle } from "@medusajs/icons";
1617
+ import {
1618
+ Button as Button6,
1619
+ Container as Container7,
1620
+ Copy as Copy3,
1621
+ Heading as Heading7,
1622
+ StatusBadge,
1623
+ Text as Text8,
1624
+ Tooltip as Tooltip2,
1625
+ toast as toast6,
1626
+ usePrompt as usePrompt2
1627
+ } from "@medusajs/ui";
1628
+ import { format } from "date-fns";
1629
+ import { useTranslation as useTranslation11 } from "react-i18next";
1630
+ import { Link as Link2, useNavigate as useNavigate5 } from "react-router-dom";
1631
+ import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
1632
+ var OrderFulfillmentSection = ({
1633
+ order
1634
+ }) => {
1635
+ const fulfillments = order.fulfillments || [];
1636
+ return /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-y-3", "data-testid": "order-fulfillment-section", children: [
1637
+ /* @__PURE__ */ jsx11(UnfulfilledItemBreakdown, { order }),
1638
+ fulfillments.map((f, index) => /* @__PURE__ */ jsx11(Fulfillment, { index, fulfillment: f, order }, f.id))
1639
+ ] });
1640
+ };
1641
+ var UnfulfilledItem = ({
1642
+ item,
1643
+ currencyCode
1644
+ }) => {
1645
+ return /* @__PURE__ */ jsxs11(
1646
+ "div",
1647
+ {
1648
+ className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",
1649
+ children: [
1650
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-start gap-x-4", children: [
1651
+ /* @__PURE__ */ jsx11(Thumbnail, { src: item.thumbnail }),
1652
+ /* @__PURE__ */ jsxs11("div", { children: [
1653
+ /* @__PURE__ */ jsx11(
1654
+ Text8,
1655
+ {
1656
+ size: "small",
1657
+ leading: "compact",
1658
+ weight: "plus",
1659
+ className: "text-ui-fg-base",
1660
+ children: item.title
1661
+ }
1662
+ ),
1663
+ item.variant_sku && /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-x-1", children: [
1664
+ /* @__PURE__ */ jsx11(Text8, { size: "small", children: item.variant_sku }),
1665
+ /* @__PURE__ */ jsx11(Copy3, { content: item.variant_sku, className: "text-ui-fg-muted" })
1666
+ ] }),
1667
+ /* @__PURE__ */ jsx11(Text8, { size: "small", children: item.variant?.options?.map((o) => o.value).join(" \xB7 ") })
1668
+ ] })
1669
+ ] }),
1670
+ /* @__PURE__ */ jsxs11("div", { className: "grid grid-cols-3 items-center gap-x-4", children: [
1671
+ /* @__PURE__ */ jsx11("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx11(Text8, { size: "small", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
1672
+ /* @__PURE__ */ jsx11("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsxs11(Text8, { children: [
1673
+ /* @__PURE__ */ jsx11("span", { className: "tabular-nums", children: item.quantity - item.detail.fulfilled_quantity }),
1674
+ "x"
1675
+ ] }) }),
1676
+ /* @__PURE__ */ jsx11("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx11(Text8, { size: "small", children: getLocaleAmount(item.subtotal || 0, currencyCode) }) })
1677
+ ] })
1678
+ ]
1679
+ },
1680
+ item.id
1681
+ );
1682
+ };
1683
+ var UnfulfilledItemBreakdown = ({ order }) => {
1684
+ const unfulfilledItemsWithShipping = order.items.filter(
1685
+ (i) => i.requires_shipping && i.detail.fulfilled_quantity < i.quantity
1686
+ );
1687
+ const unfulfilledItemsWithoutShipping = order.items.filter(
1688
+ (i) => !i.requires_shipping && i.detail.fulfilled_quantity < i.quantity
1689
+ );
1690
+ return /* @__PURE__ */ jsxs11(Fragment2, { children: [
1691
+ !!unfulfilledItemsWithShipping.length && /* @__PURE__ */ jsx11(
1692
+ UnfulfilledItemDisplay,
1693
+ {
1694
+ order,
1695
+ unfulfilledItems: unfulfilledItemsWithShipping,
1696
+ requiresShipping: true
1697
+ }
1698
+ ),
1699
+ !!unfulfilledItemsWithoutShipping.length && /* @__PURE__ */ jsx11(
1700
+ UnfulfilledItemDisplay,
1701
+ {
1702
+ order,
1703
+ unfulfilledItems: unfulfilledItemsWithoutShipping,
1704
+ requiresShipping: false
1705
+ }
1706
+ )
1707
+ ] });
1708
+ };
1709
+ var UnfulfilledItemDisplay = ({
1710
+ order,
1711
+ unfulfilledItems,
1712
+ requiresShipping = false
1713
+ }) => {
1714
+ const { t } = useTranslation11();
1715
+ if (order.status === "canceled") {
1716
+ return;
1717
+ }
1718
+ return /* @__PURE__ */ jsxs11(Container7, { className: "divide-y p-0", "data-testid": "order-fulfillment-unfulfilled", children: [
1719
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between px-6 py-4", "data-testid": "order-fulfillment-unfulfilled-header", children: [
1720
+ /* @__PURE__ */ jsx11(Heading7, { level: "h2", "data-testid": "order-fulfillment-unfulfilled-heading", children: t("orders.fulfillment.unfulfilledItems") }),
1721
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-x-4", "data-testid": "order-fulfillment-unfulfilled-badges", children: [
1722
+ requiresShipping && /* @__PURE__ */ jsx11(StatusBadge, { color: "red", className: "text-nowrap", "data-testid": "order-fulfillment-unfulfilled-requires-shipping-badge", children: t("orders.fulfillment.requiresShipping") }),
1723
+ /* @__PURE__ */ jsx11(StatusBadge, { color: "red", className: "text-nowrap", "data-testid": "order-fulfillment-unfulfilled-awaiting-badge", children: t("orders.fulfillment.awaitingFulfillmentBadge") }),
1724
+ /* @__PURE__ */ jsx11(
1725
+ ActionMenu,
1726
+ {
1727
+ groups: [
1728
+ {
1729
+ actions: [
1730
+ {
1731
+ label: t("orders.fulfillment.fulfillItems"),
1732
+ icon: /* @__PURE__ */ jsx11(Buildings, {}),
1733
+ to: `/orders/${order.id}/fulfillment?requires_shipping=${requiresShipping}`
1734
+ }
1735
+ ]
1736
+ }
1737
+ ],
1738
+ "data-testid": "order-fulfillment-unfulfilled-action-menu"
1739
+ }
1740
+ )
1741
+ ] })
1742
+ ] }),
1743
+ /* @__PURE__ */ jsx11("div", { "data-testid": "order-fulfillment-unfulfilled-items", children: unfulfilledItems.map((item) => /* @__PURE__ */ jsx11(
1744
+ UnfulfilledItem,
1745
+ {
1746
+ item,
1747
+ currencyCode: order.currency_code
1748
+ },
1749
+ item.id
1750
+ )) })
1751
+ ] });
1752
+ };
1753
+ var Fulfillment = ({
1754
+ fulfillment,
1755
+ order,
1756
+ index
1757
+ }) => {
1758
+ const { t } = useTranslation11();
1759
+ const prompt = usePrompt2();
1760
+ const navigate = useNavigate5();
1761
+ const showLocation = !!fulfillment.location_id;
1762
+ const isPickUpFulfillment = fulfillment.shipping_option?.service_zone.fulfillment_set.type === "pickup" /* Pickup */;
1763
+ const { stock_location, isError, error } = useStockLocation(
1764
+ fulfillment.location_id,
1765
+ void 0,
1766
+ {
1767
+ enabled: showLocation
1768
+ }
1769
+ );
1770
+ let statusText = fulfillment.requires_shipping ? isPickUpFulfillment ? "Awaiting pickup" : "Awaiting shipping" : "Awaiting delivery";
1771
+ let statusColor = "blue";
1772
+ let statusTimestamp = fulfillment.created_at;
1773
+ if (fulfillment.canceled_at) {
1774
+ statusText = "Canceled";
1775
+ statusColor = "red";
1776
+ statusTimestamp = fulfillment.canceled_at;
1777
+ } else if (fulfillment.delivered_at) {
1778
+ statusText = "Delivered";
1779
+ statusColor = "green";
1780
+ statusTimestamp = fulfillment.delivered_at;
1781
+ } else if (fulfillment.shipped_at) {
1782
+ statusText = "Shipped";
1783
+ statusColor = "green";
1784
+ statusTimestamp = fulfillment.shipped_at;
1785
+ }
1786
+ const { mutateAsync } = useCancelOrderFulfillment(order.id, fulfillment.id);
1787
+ const { mutateAsync: markAsDelivered } = useMarkOrderFulfillmentAsDelivered(
1788
+ order.id,
1789
+ fulfillment.id
1790
+ );
1791
+ const showShippingButton = !fulfillment.canceled_at && !fulfillment.shipped_at && !fulfillment.delivered_at && fulfillment.requires_shipping && !isPickUpFulfillment;
1792
+ const showDeliveryButton = !fulfillment.canceled_at && !fulfillment.delivered_at;
1793
+ const handleMarkAsDelivered = async () => {
1794
+ const res = await prompt({
1795
+ title: t("general.areYouSure"),
1796
+ description: t("orders.fulfillment.markAsDeliveredWarning"),
1797
+ confirmText: t("actions.continue"),
1798
+ cancelText: t("actions.cancel"),
1799
+ variant: "confirmation"
1800
+ });
1801
+ if (res) {
1802
+ await markAsDelivered(void 0, {
1803
+ onSuccess: () => {
1804
+ toast6.success(
1805
+ t(
1806
+ isPickUpFulfillment ? "orders.fulfillment.toast.fulfillmentPickedUp" : "orders.fulfillment.toast.fulfillmentDelivered"
1807
+ )
1808
+ );
1809
+ },
1810
+ onError: (e) => {
1811
+ toast6.error(e.message);
1812
+ }
1813
+ });
1814
+ }
1815
+ };
1816
+ const handleCancel = async () => {
1817
+ if (fulfillment.shipped_at) {
1818
+ toast6.warning(t("orders.fulfillment.toast.fulfillmentShipped"));
1819
+ return;
1820
+ }
1821
+ const res = await prompt({
1822
+ title: t("general.areYouSure"),
1823
+ description: t("orders.fulfillment.cancelWarning"),
1824
+ confirmText: t("actions.continue"),
1825
+ cancelText: t("actions.cancel")
1826
+ });
1827
+ if (res) {
1828
+ await mutateAsync(void 0, {
1829
+ onSuccess: () => {
1830
+ toast6.success(t("orders.fulfillment.toast.canceled"));
1831
+ },
1832
+ onError: (e) => {
1833
+ toast6.error(e.message);
1834
+ }
1835
+ });
1836
+ }
1837
+ };
1838
+ if (isError) {
1839
+ throw error;
1840
+ }
1841
+ const isValidUrl = (url) => url && url.length > 0 && url !== "#";
1842
+ return /* @__PURE__ */ jsxs11(Container7, { className: "divide-y p-0", "data-testid": `order-fulfillment-${fulfillment.id}`, children: [
1843
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between px-6 py-4", "data-testid": `order-fulfillment-${fulfillment.id}-header`, children: [
1844
+ /* @__PURE__ */ jsx11(Heading7, { level: "h2", "data-testid": `order-fulfillment-${fulfillment.id}-heading`, children: t("orders.fulfillment.number", {
1845
+ number: index + 1
1846
+ }) }),
1847
+ /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-x-4", "data-testid": `order-fulfillment-${fulfillment.id}-status-container`, children: [
1848
+ /* @__PURE__ */ jsx11(
1849
+ Tooltip2,
1850
+ {
1851
+ content: format(
1852
+ new Date(statusTimestamp),
1853
+ "dd MMM, yyyy, HH:mm:ss"
1854
+ ),
1855
+ children: /* @__PURE__ */ jsx11(StatusBadge, { color: statusColor, className: "text-nowrap", "data-testid": `order-fulfillment-${fulfillment.id}-status-badge`, children: statusText })
1856
+ }
1857
+ ),
1858
+ /* @__PURE__ */ jsx11(
1859
+ ActionMenu,
1860
+ {
1861
+ groups: [
1862
+ {
1863
+ actions: [
1864
+ {
1865
+ label: t("actions.cancel"),
1866
+ icon: /* @__PURE__ */ jsx11(XCircle, {}),
1867
+ onClick: handleCancel,
1868
+ disabled: !!fulfillment.canceled_at || !!fulfillment.shipped_at || !!fulfillment.delivered_at
1869
+ }
1870
+ ]
1871
+ }
1872
+ ],
1873
+ "data-testid": `order-fulfillment-${fulfillment.id}-action-menu`
1874
+ }
1875
+ )
1876
+ ] })
1877
+ ] }),
1878
+ /* @__PURE__ */ jsxs11("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1879
+ /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", weight: "plus", children: t("orders.fulfillment.itemsLabel") }),
1880
+ /* @__PURE__ */ jsx11("ul", { children: fulfillment.items.map((f_item) => /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsxs11(Text8, { size: "small", leading: "compact", children: [
1881
+ f_item.quantity,
1882
+ "x ",
1883
+ f_item.title
1884
+ ] }) }, f_item.line_item_id)) })
1885
+ ] }),
1886
+ showLocation && /* @__PURE__ */ jsxs11("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1887
+ /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", weight: "plus", children: t("orders.fulfillment.shippingFromLabel") }),
1888
+ stock_location ? /* @__PURE__ */ jsx11(
1889
+ Link2,
1890
+ {
1891
+ to: `/settings/locations/${stock_location.id}`,
1892
+ className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",
1893
+ children: /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", children: stock_location.name })
1894
+ }
1895
+ ) : /* @__PURE__ */ jsx11(Skeleton, { className: "w-16" })
1896
+ ] }),
1897
+ /* @__PURE__ */ jsxs11("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1898
+ /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", weight: "plus", children: t("fields.provider") }),
1899
+ /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", children: formatProvider(fulfillment.provider_id) })
1900
+ ] }),
1901
+ /* @__PURE__ */ jsxs11("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1902
+ /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", weight: "plus", children: t("orders.fulfillment.trackingLabel") }),
1903
+ /* @__PURE__ */ jsx11("div", { children: fulfillment.labels && fulfillment.labels.length > 0 ? /* @__PURE__ */ jsx11("ul", { children: fulfillment.labels.map((tlink) => {
1904
+ const hasTrackingUrl = isValidUrl(tlink.tracking_url);
1905
+ const hasLabelUrl = isValidUrl(tlink.label_url);
1906
+ if (hasTrackingUrl || hasLabelUrl) {
1907
+ return /* @__PURE__ */ jsxs11("li", { children: [
1908
+ hasTrackingUrl && /* @__PURE__ */ jsx11(
1909
+ "a",
1910
+ {
1911
+ href: tlink.tracking_url,
1912
+ target: "_blank",
1913
+ rel: "noopener noreferrer",
1914
+ className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",
1915
+ children: /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", as: "span", children: tlink.tracking_number })
1916
+ }
1917
+ ),
1918
+ hasTrackingUrl && hasLabelUrl && " - ",
1919
+ hasLabelUrl && /* @__PURE__ */ jsx11(
1920
+ "a",
1921
+ {
1922
+ href: tlink.label_url,
1923
+ target: "_blank",
1924
+ rel: "noopener noreferrer",
1925
+ className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",
1926
+ children: /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", as: "span", children: "Label" })
1927
+ }
1928
+ )
1929
+ ] }, tlink.tracking_number);
1930
+ }
1931
+ return /* @__PURE__ */ jsx11("li", { children: /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", children: tlink.tracking_number }) }, tlink.tracking_number);
1932
+ }) }) : /* @__PURE__ */ jsx11(Text8, { size: "small", leading: "compact", children: "-" }) })
1933
+ ] }),
1934
+ (showShippingButton || showDeliveryButton) && /* @__PURE__ */ jsxs11("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", "data-testid": `order-fulfillment-${fulfillment.id}-actions`, children: [
1935
+ showDeliveryButton && /* @__PURE__ */ jsx11(Button6, { onClick: handleMarkAsDelivered, variant: "secondary", "data-testid": `order-fulfillment-${fulfillment.id}-mark-delivered-button`, children: t(
1936
+ isPickUpFulfillment ? "orders.fulfillment.markAsPickedUp" : "orders.fulfillment.markAsDelivered"
1937
+ ) }),
1938
+ showShippingButton && /* @__PURE__ */ jsx11(
1939
+ Button6,
1940
+ {
1941
+ onClick: () => navigate(`./${fulfillment.id}/create-shipment`),
1942
+ variant: "secondary",
1943
+ "data-testid": `order-fulfillment-${fulfillment.id}-mark-shipped-button`,
1944
+ children: t("orders.fulfillment.markAsShipped")
1945
+ }
1946
+ )
1947
+ ] })
1948
+ ] });
1949
+ };
1950
+
1951
+ // src/pages/orders/order-detail/components/order-general-section/order-general-section.tsx
1952
+ import { XCircle as XCircle2 } from "@medusajs/icons";
1953
+ import {
1954
+ Container as Container8,
1955
+ Copy as Copy4,
1956
+ Heading as Heading8,
1957
+ StatusBadge as StatusBadge2,
1958
+ Text as Text9,
1959
+ toast as toast7,
1960
+ usePrompt as usePrompt3
1961
+ } from "@medusajs/ui";
1962
+ import { useTranslation as useTranslation12 } from "react-i18next";
1963
+ import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
1964
+ var OrderGeneralSection = ({ order }) => {
1965
+ const { t } = useTranslation12();
1966
+ const prompt = usePrompt3();
1967
+ const { getFullDate } = useDate();
1968
+ const { mutateAsync: cancelOrder } = useCancelOrder(order.id);
1969
+ const handleCancel = async () => {
1970
+ const res = await prompt({
1971
+ title: t("general.areYouSure"),
1972
+ description: t("orders.cancelWarning", {
1973
+ id: `#${order.display_id}`
1974
+ }),
1975
+ confirmText: t("actions.continue"),
1976
+ cancelText: t("actions.cancel")
1977
+ });
1978
+ if (!res) {
1979
+ return;
1980
+ }
1981
+ await cancelOrder(void 0, {
1982
+ onSuccess: () => {
1983
+ toast7.success(t("orders.orderCanceled"));
1984
+ },
1985
+ onError: (e) => {
1986
+ toast7.error(e.message);
1987
+ }
1988
+ });
1989
+ };
1990
+ return /* @__PURE__ */ jsxs12(Container8, { className: "flex items-center justify-between px-6 py-4", "data-testid": "order-general-section", children: [
1991
+ /* @__PURE__ */ jsxs12("div", { children: [
1992
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-1", "data-testid": "order-general-section-id-container", children: [
1993
+ /* @__PURE__ */ jsxs12(Heading8, { "data-testid": "order-general-section-id-heading", children: [
1994
+ "#",
1995
+ order.display_id
1996
+ ] }),
1997
+ /* @__PURE__ */ jsx12(Copy4, { content: `#${order.display_id}`, className: "text-ui-fg-muted", "data-testid": "order-general-section-id-copy" })
1998
+ ] }),
1999
+ /* @__PURE__ */ jsx12(Text9, { size: "small", className: "text-ui-fg-subtle", "data-testid": "order-general-section-date", children: t("orders.onDateFromSalesChannel", {
2000
+ date: getFullDate({ date: order.created_at, includeTime: true }),
2001
+ salesChannel: order.sales_channel?.name
2002
+ }) })
2003
+ ] }),
2004
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-4", "data-testid": "order-general-section-badges-container", children: [
2005
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-1.5", "data-testid": "order-general-section-badges", children: [
2006
+ /* @__PURE__ */ jsx12(OrderBadge, { order }),
2007
+ /* @__PURE__ */ jsx12(PaymentBadge, { order }),
2008
+ /* @__PURE__ */ jsx12(FulfillmentBadge, { order })
2009
+ ] }),
2010
+ /* @__PURE__ */ jsx12(
2011
+ ActionMenu,
2012
+ {
2013
+ groups: [
2014
+ {
2015
+ actions: [
2016
+ {
2017
+ label: t("actions.cancel"),
2018
+ onClick: handleCancel,
2019
+ disabled: !!order.canceled_at,
2020
+ icon: /* @__PURE__ */ jsx12(XCircle2, {})
2021
+ }
2022
+ ]
2023
+ }
2024
+ ],
2025
+ "data-testid": "order-general-section-action-menu"
2026
+ }
2027
+ )
2028
+ ] })
2029
+ ] });
2030
+ };
2031
+ var FulfillmentBadge = ({ order }) => {
2032
+ const { t } = useTranslation12();
2033
+ const { label, color } = getOrderFulfillmentStatus(
2034
+ t,
2035
+ order.fulfillment_status
2036
+ );
2037
+ return /* @__PURE__ */ jsx12(StatusBadge2, { color, className: "text-nowrap", "data-testid": "order-general-section-fulfillment-badge", children: label });
2038
+ };
2039
+ var PaymentBadge = ({ order }) => {
2040
+ const { t } = useTranslation12();
2041
+ const { label, color } = getOrderPaymentStatus(t, order.payment_status);
2042
+ return /* @__PURE__ */ jsx12(StatusBadge2, { color, className: "text-nowrap", "data-testid": "order-general-section-payment-badge", children: label });
2043
+ };
2044
+ var OrderBadge = ({ order }) => {
2045
+ const { t } = useTranslation12();
2046
+ const orderStatus = getCanceledOrderStatus(t, order.status);
2047
+ if (!orderStatus) {
2048
+ return null;
2049
+ }
2050
+ return /* @__PURE__ */ jsx12(StatusBadge2, { color: orderStatus.color, className: "text-nowrap", "data-testid": "order-general-section-order-badge", children: orderStatus.label });
2051
+ };
2052
+
2053
+ // src/components/common/display-id/display-id.tsx
2054
+ import { useTranslation as useTranslation13 } from "react-i18next";
2055
+ import { useState as useState4 } from "react";
2056
+ import copy from "copy-to-clipboard";
2057
+ import { clx as clx2, toast as toast8, Tooltip as Tooltip3 } from "@medusajs/ui";
2058
+ import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
2059
+ function DisplayId({ id, className }) {
2060
+ const { t } = useTranslation13();
2061
+ const [open, setOpen] = useState4(false);
2062
+ const onClick = () => {
2063
+ copy(id);
2064
+ toast8.success(t("actions.idCopiedToClipboard"));
2065
+ };
2066
+ return /* @__PURE__ */ jsx13(Tooltip3, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs13("span", { onClick, className: clx2("cursor-pointer", className), children: [
2067
+ "#",
2068
+ id.slice(-7)
2069
+ ] }) });
2070
+ }
2071
+ var display_id_default = DisplayId;
2072
+
2073
+ // src/lib/payment.ts
2074
+ var getTotalCaptured = (paymentCollections) => paymentCollections.reduce((acc, paymentCollection) => {
2075
+ acc = acc + (paymentCollection.captured_amount - paymentCollection.refunded_amount);
2076
+ return acc;
2077
+ }, 0);
2078
+ var getTotalPending = (paymentCollections) => paymentCollections.filter((pc) => pc.status !== "canceled").reduce((acc, paymentCollection) => {
2079
+ acc += paymentCollection.amount - paymentCollection.captured_amount;
2080
+ return acc;
2081
+ }, 0);
2082
+
2083
+ // src/pages/orders/order-detail/components/order-payment-section/order-payment-section.tsx
2084
+ import { ArrowDownRightMini, DocumentText, XCircle as XCircle3 } from "@medusajs/icons";
2085
+ import {
2086
+ Badge,
2087
+ Button as Button7,
2088
+ Container as Container9,
2089
+ Heading as Heading9,
2090
+ StatusBadge as StatusBadge3,
2091
+ Text as Text10,
2092
+ toast as toast9,
2093
+ Tooltip as Tooltip4,
2094
+ usePrompt as usePrompt4
2095
+ } from "@medusajs/ui";
2096
+ import { format as format2 } from "date-fns";
2097
+ import { Trans, useTranslation as useTranslation14 } from "react-i18next";
2098
+ import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
2099
+ var OrderPaymentSection = ({ order }) => {
2100
+ const payments = getPaymentsFromOrder(order);
2101
+ const refunds = payments.map((payment) => payment?.refunds).flat(1).filter(Boolean);
2102
+ return /* @__PURE__ */ jsxs14(
2103
+ Container9,
2104
+ {
2105
+ className: "divide-y divide-dashed p-0",
2106
+ "data-testid": "order-payment-section",
2107
+ children: [
2108
+ /* @__PURE__ */ jsx14(Header2, { order }),
2109
+ /* @__PURE__ */ jsx14(
2110
+ PaymentBreakdown,
2111
+ {
2112
+ order,
2113
+ payments,
2114
+ refunds,
2115
+ currencyCode: order.currency_code
2116
+ }
2117
+ ),
2118
+ /* @__PURE__ */ jsx14(Total, { order })
2119
+ ]
2120
+ }
2121
+ );
2122
+ };
2123
+ var Header2 = ({ order }) => {
2124
+ const { t } = useTranslation14();
2125
+ const { label, color } = getOrderPaymentStatus(t, order.payment_status);
2126
+ return /* @__PURE__ */ jsxs14(
2127
+ "div",
2128
+ {
2129
+ className: "flex items-center justify-between px-6 py-4",
2130
+ "data-testid": "order-payment-header",
2131
+ children: [
2132
+ /* @__PURE__ */ jsx14(Heading9, { level: "h2", "data-testid": "order-payment-heading", children: t("orders.payment.title") }),
2133
+ /* @__PURE__ */ jsx14(
2134
+ StatusBadge3,
2135
+ {
2136
+ color,
2137
+ className: "text-nowrap",
2138
+ "data-testid": "order-payment-status-badge",
2139
+ children: label
2140
+ }
2141
+ )
2142
+ ]
2143
+ }
2144
+ );
2145
+ };
2146
+ var Refund = ({
2147
+ refund,
2148
+ currencyCode
2149
+ }) => {
2150
+ const { t } = useTranslation14();
2151
+ const RefundReasonBadge = refund?.refund_reason && /* @__PURE__ */ jsx14(
2152
+ Badge,
2153
+ {
2154
+ size: "2xsmall",
2155
+ rounded: "full",
2156
+ className: "line-clamp-1",
2157
+ title: refund.refund_reason.label,
2158
+ children: refund.refund_reason.label
2159
+ }
2160
+ );
2161
+ const RefundNoteIndicator = refund.note && /* @__PURE__ */ jsx14(Tooltip4, { content: refund.note, children: /* @__PURE__ */ jsx14(DocumentText, { className: "ml-1 inline text-ui-tag-neutral-icon" }) });
2162
+ return /* @__PURE__ */ jsxs14("div", { className: "flex items-start gap-x-4 bg-ui-bg-subtle px-6 py-4 text-ui-fg-subtle sm:items-center", children: [
2163
+ /* @__PURE__ */ jsxs14("div", { className: "flex flex-1 flex-col gap-3 sm:flex-row sm:items-center", children: [
2164
+ /* @__PURE__ */ jsxs14("div", { className: "flex shrink-0 flex-row items-center gap-x-3", children: [
2165
+ /* @__PURE__ */ jsx14(ArrowDownRightMini, { className: "text-ui-fg-muted" }),
2166
+ /* @__PURE__ */ jsxs14("div", { children: [
2167
+ /* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", weight: "plus", children: t("orders.payment.refund") }),
2168
+ /* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", children: format2(new Date(refund.created_at), "dd MMM, yyyy, HH:mm:ss") })
2169
+ ] })
2170
+ ] }),
2171
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-x-3", children: [
2172
+ /* @__PURE__ */ jsx14("div", { className: "shrink-0", children: RefundNoteIndicator }),
2173
+ RefundReasonBadge
2174
+ ] })
2175
+ ] }),
2176
+ /* @__PURE__ */ jsxs14("div", { className: "flex shrink-0 items-center justify-end gap-4", children: [
2177
+ /* @__PURE__ */ jsxs14(Text10, { size: "small", leading: "compact", children: [
2178
+ "- ",
2179
+ getLocaleAmount(refund.amount, currencyCode)
2180
+ ] }),
2181
+ /* @__PURE__ */ jsx14("div", { className: "h-7 w-5" })
2182
+ ] })
2183
+ ] });
2184
+ };
2185
+ var Payment = ({
2186
+ order,
2187
+ payment,
2188
+ refunds,
2189
+ currencyCode
2190
+ }) => {
2191
+ const { t } = useTranslation14();
2192
+ const prompt = usePrompt4();
2193
+ const { mutateAsync } = useCapturePayment(order.id, payment.id);
2194
+ const handleCapture = async () => {
2195
+ const res = await prompt({
2196
+ title: t("orders.payment.capture"),
2197
+ description: t("orders.payment.capturePayment", {
2198
+ amount: formatCurrency(payment.amount, currencyCode)
2199
+ }),
2200
+ confirmText: t("actions.confirm"),
2201
+ cancelText: t("actions.cancel"),
2202
+ variant: "confirmation"
2203
+ });
2204
+ if (!res) {
2205
+ return;
2206
+ }
2207
+ await mutateAsync(
2208
+ { amount: payment.amount },
2209
+ {
2210
+ onSuccess: () => {
2211
+ toast9.success(
2212
+ t("orders.payment.capturePaymentSuccess", {
2213
+ amount: formatCurrency(payment.amount, currencyCode)
2214
+ })
2215
+ );
2216
+ },
2217
+ onError: (error) => {
2218
+ toast9.error(error.message);
2219
+ }
2220
+ }
2221
+ );
2222
+ };
2223
+ const getPaymentStatusAttributes = (payment2) => {
2224
+ if (payment2.canceled_at) {
2225
+ return ["Canceled", "red"];
2226
+ } else if (payment2.captured_at) {
2227
+ return ["Captured", "green"];
2228
+ } else {
2229
+ return ["Pending", "orange"];
2230
+ }
2231
+ };
2232
+ const [status, color] = getPaymentStatusAttributes(payment);
2233
+ const showCapture = payment.captured_at === null && payment.canceled_at === null;
2234
+ const totalRefunded = payment.refunds?.reduce((acc, next) => next.amount + acc, 0) ?? 0;
2235
+ return /* @__PURE__ */ jsxs14(
2236
+ "div",
2237
+ {
2238
+ className: "divide-y divide-dashed",
2239
+ "data-testid": `order-payment-${payment.id}`,
2240
+ children: [
2241
+ /* @__PURE__ */ jsxs14(
2242
+ "div",
2243
+ {
2244
+ className: "grid grid-cols-[1fr_1fr_1fr_20px] items-center gap-x-4 px-6 py-4 text-ui-fg-subtle sm:grid-cols-[1fr_1fr_1fr_1fr_20px]",
2245
+ "data-testid": `order-payment-${payment.id}-row`,
2246
+ children: [
2247
+ /* @__PURE__ */ jsxs14("div", { className: "w-full min-w-[60px] overflow-hidden", children: [
2248
+ /* @__PURE__ */ jsx14(
2249
+ Text10,
2250
+ {
2251
+ size: "small",
2252
+ leading: "compact",
2253
+ weight: "plus",
2254
+ className: "truncate",
2255
+ "data-testid": `order-payment-${payment.id}-id`,
2256
+ children: /* @__PURE__ */ jsx14(display_id_default, { id: payment.id })
2257
+ }
2258
+ ),
2259
+ /* @__PURE__ */ jsx14(
2260
+ Text10,
2261
+ {
2262
+ size: "small",
2263
+ leading: "compact",
2264
+ "data-testid": `order-payment-${payment.id}-date`,
2265
+ children: payment.created_at ? format2(new Date(payment.created_at), "dd MMM, yyyy, HH:mm:ss") : "-"
2266
+ }
2267
+ )
2268
+ ] }),
2269
+ /* @__PURE__ */ jsx14("div", { className: "hidden items-center justify-end sm:flex", children: /* @__PURE__ */ jsx14(
2270
+ Text10,
2271
+ {
2272
+ size: "small",
2273
+ leading: "compact",
2274
+ className: "capitalize",
2275
+ "data-testid": `order-payment-${payment.id}-provider`,
2276
+ children: payment.provider_id
2277
+ }
2278
+ ) }),
2279
+ /* @__PURE__ */ jsx14("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx14(
2280
+ StatusBadge3,
2281
+ {
2282
+ color,
2283
+ className: "text-nowrap",
2284
+ "data-testid": `order-payment-${payment.id}-status`,
2285
+ children: status
2286
+ }
2287
+ ) }),
2288
+ /* @__PURE__ */ jsx14("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx14(
2289
+ Text10,
2290
+ {
2291
+ size: "small",
2292
+ leading: "compact",
2293
+ "data-testid": `order-payment-${payment.id}-amount`,
2294
+ children: getLocaleAmount(payment.amount, payment.currency_code)
2295
+ }
2296
+ ) }),
2297
+ /* @__PURE__ */ jsx14(
2298
+ ActionMenu,
2299
+ {
2300
+ groups: [
2301
+ {
2302
+ actions: [
2303
+ {
2304
+ label: t("orders.payment.createRefund"),
2305
+ icon: /* @__PURE__ */ jsx14(XCircle3, {}),
2306
+ to: `/orders/${order.id}/refund?paymentId=${payment.id}`,
2307
+ disabled: !payment.captured_at || !!payment.canceled_at || totalRefunded >= payment.amount
2308
+ }
2309
+ ]
2310
+ }
2311
+ ],
2312
+ "data-testid": `order-payment-${payment.id}-action-menu`
2313
+ }
2314
+ )
2315
+ ]
2316
+ }
2317
+ ),
2318
+ showCapture && /* @__PURE__ */ jsxs14(
2319
+ "div",
2320
+ {
2321
+ className: "flex items-center justify-between bg-ui-bg-subtle px-6 py-4",
2322
+ "data-testid": `order-payment-${payment.id}-capture-section`,
2323
+ children: [
2324
+ /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-x-2", children: [
2325
+ /* @__PURE__ */ jsx14(ArrowDownRightMini, { className: "shrink-0 text-ui-fg-muted" }),
2326
+ /* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", children: /* @__PURE__ */ jsx14(
2327
+ Trans,
2328
+ {
2329
+ i18nKey: "orders.payment.isReadyToBeCaptured",
2330
+ components: [/* @__PURE__ */ jsx14(display_id_default, { id: payment.id }, payment.id)]
2331
+ }
2332
+ ) })
2333
+ ] }),
2334
+ /* @__PURE__ */ jsxs14(
2335
+ Button7,
2336
+ {
2337
+ className: "shrink-0",
2338
+ size: "small",
2339
+ variant: "secondary",
2340
+ onClick: handleCapture,
2341
+ "data-testid": `order-payment-${payment.id}-capture-button`,
2342
+ children: [
2343
+ /* @__PURE__ */ jsx14("span", { className: "hidden sm:block", children: t("orders.payment.capture") }),
2344
+ /* @__PURE__ */ jsx14("span", { className: "sm:hidden", children: t("orders.payment.capture_short") })
2345
+ ]
2346
+ }
2347
+ )
2348
+ ]
2349
+ }
2350
+ ),
2351
+ refunds.map((refund) => /* @__PURE__ */ jsx14(Refund, { refund, currencyCode }, refund.id))
2352
+ ]
2353
+ }
2354
+ );
2355
+ };
2356
+ var CreditLine = ({
2357
+ creditLine,
2358
+ currencyCode
2359
+ }) => {
2360
+ if (!loyaltyPlugin) {
2361
+ return null;
2362
+ }
2363
+ const prettyReference = creditLine.reference?.split("_").join(" ").split("-").join(" ");
2364
+ const prettyReferenceId = creditLine.reference_id ? /* @__PURE__ */ jsx14(display_id_default, { id: creditLine.reference_id }) : null;
2365
+ return /* @__PURE__ */ jsx14("div", { className: "divide-y divide-dashed", children: /* @__PURE__ */ jsxs14("div", { className: "grid grid-cols-[1fr_1fr_20px] items-center gap-x-4 px-6 py-4 text-ui-fg-subtle sm:grid-cols-[1fr_1fr_1fr_20px]", children: [
2366
+ /* @__PURE__ */ jsxs14("div", { className: "w-full min-w-[60px] overflow-hidden", children: [
2367
+ /* @__PURE__ */ jsx14(
2368
+ Text10,
2369
+ {
2370
+ size: "small",
2371
+ leading: "compact",
2372
+ weight: "plus",
2373
+ className: "truncate",
2374
+ children: /* @__PURE__ */ jsx14(display_id_default, { id: creditLine.id })
2375
+ }
2376
+ ),
2377
+ /* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", children: creditLine.created_at ? format2(
2378
+ new Date(creditLine.created_at),
2379
+ "dd MMM, yyyy, HH:mm:ss"
2380
+ ) : "-" })
2381
+ ] }),
2382
+ /* @__PURE__ */ jsx14("div", { className: "hidden items-center justify-end sm:flex", children: /* @__PURE__ */ jsxs14(Text10, { size: "small", leading: "compact", className: "capitalize", children: [
2383
+ prettyReference,
2384
+ " (",
2385
+ prettyReferenceId,
2386
+ ")"
2387
+ ] }) }),
2388
+ /* @__PURE__ */ jsx14("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx14(Text10, { size: "small", leading: "compact", children: getLocaleAmount(creditLine.amount, currencyCode) }) })
2389
+ ] }) });
2390
+ };
2391
+ var PaymentBreakdown = ({
2392
+ order,
2393
+ payments,
2394
+ refunds,
2395
+ currencyCode
2396
+ }) => {
2397
+ const orderRefunds = refunds.filter((refund) => refund.payment_id === null);
2398
+ const creditLines = order.credit_lines ?? [];
2399
+ const creditLineRefunds = creditLines.filter(
2400
+ (creditLine) => creditLine.amount < 0
2401
+ );
2402
+ const entries = [...orderRefunds, ...payments, ...creditLineRefunds].sort((a, b) => {
2403
+ return new Date(a.created_at).getTime() - new Date(b.created_at).getTime();
2404
+ }).map((entry) => {
2405
+ let type = entry.id.startsWith("pay_") ? "payment" : "refund";
2406
+ if (entry.id.startsWith("ordcl_")) {
2407
+ type = "credit_line_refund";
2408
+ }
2409
+ return { event: entry, type };
2410
+ });
2411
+ return /* @__PURE__ */ jsx14(
2412
+ "div",
2413
+ {
2414
+ className: "flex flex-col divide-y divide-dashed",
2415
+ "data-testid": "order-payment-breakdown",
2416
+ children: entries.map(({ type, event }) => {
2417
+ switch (type) {
2418
+ case "payment":
2419
+ return /* @__PURE__ */ jsx14(
2420
+ Payment,
2421
+ {
2422
+ order,
2423
+ payment: event,
2424
+ refunds: refunds.filter(
2425
+ (refund) => refund.payment_id === event.id
2426
+ ),
2427
+ currencyCode
2428
+ },
2429
+ event.id
2430
+ );
2431
+ case "refund":
2432
+ return /* @__PURE__ */ jsx14(
2433
+ Refund,
2434
+ {
2435
+ refund: event,
2436
+ currencyCode
2437
+ },
2438
+ event.id
2439
+ );
2440
+ case "credit_line_refund":
2441
+ return /* @__PURE__ */ jsx14(
2442
+ CreditLine,
2443
+ {
2444
+ creditLine: event,
2445
+ currencyCode
2446
+ },
2447
+ event.id
2448
+ );
2449
+ }
2450
+ })
2451
+ }
2452
+ );
2453
+ };
2454
+ var Total = ({ order }) => {
2455
+ const { t } = useTranslation14();
2456
+ const totalPending = getTotalPending(order.payment_collections);
2457
+ return /* @__PURE__ */ jsxs14(
2458
+ "div",
2459
+ {
2460
+ className: "flex flex-col gap-y-4 px-6 py-4",
2461
+ "data-testid": "order-payment-total",
2462
+ children: [
2463
+ /* @__PURE__ */ jsxs14(
2464
+ "div",
2465
+ {
2466
+ className: "flex items-center justify-between",
2467
+ "data-testid": "order-payment-total-paid",
2468
+ children: [
2469
+ /* @__PURE__ */ jsx14(Text10, { size: "small", weight: "plus", leading: "compact", children: t("orders.payment.totalPaidByCustomer") }),
2470
+ /* @__PURE__ */ jsx14(Text10, { size: "small", weight: "plus", leading: "compact", children: getStylizedAmount(
2471
+ getTotalCaptured(order.payment_collections),
2472
+ order.currency_code
2473
+ ) })
2474
+ ]
2475
+ }
2476
+ ),
2477
+ order.status !== "canceled" && totalPending > 0 && /* @__PURE__ */ jsxs14(
2478
+ "div",
2479
+ {
2480
+ className: "flex items-center justify-between",
2481
+ "data-testid": "order-payment-total-pending",
2482
+ children: [
2483
+ /* @__PURE__ */ jsx14(Text10, { size: "small", weight: "plus", leading: "compact", children: "Total pending" }),
2484
+ /* @__PURE__ */ jsx14(Text10, { size: "small", weight: "plus", leading: "compact", children: getStylizedAmount(totalPending, order.currency_code) })
2485
+ ]
2486
+ }
2487
+ )
2488
+ ]
2489
+ }
2490
+ );
2491
+ };
2492
+
2493
+ // src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
2494
+ import { useMemo as useMemo3, useState as useState6 } from "react";
2495
+ import { useTranslation as useTranslation17 } from "react-i18next";
2496
+ import { Link as Link3 } from "react-router-dom";
2497
+ import {
2498
+ ArrowDownRightMini as ArrowDownRightMini2,
2499
+ ArrowLongRight,
2500
+ ArrowPath as ArrowPath3,
2501
+ ArrowUturnLeft as ArrowUturnLeft2,
2502
+ DocumentText as DocumentText2,
2503
+ ExclamationCircle as ExclamationCircle2,
2504
+ PencilSquare,
2505
+ TriangleDownMini
2506
+ } from "@medusajs/icons";
2507
+ import {
2508
+ Badge as Badge4,
2509
+ Button as Button8,
2510
+ clx as clx3,
2511
+ Container as Container10,
2512
+ Copy as Copy5,
2513
+ Heading as Heading10,
2514
+ StatusBadge as StatusBadge4,
2515
+ Text as Text12,
2516
+ toast as toast10,
2517
+ Tooltip as Tooltip6,
2518
+ usePrompt as usePrompt5
2519
+ } from "@medusajs/ui";
2520
+ import { format as format3 } from "date-fns";
2521
+
2522
+ // src/lib/credit-line.ts
2523
+ var getTotalCreditLines = (creditLines) => creditLines.reduce((acc, creditLine) => {
2524
+ acc = acc + creditLine.amount;
2525
+ return acc;
2526
+ }, 0);
2527
+
2528
+ // src/pages/orders/order-detail/components/order-summary-section/return-info-popover.tsx
2529
+ import { InformationCircleSolid } from "@medusajs/icons";
2530
+ import { Badge as Badge2, Popover as Popover3, Text as Text11 } from "@medusajs/ui";
2531
+ import { useState as useState5 } from "react";
2532
+ import { useTranslation as useTranslation15 } from "react-i18next";
2533
+ import { jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
2534
+ function ReturnInfoPopover({ orderReturn }) {
2535
+ const { t } = useTranslation15();
2536
+ const [open, setOpen] = useState5(false);
2537
+ const { getFullDate } = useDate();
2538
+ const handleMouseEnter = () => {
2539
+ setOpen(true);
2540
+ };
2541
+ const handleMouseLeave = () => {
2542
+ setOpen(false);
2543
+ };
2544
+ let returnType = "Return";
2545
+ let returnTypeId = orderReturn.id;
2546
+ if (orderReturn.claim_id) {
2547
+ returnType = "Claim";
2548
+ returnTypeId = orderReturn.claim_id;
2549
+ }
2550
+ if (orderReturn.exchange_id) {
2551
+ returnType = "Exchange";
2552
+ returnTypeId = orderReturn.exchange_id;
2553
+ }
2554
+ if (typeof orderReturn !== "object") {
2555
+ return;
2556
+ }
2557
+ return /* @__PURE__ */ jsxs15(Popover3, { open, children: [
2558
+ /* @__PURE__ */ jsx15(
2559
+ Popover3.Trigger,
2560
+ {
2561
+ onMouseEnter: handleMouseEnter,
2562
+ onMouseLeave: handleMouseLeave,
2563
+ autoFocus: false,
2564
+ className: "align-sub focus-visible:outline-none",
2565
+ children: /* @__PURE__ */ jsx15(InformationCircleSolid, {})
2566
+ }
2567
+ ),
2568
+ /* @__PURE__ */ jsx15(
2569
+ Popover3.Content,
2570
+ {
2571
+ align: "center",
2572
+ side: "top",
2573
+ className: "bg-ui-bg-component p-2 focus-visible:outline-none",
2574
+ children: /* @__PURE__ */ jsxs15("div", { className: "", children: [
2575
+ /* @__PURE__ */ jsxs15(Badge2, { size: "2xsmall", className: "mb-2", rounded: "full", children: [
2576
+ returnType,
2577
+ ": #",
2578
+ returnTypeId.slice(-7)
2579
+ ] }),
2580
+ /* @__PURE__ */ jsxs15(Text11, { size: "xsmall", children: [
2581
+ /* @__PURE__ */ jsx15("span", { className: "text-ui-fg-subtle", children: t(`orders.returns.returnRequested`) }),
2582
+ " \xB7 ",
2583
+ getFullDate({ date: orderReturn.requested_at, includeTime: true })
2584
+ ] }),
2585
+ /* @__PURE__ */ jsxs15(Text11, { size: "xsmall", children: [
2586
+ /* @__PURE__ */ jsx15("span", { className: "text-ui-fg-subtle", children: t(`orders.returns.itemReceived`) }),
2587
+ " \xB7 ",
2588
+ orderReturn.received_at ? getFullDate({
2589
+ date: orderReturn.received_at,
2590
+ includeTime: true
2591
+ }) : "-"
2592
+ ] })
2593
+ ] })
2594
+ }
2595
+ )
2596
+ ] });
2597
+ }
2598
+ var return_info_popover_default = ReturnInfoPopover;
2599
+
2600
+ // src/pages/orders/order-detail/components/order-summary-section/shipping-info-popover.tsx
2601
+ import { InformationCircleSolid as InformationCircleSolid2 } from "@medusajs/icons";
2602
+ import { Badge as Badge3, Tooltip as Tooltip5 } from "@medusajs/ui";
2603
+ import { useTranslation as useTranslation16 } from "react-i18next";
2604
+ import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
2605
+ function ShippingInfoPopover({ shippingMethod }) {
2606
+ const { t } = useTranslation16();
2607
+ const shippingDetail = shippingMethod?.detail;
2608
+ if (!shippingDetail) {
2609
+ return;
2610
+ }
2611
+ let rmaType = t("orders.return");
2612
+ let rmaId = shippingDetail.return_id;
2613
+ if (shippingDetail.claim_id) {
2614
+ rmaType = t("orders.claim");
2615
+ rmaId = shippingDetail.claim_id;
2616
+ }
2617
+ if (shippingDetail.exchange_id) {
2618
+ rmaType = t("orders.exchange");
2619
+ rmaId = shippingDetail.exchange_id;
2620
+ }
2621
+ if (!rmaId) {
2622
+ return;
2623
+ }
2624
+ return /* @__PURE__ */ jsx16(
2625
+ Tooltip5,
2626
+ {
2627
+ content: /* @__PURE__ */ jsxs16(Badge3, { size: "2xsmall", rounded: "full", children: [
2628
+ rmaType,
2629
+ ": #",
2630
+ rmaId.slice(-7)
2631
+ ] }),
2632
+ children: /* @__PURE__ */ jsx16(InformationCircleSolid2, { className: "inline-block text-ui-fg-muted ml-1" })
2633
+ }
2634
+ );
2635
+ }
2636
+ var shipping_info_popover_default = ShippingInfoPopover;
2637
+
2638
+ // src/pages/orders/order-detail/components/order-summary-section/order-summary-section.tsx
2639
+ import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs17 } from "react/jsx-runtime";
2640
+ var OrderSummarySection = ({ order }) => {
2641
+ const { t } = useTranslation17();
2642
+ const prompt = usePrompt5();
2643
+ const { reservations } = useReservationItems(
2644
+ {
2645
+ line_item_id: order?.items?.map((i) => i.id),
2646
+ limit: getReservationsLimitCount(order)
2647
+ },
2648
+ { enabled: Array.isArray(order?.items) }
2649
+ );
2650
+ const { order: orderPreview } = useOrderPreview(order.id);
2651
+ const { returns = [] } = useReturns({
2652
+ status: "requested",
2653
+ order_id: order.id,
2654
+ fields: "+received_at"
2655
+ });
2656
+ const receivableReturns = useMemo3(
2657
+ () => returns.filter((r) => !r.canceled_at),
2658
+ [returns]
2659
+ );
2660
+ const showReturns = !!receivableReturns.length;
2661
+ const showAllocateButton = useMemo3(() => {
2662
+ if (!reservations) {
2663
+ return false;
2664
+ }
2665
+ const reservationsMap = new Map(
2666
+ reservations.map((r) => [r.line_item_id, r.id])
2667
+ );
2668
+ for (const item of order.items) {
2669
+ if (item.variant?.manage_inventory) {
2670
+ if (item.quantity - item.detail.fulfilled_quantity > 0) {
2671
+ if (!reservationsMap.has(item.id)) {
2672
+ return true;
2673
+ }
2674
+ }
2675
+ }
2676
+ }
2677
+ return false;
2678
+ }, [order.items, reservations]);
2679
+ const unpaidPaymentCollection = order.payment_collections.find(
2680
+ (pc) => pc.status === "not_paid"
2681
+ );
2682
+ const { mutateAsync: markAsPaid } = useMarkPaymentCollectionAsPaid(
2683
+ order.id,
2684
+ unpaidPaymentCollection?.id
2685
+ );
2686
+ const pendingDifference = order.summary?.pending_difference || 0;
2687
+ const isAmountSignificant = !isAmountLessThenRoundingError(
2688
+ pendingDifference,
2689
+ order.currency_code
2690
+ );
2691
+ const showPayment = unpaidPaymentCollection && pendingDifference > 0 && isAmountSignificant;
2692
+ const showRefund = pendingDifference < 0 && isAmountSignificant;
2693
+ const handleMarkAsPaid = async (paymentCollection) => {
2694
+ const res = await prompt({
2695
+ title: t("orders.payment.markAsPaid"),
2696
+ description: t("orders.payment.markAsPaidPayment", {
2697
+ amount: formatCurrency(
2698
+ paymentCollection.amount,
2699
+ order.currency_code
2700
+ )
2701
+ }),
2702
+ confirmText: t("actions.confirm"),
2703
+ cancelText: t("actions.cancel"),
2704
+ variant: "confirmation"
2705
+ });
2706
+ if (!res) {
2707
+ return;
2708
+ }
2709
+ await markAsPaid(
2710
+ { order_id: order.id },
2711
+ {
2712
+ onSuccess: () => {
2713
+ toast10.success(
2714
+ t("orders.payment.markAsPaidPaymentSuccess", {
2715
+ amount: formatCurrency(
2716
+ paymentCollection.amount,
2717
+ order.currency_code
2718
+ )
2719
+ })
2720
+ );
2721
+ },
2722
+ onError: (error) => {
2723
+ toast10.error(error.message);
2724
+ }
2725
+ }
2726
+ );
2727
+ };
2728
+ return /* @__PURE__ */ jsxs17(
2729
+ Container10,
2730
+ {
2731
+ className: "divide-y divide-dashed p-0",
2732
+ "data-testid": "order-summary-section",
2733
+ children: [
2734
+ /* @__PURE__ */ jsx17(Header3, { order, orderPreview }),
2735
+ /* @__PURE__ */ jsx17(ItemBreakdown, { order, reservations }),
2736
+ /* @__PURE__ */ jsx17(CostBreakdown, { order }),
2737
+ /* @__PURE__ */ jsx17(DiscountAndTotalBreakdown, { order }),
2738
+ /* @__PURE__ */ jsx17(Total2, { order }),
2739
+ (showAllocateButton || showReturns || showPayment || showRefund) && /* @__PURE__ */ jsxs17(
2740
+ "div",
2741
+ {
2742
+ className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4",
2743
+ "data-testid": "order-summary-actions",
2744
+ children: [
2745
+ showReturns && (receivableReturns.length === 1 ? /* @__PURE__ */ jsx17(
2746
+ Button8,
2747
+ {
2748
+ asChild: true,
2749
+ variant: "secondary",
2750
+ size: "small",
2751
+ "data-testid": "order-summary-receive-return-button",
2752
+ children: /* @__PURE__ */ jsx17(
2753
+ Link3,
2754
+ {
2755
+ to: `/orders/${order.id}/returns/${receivableReturns[0].id}/receive`,
2756
+ children: t("orders.returns.receive.action")
2757
+ }
2758
+ )
2759
+ }
2760
+ ) : /* @__PURE__ */ jsx17(
2761
+ ActionMenu,
2762
+ {
2763
+ groups: [
2764
+ {
2765
+ actions: receivableReturns.map((r) => {
2766
+ let id = r.id;
2767
+ let returnType = "Return";
2768
+ if (r.exchange_id) {
2769
+ id = r.exchange_id;
2770
+ returnType = "Exchange";
2771
+ }
2772
+ if (r.claim_id) {
2773
+ id = r.claim_id;
2774
+ returnType = "Claim";
2775
+ }
2776
+ return {
2777
+ label: t("orders.returns.receive.receiveItems", {
2778
+ id: `#${id.slice(-7)}`,
2779
+ returnType
2780
+ }),
2781
+ icon: /* @__PURE__ */ jsx17(ArrowLongRight, {}),
2782
+ to: `/orders/${order.id}/returns/${r.id}/receive`
2783
+ };
2784
+ })
2785
+ }
2786
+ ],
2787
+ "data-testid": "order-summary-receive-returns-menu",
2788
+ children: /* @__PURE__ */ jsx17(Button8, { variant: "secondary", size: "small", children: t("orders.returns.receive.action") })
2789
+ }
2790
+ )),
2791
+ showAllocateButton && /* @__PURE__ */ jsx17(
2792
+ Button8,
2793
+ {
2794
+ asChild: true,
2795
+ variant: "secondary",
2796
+ size: "small",
2797
+ "data-testid": "order-summary-allocate-items-button",
2798
+ children: /* @__PURE__ */ jsx17(Link3, { to: "allocate-items", children: t("orders.allocateItems.action") })
2799
+ }
2800
+ ),
2801
+ showPayment && /* @__PURE__ */ jsx17(
2802
+ Button8,
2803
+ {
2804
+ size: "small",
2805
+ variant: "secondary",
2806
+ onClick: () => handleMarkAsPaid(unpaidPaymentCollection),
2807
+ "data-testid": "order-summary-mark-as-paid-button",
2808
+ children: t("orders.payment.markAsPaid")
2809
+ }
2810
+ ),
2811
+ showRefund && /* @__PURE__ */ jsx17(
2812
+ Button8,
2813
+ {
2814
+ size: "small",
2815
+ variant: "secondary",
2816
+ asChild: true,
2817
+ "data-testid": "order-summary-refund-button",
2818
+ children: /* @__PURE__ */ jsx17(Link3, { to: `/orders/${order.id}/refund`, children: t("orders.payment.refundAmount", {
2819
+ amount: getStylizedAmount(
2820
+ pendingDifference * -1,
2821
+ order?.currency_code
2822
+ )
2823
+ }) })
2824
+ }
2825
+ )
2826
+ ]
2827
+ }
2828
+ )
2829
+ ]
2830
+ }
2831
+ );
2832
+ };
2833
+ var Header3 = ({
2834
+ order,
2835
+ orderPreview
2836
+ }) => {
2837
+ const { t } = useTranslation17();
2838
+ const shouldDisableReturn = order.items.every(
2839
+ (i) => !(getReturnableQuantity(i) > 0)
2840
+ );
2841
+ const isOrderEditActive = orderPreview?.order_change?.change_type === "edit";
2842
+ const isOrderEditPending = orderPreview?.order_change?.change_type === "edit" && orderPreview?.order_change?.status === "pending";
2843
+ return /* @__PURE__ */ jsxs17(
2844
+ "div",
2845
+ {
2846
+ className: "flex items-center justify-between px-6 py-4",
2847
+ "data-testid": "order-summary-header",
2848
+ children: [
2849
+ /* @__PURE__ */ jsx17(Heading10, { level: "h2", "data-testid": "order-summary-heading", children: t("fields.summary") }),
2850
+ /* @__PURE__ */ jsx17(
2851
+ ActionMenu,
2852
+ {
2853
+ groups: [
2854
+ {
2855
+ actions: [
2856
+ {
2857
+ label: t(
2858
+ isOrderEditPending ? "orders.summary.editOrderContinue" : "orders.summary.editOrder"
2859
+ ),
2860
+ to: `/orders/${order.id}/edits`,
2861
+ icon: /* @__PURE__ */ jsx17(PencilSquare, {}),
2862
+ disabled: order.status === "canceled" || orderPreview?.order_change && orderPreview?.order_change?.change_type !== "edit" || orderPreview?.order_change?.change_type === "edit" && orderPreview?.order_change?.status === "requested"
2863
+ }
2864
+ ]
2865
+ },
2866
+ {
2867
+ actions: [
2868
+ {
2869
+ label: t("orders.returns.create"),
2870
+ to: `/orders/${order.id}/returns`,
2871
+ icon: /* @__PURE__ */ jsx17(ArrowUturnLeft2, {}),
2872
+ disabled: shouldDisableReturn || isOrderEditActive || !!orderPreview?.order_change?.exchange_id || !!orderPreview?.order_change?.claim_id
2873
+ },
2874
+ {
2875
+ label: orderPreview?.order_change?.id && orderPreview?.order_change?.exchange_id ? t("orders.exchanges.manage") : t("orders.exchanges.create"),
2876
+ to: `/orders/${order.id}/exchanges`,
2877
+ icon: /* @__PURE__ */ jsx17(ArrowPath3, {}),
2878
+ disabled: shouldDisableReturn || isOrderEditActive || !!orderPreview?.order_change?.return_id && !orderPreview?.order_change?.exchange_id || !!orderPreview?.order_change?.claim_id
2879
+ },
2880
+ {
2881
+ label: orderPreview?.order_change?.id && orderPreview?.order_change?.claim_id ? t("orders.claims.manage") : t("orders.claims.create"),
2882
+ to: `/orders/${order.id}/claims`,
2883
+ icon: /* @__PURE__ */ jsx17(ExclamationCircle2, {}),
2884
+ disabled: shouldDisableReturn || isOrderEditActive || !!orderPreview?.order_change?.return_id && !orderPreview?.order_change?.claim_id || !!orderPreview?.order_change?.exchange_id
2885
+ }
2886
+ ]
2887
+ }
2888
+ ],
2889
+ "data-testid": "order-summary-action-menu"
2890
+ }
2891
+ )
2892
+ ]
2893
+ }
2894
+ );
2895
+ };
2896
+ var Item = ({
2897
+ item,
2898
+ currencyCode,
2899
+ reservation,
2900
+ returns,
2901
+ claims,
2902
+ exchanges
2903
+ }) => {
2904
+ const { t } = useTranslation17();
2905
+ const isInventoryManaged = item.variant?.manage_inventory;
2906
+ const hasInventoryKit = isInventoryManaged && ((item.variant?.inventory_items?.length || 0) > 1 || item.variant?.inventory_items?.some((i) => i.required_quantity > 1));
2907
+ const hasUnfulfilledItems = item.quantity - item.detail.fulfilled_quantity > 0;
2908
+ return /* @__PURE__ */ jsxs17(Fragment3, { children: [
2909
+ /* @__PURE__ */ jsxs17(
2910
+ "div",
2911
+ {
2912
+ className: "text-ui-fg-subtle grid grid-cols-2 items-center gap-x-4 px-6 py-4",
2913
+ "data-testid": `order-summary-item-${item.id}`,
2914
+ children: [
2915
+ /* @__PURE__ */ jsxs17(
2916
+ "div",
2917
+ {
2918
+ className: "flex items-start gap-x-4",
2919
+ "data-testid": `order-summary-item-${item.id}-info`,
2920
+ children: [
2921
+ /* @__PURE__ */ jsx17(Thumbnail, { src: item.thumbnail }),
2922
+ /* @__PURE__ */ jsxs17("div", { children: [
2923
+ /* @__PURE__ */ jsx17(
2924
+ Text12,
2925
+ {
2926
+ size: "small",
2927
+ leading: "compact",
2928
+ className: "text-ui-fg-base",
2929
+ "data-testid": `order-summary-item-${item.id}-title`,
2930
+ children: item.title
2931
+ }
2932
+ ),
2933
+ item.variant_sku && /* @__PURE__ */ jsxs17(
2934
+ "div",
2935
+ {
2936
+ className: "flex items-center gap-x-1",
2937
+ "data-testid": `order-summary-item-${item.id}-sku`,
2938
+ children: [
2939
+ /* @__PURE__ */ jsx17(Text12, { size: "small", children: item.variant_sku }),
2940
+ /* @__PURE__ */ jsx17(Copy5, { content: item.variant_sku, className: "text-ui-fg-muted" })
2941
+ ]
2942
+ }
2943
+ ),
2944
+ /* @__PURE__ */ jsx17(
2945
+ Text12,
2946
+ {
2947
+ size: "small",
2948
+ "data-testid": `order-summary-item-${item.id}-options`,
2949
+ children: item.variant?.options?.map((o) => o.value).join(" \xB7 ")
2950
+ }
2951
+ )
2952
+ ] })
2953
+ ]
2954
+ }
2955
+ ),
2956
+ /* @__PURE__ */ jsxs17(
2957
+ "div",
2958
+ {
2959
+ className: "grid grid-cols-3 items-center gap-x-4",
2960
+ "data-testid": `order-summary-item-${item.id}-pricing`,
2961
+ children: [
2962
+ /* @__PURE__ */ jsx17("div", { className: "flex items-center justify-end gap-x-4", children: /* @__PURE__ */ jsx17(
2963
+ Text12,
2964
+ {
2965
+ size: "small",
2966
+ "data-testid": `order-summary-item-${item.id}-unit-price`,
2967
+ children: getLocaleAmount(item.unit_price, currencyCode)
2968
+ }
2969
+ ) }),
2970
+ /* @__PURE__ */ jsxs17(
2971
+ "div",
2972
+ {
2973
+ className: "flex items-center gap-x-2",
2974
+ "data-testid": `order-summary-item-${item.id}-quantity`,
2975
+ children: [
2976
+ /* @__PURE__ */ jsx17("div", { className: "w-fit min-w-[27px]", children: /* @__PURE__ */ jsxs17(Text12, { size: "small", children: [
2977
+ /* @__PURE__ */ jsx17("span", { className: "tabular-nums", children: item.quantity }),
2978
+ "x"
2979
+ ] }) }),
2980
+ /* @__PURE__ */ jsx17("div", { className: "overflow-visible", children: isInventoryManaged && hasUnfulfilledItems && /* @__PURE__ */ jsx17(
2981
+ StatusBadge4,
2982
+ {
2983
+ color: reservation ? "green" : "orange",
2984
+ className: "text-nowrap",
2985
+ "data-testid": `order-summary-item-${item.id}-reservation-badge`,
2986
+ children: reservation ? t("orders.reservations.allocatedLabel") : t("orders.reservations.notAllocatedLabel")
2987
+ }
2988
+ ) })
2989
+ ]
2990
+ }
2991
+ ),
2992
+ /* @__PURE__ */ jsx17("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx17(
2993
+ Text12,
2994
+ {
2995
+ size: "small",
2996
+ className: "pt-[1px]",
2997
+ "data-testid": `order-summary-item-${item.id}-subtotal`,
2998
+ children: getLocaleAmount(item.subtotal || 0, currencyCode)
2999
+ }
3000
+ ) })
3001
+ ]
3002
+ }
3003
+ )
3004
+ ]
3005
+ },
3006
+ item.id
3007
+ ),
3008
+ hasInventoryKit && /* @__PURE__ */ jsx17(InventoryKitBreakdown, { item }),
3009
+ returns.map((r) => /* @__PURE__ */ jsx17(ReturnBreakdown, { orderReturn: r, itemId: item.id }, r.id)),
3010
+ claims.map((claim) => /* @__PURE__ */ jsx17(ClaimBreakdown, { claim, itemId: item.id }, claim.id)),
3011
+ exchanges.map((exchange) => /* @__PURE__ */ jsx17(
3012
+ ExchangeBreakdown,
3013
+ {
3014
+ exchange,
3015
+ itemId: item.id
3016
+ },
3017
+ exchange.id
3018
+ ))
3019
+ ] });
3020
+ };
3021
+ var ItemBreakdown = ({
3022
+ order,
3023
+ reservations
3024
+ }) => {
3025
+ const { claims = [] } = useClaims({
3026
+ order_id: order.id,
3027
+ fields: "*additional_items"
3028
+ });
3029
+ const { exchanges = [] } = useExchanges({
3030
+ order_id: order.id,
3031
+ fields: "*additional_items"
3032
+ });
3033
+ const { returns = [] } = useReturns({
3034
+ order_id: order.id,
3035
+ fields: "*items,*items.reason"
3036
+ });
3037
+ const reservationsMap = useMemo3(
3038
+ () => new Map((reservations || []).map((r) => [r.line_item_id, r])),
3039
+ [reservations]
3040
+ );
3041
+ return /* @__PURE__ */ jsx17("div", { "data-testid": "order-summary-items-breakdown", children: order.items?.map((item) => {
3042
+ const reservation = reservationsMap.get(item.id);
3043
+ return /* @__PURE__ */ jsx17(
3044
+ Item,
3045
+ {
3046
+ item,
3047
+ currencyCode: order.currency_code,
3048
+ reservation,
3049
+ returns,
3050
+ exchanges,
3051
+ claims
3052
+ },
3053
+ item.id
3054
+ );
3055
+ }) });
3056
+ };
3057
+ var Cost = ({
3058
+ label,
3059
+ value,
3060
+ secondaryValue,
3061
+ tooltip
3062
+ }) => /* @__PURE__ */ jsxs17("div", { className: "grid grid-cols-3 items-center", children: [
3063
+ /* @__PURE__ */ jsxs17(Text12, { size: "small", leading: "compact", children: [
3064
+ label,
3065
+ " ",
3066
+ tooltip
3067
+ ] }),
3068
+ /* @__PURE__ */ jsx17("div", { className: "text-right", children: /* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", children: secondaryValue }) }),
3069
+ /* @__PURE__ */ jsx17("div", { className: "text-right", children: /* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", children: value }) })
3070
+ ] });
3071
+ var CostBreakdown = ({
3072
+ order
3073
+ }) => {
3074
+ const { t } = useTranslation17();
3075
+ const [isTaxOpen, setIsTaxOpen] = useState6(false);
3076
+ const [isShippingOpen, setIsShippingOpen] = useState6(false);
3077
+ const taxCodes = useMemo3(() => {
3078
+ const taxCodeMap = {};
3079
+ order.items.forEach((item) => {
3080
+ item.tax_lines?.forEach((line) => {
3081
+ const currTotal = line.subtotal || 0;
3082
+ const prevTotal = taxCodeMap[line.code]?.total || 0;
3083
+ taxCodeMap[line.code] = {
3084
+ total: prevTotal + currTotal,
3085
+ rate: line.rate
3086
+ };
3087
+ });
3088
+ });
3089
+ order.shipping_methods.forEach((sm) => {
3090
+ sm.tax_lines?.forEach((line) => {
3091
+ const currTotal = line.subtotal || 0;
3092
+ const prevTotal = taxCodeMap[line.code]?.total || 0;
3093
+ taxCodeMap[line.code] = {
3094
+ total: prevTotal + currTotal,
3095
+ rate: line.rate
3096
+ };
3097
+ });
3098
+ });
3099
+ return taxCodeMap;
3100
+ }, [order]);
3101
+ const hasTaxes = !!Object.keys(taxCodes).length;
3102
+ return /* @__PURE__ */ jsxs17(
3103
+ "div",
3104
+ {
3105
+ className: "text-ui-fg-subtle flex flex-col gap-y-2 px-6 py-4",
3106
+ "data-testid": "order-summary-cost-breakdown",
3107
+ children: [
3108
+ /* @__PURE__ */ jsx17(
3109
+ Cost,
3110
+ {
3111
+ label: t("orders.summary.itemSubtotal"),
3112
+ value: getLocaleAmount(order.item_subtotal, order.currency_code)
3113
+ }
3114
+ ),
3115
+ /* @__PURE__ */ jsx17(
3116
+ Cost,
3117
+ {
3118
+ label: /* @__PURE__ */ jsxs17(
3119
+ "span",
3120
+ {
3121
+ onClick: () => setIsShippingOpen((o) => !o),
3122
+ className: "flex cursor-pointer items-center gap-1",
3123
+ children: [
3124
+ /* @__PURE__ */ jsx17("span", { children: t("orders.summary.shippingSubtotal") }),
3125
+ /* @__PURE__ */ jsx17(
3126
+ TriangleDownMini,
3127
+ {
3128
+ style: {
3129
+ transform: `rotate(${isShippingOpen ? 0 : -90}deg)`
3130
+ }
3131
+ }
3132
+ )
3133
+ ]
3134
+ }
3135
+ ),
3136
+ value: getLocaleAmount(order.shipping_subtotal, order.currency_code)
3137
+ }
3138
+ ),
3139
+ isShippingOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 pl-5", children: (order.shipping_methods || []).sort(
3140
+ (m1, m2) => m1.created_at.localeCompare(m2.created_at)
3141
+ ).map((sm, i) => {
3142
+ return /* @__PURE__ */ jsxs17(
3143
+ "div",
3144
+ {
3145
+ className: "flex items-center justify-between gap-x-2",
3146
+ children: [
3147
+ /* @__PURE__ */ jsx17("div", { children: /* @__PURE__ */ jsxs17("span", { className: "txt-small", children: [
3148
+ sm.name,
3149
+ sm.detail.return_id && ` (${t("fields.returnShipping")})`,
3150
+ " ",
3151
+ /* @__PURE__ */ jsx17(shipping_info_popover_default, { shippingMethod: sm }, i)
3152
+ ] }) }),
3153
+ /* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
3154
+ /* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(sm.subtotal, order.currency_code) })
3155
+ ]
3156
+ },
3157
+ sm.id
3158
+ );
3159
+ }) }),
3160
+ /* @__PURE__ */ jsxs17(Fragment3, { children: [
3161
+ /* @__PURE__ */ jsxs17("div", { className: "flex justify-between", children: [
3162
+ /* @__PURE__ */ jsxs17(
3163
+ "div",
3164
+ {
3165
+ onClick: () => hasTaxes && setIsTaxOpen((o) => !o),
3166
+ className: clx3("flex items-center gap-1", {
3167
+ "cursor-pointer": hasTaxes
3168
+ }),
3169
+ children: [
3170
+ /* @__PURE__ */ jsx17("span", { className: "txt-small select-none", children: t("orders.summary.taxTotal") }),
3171
+ hasTaxes && /* @__PURE__ */ jsx17(
3172
+ TriangleDownMini,
3173
+ {
3174
+ style: {
3175
+ transform: `rotate(${isTaxOpen ? 0 : -90}deg)`
3176
+ }
3177
+ }
3178
+ )
3179
+ ]
3180
+ }
3181
+ ),
3182
+ /* @__PURE__ */ jsx17("div", { className: "text-right", children: /* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", children: getLocaleAmount(order.original_tax_total, order.currency_code) }) })
3183
+ ] }),
3184
+ isTaxOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 pl-5", children: Object.entries(taxCodes).map(([code, { total, rate }]) => {
3185
+ return /* @__PURE__ */ jsxs17(
3186
+ "div",
3187
+ {
3188
+ className: "flex items-center justify-between gap-x-2",
3189
+ children: [
3190
+ /* @__PURE__ */ jsxs17("div", { className: "flex gap-1", children: [
3191
+ /* @__PURE__ */ jsx17("span", { className: "txt-small", children: code }),
3192
+ /* @__PURE__ */ jsxs17("span", { className: "txt-small", children: [
3193
+ "(",
3194
+ formatPercentage(rate),
3195
+ ")"
3196
+ ] })
3197
+ ] }),
3198
+ /* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
3199
+ /* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(total, order.currency_code) })
3200
+ ]
3201
+ },
3202
+ code
3203
+ );
3204
+ }) })
3205
+ ] }),
3206
+ /* @__PURE__ */ jsxs17("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
3207
+ /* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: t("fields.total") }),
3208
+ /* @__PURE__ */ jsx17(
3209
+ Text12,
3210
+ {
3211
+ className: "text-ui-fg-subtle text-bold",
3212
+ size: "small",
3213
+ leading: "compact",
3214
+ children: getLocaleAmount(order.original_total, order.currency_code)
3215
+ }
3216
+ )
3217
+ ] })
3218
+ ]
3219
+ }
3220
+ );
3221
+ };
3222
+ var DiscountAndTotalBreakdown = ({
3223
+ order
3224
+ }) => {
3225
+ const { t } = useTranslation17();
3226
+ const [isDiscountOpen, setIsDiscountOpen] = useState6(false);
3227
+ const [isCreditLinesOpen, setIsCreditLinesOpen] = useState6(false);
3228
+ const creditLines = order.credit_lines ?? [];
3229
+ const discounts = useMemo3(() => {
3230
+ const discounts2 = [];
3231
+ if (order.item_discount_total) {
3232
+ discounts2.push({
3233
+ type: "item",
3234
+ total: order.item_discount_total,
3235
+ codes: Array.from(
3236
+ new Set(
3237
+ order.items.flatMap((item) => item.adjustments || []).map((adjustment) => adjustment.code)
3238
+ )
3239
+ ).sort()
3240
+ });
3241
+ }
3242
+ if (order.shipping_discount_total) {
3243
+ discounts2.push({
3244
+ type: "shipping",
3245
+ total: order.shipping_discount_total,
3246
+ codes: Array.from(
3247
+ new Set(
3248
+ order.shipping_methods.flatMap((shippingMethod) => shippingMethod.adjustments || []).map((adjustment) => adjustment.code)
3249
+ )
3250
+ ).sort()
3251
+ });
3252
+ }
3253
+ return discounts2;
3254
+ }, [order]);
3255
+ const hasDiscount = discounts.length > 0;
3256
+ const hasCreditLines = creditLines.length > 0;
3257
+ return /* @__PURE__ */ jsxs17(
3258
+ "div",
3259
+ {
3260
+ className: "text-ui-fg-subtle flex flex-col gap-y-2 px-6 py-4",
3261
+ "data-testid": "order-summary-discount-breakdown",
3262
+ children: [
3263
+ /* @__PURE__ */ jsx17(
3264
+ Cost,
3265
+ {
3266
+ label: /* @__PURE__ */ jsxs17(
3267
+ "span",
3268
+ {
3269
+ onClick: () => hasDiscount && setIsDiscountOpen((o) => !o),
3270
+ className: clx3("flex items-center gap-1", {
3271
+ "cursor-pointer": hasDiscount
3272
+ }),
3273
+ "data-testid": "order-summary-discount-toggle",
3274
+ children: [
3275
+ /* @__PURE__ */ jsx17("span", { children: t("orders.summary.discountTotal") }),
3276
+ hasDiscount && /* @__PURE__ */ jsx17(
3277
+ TriangleDownMini,
3278
+ {
3279
+ style: {
3280
+ transform: `rotate(${isDiscountOpen ? 0 : -90}deg)`
3281
+ }
3282
+ }
3283
+ )
3284
+ ]
3285
+ }
3286
+ ),
3287
+ value: getLocaleAmount(order.discount_total, order.currency_code)
3288
+ }
3289
+ ),
3290
+ isDiscountOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 pl-5", children: discounts.map(({ type, total, codes }) => {
3291
+ return /* @__PURE__ */ jsxs17(
3292
+ "div",
3293
+ {
3294
+ className: "flex items-center justify-between gap-x-2",
3295
+ children: [
3296
+ /* @__PURE__ */ jsxs17("div", { className: "flex gap-1", children: [
3297
+ /* @__PURE__ */ jsx17("span", { className: "txt-small", children: t(`fields.${type}`) }),
3298
+ /* @__PURE__ */ jsxs17("span", { className: "txt-small", children: [
3299
+ "(",
3300
+ codes.join(", "),
3301
+ ")"
3302
+ ] })
3303
+ ] }),
3304
+ /* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
3305
+ /* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(total, order.currency_code) })
3306
+ ]
3307
+ },
3308
+ type
3309
+ );
3310
+ }) }),
3311
+ hasCreditLines && /* @__PURE__ */ jsxs17(Fragment3, { children: [
3312
+ /* @__PURE__ */ jsx17(
3313
+ Cost,
3314
+ {
3315
+ label: /* @__PURE__ */ jsxs17(
3316
+ "span",
3317
+ {
3318
+ onClick: () => setIsCreditLinesOpen((o) => !o),
3319
+ className: "flex cursor-pointer items-center gap-1",
3320
+ children: [
3321
+ /* @__PURE__ */ jsx17("span", { children: t("orders.creditLines.title") }),
3322
+ /* @__PURE__ */ jsx17(
3323
+ TriangleDownMini,
3324
+ {
3325
+ style: {
3326
+ transform: `rotate(${isCreditLinesOpen ? 0 : -90}deg)`
3327
+ }
3328
+ }
3329
+ )
3330
+ ]
3331
+ }
3332
+ ),
3333
+ value: getLocaleAmount(
3334
+ order.credit_line_total,
3335
+ order.currency_code
3336
+ )
3337
+ }
3338
+ ),
3339
+ isCreditLinesOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 pl-5", children: creditLines.map((creditLine) => {
3340
+ const prettyReference = creditLine.reference?.split("_").join(" ").split("-").join(" ");
3341
+ return /* @__PURE__ */ jsxs17(
3342
+ "div",
3343
+ {
3344
+ className: "flex items-center justify-between gap-x-2",
3345
+ children: [
3346
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-center", children: [
3347
+ /* @__PURE__ */ jsx17(
3348
+ Text12,
3349
+ {
3350
+ size: "small",
3351
+ leading: "compact",
3352
+ weight: "plus",
3353
+ className: "txt-small text-ui-fg-subtle font-medium",
3354
+ children: /* @__PURE__ */ jsx17(display_id_default, { id: creditLine.id })
3355
+ }
3356
+ ),
3357
+ /* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-subtle mx-1", children: "-" }),
3358
+ /* @__PURE__ */ jsx17(
3359
+ Tooltip6,
3360
+ {
3361
+ content: format3(
3362
+ new Date(creditLine.created_at),
3363
+ "dd MMM, yyyy, HH:mm:ss"
3364
+ ),
3365
+ children: /* @__PURE__ */ jsx17(
3366
+ Text12,
3367
+ {
3368
+ size: "small",
3369
+ leading: "compact",
3370
+ className: "txt-small text-ui-fg-subtle",
3371
+ children: format3(
3372
+ new Date(creditLine.created_at),
3373
+ "dd MMM, yyyy"
3374
+ )
3375
+ }
3376
+ )
3377
+ }
3378
+ ),
3379
+ /* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-subtle mx-1", children: "-" }),
3380
+ /* @__PURE__ */ jsxs17(
3381
+ Text12,
3382
+ {
3383
+ size: "small",
3384
+ leading: "compact",
3385
+ className: "txt-small text-ui-fg-subtle capitalize",
3386
+ children: [
3387
+ "(",
3388
+ prettyReference,
3389
+ ")"
3390
+ ]
3391
+ }
3392
+ )
3393
+ ] }),
3394
+ /* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
3395
+ /* @__PURE__ */ jsx17("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(
3396
+ creditLine.amount,
3397
+ order.currency_code
3398
+ ) })
3399
+ ]
3400
+ },
3401
+ creditLine.id
3402
+ );
3403
+ }) })
3404
+ ] }),
3405
+ /* @__PURE__ */ jsxs17("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
3406
+ /* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: t("orders.summary.totalAfterDiscount") }),
3407
+ /* @__PURE__ */ jsx17(
3408
+ Text12,
3409
+ {
3410
+ className: "text-ui-fg-subtle text-bold",
3411
+ size: "small",
3412
+ leading: "compact",
3413
+ children: getLocaleAmount(order.total, order.currency_code)
3414
+ }
3415
+ )
3416
+ ] })
3417
+ ]
3418
+ }
3419
+ );
3420
+ };
3421
+ var InventoryKitBreakdown = ({ item }) => {
3422
+ const { t } = useTranslation17();
3423
+ const [isOpen, setIsOpen] = useState6(false);
3424
+ const inventory = item.variant?.inventory_items || [];
3425
+ return /* @__PURE__ */ jsxs17(Fragment3, { children: [
3426
+ /* @__PURE__ */ jsxs17(
3427
+ "div",
3428
+ {
3429
+ onClick: () => setIsOpen((o) => !o),
3430
+ className: "flex cursor-pointer items-center gap-2 border-t border-dashed px-6 py-4",
3431
+ children: [
3432
+ /* @__PURE__ */ jsx17(
3433
+ TriangleDownMini,
3434
+ {
3435
+ style: {
3436
+ transform: `rotate(${isOpen ? 0 : -90}deg)`
3437
+ }
3438
+ }
3439
+ ),
3440
+ /* @__PURE__ */ jsx17("span", { className: "text-ui-fg-muted txt-small select-none", children: t("orders.summary.inventoryKit", { count: inventory.length }) })
3441
+ ]
3442
+ }
3443
+ ),
3444
+ isOpen && /* @__PURE__ */ jsx17("div", { className: "flex flex-col gap-1 px-6 pb-4", children: inventory.map((i) => {
3445
+ return /* @__PURE__ */ jsxs17(
3446
+ "div",
3447
+ {
3448
+ className: "flex items-center justify-between gap-x-2",
3449
+ children: [
3450
+ /* @__PURE__ */ jsx17("div", { children: /* @__PURE__ */ jsxs17("span", { className: "txt-small text-ui-fg-subtle font-medium", children: [
3451
+ i.inventory.title,
3452
+ i.inventory.sku && /* @__PURE__ */ jsxs17("span", { className: "text-ui-fg-subtle font-normal", children: [
3453
+ " ",
3454
+ "\u22C5 ",
3455
+ i.inventory.sku
3456
+ ] })
3457
+ ] }) }),
3458
+ /* @__PURE__ */ jsx17("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx17("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
3459
+ /* @__PURE__ */ jsxs17("span", { className: "txt-small text-ui-fg-muted", children: [
3460
+ i.required_quantity,
3461
+ "x"
3462
+ ] })
3463
+ ]
3464
+ },
3465
+ i.inventory.id
3466
+ );
3467
+ }) })
3468
+ ] });
3469
+ };
3470
+ var ReturnBreakdownWithDamages = ({
3471
+ orderReturn,
3472
+ itemId
3473
+ }) => {
3474
+ const { t } = useTranslation17();
3475
+ const item = orderReturn?.items?.find((ri) => ri.item_id === itemId);
3476
+ const damagedQuantity = item?.damaged_quantity || 0;
3477
+ return item && /* @__PURE__ */ jsxs17(
3478
+ "div",
3479
+ {
3480
+ className: "txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-t-2 border-dotted px-6 py-4",
3481
+ children: [
3482
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2", children: [
3483
+ /* @__PURE__ */ jsx17(ArrowDownRightMini2, { className: "text-ui-fg-muted" }),
3484
+ /* @__PURE__ */ jsx17(Text12, { size: "small", children: t(`orders.returns.damagedItemsReturned`, {
3485
+ quantity: damagedQuantity
3486
+ }) }),
3487
+ item?.note && /* @__PURE__ */ jsx17(Tooltip6, { content: item.note, children: /* @__PURE__ */ jsx17(DocumentText2, { className: "text-ui-tag-neutral-icon ml-1 inline" }) }),
3488
+ item?.reason && /* @__PURE__ */ jsx17(
3489
+ Badge4,
3490
+ {
3491
+ size: "2xsmall",
3492
+ className: "cursor-default select-none capitalize",
3493
+ rounded: "full",
3494
+ children: item?.reason?.label
3495
+ }
3496
+ )
3497
+ ] }),
3498
+ /* @__PURE__ */ jsxs17(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
3499
+ t(`orders.returns.damagedItemReceived`),
3500
+ /* @__PURE__ */ jsx17("span", { className: "ml-2", children: /* @__PURE__ */ jsx17(return_info_popover_default, { orderReturn }) })
3501
+ ] })
3502
+ ]
3503
+ },
3504
+ orderReturn.id
3505
+ );
3506
+ };
3507
+ var ReturnBreakdown = ({
3508
+ orderReturn,
3509
+ itemId
3510
+ }) => {
3511
+ const { t } = useTranslation17();
3512
+ const { getRelativeDate } = useDate();
3513
+ if (!["requested", "received", "partially_received"].includes(
3514
+ orderReturn.status || ""
3515
+ )) {
3516
+ return null;
3517
+ }
3518
+ const isRequested = orderReturn.status === "requested";
3519
+ const item = orderReturn?.items?.find((ri) => ri.item_id === itemId);
3520
+ const damagedQuantity = item?.damaged_quantity || 0;
3521
+ return item && /* @__PURE__ */ jsxs17(Fragment3, { children: [
3522
+ damagedQuantity > 0 && /* @__PURE__ */ jsx17(
3523
+ ReturnBreakdownWithDamages,
3524
+ {
3525
+ orderReturn,
3526
+ itemId
3527
+ }
3528
+ ),
3529
+ /* @__PURE__ */ jsxs17(
3530
+ "div",
3531
+ {
3532
+ className: "txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-t-2 border-dotted px-6 py-4",
3533
+ children: [
3534
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2", children: [
3535
+ /* @__PURE__ */ jsx17(ArrowDownRightMini2, { className: "text-ui-fg-muted" }),
3536
+ /* @__PURE__ */ jsx17(Text12, { size: "small", children: t(
3537
+ `orders.returns.${isRequested ? "returnRequestedInfo" : "returnReceivedInfo"}`,
3538
+ {
3539
+ requestedItemsCount: item?.[isRequested ? "quantity" : "received_quantity"]
3540
+ }
3541
+ ) }),
3542
+ item?.note && /* @__PURE__ */ jsx17(Tooltip6, { content: item.note, children: /* @__PURE__ */ jsx17(DocumentText2, { className: "text-ui-tag-neutral-icon ml-1 inline" }) }),
3543
+ item?.reason && /* @__PURE__ */ jsx17(
3544
+ Badge4,
3545
+ {
3546
+ size: "2xsmall",
3547
+ className: "cursor-default select-none capitalize",
3548
+ rounded: "full",
3549
+ children: item?.reason?.label
3550
+ }
3551
+ )
3552
+ ] }),
3553
+ orderReturn && isRequested && /* @__PURE__ */ jsxs17(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
3554
+ getRelativeDate(orderReturn.created_at),
3555
+ /* @__PURE__ */ jsx17("span", { className: "ml-2", children: /* @__PURE__ */ jsx17(return_info_popover_default, { orderReturn }) })
3556
+ ] }),
3557
+ orderReturn && !isRequested && /* @__PURE__ */ jsxs17(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
3558
+ t(`orders.returns.itemReceived`),
3559
+ /* @__PURE__ */ jsx17("span", { className: "ml-2", children: /* @__PURE__ */ jsx17(return_info_popover_default, { orderReturn }) })
3560
+ ] })
3561
+ ]
3562
+ },
3563
+ item.id
3564
+ )
3565
+ ] });
3566
+ };
3567
+ var ClaimBreakdown = ({
3568
+ claim,
3569
+ itemId
3570
+ }) => {
3571
+ const { t } = useTranslation17();
3572
+ const { getRelativeDate } = useDate();
3573
+ const items = claim.additional_items.filter(
3574
+ (item) => item.item?.id === itemId
3575
+ );
3576
+ return !!items.length && /* @__PURE__ */ jsxs17(
3577
+ "div",
3578
+ {
3579
+ className: "txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-b-2 border-t-2 border-dotted px-6 py-4",
3580
+ children: [
3581
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2", children: [
3582
+ /* @__PURE__ */ jsx17(ArrowDownRightMini2, { className: "text-ui-fg-muted" }),
3583
+ /* @__PURE__ */ jsx17(Text12, { size: "small", children: t(`orders.claims.outboundItemAdded`, {
3584
+ itemsCount: items.reduce(
3585
+ (acc, item) => acc = acc + item.quantity,
3586
+ 0
3587
+ )
3588
+ }) })
3589
+ ] }),
3590
+ /* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: getRelativeDate(claim.created_at) })
3591
+ ]
3592
+ },
3593
+ claim.id
3594
+ );
3595
+ };
3596
+ var ExchangeBreakdown = ({
3597
+ exchange,
3598
+ itemId
3599
+ }) => {
3600
+ const { t } = useTranslation17();
3601
+ const { getRelativeDate } = useDate();
3602
+ const items = exchange.additional_items.filter(
3603
+ (item) => item?.item?.id === itemId
3604
+ );
3605
+ return !!items.length && /* @__PURE__ */ jsxs17(
3606
+ "div",
3607
+ {
3608
+ className: "txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-subtle flex flex-row justify-between gap-y-2 border-b-2 border-t-2 border-dotted px-6 py-4",
3609
+ children: [
3610
+ /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2", children: [
3611
+ /* @__PURE__ */ jsx17(ArrowDownRightMini2, { className: "text-ui-fg-muted" }),
3612
+ /* @__PURE__ */ jsx17(Text12, { size: "small", children: t(`orders.exchanges.outboundItemAdded`, {
3613
+ itemsCount: items.reduce(
3614
+ (acc, item) => acc = acc + item.quantity,
3615
+ 0
3616
+ )
3617
+ }) })
3618
+ ] }),
3619
+ /* @__PURE__ */ jsx17(Text12, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: getRelativeDate(exchange.created_at) })
3620
+ ]
3621
+ },
3622
+ exchange.id
3623
+ );
3624
+ };
3625
+ var Total2 = ({ order }) => {
3626
+ const { t } = useTranslation17();
3627
+ return /* @__PURE__ */ jsxs17(
3628
+ "div",
3629
+ {
3630
+ className: " flex flex-col gap-y-2 px-6 py-4",
3631
+ "data-testid": "order-summary-total",
3632
+ children: [
3633
+ /* @__PURE__ */ jsxs17(
3634
+ "div",
3635
+ {
3636
+ className: "text-ui-fg-base flex items-center justify-between",
3637
+ "data-testid": "order-summary-paid-total",
3638
+ children: [
3639
+ /* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: t("fields.paidTotal") }),
3640
+ /* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: getStylizedAmount(
3641
+ getTotalCaptured(order.payment_collections || []),
3642
+ order.currency_code
3643
+ ) })
3644
+ ]
3645
+ }
3646
+ ),
3647
+ getTotalCreditLines(order.credit_lines ?? []) > 0 && /* @__PURE__ */ jsxs17("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
3648
+ /* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: t("fields.creditTotal") }),
3649
+ /* @__PURE__ */ jsx17(Text12, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: getStylizedAmount(
3650
+ getTotalCreditLines(order.credit_lines ?? []),
3651
+ order.currency_code
3652
+ ) })
3653
+ ] }),
3654
+ /* @__PURE__ */ jsxs17(
3655
+ "div",
3656
+ {
3657
+ className: "text-ui-fg-base flex items-center justify-between",
3658
+ "data-testid": "order-summary-outstanding-amount",
3659
+ children: [
3660
+ /* @__PURE__ */ jsx17(
3661
+ Text12,
3662
+ {
3663
+ className: "text-ui-fg-subtle text-semibold",
3664
+ size: "small",
3665
+ leading: "compact",
3666
+ children: t("orders.returns.outstandingAmount")
3667
+ }
3668
+ ),
3669
+ /* @__PURE__ */ jsx17(
3670
+ Text12,
3671
+ {
3672
+ className: "text-ui-fg-subtle text-bold",
3673
+ size: "small",
3674
+ leading: "compact",
3675
+ children: getStylizedAmount(
3676
+ order.summary.pending_difference || 0,
3677
+ order.currency_code
3678
+ )
3679
+ }
3680
+ )
3681
+ ]
3682
+ }
3683
+ )
3684
+ ]
3685
+ }
3686
+ );
3687
+ };
3688
+
3689
+ // src/pages/orders/order-detail/components/order-remaining-orders-group-section/order-remaining-orders-group-section.tsx
3690
+ import { Container as Container11, Heading as Heading11 } from "@medusajs/ui";
3691
+ import { createColumnHelper } from "@tanstack/react-table";
3692
+ import { useMemo as useMemo4 } from "react";
3693
+ import { useTranslation as useTranslation18 } from "react-i18next";
3694
+ import { useParams } from "react-router-dom";
3695
+ import { jsx as jsx18, jsxs as jsxs18 } from "react/jsx-runtime";
3696
+ var DEFAULT_FIELDS2 = "id,*orders,*orders.customer,*orders.seller,*orders.sales_channel";
3697
+ var OrderRemainingOrdersGroupSection = () => {
3698
+ const { id } = useParams();
3699
+ const { t } = useTranslation18();
3700
+ const { order_group, isLoading, isError, error } = useOrderGroupByOrderId(
3701
+ id,
3702
+ { fields: DEFAULT_FIELDS2 }
3703
+ );
3704
+ const orders = useMemo4(() => {
3705
+ const group = order_group;
3706
+ if (!group?.orders) return [];
3707
+ return group.orders.filter((o) => o.id !== id);
3708
+ }, [order_group, id]);
3709
+ const columns = useColumns();
3710
+ const { table } = useDataTable({
3711
+ data: orders,
3712
+ columns,
3713
+ count: orders.length,
3714
+ enablePagination: false,
3715
+ getRowId: (row) => row.id
3716
+ });
3717
+ if (isError) {
3718
+ throw error;
3719
+ }
3720
+ if (!isLoading && orders.length === 0) {
3721
+ return null;
3722
+ }
3723
+ return /* @__PURE__ */ jsxs18(
3724
+ Container11,
3725
+ {
3726
+ className: "divide-y p-0",
3727
+ "data-testid": "order-remaining-orders-group-section",
3728
+ children: [
3729
+ /* @__PURE__ */ jsx18(
3730
+ "div",
3731
+ {
3732
+ className: "flex items-center justify-between px-6 py-4",
3733
+ "data-testid": "order-remaining-orders-group-header",
3734
+ children: /* @__PURE__ */ jsxs18(Heading11, { level: "h2", "data-testid": "order-remaining-orders-group-heading", children: [
3735
+ t("orders.domain"),
3736
+ " in group"
3737
+ ] })
3738
+ }
3739
+ ),
3740
+ /* @__PURE__ */ jsx18(
3741
+ _DataTable,
3742
+ {
3743
+ columns,
3744
+ table,
3745
+ navigateTo: (row) => `/orders/${row.original.id}`,
3746
+ count: orders.length,
3747
+ isLoading,
3748
+ pageSize: orders.length,
3749
+ noRecords: {
3750
+ message: "No other orders in this group"
3751
+ }
3752
+ }
3753
+ )
3754
+ ]
3755
+ }
3756
+ );
3757
+ };
3758
+ var columnHelper = createColumnHelper();
3759
+ var useColumns = () => {
3760
+ return useMemo4(
3761
+ () => [
3762
+ columnHelper.accessor("display_id", {
3763
+ header: () => /* @__PURE__ */ jsx18(DisplayIdHeader, {}),
3764
+ cell: ({ getValue }) => /* @__PURE__ */ jsx18(DisplayIdCell, { displayId: getValue() })
3765
+ }),
3766
+ columnHelper.display({
3767
+ id: "seller",
3768
+ header: () => /* @__PURE__ */ jsx18(TextHeader, { text: "Seller" }),
3769
+ cell: ({ row }) => {
3770
+ const seller = row.original.seller;
3771
+ return /* @__PURE__ */ jsx18(TextCell, { text: seller?.name ?? "-" });
3772
+ }
3773
+ }),
3774
+ columnHelper.accessor("created_at", {
3775
+ header: () => /* @__PURE__ */ jsx18(DateHeader, {}),
3776
+ cell: ({ getValue }) => /* @__PURE__ */ jsx18(DateCell, { date: new Date(getValue()) })
3777
+ }),
3778
+ columnHelper.accessor("payment_status", {
3779
+ header: () => /* @__PURE__ */ jsx18(PaymentStatusHeader, {}),
3780
+ cell: ({ getValue }) => /* @__PURE__ */ jsx18(PaymentStatusCell, { status: getValue() })
3781
+ }),
3782
+ columnHelper.accessor("fulfillment_status", {
3783
+ header: () => /* @__PURE__ */ jsx18(FulfillmentStatusHeader, {}),
3784
+ cell: ({ getValue }) => /* @__PURE__ */ jsx18(FulfillmentStatusCell, { status: getValue() })
3785
+ }),
3786
+ columnHelper.accessor("total", {
3787
+ header: () => /* @__PURE__ */ jsx18(TotalHeader, {}),
3788
+ cell: ({ getValue, row }) => /* @__PURE__ */ jsx18(
3789
+ TotalCell,
3790
+ {
3791
+ currencyCode: row.original.currency_code,
3792
+ total: getValue()
3793
+ }
3794
+ )
3795
+ })
3796
+ ],
3797
+ []
3798
+ );
3799
+ };
3800
+
3801
+ // src/pages/orders/order-detail/order-detail.tsx
3802
+ import { jsx as jsx19, jsxs as jsxs19 } from "react/jsx-runtime";
3803
+ var Root = ({ children }) => {
3804
+ const initialData = useLoaderData();
3805
+ const { id } = useParams2();
3806
+ const { order: rawOrder, isLoading, isError, error } = useOrder(
3807
+ id,
3808
+ {
3809
+ fields: DEFAULT_FIELDS
3810
+ },
3811
+ {
3812
+ initialData
3813
+ }
3814
+ );
3815
+ const order = rawOrder ? {
3816
+ ...rawOrder,
3817
+ items: [...rawOrder.items].sort((itemA, itemB) => {
3818
+ if (itemA.created_at > itemB.created_at) {
3819
+ return 1;
3820
+ }
3821
+ if (itemA.created_at < itemB.created_at) {
3822
+ return -1;
3823
+ }
3824
+ return 0;
3825
+ })
3826
+ } : rawOrder;
3827
+ const { order: orderPreview, isLoading: isPreviewLoading } = useOrderPreview(
3828
+ id
3829
+ );
3830
+ if (isLoading || !order || isPreviewLoading) {
3831
+ return /* @__PURE__ */ jsx19(TwoColumnPageSkeleton, { mainSections: 4, sidebarSections: 2, showJSON: true });
3832
+ }
3833
+ if (isError) {
3834
+ throw error;
3835
+ }
3836
+ return Children.count(children) > 0 ? /* @__PURE__ */ jsx19(
3837
+ TwoColumnPage,
3838
+ {
3839
+ data: order,
3840
+ showJSON: true,
3841
+ showMetadata: true,
3842
+ hasOutlet: true,
3843
+ "data-testid": "order-detail-page",
3844
+ children
3845
+ }
3846
+ ) : /* @__PURE__ */ jsxs19(
3847
+ TwoColumnPage,
3848
+ {
3849
+ data: order,
3850
+ showJSON: true,
3851
+ showMetadata: true,
3852
+ hasOutlet: true,
3853
+ "data-testid": "order-detail-page",
3854
+ children: [
3855
+ /* @__PURE__ */ jsxs19(TwoColumnPage.Main, { "data-testid": "order-detail-main", children: [
3856
+ /* @__PURE__ */ jsx19(OrderActiveEditSection, { order }),
3857
+ /* @__PURE__ */ jsx19(ActiveOrderClaimSection, { orderPreview }),
3858
+ /* @__PURE__ */ jsx19(ActiveOrderExchangeSection, { orderPreview }),
3859
+ /* @__PURE__ */ jsx19(ActiveOrderReturnSection, { orderPreview }),
3860
+ /* @__PURE__ */ jsx19(OrderGeneralSection, { order }),
3861
+ /* @__PURE__ */ jsx19(OrderSummarySection, { order }),
3862
+ /* @__PURE__ */ jsx19(OrderPaymentSection, { order }),
3863
+ /* @__PURE__ */ jsx19(OrderFulfillmentSection, { order })
3864
+ ] }),
3865
+ /* @__PURE__ */ jsxs19(TwoColumnPage.Sidebar, { "data-testid": "order-detail-sidebar", children: [
3866
+ /* @__PURE__ */ jsx19(OrderCustomerSection, { order }),
3867
+ /* @__PURE__ */ jsx19(OrderActivitySection, { order }),
3868
+ /* @__PURE__ */ jsx19(OrderRemainingOrdersGroupSection, {})
3869
+ ] })
3870
+ ]
3871
+ }
3872
+ );
3873
+ };
3874
+ var OrderDetailPage = Object.assign(Root, {
3875
+ Main: TwoColumnPage.Main,
3876
+ Sidebar: TwoColumnPage.Sidebar,
3877
+ MainActiveEditSection: OrderActiveEditSection,
3878
+ MainActiveClaimSection: ActiveOrderClaimSection,
3879
+ MainActiveExchangeSection: ActiveOrderExchangeSection,
3880
+ MainActiveReturnSection: ActiveOrderReturnSection,
3881
+ MainGeneralSection: OrderGeneralSection,
3882
+ MainSummarySection: OrderSummarySection,
3883
+ MainPaymentSection: OrderPaymentSection,
3884
+ MainFulfillmentSection: OrderFulfillmentSection,
3885
+ SidebarCustomerSection: OrderCustomerSection,
3886
+ SidebarActivitySection: OrderActivitySection,
3887
+ SidebarOrderGroupSection: OrderRemainingOrdersGroupSection
3888
+ });
3889
+
3890
+ export {
3891
+ OrderDetailPage
3892
+ };