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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/dist/{[id]-GMJAPZPU.js → [id]-3LNKC5OJ.js} +41 -40
  2. package/dist/[id]-4HO4S2PX.js +3074 -0
  3. package/dist/{[id]-QWL6SUOB.js → [id]-4LIIFGET.js} +14 -14
  4. package/dist/{[id]-5ADOHZ45.js → [id]-5EECCIRP.js} +151 -58
  5. package/dist/{[id]-K2CT7BXQ.js → [id]-5P5LTATX.js} +3 -3
  6. package/dist/{[id]-T7USGHIY.js → [id]-AQUUZFRX.js} +11 -11
  7. package/dist/{[id]-BTGQJ3UD.js → [id]-CUBGVODE.js} +177 -85
  8. package/dist/{[id]-ZAQYATGN.js → [id]-DCGPICT3.js} +39 -38
  9. package/dist/{[id]-IWCWVNVI.js → [id]-DT5YJVKG.js} +32 -32
  10. package/dist/{[id]-L6FD7BRE.js → [id]-IEBZ6V3W.js} +51 -48
  11. package/dist/{[id]-ZCMSBEVM.js → [id]-N7JEZFXQ.js} +6 -6
  12. package/dist/[id]-U6FKX5UQ.js +975 -0
  13. package/dist/{[id]-BPAZLOLW.js → [id]-XB45DY2D.js} +19 -19
  14. package/dist/[id]-XP5KEMNX.js +602 -0
  15. package/dist/{[location_id]-NUBXDDJC.js → [location_id]-I4HHUHWY.js} +14 -14
  16. package/dist/{[province_id]-5KZGMQER.js → [province_id]-OYX4MOCF.js} +31 -31
  17. package/dist/{add-KMHJ6OC6.js → add-3T4GBFMM.js} +63 -57
  18. package/dist/{add-Y6GMGLYX.js → add-RPRJWCYU.js} +99 -34
  19. package/dist/{add-customer-groups-NXSWICFI.js → add-customer-groups-FB5T6PQN.js} +44 -42
  20. package/dist/{add-products-LXYF57BK.js → add-products-F243SWGD.js} +40 -40
  21. package/dist/{add-promotions-VTYAEDCN.js → add-promotions-TJDK7HLW.js} +18 -18
  22. package/dist/{add-to-campaign-DLP7PSQB.js → add-to-campaign-Q6OAJMUJ.js} +6 -6
  23. package/dist/{address-JFXH3M7D.js → address-XVBSNMFU.js} +24 -24
  24. package/dist/{adjust-inventory-V2V7NWWH.js → adjust-inventory-IZLRMQXV.js} +4 -4
  25. package/dist/allocate-items-Q3VALDYT.js +685 -0
  26. package/dist/{areas-FB63OQAI.js → areas-IYGBRCRH.js} +14 -14
  27. package/dist/attributes-LGEM2JJW.js +353 -0
  28. package/dist/breadcrumb-BC6XN2SE.js +13 -0
  29. package/dist/{breadcrumb-THJ2HPRB.js → breadcrumb-BFNJWOJ4.js} +10 -9
  30. package/dist/{breadcrumb-S4V7MJUM.js → breadcrumb-BXD3SRM7.js} +3 -3
  31. package/dist/{breadcrumb-HV67K43U.js → breadcrumb-FEYGZFJU.js} +4 -4
  32. package/dist/{breadcrumb-EG3ANCVO.js → breadcrumb-H45Z2WNG.js} +3 -3
  33. package/dist/breadcrumb-ILEAQRW7.js +33 -0
  34. package/dist/breadcrumb-K4HBKZUE.js +28 -0
  35. package/dist/{breadcrumb-YBBYFQYG.js → breadcrumb-KZPOPXGG.js} +2 -2
  36. package/dist/{breadcrumb-F3BN5753.js → breadcrumb-L262VPBO.js} +2 -2
  37. package/dist/{breadcrumb-3Z7KZG62.js → breadcrumb-LEFHXFLT.js} +3 -3
  38. package/dist/{breadcrumb-D3UDTWGE.js → breadcrumb-MOA2DBOE.js} +2 -2
  39. package/dist/breadcrumb-NZYOCEEM.js +47 -0
  40. package/dist/breadcrumb-VY5DNTTJ.js +46 -0
  41. package/dist/{breadcrumb-UAUX7XCV.js → breadcrumb-WG6TIF4C.js} +2 -2
  42. package/dist/{breadcrumb-7R6E6G2X.js → breadcrumb-XEZCMI55.js} +2 -2
  43. package/dist/{breadcrumb-FES7EKUR.js → breadcrumb-XGXKCDYS.js} +4 -4
  44. package/dist/{breadcrumb-Y5UW3I4C.js → breadcrumb-YOY6Z36F.js} +2 -2
  45. package/dist/{campaigns-JAQTSA4Z.js → campaigns-DZKRNCA4.js} +9 -9
  46. package/dist/{categories-6TVMTN62.js → categories-JZJA2IBQ.js} +13 -11
  47. package/dist/{chunk-SFQKKIHA.js → chunk-27WLUOI2.js} +1 -1
  48. package/dist/{chunk-U5XDKYZG.js → chunk-2KA4TGBQ.js} +3 -3
  49. package/dist/{chunk-6RH3VDF7.js → chunk-2NPD4S55.js} +4 -4
  50. package/dist/{chunk-M6GKMFTC.js → chunk-3ALBZK4M.js} +1 -1
  51. package/dist/{chunk-PXYDR7WQ.js → chunk-3BXCPHN6.js} +3 -2
  52. package/dist/{chunk-X4INVIWL.js → chunk-3C2T27YW.js} +3 -3
  53. package/dist/{chunk-QXLRABYH.js → chunk-3I6ZAMGN.js} +1 -1
  54. package/dist/{chunk-THMXGEZU.js → chunk-3SH24DGG.js} +2 -2
  55. package/dist/chunk-3TST3EWQ.js +438 -0
  56. package/dist/chunk-42R54Z2X.js +8 -0
  57. package/dist/{chunk-UDJ2I5A2.js → chunk-4IRQSBA7.js} +5 -6
  58. package/dist/chunk-5ALC4Z2H.js +23 -0
  59. package/dist/chunk-5BQO3YQP.js +62 -0
  60. package/dist/{chunk-QGGMG3OU.js → chunk-5BYYDBLS.js} +7 -7
  61. package/dist/{chunk-4LVP635F.js → chunk-5FBQOAXU.js} +135 -126
  62. package/dist/{chunk-2BCAQ4BB.js → chunk-5PAUN3PM.js} +3 -3
  63. package/dist/{chunk-E2HQPY32.js → chunk-5RMLLTR7.js} +5 -5
  64. package/dist/{chunk-3EF54XFY.js → chunk-634XVU3D.js} +1 -1
  65. package/dist/{chunk-LJO34DKJ.js → chunk-6FDPVW7Y.js} +35 -21
  66. package/dist/{chunk-3X3LUKDM.js → chunk-6Q3J6ZMM.js} +5 -5
  67. package/dist/chunk-7BFQKYCJ.js +127 -0
  68. package/dist/chunk-7EXKHL5L.js +30 -0
  69. package/dist/{chunk-M6N4ISXL.js → chunk-7MARNXFG.js} +1 -1
  70. package/dist/{chunk-WHSE47DM.js → chunk-AOLE7MBM.js} +1 -1
  71. package/dist/{chunk-YIZK67RW.js → chunk-BQHVM46E.js} +29 -49
  72. package/dist/chunk-CRYZK4NU.js +185 -0
  73. package/dist/{chunk-JYPPXAJG.js → chunk-CUAGC54B.js} +33 -35
  74. package/dist/{chunk-KIFSQOM2.js → chunk-D76WZZSB.js} +5 -5
  75. package/dist/{chunk-QLBIBLOY.js → chunk-DQ7LZZJX.js} +5 -5
  76. package/dist/{chunk-UCYSCKZV.js → chunk-DSTHXHJ5.js} +2114 -1699
  77. package/dist/{chunk-L7QKFC5N.js → chunk-E6W57UP3.js} +32 -122
  78. package/dist/{chunk-UFFVRF4V.js → chunk-EAAZV3B7.js} +6 -11
  79. package/dist/chunk-EDV4MTTT.js +434 -0
  80. package/dist/chunk-EEBJYXWA.js +15 -0
  81. package/dist/{chunk-UORPTGV2.js → chunk-EPRYM3FA.js} +11 -15
  82. package/dist/{chunk-YQYRAD5C.js → chunk-FCZJAYMM.js} +1 -1
  83. package/dist/{chunk-JMRWREVE.js → chunk-FDKFUIYV.js} +23 -36
  84. package/dist/chunk-FWPGOIFA.js +22 -0
  85. package/dist/{chunk-B234IELY.js → chunk-G6YNCIVF.js} +24 -41
  86. package/dist/{chunk-PVZBDWLK.js → chunk-GRH7C3QN.js} +1 -1
  87. package/dist/chunk-GSH6ZGI6.js +353 -0
  88. package/dist/{chunk-IQWK723D.js → chunk-GZ4KTAWS.js} +1 -1
  89. package/dist/{chunk-MJCL3WID.js → chunk-H6LZ77GX.js} +1 -1
  90. package/dist/{chunk-WLT7K7K7.js → chunk-HDEOZN2Q.js} +21 -24
  91. package/dist/{chunk-FDR22JMM.js → chunk-HFRHHT36.js} +8 -63
  92. package/dist/{chunk-GNDFMMC6.js → chunk-IEVN722X.js} +1 -1
  93. package/dist/{chunk-DARJTN4I.js → chunk-IMJ62GAP.js} +10 -5
  94. package/dist/{chunk-SGR4DMCW.js → chunk-INYLPVCG.js} +3 -3
  95. package/dist/{chunk-5T6UWTRU.js → chunk-IV57G2CB.js} +19 -11
  96. package/dist/chunk-J6XCRFBW.js +30 -0
  97. package/dist/{chunk-BLRZB63H.js → chunk-JDNXS37G.js} +61 -62
  98. package/dist/{chunk-3B34B2M2.js → chunk-JJP6AKMV.js} +1 -1
  99. package/dist/{chunk-XEU5ZLSB.js → chunk-JK4M3ZKY.js} +5 -5
  100. package/dist/{chunk-VXMOPVRH.js → chunk-JR7AABT5.js} +2 -2
  101. package/dist/{chunk-PBD36EZJ.js → chunk-JTHDMXZV.js} +5 -5
  102. package/dist/{chunk-Q75AC3DZ.js → chunk-JY2XON7H.js} +2 -2
  103. package/dist/{chunk-6OUPJNYO.js → chunk-KCHYLLVG.js} +2 -2
  104. package/dist/{chunk-YGRTRAWX.js → chunk-KDE4HKH2.js} +1 -0
  105. package/dist/{chunk-VPKMBJ5B.js → chunk-KG2NUK4J.js} +6 -6
  106. package/dist/{chunk-VXWN37PT.js → chunk-KIURBTC4.js} +1 -1
  107. package/dist/{chunk-7LVNAFEI.js → chunk-KTJLJTFO.js} +547 -882
  108. package/dist/{chunk-FCJ7MLQK.js → chunk-KZQFIPY2.js} +264 -76
  109. package/dist/chunk-L57USMYC.js +39 -0
  110. package/dist/{chunk-4KNL46BT.js → chunk-LWFBBTJ3.js} +5 -5
  111. package/dist/{chunk-RIN4CBRB.js → chunk-LXZXXOJ3.js} +1 -17
  112. package/dist/chunk-LYYM7H7H.js +59 -0
  113. package/dist/{chunk-MWQQVKRU.js → chunk-MAVQ636Y.js} +1 -1
  114. package/dist/{chunk-VDHW6H5F.js → chunk-MAW6ZT3D.js} +4 -4
  115. package/dist/{chunk-7CMRFP5Q.js → chunk-MJP5V3JN.js} +3 -3
  116. package/dist/{chunk-S7EKBD2C.js → chunk-MNHP6YRC.js} +3 -3
  117. package/dist/{chunk-QZJIDKQR.js → chunk-MT6WOKIW.js} +4 -4
  118. package/dist/chunk-MUGQQY6P.js +315 -0
  119. package/dist/{chunk-QT7YFHCA.js → chunk-MVEHWM7K.js} +13 -1
  120. package/dist/{chunk-VV6IKGCN.js → chunk-NTJ3BMOE.js} +1 -1
  121. package/dist/{chunk-JXQJQYGD.js → chunk-O7BGGWW6.js} +2 -2
  122. package/dist/{chunk-LWJF63JW.js → chunk-OYUJYPDF.js} +90 -15
  123. package/dist/{chunk-4S6XGIC6.js → chunk-PUAWN7SS.js} +1 -1
  124. package/dist/{chunk-U6PBLMXD.js → chunk-Q6SPIHFR.js} +8 -3
  125. package/dist/{chunk-F4OJN2F2.js → chunk-QIF4QE7T.js} +1 -1
  126. package/dist/{chunk-X22KTLZ7.js → chunk-QWJTJSIT.js} +1 -1
  127. package/dist/{chunk-2USXZSTK.js → chunk-QWW6RHZC.js} +5 -5
  128. package/dist/{chunk-TODJFRLH.js → chunk-RILHLBKW.js} +3 -3
  129. package/dist/{chunk-PP754CO7.js → chunk-RPU4UOQK.js} +1 -1
  130. package/dist/{chunk-AVOZ7TX2.js → chunk-RTMMO6IU.js} +6 -6
  131. package/dist/chunk-S7NGDLZ3.js +173 -0
  132. package/dist/{chunk-U2ZFCAPX.js → chunk-SITRHMZZ.js} +11 -8
  133. package/dist/chunk-SPFLYPY6.js +6 -0
  134. package/dist/{chunk-EIUYXS7E.js → chunk-TJKZ5QCJ.js} +4 -4
  135. package/dist/{chunk-WCSQDWMS.js → chunk-TPGIMZLI.js} +1 -1
  136. package/dist/chunk-UM7ZR3VU.js +14 -0
  137. package/dist/{chunk-PGW3VYK4.js → chunk-UNE4VD5U.js} +3 -3
  138. package/dist/chunk-UX5UYDCY.js +33 -0
  139. package/dist/{chunk-IXAQNTE7.js → chunk-V5K6HISS.js} +2 -2
  140. package/dist/chunk-VCUUITW6.js +35 -0
  141. package/dist/{chunk-T5MJWWDX.js → chunk-VD27SL7H.js} +5 -5
  142. package/dist/{chunk-LRARA622.js → chunk-VE6GRIIN.js} +2 -2
  143. package/dist/{chunk-SSUUT5LK.js → chunk-W3UHAQCV.js} +5 -4
  144. package/dist/{chunk-U5G3AVED.js → chunk-WBCWER26.js} +1 -1
  145. package/dist/{chunk-PXI47JL5.js → chunk-WCXFUBEF.js} +13 -13
  146. package/dist/{chunk-AVOIZO63.js → chunk-WFE6CT6M.js} +77 -21
  147. package/dist/{chunk-E2L5EX5A.js → chunk-WFHGJGCW.js} +7 -6
  148. package/dist/{chunk-LQD232FW.js → chunk-WJ5EU3KW.js} +1 -1
  149. package/dist/{chunk-6YA3C4NB.js → chunk-XBKWFLJG.js} +4 -13
  150. package/dist/chunk-XQUF3WIS.js +159 -0
  151. package/dist/{chunk-SS46VQJA.js → chunk-Y4PM3IDZ.js} +1 -1
  152. package/dist/chunk-YBF45CX5.js +23 -0
  153. package/dist/{chunk-JQV7CXEC.js → chunk-YNGA3GRX.js} +17 -2
  154. package/dist/chunk-ZHFFTT3I.js +17 -0
  155. package/dist/{chunk-BOZJOOGW.js → chunk-ZLHCZ5F2.js} +1 -1
  156. package/dist/{chunk-LHKHQAAY.js → chunk-ZLYGEART.js} +1 -1
  157. package/dist/{chunk-NBPMNUKZ.js → chunk-ZQCCVCHB.js} +1 -1
  158. package/dist/{chunk-ADGVQVHP.js → chunk-ZTOYVPGA.js} +3 -3
  159. package/dist/collections-XIHCTMSJ.js +70 -0
  160. package/dist/{configuration-C4IGBNXH.js → configuration-3GCBMM27.js} +3 -3
  161. package/dist/{configuration-JI22M76Z.js → configuration-FWZTMYXY.js} +5 -5
  162. package/dist/{create-OXR7WG5F.js → create-2RGNAVVY.js} +32 -32
  163. package/dist/{create-5QLYFVEK.js → create-32MXB6FD.js} +24 -24
  164. package/dist/create-3AMFYYI6.js +245 -0
  165. package/dist/create-AMNH3WXL.js +75 -0
  166. package/dist/{create-UPYB65PD.js → create-BV3QDTK2.js} +4 -4
  167. package/dist/{create-POK6SJSZ.js → create-FHIFVCSG.js} +52 -49
  168. package/dist/{create-EATFT5AB.js → create-GO7APBBU.js} +31 -31
  169. package/dist/create-HEZYB7RF.js +1179 -0
  170. package/dist/{create-R7K3ECN6.js → create-K26SM34L.js} +3 -3
  171. package/dist/{create-6I43IPLO.js → create-N534JQPH.js} +14 -14
  172. package/dist/create-NEK6JCKR.js +1798 -0
  173. package/dist/{create-YBF4YGWG.js → create-NF2LPVXA.js} +3 -3
  174. package/dist/{create-F7IDSSTP.js → create-PJVLJ7T6.js} +50 -45
  175. package/dist/{create-CK4X357V.js → create-RPBHXU32.js} +28 -28
  176. package/dist/{create-SFU3W3ZH.js → create-U64NEOEL.js} +3 -3
  177. package/dist/create-VL7LDTVE.js +1931 -0
  178. package/dist/{create-XVHOCZHJ.js → create-X5SOAPD3.js} +3 -3
  179. package/dist/{create-2XZLOG5Z.js → create-XLYGW5PN.js} +69 -41
  180. package/dist/{create-GB3ZA4LH.js → create-YKYLCEAK.js} +6 -6
  181. package/dist/customer-group-add-customers-2C53NFBJ.js +251 -0
  182. package/dist/customer-group-create-75QQEQZF.js +147 -0
  183. package/dist/customer-group-detail-AOQYYAOG.js +58 -0
  184. package/dist/customer-group-edit-N77RCW6I.js +138 -0
  185. package/dist/customer-groups-GNFV7VMT.js +284 -0
  186. package/dist/{customers-SOLJ2KQQ.js → customers-HNINO6YL.js} +11 -11
  187. package/dist/{edit-TZ4EXLKJ.js → edit-3DUCWSLA.js} +62 -46
  188. package/dist/{edit-ORXS3A2Y.js → edit-3V34KJS2.js} +3 -3
  189. package/dist/{edit-RJ3EZ5CD.js → edit-4PWAJ7A3.js} +25 -25
  190. package/dist/{edit-ZQP4MNJU.js → edit-7CLOJ3UZ.js} +50 -47
  191. package/dist/{edit-ZAHCMF5U.js → edit-7SBPHN6P.js} +3 -3
  192. package/dist/edit-BSD6667Q.js +367 -0
  193. package/dist/{edit-Q3UQIOLS.js → edit-I2RJUPWV.js} +4 -4
  194. package/dist/{edit-UUP3BQV3.js → edit-IJ6DCBUU.js} +5 -5
  195. package/dist/{edit-ZMERG3L7.js → edit-JB7KVBOL.js} +5 -5
  196. package/dist/{edit-O4JLGKQR.js → edit-NHQJLCAK.js} +4 -4
  197. package/dist/edit-O65JD54W.js +103 -0
  198. package/dist/{edit-4OEBCCXJ.js → edit-SIKOSSHF.js} +24 -24
  199. package/dist/edit-TD7QFM4Z.js +871 -0
  200. package/dist/{edit-C4OCKQVU.js → edit-UNN3QTEJ.js} +3 -3
  201. package/dist/{edit-PFAJZUWI.js → edit-WEUFBORT.js} +33 -34
  202. package/dist/{edit-KAKVPHZZ.js → edit-WN2Q3TOX.js} +4 -4
  203. package/dist/{edit-QPPMI7MU.js → edit-ZGAOUZYP.js} +33 -34
  204. package/dist/{edit-522DG3BY.js → edit-ZOLSAIKF.js} +3 -3
  205. package/dist/{edit-2LGAEKH6.js → edit-ZORE6RUD.js} +25 -25
  206. package/dist/{edit-budget-L3CCEWNF.js → edit-budget-D22WMVYR.js} +3 -3
  207. package/dist/{edit-inventory-item-A7KAPATR.js → edit-inventory-item-QMYWEBZ3.js} +3 -3
  208. package/dist/{edit-inventory-item-attributes-RNBOJR66.js → edit-inventory-item-attributes-HLG6JR6S.js} +3 -3
  209. package/dist/edit-price-F7ZWM3FN.js +197 -0
  210. package/dist/edit-stock-ITAZNHPU.js +230 -0
  211. package/dist/fulfillment-U2GRQ6DD.js +641 -0
  212. package/dist/{fulfillment-providers-6WDXCGAI.js → fulfillment-providers-CMU2JB5X.js} +40 -40
  213. package/dist/index.css +120 -24
  214. package/dist/index.js +355 -235
  215. package/dist/{offer-inventory-batch-page-4QNXDUWN.js → inventory-4JKLAZ2Q.js} +20 -20
  216. package/dist/{inventory-IOVM7GDU.js → inventory-FKEXULLT.js} +10 -10
  217. package/dist/{invite-HRKSQI4B.js → invite-3R2CEWLN.js} +23 -23
  218. package/dist/{invite-UBH7PYSH.js → invite-MNAX6EUC.js} +39 -39
  219. package/dist/loader-HTPUNIOS.js +34 -0
  220. package/dist/loader-MAAMUP2Z.js +33 -0
  221. package/dist/{locations-INS6FTMJ.js → locations-2VWSMWHL.js} +3 -3
  222. package/dist/login-YUWOWICV.js +39 -0
  223. package/dist/{manage-locations-TIYOCOZU.js → manage-locations-RWGDXXJQ.js} +3 -3
  224. package/dist/{media-EXWUWWNB.js → media-P6WSFHY4.js} +31 -30
  225. package/dist/media-YB4G5CMV.js +316 -0
  226. package/dist/{metadata-JIMHXPKE.js → metadata-5Q6FLVX4.js} +27 -27
  227. package/dist/{metadata-T6MLCEZ2.js → metadata-6OYHLPLA.js} +25 -25
  228. package/dist/{metadata-JCNPERR3.js → metadata-ADXGD4Y6.js} +25 -25
  229. package/dist/{metadata-ITS3VPE3.js → metadata-J447GEBP.js} +27 -27
  230. package/dist/{metadata-YOQEXEGO.js → metadata-VTQ2CGZX.js} +27 -27
  231. package/dist/{offer-create-page-6YTTQAXZ.js → offer-create-page-ACPKTNHA.js} +245 -266
  232. package/dist/offer-detail-page-S4R4N5GL.js +584 -0
  233. package/dist/offer-variant-detail-page-XUMDXZUD.js +402 -0
  234. package/dist/offers-OTZJBW43.js +54 -0
  235. package/dist/{onboarding-GCRT6P6M.js → onboarding-TUGXFOA6.js} +23 -23
  236. package/dist/orders-PJSJNGZS.js +63 -0
  237. package/dist/{organization-5AFVFFZQ.js → organization-YIOAVFHN.js} +26 -26
  238. package/dist/{organize-QXDKGP2X.js → organize-BTA7NJD2.js} +4 -4
  239. package/dist/{organize-AZYAANZM.js → organize-OWT5QSJR.js} +4 -4
  240. package/dist/pages/index.d.ts +232 -232
  241. package/dist/pages/index.js +89 -87
  242. package/dist/{payment-details-ENUWDVGI.js → payment-details-K2XFATEL.js} +24 -24
  243. package/dist/{payouts-2QBQSNDR.js → payouts-K5IDTJV3.js} +11 -11
  244. package/dist/{price-lists-2WBNENE7.js → price-lists-DNPIPDAW.js} +13 -13
  245. package/dist/{offer-pricing-edit-page-WZNP3TWV.js → pricing-5VUPPNKS.js} +21 -19
  246. package/dist/{pricing-4Y73YJHP.js → pricing-J5FIDZIY.js} +32 -32
  247. package/dist/{product-tags-DE32PERU.js → product-tags-SJYIGXEV.js} +47 -44
  248. package/dist/{product-types-PKUEL7X5.js → product-types-4PTJW5DE.js} +10 -10
  249. package/dist/product-variant-detail-FO6J3RFA.js +371 -0
  250. package/dist/{product-variant-edit-ESLPI5ES.js → product-variant-edit-55TAIBZO.js} +45 -27
  251. package/dist/{products-WLGCX6Z7.js → products-EQMANSO6.js} +41 -40
  252. package/dist/products-XM57LXJK.js +92 -0
  253. package/dist/{professional-details-OCVQO2MV.js → professional-details-WWZPTXSX.js} +24 -24
  254. package/dist/{profile-2HW5NX6K.js → profile-5IADQ727.js} +30 -30
  255. package/dist/{promotions-FPV6QOEQ.js → promotions-BYW6TZ5B.js} +12 -12
  256. package/dist/receive-MTXKKPKZ.js +578 -0
  257. package/dist/refund-3IXGYA7W.js +268 -0
  258. package/dist/{register-PZOHGO7N.js → register-U5PQZATC.js} +25 -25
  259. package/dist/{reset-password-Q7BNWHHO.js → reset-password-SKUJJLSV.js} +3 -3
  260. package/dist/{return-reasons-J2WFZOQH.js → return-reasons-QDPSIJG3.js} +22 -19
  261. package/dist/{sales-channels-I3PR34U5.js → sales-channels-GBSTCWVP.js} +12 -13
  262. package/dist/{sales-channels-HPG2ND4W.js → sales-channels-N4NE3FXP.js} +14 -15
  263. package/dist/{settings-RZNYWACF.js → settings-ZUBBFS67.js} +54 -51
  264. package/dist/shipment-TKSCPC3M.js +241 -0
  265. package/dist/shipping-DODEUYOQ.js +125 -0
  266. package/dist/{shipping-profile-M3GGADFI.js → shipping-profile-O4JMJLN7.js} +5 -9
  267. package/dist/shipping-profiles-4TJ4IH6U.js +46 -0
  268. package/dist/{stock-3HVQ6FYP.js → stock-GYK2GHJN.js} +27 -27
  269. package/dist/{store-LDVMG7CV.js → store-XWOALZ5Q.js} +36 -36
  270. package/dist/{store-closure-EZ2YPOPL.js → store-closure-46B3XZ2I.js} +24 -24
  271. package/dist/{store-select-AM4AE7AL.js → store-select-E77E3ZY7.js} +24 -24
  272. package/dist/{tax-regions-HDLBFZVG.js → tax-regions-S2LFRTMP.js} +9 -9
  273. package/dist/{team-6NTDISM4.js → team-N2C5JPSU.js} +37 -37
  274. package/package.json +12 -12
  275. package/dist/[id]-MOOCGOWO.js +0 -480
  276. package/dist/[id]-UVQXCYXD.js +0 -1219
  277. package/dist/[id]-VUX4FUOO.js +0 -1557
  278. package/dist/allocate-items-OK5PVJGR.js +0 -533
  279. package/dist/attributes-TRAUBTCO.js +0 -278
  280. package/dist/breadcrumb-6FV7PWEN.js +0 -33
  281. package/dist/breadcrumb-EX4C3AZY.js +0 -47
  282. package/dist/breadcrumb-Q3XSG7B2.js +0 -46
  283. package/dist/chunk-27KRIXMQ.js +0 -71
  284. package/dist/chunk-432S4FGR.js +0 -0
  285. package/dist/chunk-BDZOSMAX.js +0 -23
  286. package/dist/chunk-CFRWIQIZ.js +0 -43
  287. package/dist/chunk-G7BL4L3L.js +0 -66
  288. package/dist/chunk-RXV7INUV.js +0 -426
  289. package/dist/chunk-T6LHVNWO.js +0 -27
  290. package/dist/collections-DS63FT2E.js +0 -68
  291. package/dist/create-HR4I33SE.js +0 -73
  292. package/dist/create-UFHLPXET.js +0 -215
  293. package/dist/edit-GQNIINRR.js +0 -192
  294. package/dist/fulfillment-OIIPL7B7.js +0 -559
  295. package/dist/loader-VDYPD3RI.js +0 -31
  296. package/dist/login-HON44E3S.js +0 -39
  297. package/dist/metadata-5BPOBBU2.js +0 -45
  298. package/dist/offer-detail-page-OMZN2NTA.js +0 -492
  299. package/dist/offer-edit-page-3MO566RP.js +0 -151
  300. package/dist/offers-GVN5LCK6.js +0 -32
  301. package/dist/orders-CHSS4ASB.js +0 -63
  302. package/dist/product-variant-detail-MWUBPCOP.js +0 -209
  303. package/dist/products-XOHAQHUJ.js +0 -91
  304. package/dist/shipment-KWUXQZWK.js +0 -176
  305. package/dist/shipping-profiles-L27STQ7K.js +0 -46
@@ -0,0 +1,3074 @@
1
+ import {
2
+ useCancelExchangeBegin,
3
+ useExchanges
4
+ } from "./chunk-CRYZK4NU.js";
5
+ import {
6
+ useCancelClaimBegin,
7
+ useClaims
8
+ } from "./chunk-S7NGDLZ3.js";
9
+ import {
10
+ getReturnableQuantity
11
+ } from "./chunk-UM7ZR3VU.js";
12
+ import {
13
+ DEFAULT_FIELDS
14
+ } from "./chunk-IMJ62GAP.js";
15
+ import {
16
+ getReservationsLimitCount
17
+ } from "./chunk-EEBJYXWA.js";
18
+ import {
19
+ CLAIM_POLICY_DAYS,
20
+ EXCHANGE_POLICY_DAYS,
21
+ RETURN_POLICY_DAYS,
22
+ isOutsidePolicyWindow
23
+ } from "./chunk-VCUUITW6.js";
24
+ import {
25
+ useCancelReturn,
26
+ useCancelReturnRequest,
27
+ useReturns
28
+ } from "./chunk-3TST3EWQ.js";
29
+ import {
30
+ useCancelOrderEdit,
31
+ useConfirmOrderEdit
32
+ } from "./chunk-7BFQKYCJ.js";
33
+ import {
34
+ formatProvider
35
+ } from "./chunk-VW56KWO2.js";
36
+ import "./chunk-BCU3FKP2.js";
37
+ import {
38
+ getFormattedAddress,
39
+ isSameAddress
40
+ } from "./chunk-W6Y3PPU5.js";
41
+ import {
42
+ getCanceledOrderStatus,
43
+ getOrderFulfillmentStatus,
44
+ getOrderPaymentStatus
45
+ } from "./chunk-LQSLDDPT.js";
46
+ import {
47
+ getLocaleAmount,
48
+ getStylizedAmount,
49
+ isAmountLessThenRoundingError
50
+ } from "./chunk-3BXCPHN6.js";
51
+ import "./chunk-JRTZWK77.js";
52
+ import "./chunk-IQPN4PZJ.js";
53
+ import {
54
+ TwoColumnPage
55
+ } from "./chunk-YV6MK4PZ.js";
56
+ import {
57
+ useDate
58
+ } from "./chunk-LRD242C7.js";
59
+ import {
60
+ Thumbnail
61
+ } from "./chunk-WIYFXWRI.js";
62
+ import {
63
+ Skeleton,
64
+ TwoColumnPageSkeleton
65
+ } from "./chunk-INNFZYX2.js";
66
+ import {
67
+ ActionMenu
68
+ } from "./chunk-BDGZ4EQO.js";
69
+ import "./chunk-LAVHRER2.js";
70
+ import "./chunk-QHQWEERJ.js";
71
+ import "./chunk-Y7QKP6QU.js";
72
+ import "./chunk-BQHVM46E.js";
73
+ import "./chunk-QIF4QE7T.js";
74
+ import "./chunk-VE6GRIIN.js";
75
+ import "./chunk-7MARNXFG.js";
76
+ import "./chunk-MNHP6YRC.js";
77
+ import "./chunk-NTJ3BMOE.js";
78
+ import "./chunk-5PAUN3PM.js";
79
+ import "./chunk-ZLHCZ5F2.js";
80
+ import "./chunk-GZ4KTAWS.js";
81
+ import "./chunk-PUAWN7SS.js";
82
+ import {
83
+ useMember
84
+ } from "./chunk-MVEHWM7K.js";
85
+ import {
86
+ useCustomer
87
+ } from "./chunk-OYUJYPDF.js";
88
+ import "./chunk-O7BGGWW6.js";
89
+ import "./chunk-KIURBTC4.js";
90
+ import "./chunk-3SH24DGG.js";
91
+ import "./chunk-JR7AABT5.js";
92
+ import {
93
+ useStockLocation
94
+ } from "./chunk-ZQCCVCHB.js";
95
+ import "./chunk-5BQO3YQP.js";
96
+ import "./chunk-EPRYM3FA.js";
97
+ import {
98
+ ordersQueryKeys,
99
+ useCancelOrder,
100
+ useCancelOrderFulfillment,
101
+ useMarkOrderFulfillmentAsDelivered,
102
+ useOrder,
103
+ useOrderChanges,
104
+ useOrderCommissionLines,
105
+ useOrderPreview,
106
+ useReservationItems
107
+ } from "./chunk-6FDPVW7Y.js";
108
+ import "./chunk-JJP6AKMV.js";
109
+ import "./chunk-G6YNCIVF.js";
110
+ import "./chunk-A5DJIOHN.js";
111
+ import {
112
+ queryClient
113
+ } from "./chunk-RHKRREUU.js";
114
+ import "./chunk-ZA2KFUFR.js";
115
+ import {
116
+ fetchQuery
117
+ } from "./chunk-LXZXXOJ3.js";
118
+ import "./chunk-NBMM2TZK.js";
119
+
120
+ // src/pages/orders/[id]/loader.tsx
121
+ var orderDetailQuery = (id) => ({
122
+ queryKey: ordersQueryKeys.detail(id),
123
+ queryFn: async () => fetchQuery(`/vendor/orders/${id}`, {
124
+ method: "GET",
125
+ query: { fields: DEFAULT_FIELDS }
126
+ })
127
+ });
128
+ var loader = async ({ params }) => {
129
+ const id = params.id;
130
+ const query = orderDetailQuery(id);
131
+ return queryClient.ensureQueryData(query);
132
+ };
133
+
134
+ // src/pages/orders/[id]/order-detail-page.tsx
135
+ import { Children } from "react";
136
+ import { useLoaderData, useParams } from "react-router-dom";
137
+
138
+ // src/pages/orders/[id]/_components/active-order-claim-section/active-order-claim-section.tsx
139
+ import { ExclamationCircle } from "@medusajs/icons";
140
+ import { Button, Container, Heading, Text, toast } from "@medusajs/ui";
141
+ import { useNavigate } from "react-router-dom";
142
+ import { useTranslation } from "react-i18next";
143
+ import { jsx, jsxs } from "react/jsx-runtime";
144
+ var readClaimId = (change) => {
145
+ if (change && typeof change === "object" && "claim_id" in change && typeof change.claim_id === "string") {
146
+ return change.claim_id;
147
+ }
148
+ return void 0;
149
+ };
150
+ var ActiveOrderClaimSection = ({
151
+ orderPreview
152
+ }) => {
153
+ const { t } = useTranslation();
154
+ const navigate = useNavigate();
155
+ const claimId = readClaimId(orderPreview?.order_change);
156
+ const { mutateAsync: cancelClaim } = useCancelClaimBegin(
157
+ claimId ?? "",
158
+ orderPreview.id
159
+ );
160
+ if (!claimId) {
161
+ return null;
162
+ }
163
+ const onContinueClaim = async () => {
164
+ navigate(`/orders/${orderPreview.id}/claims/create`);
165
+ };
166
+ const onCancelClaim = async () => {
167
+ await cancelClaim(void 0, {
168
+ onSuccess: () => {
169
+ toast.success(t("orders.claims.toast.canceledSuccessfully"));
170
+ },
171
+ onError: (error) => {
172
+ toast.error(error.message);
173
+ }
174
+ });
175
+ };
176
+ return /* @__PURE__ */ jsx(
177
+ "div",
178
+ {
179
+ style: {
180
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
181
+ },
182
+ className: "-m-4 mb-1 border-b border-l p-4",
183
+ "data-testid": "active-order-claim-section",
184
+ 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: [
185
+ /* @__PURE__ */ jsxs("div", { children: [
186
+ /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", children: [
187
+ /* @__PURE__ */ jsx(ExclamationCircle, { className: "text-ui-fg-subtle" }),
188
+ /* @__PURE__ */ jsx(Heading, { level: "h2", children: t("orders.claims.panel.title") })
189
+ ] }),
190
+ /* @__PURE__ */ jsx("div", { className: "gap-2 px-6 pb-4", children: /* @__PURE__ */ jsx(Text, { children: t("orders.claims.panel.description") }) })
191
+ ] }),
192
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
193
+ /* @__PURE__ */ jsx(
194
+ Button,
195
+ {
196
+ size: "small",
197
+ variant: "secondary",
198
+ onClick: onCancelClaim,
199
+ "data-testid": "active-order-claim-cancel",
200
+ children: t("orders.claims.cancel.title")
201
+ }
202
+ ),
203
+ /* @__PURE__ */ jsx(
204
+ Button,
205
+ {
206
+ size: "small",
207
+ variant: "secondary",
208
+ onClick: onContinueClaim,
209
+ "data-testid": "active-order-claim-continue",
210
+ children: t("actions.continue")
211
+ }
212
+ )
213
+ ] })
214
+ ] }) })
215
+ }
216
+ );
217
+ };
218
+
219
+ // src/pages/orders/[id]/_components/active-order-exchange-section/active-order-exchange-section.tsx
220
+ import { ArrowPath } from "@medusajs/icons";
221
+ import { Button as Button2, Container as Container2, Heading as Heading2, Text as Text2, toast as toast2 } from "@medusajs/ui";
222
+ import { useNavigate as useNavigate2 } from "react-router-dom";
223
+ import { useTranslation as useTranslation2 } from "react-i18next";
224
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
225
+ var readExchangeId = (change) => {
226
+ if (change && typeof change === "object" && "exchange_id" in change && typeof change.exchange_id === "string") {
227
+ return change.exchange_id;
228
+ }
229
+ return void 0;
230
+ };
231
+ var ActiveOrderExchangeSection = ({
232
+ orderPreview
233
+ }) => {
234
+ const { t } = useTranslation2();
235
+ const navigate = useNavigate2();
236
+ const exchangeId = readExchangeId(orderPreview?.order_change);
237
+ const { mutateAsync: cancelExchange } = useCancelExchangeBegin(
238
+ exchangeId ?? "",
239
+ orderPreview.id
240
+ );
241
+ if (!exchangeId) {
242
+ return null;
243
+ }
244
+ const onContinueExchange = async () => {
245
+ navigate(`/orders/${orderPreview.id}/exchanges/create`);
246
+ };
247
+ const onCancelExchange = async () => {
248
+ await cancelExchange(void 0, {
249
+ onSuccess: () => {
250
+ toast2.success(t("orders.exchanges.toast.canceledSuccessfully"));
251
+ },
252
+ onError: (error) => {
253
+ toast2.error(error.message);
254
+ }
255
+ });
256
+ };
257
+ return /* @__PURE__ */ jsx2(
258
+ "div",
259
+ {
260
+ style: {
261
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
262
+ },
263
+ className: "-m-4 mb-1 border-b border-l p-4",
264
+ "data-testid": "active-order-exchange-section",
265
+ 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: [
266
+ /* @__PURE__ */ jsxs2("div", { children: [
267
+ /* @__PURE__ */ jsxs2("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", children: [
268
+ /* @__PURE__ */ jsx2(ArrowPath, { className: "text-ui-fg-subtle" }),
269
+ /* @__PURE__ */ jsx2(Heading2, { level: "h2", children: t("orders.exchanges.panel.title") })
270
+ ] }),
271
+ /* @__PURE__ */ jsx2("div", { className: "gap-2 px-6 pb-4", children: /* @__PURE__ */ jsx2(Text2, { children: t("orders.exchanges.panel.description") }) })
272
+ ] }),
273
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
274
+ /* @__PURE__ */ jsx2(
275
+ Button2,
276
+ {
277
+ size: "small",
278
+ variant: "secondary",
279
+ onClick: onCancelExchange,
280
+ "data-testid": "active-order-exchange-cancel",
281
+ children: t("orders.exchanges.cancel.title")
282
+ }
283
+ ),
284
+ /* @__PURE__ */ jsx2(
285
+ Button2,
286
+ {
287
+ size: "small",
288
+ variant: "secondary",
289
+ onClick: onContinueExchange,
290
+ "data-testid": "active-order-exchange-continue",
291
+ children: t("actions.continue")
292
+ }
293
+ )
294
+ ] })
295
+ ] }) })
296
+ }
297
+ );
298
+ };
299
+
300
+ // src/pages/orders/[id]/_components/active-order-return-section/active-order-return-section.tsx
301
+ import { ArrowUturnLeft } from "@medusajs/icons";
302
+ import { Button as Button3, Container as Container3, Heading as Heading3, Text as Text3, toast as toast3 } from "@medusajs/ui";
303
+ import { useNavigate as useNavigate3 } from "react-router-dom";
304
+ import { useTranslation as useTranslation3 } from "react-i18next";
305
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
306
+ var readReturnId = (change) => {
307
+ if (change && typeof change === "object" && "return_id" in change && typeof change.return_id === "string") {
308
+ return change.return_id;
309
+ }
310
+ return void 0;
311
+ };
312
+ var ActiveOrderReturnSection = ({
313
+ orderPreview
314
+ }) => {
315
+ const { t } = useTranslation3();
316
+ const navigate = useNavigate3();
317
+ const orderChange = orderPreview?.order_change;
318
+ const returnId = readReturnId(orderChange);
319
+ const isReturnRequest = orderChange?.change_type === "return_request" && !!returnId;
320
+ const { mutateAsync: cancelReturn } = useCancelReturnRequest(
321
+ returnId ?? "",
322
+ orderPreview.id
323
+ );
324
+ if (!returnId || !isReturnRequest) {
325
+ return null;
326
+ }
327
+ const onContinueReturn = async () => {
328
+ navigate(`/orders/${orderPreview.id}/returns/create`);
329
+ };
330
+ const onCancelReturn = async () => {
331
+ await cancelReturn(void 0, {
332
+ onSuccess: () => {
333
+ toast3.success(t("orders.returns.toast.canceledSuccessfully"));
334
+ },
335
+ onError: (error) => {
336
+ toast3.error(error.message);
337
+ }
338
+ });
339
+ };
340
+ return /* @__PURE__ */ jsx3(
341
+ "div",
342
+ {
343
+ style: {
344
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
345
+ },
346
+ className: "-m-4 mb-1 border-b border-l p-4",
347
+ "data-testid": "active-order-return-section",
348
+ 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: [
349
+ /* @__PURE__ */ jsxs3("div", { children: [
350
+ /* @__PURE__ */ jsxs3("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", children: [
351
+ /* @__PURE__ */ jsx3(ArrowUturnLeft, { className: "text-ui-fg-subtle" }),
352
+ /* @__PURE__ */ jsx3(Heading3, { level: "h2", children: t("orders.returns.panel.title") })
353
+ ] }),
354
+ /* @__PURE__ */ jsx3("div", { className: "gap-2 px-6 pb-4", children: /* @__PURE__ */ jsx3(Text3, { children: t("orders.returns.panel.description") }) })
355
+ ] }),
356
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
357
+ /* @__PURE__ */ jsx3(
358
+ Button3,
359
+ {
360
+ size: "small",
361
+ variant: "secondary",
362
+ onClick: onCancelReturn,
363
+ "data-testid": "active-order-return-cancel",
364
+ children: t("orders.returns.cancel.title")
365
+ }
366
+ ),
367
+ /* @__PURE__ */ jsx3(
368
+ Button3,
369
+ {
370
+ size: "small",
371
+ variant: "secondary",
372
+ onClick: onContinueReturn,
373
+ "data-testid": "active-order-return-continue",
374
+ children: t("actions.continue")
375
+ }
376
+ )
377
+ ] })
378
+ ] }) })
379
+ }
380
+ );
381
+ };
382
+
383
+ // src/pages/orders/[id]/_components/order-active-edit-section/order-active-edit-section.tsx
384
+ import { ExclamationCircleSolid } from "@medusajs/icons";
385
+ import { Button as Button4, Container as Container4, Copy, Heading as Heading4, toast as toast4 } from "@medusajs/ui";
386
+ import { useMemo } from "react";
387
+ import { useTranslation as useTranslation4 } from "react-i18next";
388
+ import { useNavigate as useNavigate4 } from "react-router-dom";
389
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
390
+ function EditItem({
391
+ item,
392
+ quantity
393
+ }) {
394
+ 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: [
395
+ /* @__PURE__ */ jsxs4("div", { className: "w-fit min-w-[27px]", children: [
396
+ /* @__PURE__ */ jsx4("span", { className: "txt-small tabular-nums", children: quantity }),
397
+ "x"
398
+ ] }),
399
+ /* @__PURE__ */ jsx4(Thumbnail, { src: item.thumbnail ?? void 0 }),
400
+ /* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle font-medium", children: item.title }),
401
+ item.variant_sku && " \xB7 ",
402
+ item.variant_sku && /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
403
+ /* @__PURE__ */ jsx4("span", { className: "txt-small", children: item.variant_sku }),
404
+ /* @__PURE__ */ jsx4(Copy, { content: item.variant_sku, className: "text-ui-fg-muted" })
405
+ ] })
406
+ ] }) });
407
+ }
408
+ var OrderActiveEditSection = ({
409
+ order
410
+ }) => {
411
+ const { t } = useTranslation4();
412
+ const navigate = useNavigate4();
413
+ const { order: orderPreview } = useOrderPreview(order.id);
414
+ const { mutateAsync: cancelOrderEdit } = useCancelOrderEdit(order.id);
415
+ const { mutateAsync: confirmOrderEdit } = useConfirmOrderEdit(order.id);
416
+ const isPending = orderPreview?.order_change?.status === "pending";
417
+ const [addedItems, removedItems] = useMemo(() => {
418
+ const added = [];
419
+ const removed = [];
420
+ const originals = order.items ?? [];
421
+ const previewItems = orderPreview?.items ?? [];
422
+ const orderLookupMap = new Map(originals.map((i) => [i.id, i]));
423
+ previewItems.forEach((currentItem) => {
424
+ const originalItem = orderLookupMap.get(currentItem.id);
425
+ if (!originalItem) {
426
+ added.push({ item: currentItem, quantity: currentItem.quantity });
427
+ return;
428
+ }
429
+ if (originalItem.quantity > currentItem.quantity) {
430
+ removed.push({
431
+ item: currentItem,
432
+ quantity: originalItem.quantity - currentItem.quantity
433
+ });
434
+ }
435
+ if (originalItem.quantity < currentItem.quantity) {
436
+ added.push({
437
+ item: currentItem,
438
+ quantity: currentItem.quantity - originalItem.quantity
439
+ });
440
+ }
441
+ });
442
+ return [added, removed];
443
+ }, [orderPreview, order.items]);
444
+ const onConfirmOrderEdit = async () => {
445
+ try {
446
+ await confirmOrderEdit();
447
+ toast4.success(t("orders.edits.toast.confirmedSuccessfully"));
448
+ } catch (e) {
449
+ toast4.error(
450
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
451
+ );
452
+ }
453
+ };
454
+ const onCancelOrderEdit = async () => {
455
+ try {
456
+ await cancelOrderEdit();
457
+ toast4.success(t("orders.edits.toast.canceledSuccessfully"));
458
+ } catch (e) {
459
+ toast4.error(
460
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
461
+ );
462
+ }
463
+ };
464
+ const change = orderPreview?.order_change;
465
+ if (!orderPreview || change?.change_type !== "edit") {
466
+ return null;
467
+ }
468
+ return /* @__PURE__ */ jsx4(
469
+ "div",
470
+ {
471
+ style: {
472
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
473
+ },
474
+ className: "-m-4 mb-1 border-b border-l p-4",
475
+ "data-testid": "order-active-edit-section",
476
+ 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: [
477
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2 px-6 py-4", children: [
478
+ /* @__PURE__ */ jsx4(ExclamationCircleSolid, { className: "text-blue-500" }),
479
+ /* @__PURE__ */ jsx4(Heading4, { level: "h2", children: t(
480
+ isPending ? "orders.edits.panel.titlePending" : "orders.edits.panel.title"
481
+ ) })
482
+ ] }),
483
+ !!addedItems.length && /* @__PURE__ */ jsxs4("div", { className: "txt-small text-ui-fg-subtle flex flex-row px-6 py-4", children: [
484
+ /* @__PURE__ */ jsx4("span", { className: "flex-1 font-medium", children: t("labels.added") }),
485
+ /* @__PURE__ */ jsx4("div", { className: "flex flex-1 flex-col gap-y-2", children: addedItems.map(({ item, quantity }) => /* @__PURE__ */ jsx4(EditItem, { item, quantity }, item.id)) })
486
+ ] }),
487
+ !!removedItems.length && /* @__PURE__ */ jsxs4("div", { className: "txt-small text-ui-fg-subtle flex flex-row px-6 py-4", children: [
488
+ /* @__PURE__ */ jsx4("span", { className: "flex-1 font-medium", children: t("labels.removed") }),
489
+ /* @__PURE__ */ jsx4("div", { className: "flex flex-1 flex-col gap-y-2", children: removedItems.map(({ item, quantity }) => /* @__PURE__ */ jsx4(EditItem, { item, quantity }, item.id)) })
490
+ ] }),
491
+ /* @__PURE__ */ jsxs4("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
492
+ isPending ? /* @__PURE__ */ jsx4(
493
+ Button4,
494
+ {
495
+ size: "small",
496
+ variant: "secondary",
497
+ onClick: () => navigate(`/orders/${order.id}/edit`),
498
+ "data-testid": "order-active-edit-continue",
499
+ children: t("actions.continueEdit")
500
+ }
501
+ ) : /* @__PURE__ */ jsx4(
502
+ Button4,
503
+ {
504
+ size: "small",
505
+ variant: "secondary",
506
+ onClick: onConfirmOrderEdit,
507
+ "data-testid": "order-active-edit-force-confirm",
508
+ children: t("actions.forceConfirm")
509
+ }
510
+ ),
511
+ /* @__PURE__ */ jsx4(
512
+ Button4,
513
+ {
514
+ size: "small",
515
+ variant: "secondary",
516
+ onClick: onCancelOrderEdit,
517
+ "data-testid": "order-active-edit-cancel",
518
+ children: t("actions.cancel")
519
+ }
520
+ )
521
+ ] })
522
+ ] }) })
523
+ }
524
+ );
525
+ };
526
+
527
+ // src/pages/orders/[id]/_components/order-activity-section/order-activity-section.tsx
528
+ import { Container as Container5, Heading as Heading5 } from "@medusajs/ui";
529
+ import { useTranslation as useTranslation15 } from "react-i18next";
530
+
531
+ // src/pages/orders/[id]/_components/order-activity-section/hooks/use-activity-items.tsx
532
+ import { useMemo as useMemo3 } from "react";
533
+ import { useTranslation as useTranslation14 } from "react-i18next";
534
+ import { Text as Text15 } from "@medusajs/ui";
535
+
536
+ // src/components/common/user-link/user-link.tsx
537
+ import { Avatar, Text as Text4 } from "@medusajs/ui";
538
+ import { Link } from "react-router-dom";
539
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
540
+ var UserLink = ({
541
+ id,
542
+ first_name,
543
+ last_name,
544
+ email,
545
+ type = "user"
546
+ }) => {
547
+ const name = [first_name, last_name].filter(Boolean).join(" ");
548
+ const fallback = name ? name.slice(0, 1) : email.slice(0, 1);
549
+ const link = type === "user" ? `/settings/users/${id}` : `/customers/${id}`;
550
+ return /* @__PURE__ */ jsxs5(
551
+ Link,
552
+ {
553
+ to: link,
554
+ className: "flex items-center gap-x-2 w-fit transition-fg hover:text-ui-fg-subtle outline-none focus-visible:shadow-borders-focus rounded-md",
555
+ children: [
556
+ /* @__PURE__ */ jsx5(Avatar, { size: "2xsmall", fallback: fallback.toUpperCase() }),
557
+ /* @__PURE__ */ jsx5(Text4, { size: "small", leading: "compact", weight: "regular", children: name || email })
558
+ ]
559
+ }
560
+ );
561
+ };
562
+ var By = ({ id }) => {
563
+ const { user } = useMember(id);
564
+ if (!user) {
565
+ return null;
566
+ }
567
+ return /* @__PURE__ */ jsx5(UserLink, { ...user });
568
+ };
569
+
570
+ // src/pages/orders/[id]/_components/order-activity-section/change-details-tooltip.tsx
571
+ import { Popover, Text as Text5 } from "@medusajs/ui";
572
+ import { useState } from "react";
573
+ import { useTranslation as useTranslation5 } from "react-i18next";
574
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
575
+ function ChangeDetailsTooltip(props) {
576
+ const { t } = useTranslation5();
577
+ const [open, setOpen] = useState(false);
578
+ const previous = props.previous;
579
+ const next = props.next;
580
+ const title = props.title;
581
+ const handleMouseEnter = () => {
582
+ setOpen(true);
583
+ };
584
+ const handleMouseLeave = () => {
585
+ setOpen(false);
586
+ };
587
+ if (!previous && !next) {
588
+ return null;
589
+ }
590
+ return /* @__PURE__ */ jsxs6(Popover, { open, children: [
591
+ /* @__PURE__ */ jsx6(
592
+ Popover.Trigger,
593
+ {
594
+ onMouseEnter: handleMouseEnter,
595
+ onMouseLeave: handleMouseLeave,
596
+ autoFocus: false,
597
+ className: "focus-visible:outline-none",
598
+ children: /* @__PURE__ */ jsx6(Text5, { size: "small", leading: "compact", weight: "plus", children: title })
599
+ }
600
+ ),
601
+ /* @__PURE__ */ jsx6(
602
+ Popover.Content,
603
+ {
604
+ align: "center",
605
+ side: "top",
606
+ className: "bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",
607
+ children: /* @__PURE__ */ jsxs6("div", { className: "flex flex-col", children: [
608
+ !!previous && /* @__PURE__ */ jsxs6("div", { className: "p-3", children: [
609
+ /* @__PURE__ */ jsx6("div", { className: "txt-compact-small-plus mb-1", children: t("labels.from") }),
610
+ /* @__PURE__ */ jsx6("p", { className: "txt-compact-small text-ui-fg-subtle", children: previous })
611
+ ] }),
612
+ !!next && /* @__PURE__ */ jsxs6("div", { className: "border-t-2 border-dotted p-3", children: [
613
+ /* @__PURE__ */ jsx6("div", { className: "txt-compact-small-plus mb-1", children: t("labels.to") }),
614
+ /* @__PURE__ */ jsx6("p", { className: "txt-compact-small text-ui-fg-subtle", children: next })
615
+ ] })
616
+ ] })
617
+ }
618
+ )
619
+ ] });
620
+ }
621
+ var change_details_tooltip_default = ChangeDetailsTooltip;
622
+
623
+ // src/pages/orders/[id]/_components/order-activity-section/components/fulfillment-created-body.tsx
624
+ import { Text as Text6 } from "@medusajs/ui";
625
+ import { useTranslation as useTranslation6 } from "react-i18next";
626
+ import { jsx as jsx7 } from "react/jsx-runtime";
627
+ var FulfillmentCreatedBody = ({
628
+ fulfillment
629
+ }) => {
630
+ const { t } = useTranslation6();
631
+ const numberOfItems = (fulfillment.items || []).reduce((acc, item) => {
632
+ return acc + (item.quantity || 0);
633
+ }, 0);
634
+ return /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.fulfillment.items", {
635
+ count: numberOfItems
636
+ }) }) });
637
+ };
638
+
639
+ // src/pages/orders/[id]/_components/order-activity-section/components/return-body.tsx
640
+ import { Button as Button5, Text as Text7, usePrompt } from "@medusajs/ui";
641
+ import { useTranslation as useTranslation7 } from "react-i18next";
642
+ import { Fragment, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
643
+ var ReturnBody = ({
644
+ orderReturn,
645
+ isCreated,
646
+ isReceived
647
+ }) => {
648
+ const prompt = usePrompt();
649
+ const { t } = useTranslation7();
650
+ const { mutateAsync: cancelReturnRequest } = useCancelReturn(
651
+ orderReturn.id,
652
+ orderReturn.order_id
653
+ );
654
+ const onCancel = async () => {
655
+ const res = await prompt({
656
+ title: t("orders.returns.cancel.title"),
657
+ description: t("orders.returns.cancel.description"),
658
+ confirmText: t("actions.confirm"),
659
+ cancelText: t("actions.cancel")
660
+ });
661
+ if (!res) {
662
+ return;
663
+ }
664
+ await cancelReturnRequest();
665
+ };
666
+ const numberOfItems = (orderReturn.items ?? []).reduce((acc, item) => {
667
+ return acc + (isReceived ? item.received_quantity : item.quantity);
668
+ }, 0);
669
+ return /* @__PURE__ */ jsxs7("div", { className: "flex items-start gap-1", children: [
670
+ /* @__PURE__ */ jsx8(Text7, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.return.items", {
671
+ count: numberOfItems
672
+ }) }),
673
+ isCreated && /* @__PURE__ */ jsxs7(Fragment, { children: [
674
+ /* @__PURE__ */ jsx8("div", { className: "mt-[2px] flex items-center leading-none", children: "\u22C5" }),
675
+ /* @__PURE__ */ jsx8(
676
+ Button5,
677
+ {
678
+ onClick: onCancel,
679
+ className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
680
+ variant: "transparent",
681
+ size: "small",
682
+ children: t("actions.cancel")
683
+ }
684
+ )
685
+ ] })
686
+ ] });
687
+ };
688
+
689
+ // src/pages/orders/[id]/_components/order-activity-section/components/claim-body.tsx
690
+ import { Text as Text8 } from "@medusajs/ui";
691
+ import { useTranslation as useTranslation8 } from "react-i18next";
692
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
693
+ var ClaimBody = ({
694
+ claim,
695
+ claimReturn
696
+ }) => {
697
+ const { t } = useTranslation8();
698
+ const outboundItems = (claim.additional_items || []).reduce(
699
+ (acc, item) => acc + item.quantity,
700
+ 0
701
+ );
702
+ const inboundItems = (claimReturn?.items || []).reduce(
703
+ (acc, item) => acc + item.quantity,
704
+ 0
705
+ );
706
+ return /* @__PURE__ */ jsxs8("div", { children: [
707
+ outboundItems > 0 && /* @__PURE__ */ jsx9(Text8, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.claim.itemsInbound", {
708
+ count: outboundItems
709
+ }) }),
710
+ inboundItems > 0 && /* @__PURE__ */ jsx9(Text8, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.claim.itemsOutbound", {
711
+ count: inboundItems
712
+ }) })
713
+ ] });
714
+ };
715
+
716
+ // src/pages/orders/[id]/_components/order-activity-section/components/exchange-body.tsx
717
+ import { Text as Text9 } from "@medusajs/ui";
718
+ import { useTranslation as useTranslation9 } from "react-i18next";
719
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
720
+ var ExchangeBody = ({
721
+ exchange,
722
+ exchangeReturn
723
+ }) => {
724
+ const { t } = useTranslation9();
725
+ const outboundItems = (exchange.additional_items || []).reduce(
726
+ (acc, item) => acc + item.quantity,
727
+ 0
728
+ );
729
+ const inboundItems = (exchangeReturn?.items || []).reduce(
730
+ (acc, item) => acc + item.quantity,
731
+ 0
732
+ );
733
+ return /* @__PURE__ */ jsxs9("div", { children: [
734
+ outboundItems > 0 && /* @__PURE__ */ jsx10(Text9, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.exchange.itemsInbound", {
735
+ count: outboundItems
736
+ }) }),
737
+ inboundItems > 0 && /* @__PURE__ */ jsx10(Text9, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.exchange.itemsOutbound", {
738
+ count: inboundItems
739
+ }) })
740
+ ] });
741
+ };
742
+
743
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-edit-body.tsx
744
+ import { Text as Text10 } from "@medusajs/ui";
745
+ import { useTranslation as useTranslation10 } from "react-i18next";
746
+ import { useMemo as useMemo2 } from "react";
747
+
748
+ // src/pages/orders/[id]/_components/order-activity-section/utils/count-items-change.ts
749
+ function countItemsChange(actions) {
750
+ let added = 0;
751
+ let removed = 0;
752
+ actions.forEach((action) => {
753
+ if (action.action === "ITEM_ADD") {
754
+ added += action.details.quantity;
755
+ }
756
+ if (action.action === "ITEM_UPDATE") {
757
+ const quantityDiff = action.details.quantity_diff;
758
+ if (quantityDiff > 0) {
759
+ added += quantityDiff;
760
+ } else {
761
+ removed += Math.abs(quantityDiff);
762
+ }
763
+ }
764
+ });
765
+ return [added, removed];
766
+ }
767
+
768
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-edit-body.tsx
769
+ import { jsxs as jsxs10 } from "react/jsx-runtime";
770
+ var OrderEditBody = ({ edit }) => {
771
+ const { t } = useTranslation10();
772
+ const [itemsAdded, itemsRemoved] = useMemo2(
773
+ () => countItemsChange(edit.actions),
774
+ [edit]
775
+ );
776
+ return /* @__PURE__ */ jsxs10("div", { children: [
777
+ itemsAdded > 0 && /* @__PURE__ */ jsxs10(Text10, { size: "small", className: "text-ui-fg-subtle", children: [
778
+ t("labels.added"),
779
+ ": ",
780
+ itemsAdded
781
+ ] }),
782
+ itemsRemoved > 0 && /* @__PURE__ */ jsxs10(Text10, { size: "small", className: "text-ui-fg-subtle", children: [
783
+ t("labels.removed"),
784
+ ": ",
785
+ itemsRemoved
786
+ ] })
787
+ ] });
788
+ };
789
+
790
+ // src/pages/orders/[id]/_components/order-activity-section/components/transfer-order-request-body.tsx
791
+ import { Text as Text11 } from "@medusajs/ui";
792
+ import { useTranslation as useTranslation11 } from "react-i18next";
793
+ import { jsxs as jsxs11 } from "react/jsx-runtime";
794
+ var TransferOrderRequestBody = ({
795
+ transfer
796
+ }) => {
797
+ const { t } = useTranslation11();
798
+ const action = transfer.actions[0];
799
+ const { customer } = useCustomer(action.reference_id);
800
+ return /* @__PURE__ */ jsxs11("div", { children: [
801
+ /* @__PURE__ */ jsxs11(Text11, { size: "small", className: "text-ui-fg-subtle", children: [
802
+ t("orders.activity.from"),
803
+ ": ",
804
+ String(action.details?.original_email || "")
805
+ ] }),
806
+ /* @__PURE__ */ jsxs11(Text11, { size: "small", className: "text-ui-fg-subtle", children: [
807
+ t("orders.activity.to"),
808
+ ":",
809
+ " ",
810
+ customer?.first_name ? `${customer?.first_name} ${customer?.last_name}` : customer?.email
811
+ ] })
812
+ ] });
813
+ };
814
+
815
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-activity-item.tsx
816
+ import { Text as Text13, Tooltip, clx } from "@medusajs/ui";
817
+
818
+ // src/pages/orders/[id]/_components/order-activity-section/activity-items.tsx
819
+ import { Popover as Popover2, Text as Text12 } from "@medusajs/ui";
820
+ import { useState as useState2 } from "react";
821
+ import { useTranslation as useTranslation12 } from "react-i18next";
822
+ import { jsx as jsx11, jsxs as jsxs12 } from "react/jsx-runtime";
823
+ function ActivityItems(props) {
824
+ const { t } = useTranslation12();
825
+ const [open, setOpen] = useState2(false);
826
+ const itemsToSend = props.itemsToSend;
827
+ const itemsToReturn = props.itemsToReturn;
828
+ const itemsMap = props.itemsMap;
829
+ const title = props.title;
830
+ const handleMouseEnter = () => {
831
+ setOpen(true);
832
+ };
833
+ const handleMouseLeave = () => {
834
+ setOpen(false);
835
+ };
836
+ if (!itemsToSend?.length && !itemsToReturn?.length) {
837
+ return;
838
+ }
839
+ return /* @__PURE__ */ jsxs12(Popover2, { open, children: [
840
+ /* @__PURE__ */ jsx11(
841
+ Popover2.Trigger,
842
+ {
843
+ onMouseEnter: handleMouseEnter,
844
+ onMouseLeave: handleMouseLeave,
845
+ autoFocus: false,
846
+ className: "focus-visible:outline-none",
847
+ children: /* @__PURE__ */ jsx11(Text12, { size: "small", leading: "compact", weight: "plus", children: title })
848
+ }
849
+ ),
850
+ /* @__PURE__ */ jsx11(
851
+ Popover2.Content,
852
+ {
853
+ align: "center",
854
+ side: "top",
855
+ className: "bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",
856
+ children: /* @__PURE__ */ jsxs12("div", { className: "flex flex-col", children: [
857
+ !!itemsToSend?.length && /* @__PURE__ */ jsxs12("div", { className: "p-3", children: [
858
+ /* @__PURE__ */ jsx11("div", { className: "txt-compact-small-plus mb-1", children: t("orders.activity.events.common.toSend") }),
859
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-col", children: [
860
+ itemsToSend?.map((item) => {
861
+ const originalItem = itemsMap?.get(item.item_id);
862
+ return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-3", children: [
863
+ /* @__PURE__ */ jsxs12(Text12, { size: "small", className: "text-ui-fg-subtle", children: [
864
+ item.quantity,
865
+ "x"
866
+ ] }),
867
+ /* @__PURE__ */ jsx11(Thumbnail, { src: originalItem?.thumbnail }),
868
+ /* @__PURE__ */ jsx11(Text12, { className: "txt-compact-small text-ui-fg-subtle truncate", children: `${originalItem?.variant_title} \xB7 ${originalItem?.product_title}` })
869
+ ] }, item.id);
870
+ }),
871
+ /* @__PURE__ */ jsx11("div", { className: "flex flex-1 flex-row items-center gap-2" })
872
+ ] })
873
+ ] }),
874
+ !!itemsToReturn?.length && /* @__PURE__ */ jsxs12("div", { className: "border-t-2 border-dotted p-3", children: [
875
+ /* @__PURE__ */ jsx11("div", { className: "txt-compact-small-plus mb-1", children: t("orders.activity.events.common.toReturn") }),
876
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-col", children: [
877
+ itemsToReturn?.map((item) => {
878
+ const originalItem = itemsMap?.get(item.item_id);
879
+ return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-3", children: [
880
+ /* @__PURE__ */ jsxs12(Text12, { size: "small", className: "text-ui-fg-subtle", children: [
881
+ item.quantity,
882
+ "x"
883
+ ] }),
884
+ /* @__PURE__ */ jsx11(Thumbnail, { src: originalItem?.thumbnail }),
885
+ /* @__PURE__ */ jsx11(Text12, { className: "txt-compact-small text-ui-fg-subtle truncate", children: `${originalItem?.variant_title} \xB7 ${originalItem?.product_title}` })
886
+ ] }, item.id);
887
+ }),
888
+ /* @__PURE__ */ jsx11("div", { className: "flex flex-1 flex-row items-center gap-2" })
889
+ ] })
890
+ ] })
891
+ ] })
892
+ }
893
+ )
894
+ ] });
895
+ }
896
+ var activity_items_default = ActivityItems;
897
+
898
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-activity-item.tsx
899
+ import { jsx as jsx12, jsxs as jsxs13 } from "react/jsx-runtime";
900
+ var OrderActivityItem = ({
901
+ title,
902
+ timestamp,
903
+ isFirst = false,
904
+ children,
905
+ itemsToSend,
906
+ itemsToReturn,
907
+ itemsMap
908
+ }) => {
909
+ const { getFullDate, getRelativeDate } = useDate();
910
+ return /* @__PURE__ */ jsxs13("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
911
+ /* @__PURE__ */ jsxs13("div", { className: "flex size-full flex-col items-center gap-y-0.5", children: [
912
+ /* @__PURE__ */ jsx12("div", { className: "flex size-5 items-center justify-center", children: /* @__PURE__ */ jsx12("div", { className: "bg-ui-bg-base shadow-borders-base flex size-2.5 items-center justify-center rounded-full", children: /* @__PURE__ */ jsx12("div", { className: "bg-ui-tag-neutral-icon size-1.5 rounded-full" }) }) }),
913
+ !isFirst && /* @__PURE__ */ jsx12("div", { className: "bg-ui-border-base w-px flex-1" })
914
+ ] }),
915
+ /* @__PURE__ */ jsxs13(
916
+ "div",
917
+ {
918
+ className: clx({
919
+ "pb-4": !isFirst
920
+ }),
921
+ children: [
922
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between", children: [
923
+ itemsToSend?.length || itemsToReturn?.length ? /* @__PURE__ */ jsx12(
924
+ activity_items_default,
925
+ {
926
+ title,
927
+ itemsToSend,
928
+ itemsToReturn,
929
+ itemsMap
930
+ }
931
+ ) : /* @__PURE__ */ jsx12(Text13, { size: "small", leading: "compact", weight: "plus", children: title }),
932
+ timestamp && /* @__PURE__ */ jsx12(
933
+ Tooltip,
934
+ {
935
+ content: getFullDate({
936
+ date: timestamp,
937
+ includeTime: true
938
+ }),
939
+ children: /* @__PURE__ */ jsx12(
940
+ Text13,
941
+ {
942
+ size: "small",
943
+ leading: "compact",
944
+ className: "text-ui-fg-subtle text-right",
945
+ children: getRelativeDate(timestamp)
946
+ }
947
+ )
948
+ }
949
+ )
950
+ ] }),
951
+ /* @__PURE__ */ jsx12("div", { children })
952
+ ]
953
+ }
954
+ )
955
+ ] });
956
+ };
957
+
958
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-activity-collapsible.tsx
959
+ import { Text as Text14 } from "@medusajs/ui";
960
+ import { Collapsible as RadixCollapsible } from "radix-ui";
961
+ import { useState as useState3 } from "react";
962
+ import { useTranslation as useTranslation13 } from "react-i18next";
963
+ import { jsx as jsx13, jsxs as jsxs14 } from "react/jsx-runtime";
964
+ var OrderActivityCollapsible = ({
965
+ activities
966
+ }) => {
967
+ const [open, setOpen] = useState3(false);
968
+ const { t } = useTranslation13();
969
+ if (!activities.length) {
970
+ return null;
971
+ }
972
+ return /* @__PURE__ */ jsxs14(RadixCollapsible.Root, { open, onOpenChange: setOpen, children: [
973
+ !open && /* @__PURE__ */ jsxs14("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
974
+ /* @__PURE__ */ jsx13("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsx13("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" }) }),
975
+ /* @__PURE__ */ jsx13("div", { className: "pb-4", children: /* @__PURE__ */ jsx13(RadixCollapsible.Trigger, { className: "text-left", children: /* @__PURE__ */ jsx13(
976
+ Text14,
977
+ {
978
+ size: "small",
979
+ leading: "compact",
980
+ weight: "plus",
981
+ className: "text-ui-fg-muted",
982
+ children: t("orders.activity.showMoreActivities", {
983
+ count: activities.length
984
+ })
985
+ }
986
+ ) }) })
987
+ ] }),
988
+ /* @__PURE__ */ jsx13(RadixCollapsible.Content, { children: /* @__PURE__ */ jsx13("div", { className: "flex flex-col gap-y-0.5", children: activities.map((item, index) => {
989
+ return /* @__PURE__ */ jsx13(
990
+ OrderActivityItem,
991
+ {
992
+ title: item.title,
993
+ timestamp: item.timestamp,
994
+ itemsToSend: item.itemsToSend,
995
+ itemsToReturn: item.itemsToReturn,
996
+ itemsMap: item.itemsMap,
997
+ children: item.children
998
+ },
999
+ index
1000
+ );
1001
+ }) }) })
1002
+ ] });
1003
+ };
1004
+
1005
+ // src/pages/orders/[id]/_components/order-activity-section/hooks/use-activity-items.tsx
1006
+ import { jsx as jsx14, jsxs as jsxs15 } from "react/jsx-runtime";
1007
+ var useActivityItems = (order) => {
1008
+ const { t } = useTranslation14();
1009
+ const { order_changes: orderChanges = [] } = useOrderChanges(order.id);
1010
+ const itemsMap = useMemo3(() => {
1011
+ return new Map(
1012
+ order?.items?.map((i) => [i.id, i])
1013
+ );
1014
+ }, [order.items]);
1015
+ const { returns: returnsList = [] } = useReturns({
1016
+ order_id: order.id,
1017
+ fields: "+received_at,*items"
1018
+ });
1019
+ const { claims: claimsList = [] } = useClaims({
1020
+ order_id: order.id,
1021
+ fields: "*additional_items"
1022
+ });
1023
+ const { exchanges: exchangesList = [] } = useExchanges({
1024
+ order_id: order.id,
1025
+ fields: "*additional_items"
1026
+ });
1027
+ const returns = returnsList;
1028
+ const claims = claimsList;
1029
+ const exchanges = exchangesList;
1030
+ const isLoading = false;
1031
+ const payments = useMemo3(
1032
+ () => (order.payment_collections ?? []).flatMap(
1033
+ (pc) => pc.payments ?? []
1034
+ ),
1035
+ [order.payment_collections]
1036
+ );
1037
+ return useMemo3(() => {
1038
+ if (isLoading) {
1039
+ return [];
1040
+ }
1041
+ const items = [];
1042
+ for (const payment of payments) {
1043
+ const amount = payment.amount ?? payment.authorized_amount ?? 0;
1044
+ if (!payment.captured_at && !payment.canceled_at && payment.created_at) {
1045
+ items.push({
1046
+ title: t("orders.activity.events.payment.awaiting"),
1047
+ timestamp: payment.created_at,
1048
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
1049
+ });
1050
+ }
1051
+ if (payment.captured_at) {
1052
+ items.push({
1053
+ title: t("orders.activity.events.payment.captured"),
1054
+ timestamp: payment.captured_at,
1055
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
1056
+ });
1057
+ }
1058
+ if (payment.canceled_at) {
1059
+ items.push({
1060
+ title: t("orders.activity.events.payment.canceled"),
1061
+ timestamp: payment.canceled_at,
1062
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
1063
+ });
1064
+ }
1065
+ for (const refund of payment.refunds ?? []) {
1066
+ items.push({
1067
+ title: t("orders.activity.events.payment.refunded"),
1068
+ timestamp: refund.created_at,
1069
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(
1070
+ refund.amount,
1071
+ payment.currency_code
1072
+ ) })
1073
+ });
1074
+ }
1075
+ }
1076
+ for (const fulfillment of order.fulfillments || []) {
1077
+ items.push({
1078
+ title: t("orders.activity.events.fulfillment.created"),
1079
+ timestamp: fulfillment.created_at,
1080
+ children: /* @__PURE__ */ jsx14(FulfillmentCreatedBody, { fulfillment })
1081
+ });
1082
+ if (fulfillment.delivered_at) {
1083
+ items.push({
1084
+ title: t("orders.activity.events.fulfillment.delivered"),
1085
+ timestamp: fulfillment.delivered_at,
1086
+ children: /* @__PURE__ */ jsx14(FulfillmentCreatedBody, { fulfillment })
1087
+ });
1088
+ }
1089
+ if (fulfillment.shipped_at) {
1090
+ items.push({
1091
+ title: t("orders.activity.events.fulfillment.shipped"),
1092
+ timestamp: fulfillment.shipped_at,
1093
+ children: /* @__PURE__ */ jsx14(FulfillmentCreatedBody, { fulfillment, isShipment: true })
1094
+ });
1095
+ }
1096
+ if (fulfillment.canceled_at) {
1097
+ items.push({
1098
+ title: t("orders.activity.events.fulfillment.canceled"),
1099
+ timestamp: fulfillment.canceled_at
1100
+ });
1101
+ }
1102
+ }
1103
+ const returnMap = /* @__PURE__ */ new Map();
1104
+ for (const ret of returns) {
1105
+ returnMap.set(ret.id, ret);
1106
+ if (ret.claim_id || ret.exchange_id) {
1107
+ continue;
1108
+ }
1109
+ items.push({
1110
+ title: t("orders.activity.events.return.created", {
1111
+ returnId: ret.id.slice(-7)
1112
+ }),
1113
+ timestamp: ret.created_at,
1114
+ itemsToReturn: ret?.items,
1115
+ itemsMap,
1116
+ children: /* @__PURE__ */ jsx14(ReturnBody, { orderReturn: ret, isCreated: !ret.canceled_at })
1117
+ });
1118
+ if (ret.canceled_at) {
1119
+ items.push({
1120
+ title: t("orders.activity.events.return.canceled", {
1121
+ returnId: ret.id.slice(-7)
1122
+ }),
1123
+ timestamp: ret.canceled_at
1124
+ });
1125
+ }
1126
+ if (ret.status === "received" || ret.status === "partially_received") {
1127
+ items.push({
1128
+ title: t("orders.activity.events.return.received", {
1129
+ returnId: ret.id.slice(-7)
1130
+ }),
1131
+ timestamp: ret.received_at,
1132
+ itemsToReturn: ret?.items,
1133
+ itemsMap,
1134
+ children: /* @__PURE__ */ jsx14(ReturnBody, { orderReturn: ret, isCreated: false, isReceived: true })
1135
+ });
1136
+ }
1137
+ }
1138
+ for (const claim of claims) {
1139
+ const claimReturn = returnMap.get(claim.return_id);
1140
+ items.push({
1141
+ title: t(
1142
+ claim.canceled_at ? "orders.activity.events.claim.canceled" : "orders.activity.events.claim.created",
1143
+ {
1144
+ claimId: claim.id.slice(-7)
1145
+ }
1146
+ ),
1147
+ timestamp: claim.canceled_at || claim.created_at,
1148
+ itemsToSend: claim.additional_items,
1149
+ itemsToReturn: claimReturn?.items,
1150
+ itemsMap,
1151
+ children: /* @__PURE__ */ jsx14(ClaimBody, { claim, claimReturn })
1152
+ });
1153
+ }
1154
+ for (const exchange of exchanges) {
1155
+ const exchangeReturn = returnMap.get(exchange.return_id);
1156
+ items.push({
1157
+ title: t(
1158
+ exchange.canceled_at ? "orders.activity.events.exchange.canceled" : "orders.activity.events.exchange.created",
1159
+ {
1160
+ exchangeId: exchange.id.slice(-7)
1161
+ }
1162
+ ),
1163
+ timestamp: exchange.canceled_at || exchange.created_at,
1164
+ itemsToSend: exchange.additional_items,
1165
+ itemsToReturn: exchangeReturn?.items,
1166
+ itemsMap,
1167
+ children: /* @__PURE__ */ jsx14(ExchangeBody, { exchange, exchangeReturn })
1168
+ });
1169
+ }
1170
+ for (const edit of orderChanges.filter((oc) => oc.change_type === "edit")) {
1171
+ const isConfirmed = edit.status === "confirmed";
1172
+ const isPending = edit.status === "pending";
1173
+ if (isPending) {
1174
+ continue;
1175
+ }
1176
+ const translationKey = `orders.activity.events.edit.${edit.status}`;
1177
+ items.push({
1178
+ title: t(translationKey, {
1179
+ editId: edit.id.slice(-7)
1180
+ }),
1181
+ 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,
1182
+ children: isConfirmed ? /* @__PURE__ */ jsx14(OrderEditBody, { edit }) : null
1183
+ });
1184
+ }
1185
+ for (const transfer of orderChanges.filter(
1186
+ (oc) => oc.change_type === "transfer"
1187
+ )) {
1188
+ if (transfer.requested_at) {
1189
+ items.push({
1190
+ title: t(`orders.activity.events.transfer.requested`, {
1191
+ transferId: transfer.id.slice(-7)
1192
+ }),
1193
+ timestamp: transfer.requested_at,
1194
+ children: /* @__PURE__ */ jsx14(TransferOrderRequestBody, { transfer })
1195
+ });
1196
+ }
1197
+ if (transfer.confirmed_at) {
1198
+ items.push({
1199
+ title: t(`orders.activity.events.transfer.confirmed`, {
1200
+ transferId: transfer.id.slice(-7)
1201
+ }),
1202
+ timestamp: transfer.confirmed_at
1203
+ });
1204
+ }
1205
+ if (transfer.declined_at) {
1206
+ items.push({
1207
+ title: t(`orders.activity.events.transfer.declined`, {
1208
+ transferId: transfer.id.slice(-7)
1209
+ }),
1210
+ timestamp: transfer.declined_at
1211
+ });
1212
+ }
1213
+ }
1214
+ for (const update of orderChanges.filter(
1215
+ (oc) => oc.change_type === "edit"
1216
+ )) {
1217
+ const updateType = update.actions[0]?.details?.type;
1218
+ if (updateType === "shipping_address") {
1219
+ const oldAddress = update?.actions[0]?.details?.old;
1220
+ const newAddress = update?.actions[0]?.details?.new;
1221
+ items.push({
1222
+ title: /* @__PURE__ */ jsx14(
1223
+ change_details_tooltip_default,
1224
+ {
1225
+ title: t(`orders.activity.events.update_order.shipping_address`),
1226
+ previous: getFormattedAddress({
1227
+ address: oldAddress
1228
+ }).join(", "),
1229
+ next: getFormattedAddress({
1230
+ address: newAddress
1231
+ }).join(", ")
1232
+ }
1233
+ ),
1234
+ timestamp: update.created_at,
1235
+ children: update.created_by ? /* @__PURE__ */ jsxs15("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
1236
+ t("fields.by"),
1237
+ " ",
1238
+ /* @__PURE__ */ jsx14(By, { id: update.created_by })
1239
+ ] }) : null
1240
+ });
1241
+ }
1242
+ if (updateType === "billing_address") {
1243
+ const oldAddress = update?.actions[0]?.details?.old;
1244
+ const newAddress = update?.actions[0]?.details?.new;
1245
+ items.push({
1246
+ title: /* @__PURE__ */ jsx14(
1247
+ change_details_tooltip_default,
1248
+ {
1249
+ title: t(`orders.activity.events.update_order.billing_address`),
1250
+ previous: getFormattedAddress({
1251
+ address: oldAddress
1252
+ }).join(", "),
1253
+ next: getFormattedAddress({
1254
+ address: newAddress
1255
+ }).join(", ")
1256
+ }
1257
+ ),
1258
+ timestamp: update.created_at,
1259
+ children: update.created_by ? /* @__PURE__ */ jsxs15("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
1260
+ t("fields.by"),
1261
+ " ",
1262
+ /* @__PURE__ */ jsx14(By, { id: update.created_by })
1263
+ ] }) : null
1264
+ });
1265
+ }
1266
+ if (updateType === "email") {
1267
+ const oldEmail = update.actions[0]?.details?.old;
1268
+ const newEmail = update.actions[0]?.details?.new;
1269
+ items.push({
1270
+ title: /* @__PURE__ */ jsx14(
1271
+ change_details_tooltip_default,
1272
+ {
1273
+ title: t(`orders.activity.events.update_order.email`),
1274
+ previous: oldEmail,
1275
+ next: newEmail
1276
+ }
1277
+ ),
1278
+ timestamp: update.created_at,
1279
+ children: update.created_by ? /* @__PURE__ */ jsxs15("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
1280
+ t("fields.by"),
1281
+ " ",
1282
+ /* @__PURE__ */ jsx14(By, { id: update.created_by })
1283
+ ] }) : null
1284
+ });
1285
+ }
1286
+ }
1287
+ if (order.canceled_at) {
1288
+ items.push({
1289
+ title: t("orders.activity.events.canceled.title"),
1290
+ timestamp: order.canceled_at
1291
+ });
1292
+ }
1293
+ const sortedActivities = items.sort((a, b) => {
1294
+ return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
1295
+ });
1296
+ const createdAt = {
1297
+ title: t("orders.activity.events.placed.title"),
1298
+ timestamp: order.created_at,
1299
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(order.total, order.currency_code) })
1300
+ };
1301
+ return [...sortedActivities, createdAt];
1302
+ }, [
1303
+ order,
1304
+ exchanges,
1305
+ orderChanges,
1306
+ payments,
1307
+ isLoading,
1308
+ itemsMap
1309
+ ]);
1310
+ };
1311
+
1312
+ // src/pages/orders/[id]/_components/order-activity-section/order-timeline.tsx
1313
+ import { jsx as jsx15, jsxs as jsxs16 } from "react/jsx-runtime";
1314
+ var OrderTimeline = ({ order }) => {
1315
+ const items = useActivityItems(order);
1316
+ if (items.length <= 3) {
1317
+ return /* @__PURE__ */ jsx15("div", { className: "flex flex-col gap-y-0.5", children: items.map((item, index) => {
1318
+ return /* @__PURE__ */ jsx15(
1319
+ OrderActivityItem,
1320
+ {
1321
+ title: item.title,
1322
+ timestamp: item.timestamp,
1323
+ isFirst: index === items.length - 1,
1324
+ itemsToSend: item.itemsToSend,
1325
+ itemsToReturn: item.itemsToReturn,
1326
+ itemsMap: item.itemsMap,
1327
+ children: item.children
1328
+ },
1329
+ index
1330
+ );
1331
+ }) });
1332
+ }
1333
+ const lastItems = items.slice(0, 2);
1334
+ const collapsibleItems = items.slice(2, items.length - 1);
1335
+ const firstItem = items[items.length - 1];
1336
+ return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-y-0.5", children: [
1337
+ lastItems.map((item, index) => {
1338
+ return /* @__PURE__ */ jsx15(
1339
+ OrderActivityItem,
1340
+ {
1341
+ title: item.title,
1342
+ timestamp: item.timestamp,
1343
+ itemsToSend: item.itemsToSend,
1344
+ itemsToReturn: item.itemsToReturn,
1345
+ itemsMap: item.itemsMap,
1346
+ children: item.children
1347
+ },
1348
+ index
1349
+ );
1350
+ }),
1351
+ /* @__PURE__ */ jsx15(OrderActivityCollapsible, { activities: collapsibleItems }),
1352
+ /* @__PURE__ */ jsx15(
1353
+ OrderActivityItem,
1354
+ {
1355
+ title: firstItem.title,
1356
+ timestamp: firstItem.timestamp,
1357
+ isFirst: true,
1358
+ itemsToSend: firstItem.itemsToSend,
1359
+ itemsToReturn: firstItem.itemsToReturn,
1360
+ itemsMap: firstItem.itemsMap,
1361
+ children: firstItem.children
1362
+ }
1363
+ )
1364
+ ] });
1365
+ };
1366
+
1367
+ // src/pages/orders/[id]/_components/order-activity-section/order-activity-section.tsx
1368
+ import { jsx as jsx16, jsxs as jsxs17 } from "react/jsx-runtime";
1369
+ var OrderActivitySection = ({ order }) => {
1370
+ const { t } = useTranslation15();
1371
+ return /* @__PURE__ */ jsxs17(Container5, { className: "flex flex-col gap-y-8 px-6 py-4", children: [
1372
+ /* @__PURE__ */ jsx16("div", { className: "flex flex-col gap-y-4", children: /* @__PURE__ */ jsx16("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsx16(Heading5, { level: "h2", children: t("orders.activity.header") }) }) }),
1373
+ /* @__PURE__ */ jsx16(OrderTimeline, { order })
1374
+ ] });
1375
+ };
1376
+
1377
+ // src/pages/orders/[id]/_components/order-commission-section/order-commission-section.tsx
1378
+ import { Container as Container6, Heading as Heading6, Text as Text16 } from "@medusajs/ui";
1379
+ import { useMemo as useMemo4 } from "react";
1380
+ import { useTranslation as useTranslation16 } from "react-i18next";
1381
+ import { jsx as jsx17, jsxs as jsxs18 } from "react/jsx-runtime";
1382
+ var OrderCommissionSection = ({
1383
+ order
1384
+ }) => {
1385
+ const { t } = useTranslation16();
1386
+ const { commission_lines, isLoading } = useOrderCommissionLines(order.id);
1387
+ const itemTitleById = useMemo4(() => {
1388
+ const map = /* @__PURE__ */ new Map();
1389
+ order.items?.forEach((item) => {
1390
+ map.set(item.id, item.product_title ?? item.title);
1391
+ });
1392
+ return map;
1393
+ }, [order.items]);
1394
+ if (isLoading || !commission_lines.length) {
1395
+ return null;
1396
+ }
1397
+ const total = commission_lines.reduce(
1398
+ (acc, line) => acc + (line.amount ?? 0),
1399
+ 0
1400
+ );
1401
+ return /* @__PURE__ */ jsxs18(Container6, { className: "divide-y p-0", "data-testid": "order-commission-section", children: [
1402
+ /* @__PURE__ */ jsx17("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsx17(Heading6, { level: "h2", children: t("fields.commission", "Commission") }) }),
1403
+ /* @__PURE__ */ jsx17("div", { className: "divide-y", children: commission_lines.map((line) => {
1404
+ const label = line.shipping_method_id ? t("fields.shipping") : itemTitleById.get(line.item_id ?? "") ?? line.code;
1405
+ return /* @__PURE__ */ jsxs18(
1406
+ "div",
1407
+ {
1408
+ className: "text-ui-fg-subtle grid grid-cols-2 items-center gap-4 px-6 py-4",
1409
+ children: [
1410
+ /* @__PURE__ */ jsx17(Text16, { size: "small", leading: "compact", children: label }),
1411
+ /* @__PURE__ */ jsx17(Text16, { size: "small", leading: "compact", className: "text-right", children: getLocaleAmount(line.amount, order.currency_code) })
1412
+ ]
1413
+ },
1414
+ line.id
1415
+ );
1416
+ }) }),
1417
+ /* @__PURE__ */ jsxs18("div", { className: "flex items-center justify-between px-6 py-4", children: [
1418
+ /* @__PURE__ */ jsx17(Text16, { size: "small", weight: "plus", leading: "compact", children: t("orders.commission.total", "Total") }),
1419
+ /* @__PURE__ */ jsx17(Text16, { size: "small", weight: "plus", leading: "compact", children: getLocaleAmount(total, order.currency_code) })
1420
+ ] })
1421
+ ] });
1422
+ };
1423
+
1424
+ // src/pages/orders/[id]/_components/order-customer-section/order-customer-section.tsx
1425
+ import { Container as Container7, Heading as Heading7 } from "@medusajs/ui";
1426
+ import { useTranslation as useTranslation18 } from "react-i18next";
1427
+
1428
+ // src/components/common/customer-info/customer-info.tsx
1429
+ import { Avatar as Avatar2, Copy as Copy2, Text as Text17 } from "@medusajs/ui";
1430
+ import { useTranslation as useTranslation17 } from "react-i18next";
1431
+ import { Link as Link2 } from "react-router-dom";
1432
+ import { jsx as jsx18, jsxs as jsxs19 } from "react/jsx-runtime";
1433
+ var ID = ({ data }) => {
1434
+ const { t } = useTranslation17();
1435
+ const id = data.customer_id;
1436
+ const name = getOrderCustomer(data);
1437
+ const email = data.email;
1438
+ const fallback = (name || email || "").charAt(0).toUpperCase();
1439
+ return /* @__PURE__ */ jsxs19("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1440
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", weight: "plus", children: t("fields.id") }),
1441
+ /* @__PURE__ */ jsx18(
1442
+ Link2,
1443
+ {
1444
+ to: `/customers/${id}`,
1445
+ className: "focus:shadow-borders-focus rounded-[4px] outline-none transition-shadow",
1446
+ children: /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-x-2 overflow-hidden", children: [
1447
+ /* @__PURE__ */ jsx18(Avatar2, { size: "2xsmall", fallback }),
1448
+ /* @__PURE__ */ jsx18(
1449
+ Text17,
1450
+ {
1451
+ size: "small",
1452
+ leading: "compact",
1453
+ className: "text-ui-fg-subtle hover:text-ui-fg-base transition-fg truncate",
1454
+ children: name || email
1455
+ }
1456
+ )
1457
+ ] })
1458
+ }
1459
+ )
1460
+ ] });
1461
+ };
1462
+ var Company = ({ data }) => {
1463
+ const { t } = useTranslation17();
1464
+ const company = data.shipping_address?.company || data.billing_address?.company;
1465
+ if (!company) {
1466
+ return null;
1467
+ }
1468
+ return /* @__PURE__ */ jsxs19("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1469
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", weight: "plus", children: t("fields.company") }),
1470
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", className: "truncate", children: company })
1471
+ ] });
1472
+ };
1473
+ var Contact = ({ data }) => {
1474
+ const { t } = useTranslation17();
1475
+ const phone = data.shipping_address?.phone || data.billing_address?.phone;
1476
+ const email = data.email || "";
1477
+ return /* @__PURE__ */ jsxs19("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1478
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", weight: "plus", children: t("orders.customer.contactLabel") }),
1479
+ /* @__PURE__ */ jsxs19("div", { className: "flex flex-col gap-y-2", children: [
1480
+ /* @__PURE__ */ jsxs19("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
1481
+ /* @__PURE__ */ jsx18(
1482
+ Text17,
1483
+ {
1484
+ size: "small",
1485
+ leading: "compact",
1486
+ className: "text-pretty break-all",
1487
+ children: email
1488
+ }
1489
+ ),
1490
+ /* @__PURE__ */ jsx18("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx18(Copy2, { content: email, className: "text-ui-fg-muted" }) })
1491
+ ] }),
1492
+ phone && /* @__PURE__ */ jsxs19("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
1493
+ /* @__PURE__ */ jsx18(
1494
+ Text17,
1495
+ {
1496
+ size: "small",
1497
+ leading: "compact",
1498
+ className: "text-pretty break-all",
1499
+ children: phone
1500
+ }
1501
+ ),
1502
+ /* @__PURE__ */ jsx18("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx18(Copy2, { content: phone, className: "text-ui-fg-muted" }) })
1503
+ ] })
1504
+ ] })
1505
+ ] });
1506
+ };
1507
+ var AddressPrint = ({
1508
+ address,
1509
+ type
1510
+ }) => {
1511
+ const { t } = useTranslation17();
1512
+ return /* @__PURE__ */ jsxs19("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1513
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", weight: "plus", children: type === "shipping" ? t("addresses.shippingAddress.label") : t("addresses.billingAddress.label") }),
1514
+ address ? /* @__PURE__ */ jsxs19("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
1515
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", children: getFormattedAddress({ address }).map((line, i) => {
1516
+ return /* @__PURE__ */ jsxs19("span", { className: "break-words", children: [
1517
+ line,
1518
+ /* @__PURE__ */ jsx18("br", {})
1519
+ ] }, i);
1520
+ }) }),
1521
+ /* @__PURE__ */ jsx18("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx18(
1522
+ Copy2,
1523
+ {
1524
+ content: getFormattedAddress({ address }).join("\n"),
1525
+ className: "text-ui-fg-muted"
1526
+ }
1527
+ ) })
1528
+ ] }) : /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", children: "-" })
1529
+ ] });
1530
+ };
1531
+ var Addresses = ({ data }) => {
1532
+ const { t } = useTranslation17();
1533
+ return /* @__PURE__ */ jsxs19("div", { className: "divide-y", children: [
1534
+ /* @__PURE__ */ jsx18(AddressPrint, { address: data.shipping_address, type: "shipping" }),
1535
+ !isSameAddress(data.shipping_address, data.billing_address) ? /* @__PURE__ */ jsx18(AddressPrint, { address: data.billing_address, type: "billing" }) : /* @__PURE__ */ jsxs19("div", { className: "grid grid-cols-2 items-center px-6 py-4", children: [
1536
+ /* @__PURE__ */ jsx18(
1537
+ Text17,
1538
+ {
1539
+ size: "small",
1540
+ leading: "compact",
1541
+ weight: "plus",
1542
+ className: "text-ui-fg-subtle",
1543
+ children: t("addresses.billingAddress.label")
1544
+ }
1545
+ ),
1546
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: t("addresses.billingAddress.sameAsShipping") })
1547
+ ] })
1548
+ ] });
1549
+ };
1550
+ var CustomerInfo = Object.assign(
1551
+ {},
1552
+ {
1553
+ ID,
1554
+ Company,
1555
+ Contact,
1556
+ Addresses
1557
+ }
1558
+ );
1559
+ var getOrderCustomer = (obj) => {
1560
+ const { first_name: sFirstName, last_name: sLastName } = obj.shipping_address || {};
1561
+ const { first_name: bFirstName, last_name: bLastName } = obj.billing_address || {};
1562
+ const { first_name: cFirstName, last_name: cLastName } = obj.customer || {};
1563
+ const customerName = [cFirstName, cLastName].filter(Boolean).join(" ");
1564
+ const shippingName = [sFirstName, sLastName].filter(Boolean).join(" ");
1565
+ const billingName = [bFirstName, bLastName].filter(Boolean).join(" ");
1566
+ const name = customerName || shippingName || billingName;
1567
+ return name;
1568
+ };
1569
+
1570
+ // src/pages/orders/[id]/_components/order-customer-section/order-customer-section.tsx
1571
+ import { jsx as jsx19, jsxs as jsxs20 } from "react/jsx-runtime";
1572
+ var OrderCustomerSection = ({ order }) => {
1573
+ return /* @__PURE__ */ jsxs20(Container7, { className: "divide-y p-0", children: [
1574
+ /* @__PURE__ */ jsx19(Header, {}),
1575
+ /* @__PURE__ */ jsx19(CustomerInfo.ID, { data: order }),
1576
+ /* @__PURE__ */ jsx19(CustomerInfo.Contact, { data: order }),
1577
+ /* @__PURE__ */ jsx19(CustomerInfo.Company, { data: order }),
1578
+ /* @__PURE__ */ jsx19(CustomerInfo.Addresses, { data: order })
1579
+ ] });
1580
+ };
1581
+ var Header = () => {
1582
+ const { t } = useTranslation18();
1583
+ return /* @__PURE__ */ jsx19("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsx19(Heading7, { level: "h2", children: t("fields.customer") }) });
1584
+ };
1585
+
1586
+ // src/pages/orders/[id]/_components/order-fulfillment-section/order-fulfillment-section.tsx
1587
+ import { Buildings, XCircle } from "@medusajs/icons";
1588
+ import {
1589
+ Button as Button6,
1590
+ Container as Container8,
1591
+ Copy as Copy3,
1592
+ Heading as Heading8,
1593
+ StatusBadge,
1594
+ Text as Text18,
1595
+ Tooltip as Tooltip2,
1596
+ toast as toast5,
1597
+ usePrompt as usePrompt2
1598
+ } from "@medusajs/ui";
1599
+ import { format } from "date-fns";
1600
+ import { useTranslation as useTranslation19 } from "react-i18next";
1601
+ import { Link as Link3, useNavigate as useNavigate5 } from "react-router-dom";
1602
+ import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs21 } from "react/jsx-runtime";
1603
+ var OrderFulfillmentSection = ({
1604
+ order
1605
+ }) => {
1606
+ const fulfillments = order.fulfillments || [];
1607
+ return /* @__PURE__ */ jsxs21("div", { className: "flex flex-col gap-y-3", children: [
1608
+ /* @__PURE__ */ jsx20(UnfulfilledItemBreakdown, { order }),
1609
+ fulfillments.map((f, index) => /* @__PURE__ */ jsx20(Fulfillment, { index, fulfillment: f, order }, f.id))
1610
+ ] });
1611
+ };
1612
+ var UnfulfilledItem = ({
1613
+ item,
1614
+ currencyCode
1615
+ }) => {
1616
+ return /* @__PURE__ */ jsxs21(
1617
+ "div",
1618
+ {
1619
+ className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",
1620
+ children: [
1621
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-start gap-x-4", children: [
1622
+ /* @__PURE__ */ jsx20(Thumbnail, { src: item.thumbnail }),
1623
+ /* @__PURE__ */ jsxs21("div", { children: [
1624
+ /* @__PURE__ */ jsx20(
1625
+ Text18,
1626
+ {
1627
+ size: "small",
1628
+ leading: "compact",
1629
+ weight: "plus",
1630
+ className: "text-ui-fg-base",
1631
+ children: item.title
1632
+ }
1633
+ ),
1634
+ item.variant_sku && /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-x-1", children: [
1635
+ /* @__PURE__ */ jsx20(Text18, { size: "small", children: item.variant_sku }),
1636
+ /* @__PURE__ */ jsx20(Copy3, { content: item.variant_sku, className: "text-ui-fg-muted" })
1637
+ ] }),
1638
+ /* @__PURE__ */ jsx20(Text18, { size: "small", children: item.variant?.options?.map((o) => o.value).join(" \xB7 ") })
1639
+ ] })
1640
+ ] }),
1641
+ /* @__PURE__ */ jsxs21("div", { className: "grid grid-cols-3 items-center gap-x-4", children: [
1642
+ /* @__PURE__ */ jsx20("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx20(Text18, { size: "small", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
1643
+ /* @__PURE__ */ jsx20("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsxs21(Text18, { children: [
1644
+ /* @__PURE__ */ jsx20("span", { className: "tabular-nums", children: item.quantity - item.detail.fulfilled_quantity }),
1645
+ "x"
1646
+ ] }) }),
1647
+ /* @__PURE__ */ jsx20("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx20(Text18, { size: "small", children: getLocaleAmount(item.subtotal || 0, currencyCode) }) })
1648
+ ] })
1649
+ ]
1650
+ },
1651
+ item.id
1652
+ );
1653
+ };
1654
+ var UnfulfilledItemBreakdown = ({ order }) => {
1655
+ const unfulfilledItemsWithShipping = order.items.filter(
1656
+ (i) => i.requires_shipping && i.detail && i.quantity && i.detail.fulfilled_quantity < i.quantity
1657
+ );
1658
+ const unfulfilledItemsWithoutShipping = order.items.filter(
1659
+ (i) => !i.requires_shipping && i.detail && i.quantity && i.detail.fulfilled_quantity < i.quantity
1660
+ );
1661
+ return /* @__PURE__ */ jsxs21(Fragment2, { children: [
1662
+ !!unfulfilledItemsWithShipping.length && /* @__PURE__ */ jsx20(
1663
+ UnfulfilledItemDisplay,
1664
+ {
1665
+ order,
1666
+ unfulfilledItems: unfulfilledItemsWithShipping,
1667
+ requiresShipping: true
1668
+ }
1669
+ ),
1670
+ !!unfulfilledItemsWithoutShipping.length && /* @__PURE__ */ jsx20(
1671
+ UnfulfilledItemDisplay,
1672
+ {
1673
+ order,
1674
+ unfulfilledItems: unfulfilledItemsWithoutShipping,
1675
+ requiresShipping: false
1676
+ }
1677
+ )
1678
+ ] });
1679
+ };
1680
+ var UnfulfilledItemDisplay = ({
1681
+ order,
1682
+ unfulfilledItems,
1683
+ requiresShipping = false
1684
+ }) => {
1685
+ const { t } = useTranslation19();
1686
+ if (order.status === "canceled") {
1687
+ return;
1688
+ }
1689
+ return /* @__PURE__ */ jsxs21(Container8, { className: "divide-y p-0", children: [
1690
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between px-6 py-4", children: [
1691
+ /* @__PURE__ */ jsx20(Heading8, { level: "h2", children: t("orders.fulfillment.unfulfilledItems") }),
1692
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-x-4", children: [
1693
+ requiresShipping && /* @__PURE__ */ jsx20(StatusBadge, { color: "red", className: "text-nowrap", children: t("orders.fulfillment.requiresShipping") }),
1694
+ /* @__PURE__ */ jsx20(StatusBadge, { color: "red", className: "text-nowrap", children: t("orders.fulfillment.awaitingFulfillmentBadge") }),
1695
+ /* @__PURE__ */ jsx20(
1696
+ ActionMenu,
1697
+ {
1698
+ groups: [
1699
+ {
1700
+ actions: [
1701
+ {
1702
+ label: t("orders.fulfillment.fulfillItems"),
1703
+ icon: /* @__PURE__ */ jsx20(Buildings, {}),
1704
+ to: `/orders/${order.id}/fulfillment?requires_shipping=${requiresShipping}`
1705
+ }
1706
+ ]
1707
+ }
1708
+ ]
1709
+ }
1710
+ )
1711
+ ] })
1712
+ ] }),
1713
+ /* @__PURE__ */ jsx20("div", { children: unfulfilledItems.map((item) => /* @__PURE__ */ jsx20(
1714
+ UnfulfilledItem,
1715
+ {
1716
+ item,
1717
+ currencyCode: order.currency_code
1718
+ },
1719
+ item.id
1720
+ )) })
1721
+ ] });
1722
+ };
1723
+ var Fulfillment = ({
1724
+ fulfillment,
1725
+ order,
1726
+ index
1727
+ }) => {
1728
+ const { t } = useTranslation19();
1729
+ const prompt = usePrompt2();
1730
+ const navigate = useNavigate5();
1731
+ const showLocation = !!fulfillment.location_id;
1732
+ const isPickUpFulfillment = fulfillment.shipping_option?.service_zone.fulfillment_set.type === "pickup" /* Pickup */;
1733
+ const { stock_location, isError, error } = useStockLocation(
1734
+ fulfillment.location_id,
1735
+ void 0,
1736
+ {
1737
+ enabled: showLocation
1738
+ }
1739
+ );
1740
+ let statusText = fulfillment.requires_shipping ? isPickUpFulfillment ? t("orders.fulfillment.status.awaitingPickup") : t("orders.fulfillment.status.awaitingShipping") : t("orders.fulfillment.status.awaitingDelivery");
1741
+ let statusColor = "blue";
1742
+ let statusTimestamp = fulfillment.created_at;
1743
+ if (fulfillment.canceled_at) {
1744
+ statusText = t("orders.fulfillment.status.canceled");
1745
+ statusColor = "red";
1746
+ statusTimestamp = fulfillment.canceled_at;
1747
+ } else if (fulfillment.delivered_at) {
1748
+ statusText = t("orders.fulfillment.status.delivered");
1749
+ statusColor = "green";
1750
+ statusTimestamp = fulfillment.delivered_at;
1751
+ } else if (fulfillment.shipped_at) {
1752
+ statusText = t("orders.fulfillment.status.shipped");
1753
+ statusColor = "green";
1754
+ statusTimestamp = fulfillment.shipped_at;
1755
+ }
1756
+ const { mutateAsync } = useCancelOrderFulfillment(order.id, fulfillment.id);
1757
+ const { mutateAsync: markAsDelivered } = useMarkOrderFulfillmentAsDelivered(
1758
+ order.id,
1759
+ fulfillment.id
1760
+ );
1761
+ const showShippingButton = !fulfillment.canceled_at && !fulfillment.shipped_at && !fulfillment.delivered_at && fulfillment.requires_shipping && !isPickUpFulfillment;
1762
+ const showDeliveryButton = !fulfillment.canceled_at && !fulfillment.delivered_at;
1763
+ const cancelDisabled = !!fulfillment.canceled_at || !!fulfillment.shipped_at || !!fulfillment.delivered_at;
1764
+ const handleMarkAsDelivered = async () => {
1765
+ const res = await prompt({
1766
+ title: t("general.areYouSure"),
1767
+ description: t("orders.fulfillment.markAsDeliveredWarning"),
1768
+ confirmText: t("actions.continue"),
1769
+ cancelText: t("actions.cancel"),
1770
+ variant: "confirmation"
1771
+ });
1772
+ if (res) {
1773
+ await markAsDelivered(void 0, {
1774
+ onSuccess: () => {
1775
+ toast5.success(
1776
+ t(
1777
+ isPickUpFulfillment ? "orders.fulfillment.toast.fulfillmentPickedUp" : "orders.fulfillment.toast.fulfillmentDelivered"
1778
+ )
1779
+ );
1780
+ },
1781
+ onError: (e) => {
1782
+ toast5.error(e.message);
1783
+ }
1784
+ });
1785
+ }
1786
+ };
1787
+ const handleCancel = async () => {
1788
+ if (fulfillment.shipped_at) {
1789
+ toast5.warning(t("orders.fulfillment.toast.fulfillmentShipped"));
1790
+ return;
1791
+ }
1792
+ const res = await prompt({
1793
+ title: t("general.areYouSure"),
1794
+ description: t("orders.fulfillment.cancelWarning"),
1795
+ confirmText: t("actions.continue"),
1796
+ cancelText: t("actions.cancel")
1797
+ });
1798
+ if (res) {
1799
+ await mutateAsync(void 0, {
1800
+ onSuccess: () => {
1801
+ toast5.success(t("orders.fulfillment.toast.canceled"));
1802
+ },
1803
+ onError: (e) => {
1804
+ toast5.error(e.message);
1805
+ }
1806
+ });
1807
+ }
1808
+ };
1809
+ if (isError) {
1810
+ throw error;
1811
+ }
1812
+ return /* @__PURE__ */ jsxs21(Container8, { className: "divide-y p-0", children: [
1813
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between px-6 py-4", children: [
1814
+ /* @__PURE__ */ jsx20(Heading8, { level: "h2", children: t("orders.fulfillment.number", {
1815
+ number: index + 1
1816
+ }) }),
1817
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-x-4", children: [
1818
+ /* @__PURE__ */ jsx20(
1819
+ Tooltip2,
1820
+ {
1821
+ content: format(
1822
+ new Date(statusTimestamp),
1823
+ "dd MMM, yyyy, HH:mm:ss"
1824
+ ),
1825
+ children: /* @__PURE__ */ jsx20(StatusBadge, { color: statusColor, className: "text-nowrap", children: statusText })
1826
+ }
1827
+ ),
1828
+ /* @__PURE__ */ jsx20(
1829
+ ActionMenu,
1830
+ {
1831
+ groups: [
1832
+ {
1833
+ actions: [
1834
+ {
1835
+ label: t("actions.cancel"),
1836
+ icon: /* @__PURE__ */ jsx20(XCircle, {}),
1837
+ onClick: handleCancel,
1838
+ disabled: cancelDisabled
1839
+ }
1840
+ ]
1841
+ }
1842
+ ]
1843
+ }
1844
+ )
1845
+ ] })
1846
+ ] }),
1847
+ /* @__PURE__ */ jsxs21("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1848
+ /* @__PURE__ */ jsx20(Text18, { size: "small", leading: "compact", weight: "plus", children: t("orders.fulfillment.itemsLabel") }),
1849
+ /* @__PURE__ */ jsx20("ul", { children: (fulfillment.items || []).map((f_item) => /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsxs21(Text18, { size: "small", leading: "compact", children: [
1850
+ f_item.quantity,
1851
+ "x ",
1852
+ f_item.title
1853
+ ] }) }, f_item.line_item_id)) })
1854
+ ] }),
1855
+ showLocation && /* @__PURE__ */ jsxs21("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1856
+ /* @__PURE__ */ jsx20(Text18, { size: "small", leading: "compact", weight: "plus", children: t("orders.fulfillment.shippingFromLabel") }),
1857
+ stock_location ? /* @__PURE__ */ jsx20(
1858
+ Link3,
1859
+ {
1860
+ to: `/settings/locations/${stock_location.id}`,
1861
+ className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",
1862
+ children: /* @__PURE__ */ jsx20(Text18, { size: "small", leading: "compact", children: stock_location.name })
1863
+ }
1864
+ ) : /* @__PURE__ */ jsx20(Skeleton, { className: "w-16" })
1865
+ ] }),
1866
+ /* @__PURE__ */ jsxs21("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1867
+ /* @__PURE__ */ jsx20(Text18, { size: "small", leading: "compact", weight: "plus", children: t("fields.provider") }),
1868
+ /* @__PURE__ */ jsx20(Text18, { size: "small", leading: "compact", children: formatProvider(fulfillment.provider_id) })
1869
+ ] }),
1870
+ /* @__PURE__ */ jsxs21("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1871
+ /* @__PURE__ */ jsx20(Text18, { size: "small", leading: "compact", weight: "plus", children: t("orders.fulfillment.trackingLabel") }),
1872
+ /* @__PURE__ */ jsx20("div", { children: fulfillment.labels && fulfillment.labels.length > 0 ? /* @__PURE__ */ jsx20("ul", { children: fulfillment.labels.map((tlink) => {
1873
+ const hasUrl = !!tlink.tracking_url?.length && tlink.tracking_url !== "#";
1874
+ if (hasUrl) {
1875
+ return /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsx20(
1876
+ "a",
1877
+ {
1878
+ href: tlink.tracking_url || "",
1879
+ target: "_blank",
1880
+ rel: "noopener noreferrer",
1881
+ className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",
1882
+ children: /* @__PURE__ */ jsx20(Text18, { size: "small", leading: "compact", children: tlink.tracking_number })
1883
+ }
1884
+ ) }, tlink.tracking_number);
1885
+ }
1886
+ return /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsx20(Text18, { size: "small", leading: "compact", children: tlink.tracking_number }) }, tlink.tracking_number);
1887
+ }) }) : /* @__PURE__ */ jsx20(Text18, { size: "small", leading: "compact", children: "-" }) })
1888
+ ] }),
1889
+ (showShippingButton || showDeliveryButton) && /* @__PURE__ */ jsxs21("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
1890
+ showDeliveryButton && /* @__PURE__ */ jsx20(
1891
+ Button6,
1892
+ {
1893
+ size: "small",
1894
+ onClick: handleMarkAsDelivered,
1895
+ variant: "secondary",
1896
+ children: t(
1897
+ isPickUpFulfillment ? "orders.fulfillment.markAsPickedUp" : "orders.fulfillment.markAsDelivered"
1898
+ )
1899
+ }
1900
+ ),
1901
+ showShippingButton && /* @__PURE__ */ jsx20(
1902
+ Button6,
1903
+ {
1904
+ size: "small",
1905
+ onClick: () => navigate(`./${fulfillment.id}/create-shipment`),
1906
+ variant: "secondary",
1907
+ children: t("orders.fulfillment.markAsShipped")
1908
+ }
1909
+ )
1910
+ ] })
1911
+ ] });
1912
+ };
1913
+
1914
+ // src/pages/orders/[id]/_components/order-general-section/order-general-section.tsx
1915
+ import { XCircle as XCircle2 } from "@medusajs/icons";
1916
+ import {
1917
+ Container as Container9,
1918
+ Copy as Copy4,
1919
+ Heading as Heading9,
1920
+ StatusBadge as StatusBadge2,
1921
+ Text as Text19,
1922
+ toast as toast6,
1923
+ usePrompt as usePrompt3
1924
+ } from "@medusajs/ui";
1925
+ import { useTranslation as useTranslation20 } from "react-i18next";
1926
+ import { jsx as jsx21, jsxs as jsxs22 } from "react/jsx-runtime";
1927
+ var OrderGeneralSection = ({ order }) => {
1928
+ const { t } = useTranslation20();
1929
+ const prompt = usePrompt3();
1930
+ const { getFullDate } = useDate();
1931
+ const { mutateAsync: cancelOrder } = useCancelOrder(order.id);
1932
+ const hasAnyFulfilledItem = order.items?.some(
1933
+ // @ts-ignore — detail.fulfilled_quantity is exposed via Mercur query-config
1934
+ (i) => (i.detail?.fulfilled_quantity ?? 0) > 0
1935
+ );
1936
+ const cancelDisabled = !!order.canceled_at || !!hasAnyFulfilledItem;
1937
+ const cancelDisabledTooltip = order.canceled_at ? void 0 : hasAnyFulfilledItem ? t("orders.actions.cancelDisabledFulfilled") : void 0;
1938
+ const handleCancel = async () => {
1939
+ const res = await prompt({
1940
+ title: t("general.areYouSure"),
1941
+ description: t("orders.cancelWarning", {
1942
+ id: `#${order.display_id}`
1943
+ }),
1944
+ confirmText: t("actions.continue"),
1945
+ cancelText: t("actions.cancel")
1946
+ });
1947
+ if (!res) {
1948
+ return;
1949
+ }
1950
+ await cancelOrder(void 0, {
1951
+ onSuccess: () => {
1952
+ toast6.success(t("orders.orderCanceled"));
1953
+ },
1954
+ onError: (e) => {
1955
+ toast6.error(e.message);
1956
+ }
1957
+ });
1958
+ };
1959
+ return /* @__PURE__ */ jsxs22(Container9, { className: "flex items-center justify-between px-6 py-4", children: [
1960
+ /* @__PURE__ */ jsxs22("div", { children: [
1961
+ /* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-x-1", children: [
1962
+ /* @__PURE__ */ jsxs22(Heading9, { children: [
1963
+ "#",
1964
+ order.display_id
1965
+ ] }),
1966
+ /* @__PURE__ */ jsx21(Copy4, { content: `#${order.display_id}`, className: "text-ui-fg-muted" })
1967
+ ] }),
1968
+ /* @__PURE__ */ jsx21(Text19, { size: "small", className: "text-ui-fg-subtle", children: t("orders.onDateFromSalesChannel", {
1969
+ date: getFullDate({ date: order.created_at, includeTime: true }),
1970
+ salesChannel: order.sales_channel?.name
1971
+ }) })
1972
+ ] }),
1973
+ /* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-x-4", children: [
1974
+ /* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-x-1.5", children: [
1975
+ /* @__PURE__ */ jsx21(OrderBadge, { order }),
1976
+ /* @__PURE__ */ jsx21(PaymentBadge, { order }),
1977
+ /* @__PURE__ */ jsx21(FulfillmentBadge, { order })
1978
+ ] }),
1979
+ /* @__PURE__ */ jsx21(
1980
+ ActionMenu,
1981
+ {
1982
+ groups: [
1983
+ {
1984
+ actions: [
1985
+ {
1986
+ label: t("actions.cancel"),
1987
+ onClick: handleCancel,
1988
+ disabled: cancelDisabled,
1989
+ disabledTooltip: cancelDisabledTooltip,
1990
+ icon: /* @__PURE__ */ jsx21(XCircle2, {})
1991
+ }
1992
+ ]
1993
+ }
1994
+ ]
1995
+ }
1996
+ )
1997
+ ] })
1998
+ ] });
1999
+ };
2000
+ var FulfillmentBadge = ({ order }) => {
2001
+ const { t } = useTranslation20();
2002
+ if (!order.fulfillment_status) {
2003
+ return null;
2004
+ }
2005
+ const { label, color } = getOrderFulfillmentStatus(
2006
+ t,
2007
+ order.fulfillment_status
2008
+ );
2009
+ return /* @__PURE__ */ jsx21(StatusBadge2, { color, className: "text-nowrap", children: label });
2010
+ };
2011
+ var PaymentBadge = ({ order }) => {
2012
+ const { t } = useTranslation20();
2013
+ if (!order.payment_status) {
2014
+ return null;
2015
+ }
2016
+ const { label, color } = getOrderPaymentStatus(t, order.payment_status);
2017
+ return /* @__PURE__ */ jsx21(StatusBadge2, { color, className: "text-nowrap", children: label });
2018
+ };
2019
+ var OrderBadge = ({ order }) => {
2020
+ const { t } = useTranslation20();
2021
+ const orderStatus = getCanceledOrderStatus(t, order.status);
2022
+ if (!orderStatus) {
2023
+ return null;
2024
+ }
2025
+ return /* @__PURE__ */ jsx21(StatusBadge2, { color: orderStatus.color, className: "text-nowrap", children: orderStatus.label });
2026
+ };
2027
+
2028
+ // src/pages/orders/[id]/_components/order-payment-section/order-payment-section.tsx
2029
+ import { ArrowUturnLeft as ArrowUturnLeft2, DocumentText } from "@medusajs/icons";
2030
+ import {
2031
+ Badge,
2032
+ Container as Container10,
2033
+ Heading as Heading10,
2034
+ StatusBadge as StatusBadge3,
2035
+ Text as Text20,
2036
+ Tooltip as Tooltip3
2037
+ } from "@medusajs/ui";
2038
+ import { useTranslation as useTranslation21 } from "react-i18next";
2039
+
2040
+ // src/lib/payment.ts
2041
+ var getTotalCaptured = (paymentCollections) => paymentCollections.reduce((acc, paymentCollection) => {
2042
+ acc = acc + (paymentCollection.captured_amount - paymentCollection.refunded_amount);
2043
+ return acc;
2044
+ }, 0);
2045
+ var getTotalPending = (paymentCollections) => paymentCollections.filter((pc) => pc.status !== "canceled").reduce((acc, paymentCollection) => {
2046
+ acc += paymentCollection.amount - paymentCollection.captured_amount;
2047
+ return acc;
2048
+ }, 0);
2049
+
2050
+ // src/pages/orders/[id]/_components/order-payment-section/order-payment-section.tsx
2051
+ import { jsx as jsx22, jsxs as jsxs23 } from "react/jsx-runtime";
2052
+ var getPaymentsFromOrder = (order) => {
2053
+ return order.payment_collections?.map((collection) => collection.payments).flat(1).filter(Boolean);
2054
+ };
2055
+ var OrderPaymentSection = ({ order }) => {
2056
+ const payments = getPaymentsFromOrder(order) ?? [];
2057
+ return /* @__PURE__ */ jsxs23(Container10, { className: "divide-y p-0", children: [
2058
+ /* @__PURE__ */ jsx22(Header2, { order }),
2059
+ payments.length > 0 && /* @__PURE__ */ jsx22("ul", { className: "divide-y", children: payments.map((payment) => /* @__PURE__ */ jsx22(PaymentRow, { order, payment }, payment.id)) }),
2060
+ /* @__PURE__ */ jsx22(Total, { order })
2061
+ ] });
2062
+ };
2063
+ var Header2 = ({ order }) => {
2064
+ const { t } = useTranslation21();
2065
+ return /* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-between px-6 py-4", children: [
2066
+ /* @__PURE__ */ jsx22(Heading10, { level: "h2", children: t("orders.payment.title") }),
2067
+ order.payment_status && /* @__PURE__ */ jsx22(
2068
+ StatusBadge3,
2069
+ {
2070
+ color: getOrderPaymentStatus(t, order.payment_status).color,
2071
+ className: "text-nowrap",
2072
+ children: getOrderPaymentStatus(t, order.payment_status).label
2073
+ }
2074
+ )
2075
+ ] });
2076
+ };
2077
+ var Total = ({ order }) => {
2078
+ const { t } = useTranslation21();
2079
+ if (!order.payment_collections?.length) {
2080
+ return null;
2081
+ }
2082
+ const paymentCollections = order.payment_collections;
2083
+ const totalCaptured = getTotalCaptured(paymentCollections);
2084
+ const totalPending = getTotalPending(paymentCollections);
2085
+ const totalRefunded = paymentCollections.reduce(
2086
+ (acc, pc) => acc + (pc.refunded_amount || 0),
2087
+ 0
2088
+ );
2089
+ return /* @__PURE__ */ jsxs23("div", { children: [
2090
+ /* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-between px-6 py-4", children: [
2091
+ /* @__PURE__ */ jsx22(Text20, { size: "small", weight: "plus", leading: "compact", children: t("orders.payment.totalPaidByCustomer") }),
2092
+ /* @__PURE__ */ jsx22(Text20, { size: "small", weight: "plus", leading: "compact", children: getStylizedAmount(totalCaptured, order.currency_code) })
2093
+ ] }),
2094
+ totalRefunded > 0 && /* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-between px-6 py-4", children: [
2095
+ /* @__PURE__ */ jsx22(Text20, { size: "small", weight: "plus", leading: "compact", children: t("orders.payment.totalRefunded") }),
2096
+ /* @__PURE__ */ jsx22(Text20, { size: "small", weight: "plus", leading: "compact", children: getStylizedAmount(totalRefunded, order.currency_code) })
2097
+ ] }),
2098
+ order.status !== "canceled" && totalPending > 0 && /* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-between px-6 py-4", children: [
2099
+ /* @__PURE__ */ jsx22(Text20, { size: "small", weight: "plus", leading: "compact", children: t("orders.payment.totalPending") }),
2100
+ /* @__PURE__ */ jsx22(Text20, { size: "small", weight: "plus", leading: "compact", children: getStylizedAmount(totalPending, order.currency_code) })
2101
+ ] })
2102
+ ] });
2103
+ };
2104
+ var getPaymentStatus = (payment) => {
2105
+ const refundedAmount = (payment.refunds ?? []).reduce(
2106
+ (acc, r) => acc + (r.amount ?? 0),
2107
+ 0
2108
+ );
2109
+ if (payment.canceled_at) {
2110
+ return { labelKey: "orders.payment.status.canceled", color: "red" };
2111
+ }
2112
+ if (refundedAmount > 0 && refundedAmount >= payment.amount) {
2113
+ return { labelKey: "orders.payment.status.refunded", color: "grey" };
2114
+ }
2115
+ if (refundedAmount > 0) {
2116
+ return { labelKey: "orders.payment.status.partiallyRefunded", color: "orange" };
2117
+ }
2118
+ if (payment.captured_at) {
2119
+ return { labelKey: "orders.payment.status.captured", color: "green" };
2120
+ }
2121
+ return { labelKey: "orders.payment.status.pending", color: "orange" };
2122
+ };
2123
+ var PaymentRow = ({
2124
+ order,
2125
+ payment
2126
+ }) => {
2127
+ const { t } = useTranslation21();
2128
+ const { getFullDate } = useDate();
2129
+ const status = getPaymentStatus(payment);
2130
+ const refunds = payment.refunds ?? [];
2131
+ const refundedAmount = refunds.reduce(
2132
+ (acc, r) => acc + (r.amount ?? 0),
2133
+ 0
2134
+ );
2135
+ const isFullyRefunded = refundedAmount > 0 && refundedAmount >= payment.amount;
2136
+ const canRefund = !!payment.captured_at && !payment.canceled_at && !isFullyRefunded;
2137
+ return /* @__PURE__ */ jsxs23("li", { "data-testid": `payment-row-${payment.id}`, children: [
2138
+ /* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-between px-6 py-4", children: [
2139
+ /* @__PURE__ */ jsxs23("div", { className: "flex min-w-0 flex-col", children: [
2140
+ /* @__PURE__ */ jsx22(Tooltip3, { content: payment.id, children: /* @__PURE__ */ jsx22(
2141
+ Text20,
2142
+ {
2143
+ size: "small",
2144
+ weight: "plus",
2145
+ leading: "compact",
2146
+ className: isFullyRefunded ? "text-ui-fg-muted truncate line-through" : "text-ui-fg-base truncate",
2147
+ children: `#${payment.id.slice(-7)}`
2148
+ }
2149
+ ) }),
2150
+ /* @__PURE__ */ jsx22(
2151
+ Text20,
2152
+ {
2153
+ size: "xsmall",
2154
+ leading: "compact",
2155
+ className: isFullyRefunded ? "text-ui-fg-muted line-through" : "text-ui-fg-subtle",
2156
+ children: payment.created_at ? getFullDate({ date: payment.created_at, includeTime: true }) : null
2157
+ }
2158
+ )
2159
+ ] }),
2160
+ /* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-x-3", children: [
2161
+ /* @__PURE__ */ jsx22(StatusBadge3, { color: status.color, className: "text-nowrap", children: t(status.labelKey) }),
2162
+ /* @__PURE__ */ jsx22(
2163
+ Text20,
2164
+ {
2165
+ size: "small",
2166
+ weight: "plus",
2167
+ leading: "compact",
2168
+ className: isFullyRefunded ? "line-through" : void 0,
2169
+ children: getStylizedAmount(payment.amount, order.currency_code)
2170
+ }
2171
+ ),
2172
+ /* @__PURE__ */ jsx22(
2173
+ ActionMenu,
2174
+ {
2175
+ groups: [
2176
+ {
2177
+ actions: [
2178
+ {
2179
+ label: t("orders.payment.createRefund"),
2180
+ icon: /* @__PURE__ */ jsx22(ArrowUturnLeft2, {}),
2181
+ to: `/orders/${order.id}/refund?payment_id=${payment.id}`,
2182
+ disabled: !canRefund
2183
+ }
2184
+ ]
2185
+ }
2186
+ ]
2187
+ }
2188
+ )
2189
+ ] })
2190
+ ] }),
2191
+ refunds.map((refund) => /* @__PURE__ */ jsx22(
2192
+ RefundRow,
2193
+ {
2194
+ refund,
2195
+ currencyCode: order.currency_code
2196
+ },
2197
+ refund.id
2198
+ ))
2199
+ ] });
2200
+ };
2201
+ var RefundRow = ({
2202
+ refund,
2203
+ currencyCode
2204
+ }) => {
2205
+ const { t } = useTranslation21();
2206
+ const { getFullDate } = useDate();
2207
+ const reasonLabel = refund.refund_reason?.label ?? null;
2208
+ return /* @__PURE__ */ jsxs23(
2209
+ "div",
2210
+ {
2211
+ className: "flex items-center justify-between px-6 py-3 pl-12 bg-ui-bg-subtle",
2212
+ "data-testid": `refund-row-${refund.id}`,
2213
+ children: [
2214
+ /* @__PURE__ */ jsxs23("div", { className: "flex min-w-0 flex-col", children: [
2215
+ /* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-x-2", children: [
2216
+ /* @__PURE__ */ jsx22(Text20, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: t("orders.payment.refund") }),
2217
+ reasonLabel && /* @__PURE__ */ jsx22(Badge, { size: "2xsmall", rounded: "full", children: reasonLabel }),
2218
+ refund.note && /* @__PURE__ */ jsx22(Tooltip3, { content: refund.note, children: /* @__PURE__ */ jsx22(DocumentText, { className: "text-ui-fg-subtle h-3 w-3" }) })
2219
+ ] }),
2220
+ refund.created_at && /* @__PURE__ */ jsx22(Text20, { size: "xsmall", leading: "compact", className: "text-ui-fg-subtle", children: getFullDate({ date: refund.created_at, includeTime: true }) })
2221
+ ] }),
2222
+ /* @__PURE__ */ jsx22(Text20, { size: "small", weight: "plus", leading: "compact", children: `- ${getLocaleAmount(refund.amount ?? 0, currencyCode)}` })
2223
+ ]
2224
+ }
2225
+ );
2226
+ };
2227
+
2228
+ // src/pages/orders/[id]/_components/order-summary-section/order-summary-section.tsx
2229
+ import { useMemo as useMemo5, useState as useState5 } from "react";
2230
+ import { useTranslation as useTranslation24 } from "react-i18next";
2231
+ import { Link as Link4 } from "react-router-dom";
2232
+ import {
2233
+ ArrowDownRightMini,
2234
+ ArrowLongRight,
2235
+ ArrowPath as ArrowPath2,
2236
+ ArrowUturnLeft as ArrowUturnLeft3,
2237
+ DocumentText as DocumentText2,
2238
+ ExclamationCircle as ExclamationCircle2,
2239
+ PencilSquare,
2240
+ TriangleDownMini
2241
+ } from "@medusajs/icons";
2242
+ import {
2243
+ Badge as Badge4,
2244
+ Button as Button7,
2245
+ clx as clx2,
2246
+ Container as Container11,
2247
+ Copy as Copy5,
2248
+ Heading as Heading11,
2249
+ StatusBadge as StatusBadge4,
2250
+ Text as Text22,
2251
+ Tooltip as Tooltip5,
2252
+ toast as toast7
2253
+ } from "@medusajs/ui";
2254
+
2255
+ // src/pages/orders/[id]/_components/order-summary-section/return-info-popover.tsx
2256
+ import { useState as useState4 } from "react";
2257
+ import { useTranslation as useTranslation22 } from "react-i18next";
2258
+ import { InformationCircleSolid } from "@medusajs/icons";
2259
+ import { Badge as Badge2, Popover as Popover3, Text as Text21 } from "@medusajs/ui";
2260
+ import { jsx as jsx23, jsxs as jsxs24 } from "react/jsx-runtime";
2261
+ function ReturnInfoPopover({ orderReturn }) {
2262
+ const { t } = useTranslation22();
2263
+ const { getFullDate } = useDate();
2264
+ const [open, setOpen] = useState4(false);
2265
+ if (typeof orderReturn !== "object") {
2266
+ return null;
2267
+ }
2268
+ let returnType = "Return";
2269
+ let returnTypeId = orderReturn.id;
2270
+ if (orderReturn.claim_id) {
2271
+ returnType = "Claim";
2272
+ returnTypeId = orderReturn.claim_id;
2273
+ }
2274
+ if (orderReturn.exchange_id) {
2275
+ returnType = "Exchange";
2276
+ returnTypeId = orderReturn.exchange_id;
2277
+ }
2278
+ return /* @__PURE__ */ jsxs24(Popover3, { open, children: [
2279
+ /* @__PURE__ */ jsx23(
2280
+ Popover3.Trigger,
2281
+ {
2282
+ onMouseEnter: () => setOpen(true),
2283
+ onMouseLeave: () => setOpen(false),
2284
+ autoFocus: false,
2285
+ className: "align-sub focus-visible:outline-none",
2286
+ "data-testid": "order-summary-return-info-trigger",
2287
+ children: /* @__PURE__ */ jsx23(InformationCircleSolid, {})
2288
+ }
2289
+ ),
2290
+ /* @__PURE__ */ jsx23(
2291
+ Popover3.Content,
2292
+ {
2293
+ align: "center",
2294
+ side: "top",
2295
+ className: "bg-ui-bg-component p-2 focus-visible:outline-none",
2296
+ children: /* @__PURE__ */ jsxs24("div", { children: [
2297
+ /* @__PURE__ */ jsxs24(Badge2, { size: "2xsmall", className: "mb-2", rounded: "full", children: [
2298
+ returnType,
2299
+ ": #",
2300
+ returnTypeId.slice(-7)
2301
+ ] }),
2302
+ /* @__PURE__ */ jsxs24(Text21, { size: "xsmall", children: [
2303
+ /* @__PURE__ */ jsx23("span", { className: "text-ui-fg-subtle", children: t("orders.returns.returnRequested") }),
2304
+ " \xB7 ",
2305
+ getFullDate({
2306
+ date: orderReturn.requested_at,
2307
+ includeTime: true
2308
+ })
2309
+ ] }),
2310
+ /* @__PURE__ */ jsxs24(Text21, { size: "xsmall", children: [
2311
+ /* @__PURE__ */ jsx23("span", { className: "text-ui-fg-subtle", children: t("orders.returns.itemReceived") }),
2312
+ " \xB7 ",
2313
+ orderReturn.received_at ? getFullDate({
2314
+ date: orderReturn.received_at,
2315
+ includeTime: true
2316
+ }) : "-"
2317
+ ] })
2318
+ ] })
2319
+ }
2320
+ )
2321
+ ] });
2322
+ }
2323
+ var return_info_popover_default = ReturnInfoPopover;
2324
+
2325
+ // src/pages/orders/[id]/_components/order-summary-section/shipping-info-popover.tsx
2326
+ import { InformationCircleSolid as InformationCircleSolid2 } from "@medusajs/icons";
2327
+ import { Badge as Badge3, Tooltip as Tooltip4 } from "@medusajs/ui";
2328
+ import { useTranslation as useTranslation23 } from "react-i18next";
2329
+ import { jsx as jsx24, jsxs as jsxs25 } from "react/jsx-runtime";
2330
+ function ShippingInfoPopover({ shippingMethod }) {
2331
+ const { t } = useTranslation23();
2332
+ const shippingDetail = shippingMethod?.detail;
2333
+ if (!shippingDetail) {
2334
+ return;
2335
+ }
2336
+ let rmaType = t("orders.return");
2337
+ let rmaId = shippingDetail.return_id;
2338
+ if (shippingDetail.claim_id) {
2339
+ rmaType = t("orders.claim");
2340
+ rmaId = shippingDetail.claim_id;
2341
+ }
2342
+ if (shippingDetail.exchange_id) {
2343
+ rmaType = t("orders.exchange");
2344
+ rmaId = shippingDetail.exchange_id;
2345
+ }
2346
+ if (!rmaId) {
2347
+ return;
2348
+ }
2349
+ return /* @__PURE__ */ jsx24(
2350
+ Tooltip4,
2351
+ {
2352
+ content: /* @__PURE__ */ jsxs25(Badge3, { size: "2xsmall", rounded: "full", children: [
2353
+ rmaType,
2354
+ ": #",
2355
+ rmaId.slice(-7)
2356
+ ] }),
2357
+ children: /* @__PURE__ */ jsx24(InformationCircleSolid2, { className: "inline-block text-ui-fg-muted ml-1" })
2358
+ }
2359
+ );
2360
+ }
2361
+ var shipping_info_popover_default = ShippingInfoPopover;
2362
+
2363
+ // src/pages/orders/[id]/_components/order-summary-section/order-summary-section.tsx
2364
+ import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs26 } from "react/jsx-runtime";
2365
+ var OrderSummarySection = ({
2366
+ order
2367
+ }) => {
2368
+ const { t } = useTranslation24();
2369
+ const { reservations } = useReservationItems(
2370
+ {
2371
+ line_item_id: order?.items?.map((i) => i.id),
2372
+ limit: getReservationsLimitCount(order)
2373
+ },
2374
+ { enabled: Array.isArray(order?.items) }
2375
+ );
2376
+ const { order: orderPreview } = useOrderPreview(order.id);
2377
+ const reservationList = useMemo5(
2378
+ () => reservations ?? [],
2379
+ [reservations]
2380
+ );
2381
+ const { returns: receivableReturnsList = [] } = useReturns({
2382
+ status: "requested",
2383
+ order_id: order.id,
2384
+ fields: "+received_at"
2385
+ });
2386
+ const receivableReturns = useMemo5(
2387
+ () => receivableReturnsList.filter((r) => !r.canceled_at),
2388
+ [receivableReturnsList]
2389
+ );
2390
+ const showReturns = !!receivableReturns.length;
2391
+ const showAllocateButton = useMemo5(() => {
2392
+ if (!reservations) {
2393
+ return false;
2394
+ }
2395
+ const reservationsMap = new Map(
2396
+ reservationList.map((r) => [r.line_item_id, r.id])
2397
+ );
2398
+ return order.items?.some((item) => {
2399
+ const offerLinks = item.offer?.inventory_item_link;
2400
+ if (!offerLinks?.length) {
2401
+ return false;
2402
+ }
2403
+ const fulfilled = item.detail?.fulfilled_quantity ?? 0;
2404
+ if (item.quantity - fulfilled <= 0) {
2405
+ return false;
2406
+ }
2407
+ return !reservationsMap.has(item.id);
2408
+ }) ?? false;
2409
+ }, [order.items, reservations, reservationList]);
2410
+ const unpaidPaymentCollection = order.payment_collections?.find(
2411
+ (pc) => pc.status !== "captured" && pc.status !== "canceled"
2412
+ );
2413
+ const pendingDifference = order.summary?.pending_difference || 0;
2414
+ const isAmountSignificant = !isAmountLessThenRoundingError(
2415
+ pendingDifference,
2416
+ order.currency_code
2417
+ );
2418
+ const showRefund = unpaidPaymentCollection && pendingDifference < 0 && isAmountSignificant;
2419
+ return /* @__PURE__ */ jsxs26(Container11, { className: "divide-y p-0", children: [
2420
+ /* @__PURE__ */ jsx25(Header3, { order, orderPreview }),
2421
+ /* @__PURE__ */ jsx25(ItemBreakdown, { order, reservations: reservationList }),
2422
+ /* @__PURE__ */ jsx25(CostBreakdown, { order }),
2423
+ /* @__PURE__ */ jsx25(Total2, { order }),
2424
+ (showReturns || showRefund || showAllocateButton) && /* @__PURE__ */ jsxs26("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
2425
+ showReturns && (receivableReturns.length === 1 ? /* @__PURE__ */ jsx25(Button7, { asChild: true, variant: "secondary", size: "small", children: /* @__PURE__ */ jsx25(
2426
+ Link4,
2427
+ {
2428
+ to: `/orders/${order.id}/returns/${receivableReturns[0].id}/receive`,
2429
+ children: t("orders.returns.receive.action")
2430
+ }
2431
+ ) }) : /* @__PURE__ */ jsx25(
2432
+ ActionMenu,
2433
+ {
2434
+ groups: [
2435
+ {
2436
+ actions: receivableReturns.map((r) => {
2437
+ let id = r.id;
2438
+ let returnType = "Return";
2439
+ if (r.exchange_id) {
2440
+ id = r.exchange_id;
2441
+ returnType = "Exchange";
2442
+ }
2443
+ if (r.claim_id) {
2444
+ id = r.claim_id;
2445
+ returnType = "Claim";
2446
+ }
2447
+ return {
2448
+ label: t("orders.returns.receive.receiveItems", {
2449
+ id: `#${id?.slice(-7)}`,
2450
+ returnType
2451
+ }),
2452
+ icon: /* @__PURE__ */ jsx25(ArrowLongRight, {}),
2453
+ to: `/orders/${order.id}/returns/${r.id}/receive`
2454
+ };
2455
+ })
2456
+ }
2457
+ ],
2458
+ children: /* @__PURE__ */ jsx25(Button7, { variant: "secondary", size: "small", children: t("orders.returns.receive.action") })
2459
+ }
2460
+ )),
2461
+ showAllocateButton && /* @__PURE__ */ jsx25(
2462
+ Button7,
2463
+ {
2464
+ asChild: true,
2465
+ variant: "secondary",
2466
+ size: "small",
2467
+ "data-testid": "order-summary-allocate-items-cta",
2468
+ children: /* @__PURE__ */ jsx25(Link4, { to: "allocate-items", children: t("orders.allocateItems.action") })
2469
+ }
2470
+ ),
2471
+ showRefund && /* @__PURE__ */ jsx25(Button7, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx25(Link4, { to: `/orders/${order.id}/refund`, children: t("orders.payment.refundAmount", {
2472
+ amount: getStylizedAmount(
2473
+ pendingDifference * -1,
2474
+ order?.currency_code
2475
+ )
2476
+ }) }) })
2477
+ ] }),
2478
+ /* @__PURE__ */ jsx25(OutstandingActions, { order })
2479
+ ] });
2480
+ };
2481
+ var Header3 = ({
2482
+ order,
2483
+ orderPreview
2484
+ }) => {
2485
+ const { t } = useTranslation24();
2486
+ const isCanceled = !!order.canceled_at;
2487
+ const returnOutOfPolicy = isOutsidePolicyWindow(order, RETURN_POLICY_DAYS);
2488
+ const exchangeOutOfPolicy = isOutsidePolicyWindow(
2489
+ order,
2490
+ EXCHANGE_POLICY_DAYS
2491
+ );
2492
+ const claimOutOfPolicy = isOutsidePolicyWindow(order, CLAIM_POLICY_DAYS);
2493
+ const shouldDisableReturn = (order.items || []).every(
2494
+ (i) => !(getReturnableQuantity(i) > 0)
2495
+ );
2496
+ const orderChange = orderPreview?.order_change;
2497
+ const isOrderEditActive = orderChange?.change_type === "edit";
2498
+ const isOrderEditPending = orderChange?.change_type === "edit" && orderChange?.status === "pending";
2499
+ const editDisabled = isCanceled || !!orderChange && orderChange.change_type !== "edit" || orderChange?.change_type === "edit" && orderChange?.status === "requested";
2500
+ const returnDisabledByChange = isOrderEditActive || !!orderChange?.exchange_id || !!orderChange?.claim_id;
2501
+ const exchangeDisabledByChange = isOrderEditActive || !!orderChange?.return_id && !orderChange?.exchange_id || !!orderChange?.claim_id;
2502
+ const claimDisabledByChange = isOrderEditActive || !!orderChange?.return_id && !orderChange?.claim_id || !!orderChange?.exchange_id;
2503
+ return /* @__PURE__ */ jsxs26("div", { className: "flex items-center justify-between px-6 py-4", children: [
2504
+ /* @__PURE__ */ jsx25(Heading11, { level: "h2", children: t("fields.summary") }),
2505
+ /* @__PURE__ */ jsx25(
2506
+ ActionMenu,
2507
+ {
2508
+ groups: [
2509
+ {
2510
+ actions: [
2511
+ {
2512
+ label: t(
2513
+ isOrderEditPending ? "orders.summary.editOrderContinue" : "orders.edits.create"
2514
+ ),
2515
+ to: "edit",
2516
+ disabled: editDisabled,
2517
+ icon: /* @__PURE__ */ jsx25(PencilSquare, {})
2518
+ }
2519
+ ]
2520
+ },
2521
+ {
2522
+ actions: [
2523
+ {
2524
+ label: t("orders.returns.create"),
2525
+ to: "returns/create",
2526
+ disabled: isCanceled || returnOutOfPolicy || shouldDisableReturn || returnDisabledByChange,
2527
+ disabledTooltip: returnOutOfPolicy ? t("orders.returns.outOfPolicy", {
2528
+ days: RETURN_POLICY_DAYS
2529
+ }) : void 0,
2530
+ icon: /* @__PURE__ */ jsx25(ArrowUturnLeft3, {})
2531
+ },
2532
+ {
2533
+ label: orderChange?.id && orderChange?.exchange_id ? t("orders.exchanges.manage") : t("orders.exchanges.create"),
2534
+ to: "exchanges/create",
2535
+ disabled: isCanceled || exchangeOutOfPolicy || shouldDisableReturn || exchangeDisabledByChange,
2536
+ disabledTooltip: exchangeOutOfPolicy ? t("orders.exchanges.outOfPolicy", {
2537
+ days: EXCHANGE_POLICY_DAYS
2538
+ }) : void 0,
2539
+ icon: /* @__PURE__ */ jsx25(ArrowPath2, {})
2540
+ },
2541
+ {
2542
+ label: orderChange?.id && orderChange?.claim_id ? t("orders.claims.manage") : t("orders.claims.create"),
2543
+ to: "claims/create",
2544
+ disabled: isCanceled || claimOutOfPolicy || shouldDisableReturn || claimDisabledByChange,
2545
+ disabledTooltip: claimOutOfPolicy ? t("orders.claims.outOfPolicy", {
2546
+ days: CLAIM_POLICY_DAYS
2547
+ }) : void 0,
2548
+ icon: /* @__PURE__ */ jsx25(ExclamationCircle2, {})
2549
+ }
2550
+ ]
2551
+ }
2552
+ ]
2553
+ }
2554
+ )
2555
+ ] });
2556
+ };
2557
+ var Item = ({
2558
+ item,
2559
+ currencyCode,
2560
+ returns,
2561
+ reservation
2562
+ }) => {
2563
+ const { t } = useTranslation24();
2564
+ const original_price = item.variant?.prices?.find((price2) => price2.currency_code === currencyCode)?.amount || 0;
2565
+ const price = item.unit_price;
2566
+ const offerInventoryLinks = item.offer?.inventory_item_link ?? [];
2567
+ const isInventoryManaged = !!offerInventoryLinks.length;
2568
+ const hasUnfulfilledItems = item.quantity - (item.detail?.fulfilled_quantity ?? 0) > 0;
2569
+ const offerSku = item.offer?.sku ?? null;
2570
+ const captionSku = offerSku ?? item.variant_sku ?? null;
2571
+ return /* @__PURE__ */ jsxs26(Fragment3, { children: [
2572
+ /* @__PURE__ */ jsxs26(
2573
+ "div",
2574
+ {
2575
+ className: "text-ui-fg-subtle grid grid-cols-2 items-center gap-x-4 px-6 py-4",
2576
+ children: [
2577
+ /* @__PURE__ */ jsxs26("div", { className: "flex items-start gap-x-4", children: [
2578
+ /* @__PURE__ */ jsx25(Thumbnail, { src: item.thumbnail }),
2579
+ /* @__PURE__ */ jsxs26("div", { children: [
2580
+ /* @__PURE__ */ jsx25(
2581
+ Text22,
2582
+ {
2583
+ size: "small",
2584
+ leading: "compact",
2585
+ weight: "plus",
2586
+ className: "text-ui-fg-base",
2587
+ children: item.title || item.product_title
2588
+ }
2589
+ ),
2590
+ captionSku && /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-x-1", children: [
2591
+ /* @__PURE__ */ jsx25(Text22, { size: "small", children: captionSku }),
2592
+ /* @__PURE__ */ jsx25(Copy5, { content: captionSku, className: "text-ui-fg-muted" })
2593
+ ] }),
2594
+ /* @__PURE__ */ jsx25(Text22, { size: "small", children: item.variant?.options?.map((o) => o.value).join(" \xB7 ") })
2595
+ ] })
2596
+ ] }),
2597
+ /* @__PURE__ */ jsxs26("div", { className: "grid grid-cols-3 items-center gap-x-4", children: [
2598
+ /* @__PURE__ */ jsx25("div", { className: "flex items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs26(Text22, { size: "small", children: [
2599
+ original_price !== price && /* @__PURE__ */ jsx25("span", { className: "line-through text-ui-fg-muted text-xs mr-1", children: getLocaleAmount(original_price, currencyCode) }),
2600
+ getLocaleAmount(price, currencyCode)
2601
+ ] }) }),
2602
+ /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-x-2", children: [
2603
+ /* @__PURE__ */ jsx25("div", { className: "w-fit min-w-[27px]", children: /* @__PURE__ */ jsxs26(Text22, { size: "small", children: [
2604
+ /* @__PURE__ */ jsx25("span", { className: "tabular-nums", children: item.quantity }),
2605
+ "x"
2606
+ ] }) }),
2607
+ /* @__PURE__ */ jsx25("div", { className: "overflow-visible", children: isInventoryManaged && hasUnfulfilledItems && /* @__PURE__ */ jsx25(
2608
+ StatusBadge4,
2609
+ {
2610
+ color: reservation ? "green" : "orange",
2611
+ className: "text-nowrap",
2612
+ children: reservation ? t("orders.reservations.allocatedLabel") : t("orders.reservations.notAllocatedLabel")
2613
+ }
2614
+ ) })
2615
+ ] }),
2616
+ /* @__PURE__ */ jsx25("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx25(Text22, { size: "small", className: "pt-[1px]", children: getLocaleAmount(item.original_total || 0, currencyCode) }) })
2617
+ ] })
2618
+ ]
2619
+ },
2620
+ item.id
2621
+ ),
2622
+ returns.map((r) => /* @__PURE__ */ jsx25(ReturnBreakdown, { orderReturn: r, itemId: item.id }, r.id))
2623
+ ] });
2624
+ };
2625
+ var ItemBreakdown = ({
2626
+ order,
2627
+ reservations
2628
+ }) => {
2629
+ const { returns: returnsList = [] } = useReturns({
2630
+ order_id: order.id,
2631
+ fields: "*items,*items.reason"
2632
+ });
2633
+ const returns = useMemo5(
2634
+ () => returnsList.filter((r) => !r.canceled_at),
2635
+ [returnsList]
2636
+ );
2637
+ const reservationsMap = useMemo5(
2638
+ () => new Map(reservations.map((r) => [r.line_item_id, r])),
2639
+ [reservations]
2640
+ );
2641
+ return /* @__PURE__ */ jsx25("div", { children: order.items?.map((item) => {
2642
+ return /* @__PURE__ */ jsx25(
2643
+ Item,
2644
+ {
2645
+ item,
2646
+ currencyCode: order.currency_code,
2647
+ returns,
2648
+ reservation: reservationsMap.get(item.id)
2649
+ },
2650
+ item.id
2651
+ );
2652
+ }) });
2653
+ };
2654
+ var ReturnBreakdownWithDamages = ({
2655
+ orderReturn,
2656
+ itemId
2657
+ }) => {
2658
+ const { t } = useTranslation24();
2659
+ const item = orderReturn.items?.find((ri) => ri.item_id === itemId);
2660
+ const damagedQuantity = item?.damaged_quantity || 0;
2661
+ if (!item || damagedQuantity <= 0) {
2662
+ return null;
2663
+ }
2664
+ return /* @__PURE__ */ jsxs26(
2665
+ "div",
2666
+ {
2667
+ 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",
2668
+ children: [
2669
+ /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-2", children: [
2670
+ /* @__PURE__ */ jsx25(ArrowDownRightMini, { className: "text-ui-fg-muted" }),
2671
+ /* @__PURE__ */ jsx25(Text22, { size: "small", children: t("orders.returns.damagedItemsReturned", {
2672
+ quantity: damagedQuantity
2673
+ }) }),
2674
+ item.note && /* @__PURE__ */ jsx25(Tooltip5, { content: item.note, children: /* @__PURE__ */ jsx25(DocumentText2, { className: "text-ui-tag-neutral-icon ml-1 inline" }) }),
2675
+ item.reason && /* @__PURE__ */ jsx25(
2676
+ Badge4,
2677
+ {
2678
+ size: "2xsmall",
2679
+ className: "cursor-default select-none capitalize",
2680
+ rounded: "full",
2681
+ children: item.reason.label
2682
+ }
2683
+ )
2684
+ ] }),
2685
+ /* @__PURE__ */ jsxs26(Text22, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
2686
+ t("orders.returns.damagedItemReceived"),
2687
+ /* @__PURE__ */ jsx25("span", { className: "ml-2", children: /* @__PURE__ */ jsx25(return_info_popover_default, { orderReturn }) })
2688
+ ] })
2689
+ ]
2690
+ },
2691
+ `${orderReturn.id}-damaged`
2692
+ );
2693
+ };
2694
+ var ReturnBreakdown = ({
2695
+ orderReturn,
2696
+ itemId
2697
+ }) => {
2698
+ const { t } = useTranslation24();
2699
+ const { getRelativeDate } = useDate();
2700
+ if (!["requested", "received", "partially_received"].includes(
2701
+ orderReturn.status || ""
2702
+ )) {
2703
+ return null;
2704
+ }
2705
+ const isRequested = orderReturn.status === "requested";
2706
+ const item = orderReturn.items?.find((ri) => ri.item_id === itemId);
2707
+ if (!item) {
2708
+ return null;
2709
+ }
2710
+ const damagedQuantity = item.damaged_quantity || 0;
2711
+ return /* @__PURE__ */ jsxs26(Fragment3, { children: [
2712
+ damagedQuantity > 0 && /* @__PURE__ */ jsx25(
2713
+ ReturnBreakdownWithDamages,
2714
+ {
2715
+ orderReturn,
2716
+ itemId
2717
+ }
2718
+ ),
2719
+ /* @__PURE__ */ jsxs26(
2720
+ "div",
2721
+ {
2722
+ 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",
2723
+ children: [
2724
+ /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-2", children: [
2725
+ /* @__PURE__ */ jsx25(ArrowDownRightMini, { className: "text-ui-fg-muted" }),
2726
+ /* @__PURE__ */ jsx25(Text22, { size: "small", children: t(
2727
+ `orders.returns.${isRequested ? "returnRequestedInfo" : "returnReceivedInfo"}`,
2728
+ {
2729
+ requestedItemsCount: isRequested ? item.quantity : item.received_quantity
2730
+ }
2731
+ ) }),
2732
+ item.note && /* @__PURE__ */ jsx25(Tooltip5, { content: item.note, children: /* @__PURE__ */ jsx25(DocumentText2, { className: "text-ui-tag-neutral-icon ml-1 inline" }) }),
2733
+ item.reason && /* @__PURE__ */ jsx25(
2734
+ Badge4,
2735
+ {
2736
+ size: "2xsmall",
2737
+ className: "cursor-default select-none capitalize",
2738
+ rounded: "full",
2739
+ children: item.reason.label
2740
+ }
2741
+ )
2742
+ ] }),
2743
+ isRequested ? /* @__PURE__ */ jsxs26(Text22, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
2744
+ getRelativeDate(orderReturn.created_at),
2745
+ /* @__PURE__ */ jsx25("span", { className: "ml-2", children: /* @__PURE__ */ jsx25(return_info_popover_default, { orderReturn }) })
2746
+ ] }) : /* @__PURE__ */ jsxs26(Text22, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
2747
+ t("orders.returns.itemReceived"),
2748
+ /* @__PURE__ */ jsx25("span", { className: "ml-2", children: /* @__PURE__ */ jsx25(return_info_popover_default, { orderReturn }) })
2749
+ ] })
2750
+ ]
2751
+ },
2752
+ item.id
2753
+ )
2754
+ ] });
2755
+ };
2756
+ var Cost = ({
2757
+ label,
2758
+ value,
2759
+ secondaryValue,
2760
+ tooltip
2761
+ }) => /* @__PURE__ */ jsxs26("div", { className: "grid grid-cols-3 items-center", children: [
2762
+ /* @__PURE__ */ jsxs26(Text22, { size: "small", leading: "compact", children: [
2763
+ label,
2764
+ " ",
2765
+ tooltip
2766
+ ] }),
2767
+ /* @__PURE__ */ jsx25("div", { className: "text-right", children: /* @__PURE__ */ jsx25(Text22, { size: "small", leading: "compact", children: secondaryValue }) }),
2768
+ /* @__PURE__ */ jsx25("div", { className: "text-right", children: /* @__PURE__ */ jsx25(Text22, { size: "small", leading: "compact", children: value }) })
2769
+ ] });
2770
+ var CostBreakdown = ({
2771
+ order
2772
+ }) => {
2773
+ const { t } = useTranslation24();
2774
+ const [isTaxOpen, setIsTaxOpen] = useState5(false);
2775
+ const [isShippingOpen, setIsShippingOpen] = useState5(false);
2776
+ const discountCodes = useMemo5(() => {
2777
+ const codes = /* @__PURE__ */ new Set();
2778
+ order.items.forEach(
2779
+ (item) => item.adjustments?.forEach((adj) => {
2780
+ codes.add(adj.code);
2781
+ })
2782
+ );
2783
+ return Array.from(codes).sort();
2784
+ }, [order]);
2785
+ const taxCodes = useMemo5(() => {
2786
+ const taxCodeMap = {};
2787
+ order.items.forEach((item) => {
2788
+ item.tax_lines?.forEach((line) => {
2789
+ taxCodeMap[line.code] = (taxCodeMap[line.code] || 0) + line.total;
2790
+ });
2791
+ });
2792
+ order.shipping_methods.forEach((sm) => {
2793
+ sm.tax_lines?.forEach((line) => {
2794
+ taxCodeMap[line.code] = (taxCodeMap[line.code] || 0) + line.total;
2795
+ });
2796
+ });
2797
+ return taxCodeMap;
2798
+ }, [order]);
2799
+ const automaticTaxesOn = !!order.region?.automatic_taxes;
2800
+ const hasTaxLines = !!Object.keys(taxCodes).length;
2801
+ const discountTotal = automaticTaxesOn ? order.discount_total : order.discount_subtotal;
2802
+ return /* @__PURE__ */ jsxs26("div", { className: "text-ui-fg-subtle flex flex-col gap-y-2 px-6 py-4", children: [
2803
+ /* @__PURE__ */ jsx25(
2804
+ Cost,
2805
+ {
2806
+ label: t(
2807
+ automaticTaxesOn ? "orders.summary.itemTotal" : "orders.summary.itemSubtotal"
2808
+ ),
2809
+ value: getLocaleAmount(order.item_total, order.currency_code)
2810
+ }
2811
+ ),
2812
+ /* @__PURE__ */ jsx25(
2813
+ Cost,
2814
+ {
2815
+ label: (
2816
+ // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
2817
+ /* @__PURE__ */ jsxs26(
2818
+ "span",
2819
+ {
2820
+ onClick: () => setIsShippingOpen((o) => !o),
2821
+ className: "flex cursor-pointer items-center gap-1",
2822
+ children: [
2823
+ /* @__PURE__ */ jsx25("span", { children: t(
2824
+ automaticTaxesOn ? "orders.summary.shippingTotal" : "orders.summary.shippingSubtotal"
2825
+ ) }),
2826
+ /* @__PURE__ */ jsx25(
2827
+ TriangleDownMini,
2828
+ {
2829
+ style: {
2830
+ transform: `rotate(${isShippingOpen ? 0 : -90}deg)`
2831
+ }
2832
+ }
2833
+ )
2834
+ ]
2835
+ }
2836
+ )
2837
+ ),
2838
+ value: getLocaleAmount(
2839
+ automaticTaxesOn ? order.shipping_total : order.shipping_subtotal,
2840
+ order.currency_code
2841
+ )
2842
+ }
2843
+ ),
2844
+ isShippingOpen && /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1 pl-5", children: (order.shipping_methods || []).sort(
2845
+ (m1, m2) => m1.created_at.localeCompare(m2.created_at)
2846
+ ).map((sm, i) => {
2847
+ return /* @__PURE__ */ jsxs26(
2848
+ "div",
2849
+ {
2850
+ className: "flex items-center justify-between gap-x-2",
2851
+ children: [
2852
+ /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsxs26("span", { className: "txt-small text-ui-fg-subtle font-medium", children: [
2853
+ sm.name,
2854
+ sm.detail?.return_id && ` (${t("fields.returnShipping")})`,
2855
+ " ",
2856
+ /* @__PURE__ */ jsx25(shipping_info_popover_default, { shippingMethod: sm }, i)
2857
+ ] }) }),
2858
+ /* @__PURE__ */ jsx25("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx25("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
2859
+ /* @__PURE__ */ jsx25("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(
2860
+ automaticTaxesOn ? sm.total : sm.subtotal,
2861
+ order.currency_code
2862
+ ) })
2863
+ ]
2864
+ },
2865
+ sm.id
2866
+ );
2867
+ }) }),
2868
+ /* @__PURE__ */ jsx25(
2869
+ Cost,
2870
+ {
2871
+ label: t(
2872
+ automaticTaxesOn ? "orders.summary.discountTotal" : "orders.summary.discountSubtotal"
2873
+ ),
2874
+ secondaryValue: discountCodes.join(", "),
2875
+ value: discountTotal > 0 ? `- ${getLocaleAmount(discountTotal, order.currency_code)}` : "-"
2876
+ }
2877
+ ),
2878
+ /* @__PURE__ */ jsxs26(Fragment3, { children: [
2879
+ /* @__PURE__ */ jsxs26("div", { className: "flex justify-between", children: [
2880
+ /* @__PURE__ */ jsxs26(
2881
+ "div",
2882
+ {
2883
+ onClick: () => hasTaxLines && setIsTaxOpen((o) => !o),
2884
+ className: clx2("flex items-center gap-1", {
2885
+ "cursor-pointer": hasTaxLines
2886
+ }),
2887
+ children: [
2888
+ /* @__PURE__ */ jsx25("span", { className: "txt-small select-none", children: t(
2889
+ automaticTaxesOn ? "orders.summary.taxTotalIncl" : "orders.summary.taxTotal"
2890
+ ) }),
2891
+ hasTaxLines && /* @__PURE__ */ jsx25(
2892
+ TriangleDownMini,
2893
+ {
2894
+ style: {
2895
+ transform: `rotate(${isTaxOpen ? 0 : -90}deg)`
2896
+ }
2897
+ }
2898
+ )
2899
+ ]
2900
+ }
2901
+ ),
2902
+ /* @__PURE__ */ jsx25("div", { className: "text-right", children: /* @__PURE__ */ jsx25(Text22, { size: "small", leading: "compact", children: getLocaleAmount(order.tax_total, order.currency_code) }) })
2903
+ ] }),
2904
+ isTaxOpen && /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1 pl-5", children: Object.entries(taxCodes).map(([code, total]) => {
2905
+ return /* @__PURE__ */ jsxs26(
2906
+ "div",
2907
+ {
2908
+ className: "flex items-center justify-between gap-x-2",
2909
+ children: [
2910
+ /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25("span", { className: "txt-small text-ui-fg-subtle font-medium", children: code }) }),
2911
+ /* @__PURE__ */ jsx25("div", { className: "relative flex-1", children: /* @__PURE__ */ jsx25("div", { className: "bottom-[calc(50% - 2px)] absolute h-[1px] w-full border-b border-dashed" }) }),
2912
+ /* @__PURE__ */ jsx25("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(total, order.currency_code) })
2913
+ ]
2914
+ },
2915
+ code
2916
+ );
2917
+ }) })
2918
+ ] })
2919
+ ] });
2920
+ };
2921
+ var Total2 = ({ order }) => {
2922
+ const { t } = useTranslation24();
2923
+ const totalCaptured = getTotalCaptured(order.payment_collections || []);
2924
+ const outstanding = Math.max(0, order.total - totalCaptured);
2925
+ return /* @__PURE__ */ jsxs26("div", { className: " flex flex-col gap-y-2 px-6 py-4", children: [
2926
+ /* @__PURE__ */ jsxs26("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
2927
+ /* @__PURE__ */ jsx25(
2928
+ Text22,
2929
+ {
2930
+ weight: "plus",
2931
+ className: "text-ui-fg-subtle",
2932
+ size: "small",
2933
+ leading: "compact",
2934
+ children: t("fields.total")
2935
+ }
2936
+ ),
2937
+ /* @__PURE__ */ jsx25(
2938
+ Text22,
2939
+ {
2940
+ weight: "plus",
2941
+ className: "text-ui-fg-subtle",
2942
+ size: "small",
2943
+ leading: "compact",
2944
+ children: getStylizedAmount(order.total, order.currency_code)
2945
+ }
2946
+ )
2947
+ ] }),
2948
+ /* @__PURE__ */ jsxs26("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
2949
+ /* @__PURE__ */ jsx25(
2950
+ Text22,
2951
+ {
2952
+ weight: "plus",
2953
+ className: "text-ui-fg-subtle",
2954
+ size: "small",
2955
+ leading: "compact",
2956
+ children: t("fields.paidTotal")
2957
+ }
2958
+ ),
2959
+ /* @__PURE__ */ jsx25(
2960
+ Text22,
2961
+ {
2962
+ weight: "plus",
2963
+ className: "text-ui-fg-subtle",
2964
+ size: "small",
2965
+ leading: "compact",
2966
+ children: getStylizedAmount(totalCaptured, order.currency_code)
2967
+ }
2968
+ )
2969
+ ] }),
2970
+ /* @__PURE__ */ jsxs26("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
2971
+ /* @__PURE__ */ jsx25(Text22, { weight: "plus", size: "small", leading: "compact", children: t("orders.payment.outstandingAmount") }),
2972
+ /* @__PURE__ */ jsx25(Text22, { weight: "plus", size: "small", leading: "compact", children: getStylizedAmount(outstanding, order.currency_code) })
2973
+ ] })
2974
+ ] });
2975
+ };
2976
+ var OutstandingActions = ({ order }) => {
2977
+ const { t } = useTranslation24();
2978
+ const unpaidCollection = order.payment_collections?.find(
2979
+ (pc) => pc.status !== "captured" && pc.status !== "canceled"
2980
+ );
2981
+ const pendingDifference = order.summary?.pending_difference || 0;
2982
+ const isOutstanding = pendingDifference > 5e-3 && order.status !== "canceled" && !!unpaidCollection;
2983
+ if (!isOutstanding || !unpaidCollection) {
2984
+ return null;
2985
+ }
2986
+ const paymentLink = unpaidCollection.payment_sessions?.[0]?.data?.url ?? null;
2987
+ if (!paymentLink) {
2988
+ return null;
2989
+ }
2990
+ const handleCopyLink = async () => {
2991
+ try {
2992
+ await navigator.clipboard.writeText(paymentLink);
2993
+ toast7.success(t("orders.payment.copyLinkSuccess"));
2994
+ } catch {
2995
+ toast7.error(t("orders.payment.copyLinkError"));
2996
+ }
2997
+ };
2998
+ return /* @__PURE__ */ jsx25("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: /* @__PURE__ */ jsx25(Button7, { size: "small", variant: "secondary", onClick: handleCopyLink, children: t("orders.payment.copyPaymentLink", {
2999
+ amount: getStylizedAmount(pendingDifference, order.currency_code)
3000
+ }) }) });
3001
+ };
3002
+
3003
+ // src/pages/orders/[id]/order-detail-page.tsx
3004
+ import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs27 } from "react/jsx-runtime";
3005
+ var Root = ({ children }) => {
3006
+ const initialData = useLoaderData();
3007
+ const { id } = useParams();
3008
+ const { order, isLoading, isError, error } = useOrder(
3009
+ id,
3010
+ {
3011
+ fields: DEFAULT_FIELDS
3012
+ },
3013
+ {
3014
+ initialData
3015
+ }
3016
+ );
3017
+ const { order: orderPreview, isLoading: isPreviewLoading } = useOrderPreview(
3018
+ id
3019
+ );
3020
+ if (order) {
3021
+ order.items = order.items.sort((itemA, itemB) => {
3022
+ if (itemA.created_at > itemB.created_at) {
3023
+ return 1;
3024
+ }
3025
+ if (itemA.created_at < itemB.created_at) {
3026
+ return -1;
3027
+ }
3028
+ return 0;
3029
+ });
3030
+ }
3031
+ if (isLoading || !order || isPreviewLoading) {
3032
+ return /* @__PURE__ */ jsx26(TwoColumnPageSkeleton, { mainSections: 4, sidebarSections: 2, showJSON: true });
3033
+ }
3034
+ if (isError) {
3035
+ throw error;
3036
+ }
3037
+ return /* @__PURE__ */ jsx26(Fragment4, { children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs27(TwoColumnPage, { data: order, hasOutlet: true, showMetadata: true, showJSON: true, children: [
3038
+ /* @__PURE__ */ jsxs27(TwoColumnPage.Main, { children: [
3039
+ /* @__PURE__ */ jsx26(OrderActiveEditSection, { order }),
3040
+ orderPreview && /* @__PURE__ */ jsxs27(Fragment4, { children: [
3041
+ /* @__PURE__ */ jsx26(ActiveOrderClaimSection, { orderPreview }),
3042
+ /* @__PURE__ */ jsx26(ActiveOrderExchangeSection, { orderPreview }),
3043
+ /* @__PURE__ */ jsx26(ActiveOrderReturnSection, { orderPreview })
3044
+ ] }),
3045
+ /* @__PURE__ */ jsx26(OrderGeneralSection, { order }),
3046
+ /* @__PURE__ */ jsx26(OrderSummarySection, { order }),
3047
+ /* @__PURE__ */ jsx26(OrderCommissionSection, { order }),
3048
+ /* @__PURE__ */ jsx26(OrderPaymentSection, { order }),
3049
+ /* @__PURE__ */ jsx26(OrderFulfillmentSection, { order })
3050
+ ] }),
3051
+ /* @__PURE__ */ jsxs27(TwoColumnPage.Sidebar, { children: [
3052
+ /* @__PURE__ */ jsx26(OrderCustomerSection, { order }),
3053
+ /* @__PURE__ */ jsx26(OrderActivitySection, { order })
3054
+ ] })
3055
+ ] }) });
3056
+ };
3057
+ var OrderDetailPage = Object.assign(Root, {
3058
+ Main: TwoColumnPage.Main,
3059
+ Sidebar: TwoColumnPage.Sidebar,
3060
+ MainActiveEditSection: OrderActiveEditSection,
3061
+ MainActiveClaimSection: ActiveOrderClaimSection,
3062
+ MainActiveExchangeSection: ActiveOrderExchangeSection,
3063
+ MainActiveReturnSection: ActiveOrderReturnSection,
3064
+ MainGeneralSection: OrderGeneralSection,
3065
+ MainSummarySection: OrderSummarySection,
3066
+ MainPaymentSection: OrderPaymentSection,
3067
+ MainFulfillmentSection: OrderFulfillmentSection,
3068
+ SidebarCustomerSection: OrderCustomerSection,
3069
+ SidebarActivitySection: OrderActivitySection
3070
+ });
3071
+ export {
3072
+ OrderDetailPage,
3073
+ loader
3074
+ };