@mercurjs/vendor 2.2.0-canary.2 → 2.2.0-canary.20

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 (261) hide show
  1. package/dist/{[id]-KRLGIVLR.js → [id]-26KNXVZ3.js} +22 -21
  2. package/dist/{[id]-KVWYLDN3.js → [id]-45QR6M3C.js} +21 -20
  3. package/dist/[id]-7MPUE2JE.js +3111 -0
  4. package/dist/{[id]-7BAKUHUO.js → [id]-DDGHFRSB.js} +5 -5
  5. package/dist/{[id]-LUFRJLAU.js → [id]-E76GYCHF.js} +34 -32
  6. package/dist/{[id]-4OBGG7OH.js → [id]-FIP4UMQ4.js} +197 -105
  7. package/dist/{[id]-3EC6HYXL.js → [id]-FZRXOJWL.js} +22 -21
  8. package/dist/{[id]-UUUQK22M.js → [id]-Q5AXQ5XO.js} +460 -581
  9. package/dist/{[id]-KJIQTFGE.js → [id]-VSNA6SV5.js} +15 -15
  10. package/dist/{[id]-ZWWMJAKI.js → [id]-W4ARB473.js} +7 -7
  11. package/dist/{[id]-K2CT7BXQ.js → [id]-YPCO3DJV.js} +1 -1
  12. package/dist/{[id]-Y2ISCLUD.js → [id]-ZB25Z6NK.js} +3 -3
  13. package/dist/{[id]-COLO4TQJ.js → [id]-ZW7TBWDU.js} +24 -23
  14. package/dist/{[province_id]-H2QAPKVH.js → [province_id]-CHOO7ERP.js} +14 -14
  15. package/dist/{add-PBZQCIZQ.js → add-IC5R27X3.js} +95 -32
  16. package/dist/{add-FIWTANZX.js → add-TFZ5CKSA.js} +38 -36
  17. package/dist/{add-customer-groups-RAHCP67U.js → add-customer-groups-KIGBZT5G.js} +20 -23
  18. package/dist/{add-products-N3V2MVLD.js → add-products-ALJVIFXU.js} +23 -22
  19. package/dist/{add-promotions-CSCAJZHV.js → add-promotions-3KKONG7D.js} +8 -8
  20. package/dist/{add-to-campaign-DLP7PSQB.js → add-to-campaign-C6JDNB6F.js} +4 -4
  21. package/dist/{address-7F5SN7PV.js → address-UKLDTSTP.js} +13 -13
  22. package/dist/{adjust-inventory-SZF4W7LR.js → adjust-inventory-5XPGE44Y.js} +2 -2
  23. package/dist/allocate-items-UOSOCC6N.js +654 -0
  24. package/dist/{areas-7Y6BVS5A.js → areas-64VXOFYS.js} +6 -6
  25. package/dist/{attributes-MBZ76HVZ.js → attributes-YQNW5JBY.js} +2 -2
  26. package/dist/{breadcrumb-HND5FFWC.js → breadcrumb-26G7BS3Q.js} +3 -3
  27. package/dist/{breadcrumb-7PURSRTT.js → breadcrumb-2AYN2SV7.js} +12 -12
  28. package/dist/{breadcrumb-ZCG2RHIU.js → breadcrumb-4KKLMVC3.js} +12 -12
  29. package/dist/{breadcrumb-WRG4SITG.js → breadcrumb-4XSHX5RV.js} +13 -13
  30. package/dist/{breadcrumb-QV2IAX7N.js → breadcrumb-E5OF4L2J.js} +2 -2
  31. package/dist/breadcrumb-JC5FUQYF.js +28 -0
  32. package/dist/{breadcrumb-YBBYFQYG.js → breadcrumb-LBO2I4OJ.js} +1 -1
  33. package/dist/breadcrumb-PIDJ23EZ.js +13 -0
  34. package/dist/{breadcrumb-65SAGUUL.js → breadcrumb-RWYEU5JK.js} +3 -3
  35. package/dist/{breadcrumb-VWELWDB2.js → breadcrumb-VXKAO6GP.js} +1 -1
  36. package/dist/{breadcrumb-FLDHJRVY.js → breadcrumb-WMNG4P6C.js} +9 -8
  37. package/dist/{breadcrumb-EDPMEN2P.js → breadcrumb-XPQETVMM.js} +2 -2
  38. package/dist/{campaigns-L6ULR6KR.js → campaigns-4I2T6EDZ.js} +5 -5
  39. package/dist/{categories-FUZQKBXV.js → categories-VYVQ5G3H.js} +7 -7
  40. package/dist/{chunk-EZ3JOAUS.js → chunk-22CIYLKO.js} +1 -1
  41. package/dist/{chunk-RZLN2Q6G.js → chunk-247L47JD.js} +1 -1
  42. package/dist/{chunk-SFQKKIHA.js → chunk-27WLUOI2.js} +1 -1
  43. package/dist/{chunk-M7KSRYRI.js → chunk-2ECD67FO.js} +2 -2
  44. package/dist/{chunk-36L54SQQ.js → chunk-2H4FGZ4U.js} +1 -1
  45. package/dist/{chunk-X2FVFUET.js → chunk-2NUZTTBU.js} +27 -8
  46. package/dist/chunk-2OY4NW7L.js +185 -0
  47. package/dist/{chunk-K4X324QP.js → chunk-36WXPGD2.js} +6 -5
  48. package/dist/{chunk-PXYDR7WQ.js → chunk-3BXCPHN6.js} +3 -2
  49. package/dist/chunk-3EDZQSKG.js +33 -0
  50. package/dist/{chunk-UAF2S447.js → chunk-4OIOYUQE.js} +3 -3
  51. package/dist/{chunk-UORPTGV2.js → chunk-4R5GESED.js} +10 -14
  52. package/dist/{chunk-6Y53VZ3C.js → chunk-4XSO2NKC.js} +10 -10
  53. package/dist/chunk-4YWKKCTT.js +32 -0
  54. package/dist/{chunk-XFQJU6FA.js → chunk-5QG6P6EU.js} +1 -1
  55. package/dist/{chunk-N4MVIBFM.js → chunk-5Y6RDTW2.js} +3 -3
  56. package/dist/{chunk-DZIXC7OE.js → chunk-6FLSBL4Q.js} +30 -85
  57. package/dist/{chunk-DVEKYLPV.js → chunk-6QS6IZC6.js} +1 -1
  58. package/dist/{chunk-WUPJADSO.js → chunk-6XO5XJJX.js} +2 -2
  59. package/dist/chunk-6ZGQ3SOR.js +127 -0
  60. package/dist/{chunk-NXNJQZCP.js → chunk-7FIPNQM2.js} +1 -1
  61. package/dist/{chunk-NSZQERLE.js → chunk-7GGWRJJF.js} +2 -2
  62. package/dist/{chunk-QS6RWIBL.js → chunk-7RGUD6PI.js} +34 -20
  63. package/dist/{chunk-5L2DCA4W.js → chunk-7ZPJGL4C.js} +57 -6
  64. package/dist/{chunk-KD7RYE6R.js → chunk-AG6KIAUD.js} +2 -2
  65. package/dist/{chunk-CNMY5HVP.js → chunk-AJREJFHL.js} +2 -2
  66. package/dist/chunk-CHBURL76.js +438 -0
  67. package/dist/{chunk-PBD36EZJ.js → chunk-CI4YXVQF.js} +2 -2
  68. package/dist/{chunk-7LBY5JLV.js → chunk-DAV7WS53.js} +1 -1
  69. package/dist/{chunk-6BS2AVGJ.js → chunk-DNXMONCL.js} +6 -6
  70. package/dist/{chunk-TNVYTMBL.js → chunk-E4O5PARZ.js} +4 -4
  71. package/dist/{chunk-L7QKFC5N.js → chunk-E6W57UP3.js} +32 -122
  72. package/dist/chunk-FP6U6BPH.js +61 -0
  73. package/dist/{chunk-SGR4DMCW.js → chunk-FRYZRBLA.js} +1 -1
  74. package/dist/chunk-FWPGOIFA.js +22 -0
  75. package/dist/chunk-GL7F6NDU.js +30 -0
  76. package/dist/{chunk-EROX26D4.js → chunk-GLOEJSV4.js} +1 -1
  77. package/dist/{chunk-UCQKXXLD.js → chunk-GMIN5OB5.js} +2 -2
  78. package/dist/chunk-H7BVANDX.js +407 -0
  79. package/dist/{chunk-FDR22JMM.js → chunk-HFRHHT36.js} +8 -63
  80. package/dist/{chunk-FJUUGFXL.js → chunk-HOUDNM5M.js} +1 -1
  81. package/dist/chunk-I75SROQZ.js +315 -0
  82. package/dist/{chunk-DARJTN4I.js → chunk-IMJ62GAP.js} +10 -5
  83. package/dist/{chunk-PPLC4IKI.js → chunk-IV57G2CB.js} +14 -1
  84. package/dist/{chunk-7SLWXX6L.js → chunk-J434WDD3.js} +5 -6
  85. package/dist/chunk-J6XCRFBW.js +30 -0
  86. package/dist/{chunk-KAZ5BYTQ.js → chunk-KCHYLLVG.js} +6 -4
  87. package/dist/{chunk-YGRTRAWX.js → chunk-KDE4HKH2.js} +1 -0
  88. package/dist/{chunk-GXIAIITP.js → chunk-KZYRC3WR.js} +36 -39
  89. package/dist/chunk-L57USMYC.js +39 -0
  90. package/dist/chunk-LFX6WU4A.js +36 -0
  91. package/dist/{chunk-LWJF63JW.js → chunk-LTQQRVZG.js} +89 -14
  92. package/dist/{chunk-DIW4GRTI.js → chunk-M2JP43HN.js} +47 -31
  93. package/dist/{chunk-NHFEY3EI.js → chunk-M3YUT5AY.js} +2 -2
  94. package/dist/{chunk-H6LZ77GX.js → chunk-MJCL3WID.js} +1 -1
  95. package/dist/{chunk-X4INVIWL.js → chunk-MZRZVLWD.js} +3 -3
  96. package/dist/{chunk-QXLRABYH.js → chunk-O7VOGTLX.js} +1 -1
  97. package/dist/{chunk-35G3SZRN.js → chunk-P3SOE76R.js} +1 -1
  98. package/dist/{chunk-PZ44R4AS.js → chunk-P7Q5ZSZD.js} +1 -1
  99. package/dist/{chunk-5ATEALH7.js → chunk-PFJFS3F4.js} +1 -5
  100. package/dist/chunk-POOTMH3K.js +62 -0
  101. package/dist/{chunk-GGWUWT55.js → chunk-QJI4OET7.js} +23 -36
  102. package/dist/{chunk-NJMNYS7G.js → chunk-QS35HWC5.js} +1 -1
  103. package/dist/{chunk-QT7YFHCA.js → chunk-S23FD6FA.js} +12 -0
  104. package/dist/{chunk-U2ZFCAPX.js → chunk-SITRHMZZ.js} +11 -8
  105. package/dist/chunk-SPFLYPY6.js +6 -0
  106. package/dist/{chunk-EIUYXS7E.js → chunk-SZBERGA4.js} +1 -1
  107. package/dist/chunk-T6DSYOY5.js +173 -0
  108. package/dist/{chunk-4LVP635F.js → chunk-TKSKCYM3.js} +128 -126
  109. package/dist/{chunk-QNNJN4H6.js → chunk-TSTUAL6N.js} +59 -0
  110. package/dist/{chunk-LNM2D2I4.js → chunk-TZMNEN7A.js} +7 -6
  111. package/dist/chunk-UM7ZR3VU.js +14 -0
  112. package/dist/{chunk-X22KTLZ7.js → chunk-UO6IX5Y7.js} +1 -1
  113. package/dist/chunk-VCUUITW6.js +35 -0
  114. package/dist/{chunk-RTBNJQOV.js → chunk-VDH3AG7D.js} +419 -538
  115. package/dist/{chunk-DDH7ULIQ.js → chunk-VKMNSMCS.js} +1 -1
  116. package/dist/{chunk-44RQ5PTN.js → chunk-WBFAUHKO.js} +185 -85
  117. package/dist/{chunk-LQD232FW.js → chunk-WJ5EU3KW.js} +1 -1
  118. package/dist/{chunk-AIF2KTEE.js → chunk-WKRW5OPL.js} +12 -2
  119. package/dist/{chunk-6YA3C4NB.js → chunk-XBKWFLJG.js} +4 -13
  120. package/dist/{chunk-WBHFU3MG.js → chunk-XJYQ4SW5.js} +2 -2
  121. package/dist/chunk-XQUF3WIS.js +159 -0
  122. package/dist/chunk-YBF45CX5.js +23 -0
  123. package/dist/{chunk-AVOIZO63.js → chunk-YQZBAP3S.js} +4 -2
  124. package/dist/{chunk-2DXNJURE.js → chunk-YXJYCCIU.js} +1 -1
  125. package/dist/chunk-ZHFFTT3I.js +17 -0
  126. package/dist/{chunk-TODJFRLH.js → chunk-ZHR77OQI.js} +2 -2
  127. package/dist/chunk-ZUHIKMQL.js +353 -0
  128. package/dist/{collections-YCAAFGSW.js → collections-A5GNFU6H.js} +25 -25
  129. package/dist/{configuration-UOSNP45I.js → configuration-5IDQRYJQ.js} +4 -4
  130. package/dist/{configuration-C4IGBNXH.js → configuration-TXRAYMI4.js} +1 -1
  131. package/dist/{create-BJ4OO6LS.js → create-2N73Y6FO.js} +14 -14
  132. package/dist/{create-R7K3ECN6.js → create-3MUVY3UY.js} +1 -1
  133. package/dist/{create-SFU3W3ZH.js → create-6DRXGPYA.js} +1 -1
  134. package/dist/{create-XAD5NMSJ.js → create-6KM5AZCG.js} +20 -20
  135. package/dist/{create-YDDBH4VQ.js → create-A6CPQMMH.js} +27 -26
  136. package/dist/create-B4EWCX7X.js +1798 -0
  137. package/dist/{create-YBF4YGWG.js → create-BHSMHOFN.js} +1 -1
  138. package/dist/{create-XVHOCZHJ.js → create-BVUZWMET.js} +1 -1
  139. package/dist/create-CJEZCYN6.js +1179 -0
  140. package/dist/create-DAVMJNC2.js +1931 -0
  141. package/dist/{create-35MYQPVM.js → create-E4HTVPP7.js} +17 -17
  142. package/dist/{create-JDGM5KXE.js → create-G4TF2M7G.js} +88 -42
  143. package/dist/{create-HI5UI2EZ.js → create-HU3EIJO6.js} +31 -26
  144. package/dist/{create-B5ZXTK3K.js → create-KV4S6DA2.js} +35 -33
  145. package/dist/{create-UQNYMVBM.js → create-LOP7AF5N.js} +6 -6
  146. package/dist/{create-UPYB65PD.js → create-MKFDE32U.js} +1 -1
  147. package/dist/{create-GB3ZA4LH.js → create-SYI6DVKM.js} +4 -4
  148. package/dist/{create-ORXYT74H.js → create-ZAGMLDR4.js} +13 -13
  149. package/dist/create-ZP4LSJYQ.js +216 -0
  150. package/dist/customer-group-add-customers-GTM556QA.js +251 -0
  151. package/dist/customer-group-create-OYHAXX2T.js +140 -0
  152. package/dist/customer-group-detail-KW62TLWA.js +58 -0
  153. package/dist/customer-group-edit-WH7O4N4L.js +137 -0
  154. package/dist/customer-groups-UJFZBZ2B.js +276 -0
  155. package/dist/{customers-ETXVNM3G.js → customers-4WKIFPUU.js} +7 -7
  156. package/dist/{edit-ZMERG3L7.js → edit-3VNT35DW.js} +1 -1
  157. package/dist/{edit-ORXS3A2Y.js → edit-6DUTTLEV.js} +1 -1
  158. package/dist/{edit-REDDBLTA.js → edit-6Z6RIJRZ.js} +4 -4
  159. package/dist/{edit-2Q7TRUTL.js → edit-CVSO5CX7.js} +14 -14
  160. package/dist/{edit-ZAHCMF5U.js → edit-FQDSESVI.js} +1 -1
  161. package/dist/edit-GZXLWSTL.js +176 -0
  162. package/dist/edit-HOIS3BEW.js +103 -0
  163. package/dist/edit-LLNKSZR4.js +871 -0
  164. package/dist/{edit-O4JLGKQR.js → edit-MKVDAUA5.js} +1 -1
  165. package/dist/{edit-ZCXUG42Q.js → edit-NDUSRTWY.js} +13 -13
  166. package/dist/{edit-522DG3BY.js → edit-RBREBAQQ.js} +1 -1
  167. package/dist/{edit-Q3UQIOLS.js → edit-RQHOHZR6.js} +1 -1
  168. package/dist/{edit-L5ZZLMAY.js → edit-RXDAL7SX.js} +43 -32
  169. package/dist/{edit-VKT62KHG.js → edit-SAB6F3ZG.js} +36 -15
  170. package/dist/{edit-C4OCKQVU.js → edit-SM2GHVKW.js} +1 -1
  171. package/dist/{edit-KAKVPHZZ.js → edit-UVY3TEHD.js} +1 -1
  172. package/dist/{edit-SGUY2CCK.js → edit-V7WLYLOQ.js} +16 -16
  173. package/dist/{edit-UGEC27HP.js → edit-VPU333HQ.js} +37 -35
  174. package/dist/{edit-FKXIQ6ZI.js → edit-XMZSLH4O.js} +16 -16
  175. package/dist/{edit-budget-L3CCEWNF.js → edit-budget-4JMGEPNF.js} +1 -1
  176. package/dist/{edit-inventory-item-6B7ITDGD.js → edit-inventory-item-G22KFCYY.js} +2 -2
  177. package/dist/{edit-inventory-item-attributes-Y7MQZLXI.js → edit-inventory-item-attributes-RJSM4MEI.js} +2 -2
  178. package/dist/edit-price-K6K2FTMF.js +196 -0
  179. package/dist/edit-stock-6TUSJD5R.js +229 -0
  180. package/dist/fulfillment-6I3ERWZW.js +654 -0
  181. package/dist/{fulfillment-providers-DQAU43JZ.js → fulfillment-providers-VKBWFH45.js} +24 -24
  182. package/dist/index.css +107 -10
  183. package/dist/index.js +302 -183
  184. package/dist/{inventory-KAUVPMPZ.js → inventory-OCIGVZ4V.js} +6 -6
  185. package/dist/{offer-inventory-batch-page-WKCWNDNK.js → inventory-T7BRSFKY.js} +16 -16
  186. package/dist/{invite-CI2P4GF6.js → invite-J6L3Q7MQ.js} +12 -12
  187. package/dist/{invite-Q6EYDZVQ.js → invite-VWNUFOFI.js} +21 -21
  188. package/dist/loader-2EQ4ROTD.js +34 -0
  189. package/dist/loader-HYUC2XZX.js +33 -0
  190. package/dist/{login-KY342RMK.js → login-WOZMCEFY.js} +12 -12
  191. package/dist/{manage-locations-WNHEBS3A.js → manage-locations-R3ASMF5B.js} +1 -1
  192. package/dist/{media-B6ME2WXY.js → media-Q3AN34MZ.js} +18 -17
  193. package/dist/media-RJHUSBXL.js +315 -0
  194. package/dist/{metadata-WR4RFXO5.js → metadata-45S6CFKY.js} +14 -14
  195. package/dist/{metadata-2CMH4I6U.js → metadata-FCATUWIZ.js} +14 -14
  196. package/dist/{metadata-GWI6R4ES.js → metadata-L5GBBXC4.js} +14 -14
  197. package/dist/{metadata-TLDUF5KV.js → metadata-R4ZRMAO6.js} +14 -14
  198. package/dist/{metadata-NUXUC2JA.js → metadata-RM5VVAOS.js} +14 -14
  199. package/dist/{offer-create-page-4Z6L63BU.js → offer-create-page-ZRPBFHZO.js} +186 -189
  200. package/dist/offer-detail-page-TIBYGQBS.js +590 -0
  201. package/dist/offer-variant-detail-page-LYG62KTY.js +421 -0
  202. package/dist/offers-VA63KV3C.js +54 -0
  203. package/dist/{onboarding-43LQQQGQ.js → onboarding-L5RRKT65.js} +12 -12
  204. package/dist/{orders-ZV4D6L2V.js → orders-KKJD6EWZ.js} +27 -27
  205. package/dist/{organization-ZTQGRJWS.js → organization-6YPU2RQP.js} +53 -89
  206. package/dist/{organize-K6QMAMEN.js → organize-LR7FWK2J.js} +3 -3
  207. package/dist/{organize-HNJUHEEG.js → organize-SUG4SGVR.js} +3 -3
  208. package/dist/pages/index.d.ts +40 -16
  209. package/dist/pages/index.js +70 -71
  210. package/dist/{payment-details-64US5XWD.js → payment-details-UVEIHQA5.js} +13 -13
  211. package/dist/{payouts-UXJDTXDL.js → payouts-D4A4CILI.js} +8 -8
  212. package/dist/{price-lists-KBPUVSZI.js → price-lists-WJFXFGEV.js} +10 -10
  213. package/dist/{pricing-DF6C5XK4.js → pricing-QEVR2Z4K.js} +19 -19
  214. package/dist/{offer-pricing-edit-page-4TYGGSOE.js → pricing-XJUUCYL5.js} +24 -18
  215. package/dist/{product-tags-6MZB4W5R.js → product-tags-RNK4N72O.js} +34 -32
  216. package/dist/{product-types-UUHBV4IZ.js → product-types-XXU7X42K.js} +6 -6
  217. package/dist/product-variant-detail-XZWTSH3H.js +369 -0
  218. package/dist/{product-variant-edit-YYNPHE4L.js → product-variant-edit-A2KO3E7B.js} +41 -44
  219. package/dist/{products-MZBU5MEV.js → products-P5DGEYTS.js} +37 -37
  220. package/dist/{products-IWKTGZS6.js → products-XSXEUKIB.js} +23 -22
  221. package/dist/{professional-details-5T2VS6MM.js → professional-details-ELUEJPOH.js} +13 -13
  222. package/dist/{profile-6XGHAT7H.js → profile-EDVGIBW6.js} +16 -16
  223. package/dist/{promotions-O7U4BTK6.js → promotions-SY4DKTT5.js} +8 -8
  224. package/dist/receive-47SMYKIJ.js +578 -0
  225. package/dist/refund-IU7B77FV.js +268 -0
  226. package/dist/{register-N6WOSMLA.js → register-JZK5LFZU.js} +14 -14
  227. package/dist/{reset-password-EICPAY2N.js → reset-password-HGLJ75PJ.js} +1 -1
  228. package/dist/{return-reasons-IX3LIOCU.js → return-reasons-2TMOZGMV.js} +16 -14
  229. package/dist/{sales-channels-JW3QUYR7.js → sales-channels-ETB6QRRY.js} +8 -8
  230. package/dist/{sales-channels-B6FULRWI.js → sales-channels-YXRRARDL.js} +7 -7
  231. package/dist/{settings-MV53ZZ53.js → settings-QEARGBMK.js} +36 -34
  232. package/dist/shipment-ZX6PQ32L.js +241 -0
  233. package/dist/shipping-UBQAPPM4.js +113 -0
  234. package/dist/{shipping-profile-Y4SNEPZX.js → shipping-profile-L5CFXVEE.js} +4 -8
  235. package/dist/{shipping-profiles-2NWKCEJK.js → shipping-profiles-QBJUWXVQ.js} +17 -17
  236. package/dist/{stock-7CSVEJJU.js → stock-FW4DOVFV.js} +14 -14
  237. package/dist/{store-X23G3JCJ.js → store-NWWBV2UO.js} +75 -144
  238. package/dist/{store-closure-P5PD2RSV.js → store-closure-O3CBSOJD.js} +19 -14
  239. package/dist/{store-select-TREPDS3G.js → store-select-C7GI5MKK.js} +13 -13
  240. package/dist/{tax-regions-YXZW7UVX.js → tax-regions-2JCIB4T7.js} +2 -2
  241. package/dist/{team-SPP5OY5W.js → team-MY24J5WO.js} +20 -20
  242. package/package.json +2 -2
  243. package/dist/[id]-LTNOHLGE.js +0 -1219
  244. package/dist/allocate-items-SDFS5GYN.js +0 -533
  245. package/dist/chunk-432S4FGR.js +0 -0
  246. package/dist/chunk-AIZM66CG.js +0 -66
  247. package/dist/chunk-CFRWIQIZ.js +0 -43
  248. package/dist/chunk-GKZHBXZK.js +0 -426
  249. package/dist/chunk-RXZFEFNV.js +0 -73
  250. package/dist/chunk-T6LHVNWO.js +0 -27
  251. package/dist/chunk-WLT7K7K7.js +0 -63
  252. package/dist/create-FCKGCZSM.js +0 -210
  253. package/dist/edit-GQNIINRR.js +0 -192
  254. package/dist/fulfillment-75Z4H23W.js +0 -559
  255. package/dist/loader-FBB5OQRT.js +0 -31
  256. package/dist/metadata-5BPOBBU2.js +0 -45
  257. package/dist/offer-detail-page-6MAHNNIO.js +0 -488
  258. package/dist/offer-edit-page-DYQFU6JU.js +0 -151
  259. package/dist/offers-ZG6OTDZ2.js +0 -32
  260. package/dist/product-variant-detail-RVWEYVPC.js +0 -220
  261. package/dist/shipment-Q33QBMXX.js +0 -176
@@ -0,0 +1,3111 @@
1
+ import {
2
+ useCancelOrderEdit,
3
+ useConfirmOrderEdit
4
+ } from "./chunk-6ZGQ3SOR.js";
5
+ import {
6
+ useCancelExchangeBegin,
7
+ useExchanges
8
+ } from "./chunk-2OY4NW7L.js";
9
+ import {
10
+ CLAIM_POLICY_DAYS,
11
+ EXCHANGE_POLICY_DAYS,
12
+ RETURN_POLICY_DAYS,
13
+ isOutsidePolicyWindow
14
+ } from "./chunk-VCUUITW6.js";
15
+ import {
16
+ useCancelClaimBegin,
17
+ useClaims
18
+ } from "./chunk-T6DSYOY5.js";
19
+ import {
20
+ useCancelReturn,
21
+ useCancelReturnRequest,
22
+ useReturns
23
+ } from "./chunk-CHBURL76.js";
24
+ import {
25
+ getReturnableQuantity
26
+ } from "./chunk-UM7ZR3VU.js";
27
+ import {
28
+ DEFAULT_FIELDS
29
+ } from "./chunk-IMJ62GAP.js";
30
+ import "./chunk-BCU3FKP2.js";
31
+ import {
32
+ formatProvider
33
+ } from "./chunk-VW56KWO2.js";
34
+ import {
35
+ getFormattedAddress,
36
+ isSameAddress
37
+ } from "./chunk-W6Y3PPU5.js";
38
+ import {
39
+ getCanceledOrderStatus,
40
+ getOrderFulfillmentStatus,
41
+ getOrderPaymentStatus
42
+ } from "./chunk-LQSLDDPT.js";
43
+ import {
44
+ getLocaleAmount,
45
+ getStylizedAmount,
46
+ isAmountLessThenRoundingError
47
+ } from "./chunk-3BXCPHN6.js";
48
+ import "./chunk-JRTZWK77.js";
49
+ import "./chunk-IQPN4PZJ.js";
50
+ import {
51
+ TwoColumnPage
52
+ } from "./chunk-YV6MK4PZ.js";
53
+ import {
54
+ useDate
55
+ } from "./chunk-LRD242C7.js";
56
+ import {
57
+ Thumbnail
58
+ } from "./chunk-WIYFXWRI.js";
59
+ import {
60
+ Skeleton,
61
+ TwoColumnPageSkeleton
62
+ } from "./chunk-INNFZYX2.js";
63
+ import {
64
+ useMarkPaymentCollectionAsPaid
65
+ } from "./chunk-KZYRC3WR.js";
66
+ import "./chunk-F4OJN2F2.js";
67
+ import "./chunk-LRARA622.js";
68
+ import "./chunk-M6N4ISXL.js";
69
+ import "./chunk-S7EKBD2C.js";
70
+ import "./chunk-VV6IKGCN.js";
71
+ import "./chunk-M3YUT5AY.js";
72
+ import "./chunk-BOZJOOGW.js";
73
+ import "./chunk-IQWK723D.js";
74
+ import "./chunk-4S6XGIC6.js";
75
+ import {
76
+ useMember
77
+ } from "./chunk-S23FD6FA.js";
78
+ import "./chunk-7FIPNQM2.js";
79
+ import {
80
+ useCustomer
81
+ } from "./chunk-LTQQRVZG.js";
82
+ import "./chunk-VXWN37PT.js";
83
+ import "./chunk-247L47JD.js";
84
+ import "./chunk-POOTMH3K.js";
85
+ import "./chunk-VXMOPVRH.js";
86
+ import {
87
+ useStockLocation
88
+ } from "./chunk-NBPMNUKZ.js";
89
+ import "./chunk-4R5GESED.js";
90
+ import {
91
+ ordersQueryKeys,
92
+ useCancelOrder,
93
+ useCancelOrderFulfillment,
94
+ useMarkOrderFulfillmentAsDelivered,
95
+ useOrder,
96
+ useOrderChanges,
97
+ useOrderCommissionLines,
98
+ useOrderPreview,
99
+ useReservationItems
100
+ } from "./chunk-7RGUD6PI.js";
101
+ import "./chunk-3B34B2M2.js";
102
+ import {
103
+ ActionMenu
104
+ } from "./chunk-BDGZ4EQO.js";
105
+ import "./chunk-LAVHRER2.js";
106
+ import "./chunk-QHQWEERJ.js";
107
+ import "./chunk-Y7QKP6QU.js";
108
+ import "./chunk-TSTUAL6N.js";
109
+ import "./chunk-A5DJIOHN.js";
110
+ import {
111
+ queryClient
112
+ } from "./chunk-RHKRREUU.js";
113
+ import "./chunk-ZA2KFUFR.js";
114
+ import {
115
+ fetchQuery
116
+ } from "./chunk-RIN4CBRB.js";
117
+ import "./chunk-NBMM2TZK.js";
118
+
119
+ // src/pages/orders/[id]/loader.tsx
120
+ var orderDetailQuery = (id) => ({
121
+ queryKey: ordersQueryKeys.detail(id),
122
+ queryFn: async () => fetchQuery(`/vendor/orders/${id}`, {
123
+ method: "GET",
124
+ query: { fields: DEFAULT_FIELDS }
125
+ })
126
+ });
127
+ var loader = async ({ params }) => {
128
+ const id = params.id;
129
+ const query = orderDetailQuery(id);
130
+ return queryClient.ensureQueryData(query);
131
+ };
132
+
133
+ // src/pages/orders/[id]/order-detail-page.tsx
134
+ import { Children } from "react";
135
+ import { useLoaderData, useParams } from "react-router-dom";
136
+
137
+ // src/pages/orders/[id]/_components/active-order-claim-section/active-order-claim-section.tsx
138
+ import { ExclamationCircle } from "@medusajs/icons";
139
+ import { Button, Container, Heading, Text, toast } from "@medusajs/ui";
140
+ import { useNavigate } from "react-router-dom";
141
+ import { useTranslation } from "react-i18next";
142
+ import { jsx, jsxs } from "react/jsx-runtime";
143
+ var readClaimId = (change) => {
144
+ if (change && typeof change === "object" && "claim_id" in change && typeof change.claim_id === "string") {
145
+ return change.claim_id;
146
+ }
147
+ return void 0;
148
+ };
149
+ var ActiveOrderClaimSection = ({
150
+ orderPreview
151
+ }) => {
152
+ const { t } = useTranslation();
153
+ const navigate = useNavigate();
154
+ const claimId = readClaimId(orderPreview?.order_change);
155
+ const { mutateAsync: cancelClaim } = useCancelClaimBegin(
156
+ claimId ?? "",
157
+ orderPreview.id
158
+ );
159
+ if (!claimId) {
160
+ return null;
161
+ }
162
+ const onContinueClaim = async () => {
163
+ navigate(`/orders/${orderPreview.id}/claims/create`);
164
+ };
165
+ const onCancelClaim = async () => {
166
+ await cancelClaim(void 0, {
167
+ onSuccess: () => {
168
+ toast.success(t("orders.claims.toast.canceledSuccessfully"));
169
+ },
170
+ onError: (error) => {
171
+ toast.error(error.message);
172
+ }
173
+ });
174
+ };
175
+ return /* @__PURE__ */ jsx(
176
+ "div",
177
+ {
178
+ style: {
179
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
180
+ },
181
+ className: "-m-4 mb-1 border-b border-l p-4",
182
+ "data-testid": "active-order-claim-section",
183
+ 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: [
184
+ /* @__PURE__ */ jsxs("div", { children: [
185
+ /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", children: [
186
+ /* @__PURE__ */ jsx(ExclamationCircle, { className: "text-ui-fg-subtle" }),
187
+ /* @__PURE__ */ jsx(Heading, { level: "h2", children: t("orders.claims.panel.title") })
188
+ ] }),
189
+ /* @__PURE__ */ jsx("div", { className: "gap-2 px-6 pb-4", children: /* @__PURE__ */ jsx(Text, { children: t("orders.claims.panel.description") }) })
190
+ ] }),
191
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
192
+ /* @__PURE__ */ jsx(
193
+ Button,
194
+ {
195
+ size: "small",
196
+ variant: "secondary",
197
+ onClick: onCancelClaim,
198
+ "data-testid": "active-order-claim-cancel",
199
+ children: t("orders.claims.cancel.title")
200
+ }
201
+ ),
202
+ /* @__PURE__ */ jsx(
203
+ Button,
204
+ {
205
+ size: "small",
206
+ variant: "secondary",
207
+ onClick: onContinueClaim,
208
+ "data-testid": "active-order-claim-continue",
209
+ children: t("actions.continue")
210
+ }
211
+ )
212
+ ] })
213
+ ] }) })
214
+ }
215
+ );
216
+ };
217
+
218
+ // src/pages/orders/[id]/_components/active-order-exchange-section/active-order-exchange-section.tsx
219
+ import { ArrowPath } from "@medusajs/icons";
220
+ import { Button as Button2, Container as Container2, Heading as Heading2, Text as Text2, toast as toast2 } from "@medusajs/ui";
221
+ import { useNavigate as useNavigate2 } from "react-router-dom";
222
+ import { useTranslation as useTranslation2 } from "react-i18next";
223
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
224
+ var readExchangeId = (change) => {
225
+ if (change && typeof change === "object" && "exchange_id" in change && typeof change.exchange_id === "string") {
226
+ return change.exchange_id;
227
+ }
228
+ return void 0;
229
+ };
230
+ var ActiveOrderExchangeSection = ({
231
+ orderPreview
232
+ }) => {
233
+ const { t } = useTranslation2();
234
+ const navigate = useNavigate2();
235
+ const exchangeId = readExchangeId(orderPreview?.order_change);
236
+ const { mutateAsync: cancelExchange } = useCancelExchangeBegin(
237
+ exchangeId ?? "",
238
+ orderPreview.id
239
+ );
240
+ if (!exchangeId) {
241
+ return null;
242
+ }
243
+ const onContinueExchange = async () => {
244
+ navigate(`/orders/${orderPreview.id}/exchanges/create`);
245
+ };
246
+ const onCancelExchange = async () => {
247
+ await cancelExchange(void 0, {
248
+ onSuccess: () => {
249
+ toast2.success(t("orders.exchanges.toast.canceledSuccessfully"));
250
+ },
251
+ onError: (error) => {
252
+ toast2.error(error.message);
253
+ }
254
+ });
255
+ };
256
+ return /* @__PURE__ */ jsx2(
257
+ "div",
258
+ {
259
+ style: {
260
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
261
+ },
262
+ className: "-m-4 mb-1 border-b border-l p-4",
263
+ "data-testid": "active-order-exchange-section",
264
+ 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: [
265
+ /* @__PURE__ */ jsxs2("div", { children: [
266
+ /* @__PURE__ */ jsxs2("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", children: [
267
+ /* @__PURE__ */ jsx2(ArrowPath, { className: "text-ui-fg-subtle" }),
268
+ /* @__PURE__ */ jsx2(Heading2, { level: "h2", children: t("orders.exchanges.panel.title") })
269
+ ] }),
270
+ /* @__PURE__ */ jsx2("div", { className: "gap-2 px-6 pb-4", children: /* @__PURE__ */ jsx2(Text2, { children: t("orders.exchanges.panel.description") }) })
271
+ ] }),
272
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
273
+ /* @__PURE__ */ jsx2(
274
+ Button2,
275
+ {
276
+ size: "small",
277
+ variant: "secondary",
278
+ onClick: onCancelExchange,
279
+ "data-testid": "active-order-exchange-cancel",
280
+ children: t("orders.exchanges.cancel.title")
281
+ }
282
+ ),
283
+ /* @__PURE__ */ jsx2(
284
+ Button2,
285
+ {
286
+ size: "small",
287
+ variant: "secondary",
288
+ onClick: onContinueExchange,
289
+ "data-testid": "active-order-exchange-continue",
290
+ children: t("actions.continue")
291
+ }
292
+ )
293
+ ] })
294
+ ] }) })
295
+ }
296
+ );
297
+ };
298
+
299
+ // src/pages/orders/[id]/_components/active-order-return-section/active-order-return-section.tsx
300
+ import { ArrowUturnLeft } from "@medusajs/icons";
301
+ import { Button as Button3, Container as Container3, Heading as Heading3, Text as Text3, toast as toast3 } from "@medusajs/ui";
302
+ import { useNavigate as useNavigate3 } from "react-router-dom";
303
+ import { useTranslation as useTranslation3 } from "react-i18next";
304
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
305
+ var readReturnId = (change) => {
306
+ if (change && typeof change === "object" && "return_id" in change && typeof change.return_id === "string") {
307
+ return change.return_id;
308
+ }
309
+ return void 0;
310
+ };
311
+ var ActiveOrderReturnSection = ({
312
+ orderPreview
313
+ }) => {
314
+ const { t } = useTranslation3();
315
+ const navigate = useNavigate3();
316
+ const orderChange = orderPreview?.order_change;
317
+ const returnId = readReturnId(orderChange);
318
+ const isReturnRequest = orderChange?.change_type === "return_request" && !!returnId;
319
+ const { mutateAsync: cancelReturn } = useCancelReturnRequest(
320
+ returnId ?? "",
321
+ orderPreview.id
322
+ );
323
+ if (!returnId || !isReturnRequest) {
324
+ return null;
325
+ }
326
+ const onContinueReturn = async () => {
327
+ navigate(`/orders/${orderPreview.id}/returns/create`);
328
+ };
329
+ const onCancelReturn = async () => {
330
+ await cancelReturn(void 0, {
331
+ onSuccess: () => {
332
+ toast3.success(t("orders.returns.toast.canceledSuccessfully"));
333
+ },
334
+ onError: (error) => {
335
+ toast3.error(error.message);
336
+ }
337
+ });
338
+ };
339
+ return /* @__PURE__ */ jsx3(
340
+ "div",
341
+ {
342
+ style: {
343
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
344
+ },
345
+ className: "-m-4 mb-1 border-b border-l p-4",
346
+ "data-testid": "active-order-return-section",
347
+ 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: [
348
+ /* @__PURE__ */ jsxs3("div", { children: [
349
+ /* @__PURE__ */ jsxs3("div", { className: "mb-2 flex items-center gap-2 px-6 pt-4", children: [
350
+ /* @__PURE__ */ jsx3(ArrowUturnLeft, { className: "text-ui-fg-subtle" }),
351
+ /* @__PURE__ */ jsx3(Heading3, { level: "h2", children: t("orders.returns.panel.title") })
352
+ ] }),
353
+ /* @__PURE__ */ jsx3("div", { className: "gap-2 px-6 pb-4", children: /* @__PURE__ */ jsx3(Text3, { children: t("orders.returns.panel.description") }) })
354
+ ] }),
355
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
356
+ /* @__PURE__ */ jsx3(
357
+ Button3,
358
+ {
359
+ size: "small",
360
+ variant: "secondary",
361
+ onClick: onCancelReturn,
362
+ "data-testid": "active-order-return-cancel",
363
+ children: t("orders.returns.cancel.title")
364
+ }
365
+ ),
366
+ /* @__PURE__ */ jsx3(
367
+ Button3,
368
+ {
369
+ size: "small",
370
+ variant: "secondary",
371
+ onClick: onContinueReturn,
372
+ "data-testid": "active-order-return-continue",
373
+ children: t("actions.continue")
374
+ }
375
+ )
376
+ ] })
377
+ ] }) })
378
+ }
379
+ );
380
+ };
381
+
382
+ // src/pages/orders/[id]/_components/order-active-edit-section/order-active-edit-section.tsx
383
+ import { ExclamationCircleSolid } from "@medusajs/icons";
384
+ import { Button as Button4, Container as Container4, Copy, Heading as Heading4, toast as toast4 } from "@medusajs/ui";
385
+ import { useMemo } from "react";
386
+ import { useTranslation as useTranslation4 } from "react-i18next";
387
+ import { useNavigate as useNavigate4 } from "react-router-dom";
388
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
389
+ function EditItem({
390
+ item,
391
+ quantity
392
+ }) {
393
+ 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: [
394
+ /* @__PURE__ */ jsxs4("div", { className: "w-fit min-w-[27px]", children: [
395
+ /* @__PURE__ */ jsx4("span", { className: "txt-small tabular-nums", children: quantity }),
396
+ "x"
397
+ ] }),
398
+ /* @__PURE__ */ jsx4(Thumbnail, { src: item.thumbnail ?? void 0 }),
399
+ /* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle font-medium", children: item.title }),
400
+ item.variant_sku && " \xB7 ",
401
+ item.variant_sku && /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
402
+ /* @__PURE__ */ jsx4("span", { className: "txt-small", children: item.variant_sku }),
403
+ /* @__PURE__ */ jsx4(Copy, { content: item.variant_sku, className: "text-ui-fg-muted" })
404
+ ] })
405
+ ] }) });
406
+ }
407
+ var OrderActiveEditSection = ({
408
+ order
409
+ }) => {
410
+ const { t } = useTranslation4();
411
+ const navigate = useNavigate4();
412
+ const { order: orderPreview } = useOrderPreview(order.id);
413
+ const { mutateAsync: cancelOrderEdit } = useCancelOrderEdit(order.id);
414
+ const { mutateAsync: confirmOrderEdit } = useConfirmOrderEdit(order.id);
415
+ const isPending = orderPreview?.order_change?.status === "pending";
416
+ const [addedItems, removedItems] = useMemo(() => {
417
+ const added = [];
418
+ const removed = [];
419
+ const originals = order.items ?? [];
420
+ const previewItems = orderPreview?.items ?? [];
421
+ const orderLookupMap = new Map(originals.map((i) => [i.id, i]));
422
+ previewItems.forEach((currentItem) => {
423
+ const originalItem = orderLookupMap.get(currentItem.id);
424
+ if (!originalItem) {
425
+ added.push({ item: currentItem, quantity: currentItem.quantity });
426
+ return;
427
+ }
428
+ if (originalItem.quantity > currentItem.quantity) {
429
+ removed.push({
430
+ item: currentItem,
431
+ quantity: originalItem.quantity - currentItem.quantity
432
+ });
433
+ }
434
+ if (originalItem.quantity < currentItem.quantity) {
435
+ added.push({
436
+ item: currentItem,
437
+ quantity: currentItem.quantity - originalItem.quantity
438
+ });
439
+ }
440
+ });
441
+ return [added, removed];
442
+ }, [orderPreview, order.items]);
443
+ const onConfirmOrderEdit = async () => {
444
+ try {
445
+ await confirmOrderEdit();
446
+ toast4.success(t("orders.edits.toast.confirmedSuccessfully"));
447
+ } catch (e) {
448
+ toast4.error(
449
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
450
+ );
451
+ }
452
+ };
453
+ const onCancelOrderEdit = async () => {
454
+ try {
455
+ await cancelOrderEdit();
456
+ toast4.success(t("orders.edits.toast.canceledSuccessfully"));
457
+ } catch (e) {
458
+ toast4.error(
459
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
460
+ );
461
+ }
462
+ };
463
+ const change = orderPreview?.order_change;
464
+ if (!orderPreview || change?.change_type !== "edit") {
465
+ return null;
466
+ }
467
+ return /* @__PURE__ */ jsx4(
468
+ "div",
469
+ {
470
+ style: {
471
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
472
+ },
473
+ className: "-m-4 mb-1 border-b border-l p-4",
474
+ "data-testid": "order-active-edit-section",
475
+ 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: [
476
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2 px-6 py-4", children: [
477
+ /* @__PURE__ */ jsx4(ExclamationCircleSolid, { className: "text-blue-500" }),
478
+ /* @__PURE__ */ jsx4(Heading4, { level: "h2", children: t(
479
+ isPending ? "orders.edits.panel.titlePending" : "orders.edits.panel.title"
480
+ ) })
481
+ ] }),
482
+ !!addedItems.length && /* @__PURE__ */ jsxs4("div", { className: "txt-small text-ui-fg-subtle flex flex-row px-6 py-4", children: [
483
+ /* @__PURE__ */ jsx4("span", { className: "flex-1 font-medium", children: t("labels.added") }),
484
+ /* @__PURE__ */ jsx4("div", { className: "flex flex-1 flex-col gap-y-2", children: addedItems.map(({ item, quantity }) => /* @__PURE__ */ jsx4(EditItem, { item, quantity }, item.id)) })
485
+ ] }),
486
+ !!removedItems.length && /* @__PURE__ */ jsxs4("div", { className: "txt-small text-ui-fg-subtle flex flex-row px-6 py-4", children: [
487
+ /* @__PURE__ */ jsx4("span", { className: "flex-1 font-medium", children: t("labels.removed") }),
488
+ /* @__PURE__ */ jsx4("div", { className: "flex flex-1 flex-col gap-y-2", children: removedItems.map(({ item, quantity }) => /* @__PURE__ */ jsx4(EditItem, { item, quantity }, item.id)) })
489
+ ] }),
490
+ /* @__PURE__ */ jsxs4("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
491
+ isPending ? /* @__PURE__ */ jsx4(
492
+ Button4,
493
+ {
494
+ size: "small",
495
+ variant: "secondary",
496
+ onClick: () => navigate(`/orders/${order.id}/edit`),
497
+ "data-testid": "order-active-edit-continue",
498
+ children: t("actions.continueEdit")
499
+ }
500
+ ) : /* @__PURE__ */ jsx4(
501
+ Button4,
502
+ {
503
+ size: "small",
504
+ variant: "secondary",
505
+ onClick: onConfirmOrderEdit,
506
+ "data-testid": "order-active-edit-force-confirm",
507
+ children: t("actions.forceConfirm")
508
+ }
509
+ ),
510
+ /* @__PURE__ */ jsx4(
511
+ Button4,
512
+ {
513
+ size: "small",
514
+ variant: "secondary",
515
+ onClick: onCancelOrderEdit,
516
+ "data-testid": "order-active-edit-cancel",
517
+ children: t("actions.cancel")
518
+ }
519
+ )
520
+ ] })
521
+ ] }) })
522
+ }
523
+ );
524
+ };
525
+
526
+ // src/pages/orders/[id]/_components/order-activity-section/order-activity-section.tsx
527
+ import { Container as Container5, Heading as Heading5 } from "@medusajs/ui";
528
+ import { useTranslation as useTranslation15 } from "react-i18next";
529
+
530
+ // src/pages/orders/[id]/_components/order-activity-section/hooks/use-activity-items.tsx
531
+ import { useMemo as useMemo3 } from "react";
532
+ import { useTranslation as useTranslation14 } from "react-i18next";
533
+ import { Text as Text15 } from "@medusajs/ui";
534
+
535
+ // src/components/common/user-link/user-link.tsx
536
+ import { Avatar, Text as Text4 } from "@medusajs/ui";
537
+ import { Link } from "react-router-dom";
538
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
539
+ var UserLink = ({
540
+ id,
541
+ first_name,
542
+ last_name,
543
+ email,
544
+ type = "user"
545
+ }) => {
546
+ const name = [first_name, last_name].filter(Boolean).join(" ");
547
+ const fallback = name ? name.slice(0, 1) : email.slice(0, 1);
548
+ const link = type === "user" ? `/settings/users/${id}` : `/customers/${id}`;
549
+ return /* @__PURE__ */ jsxs5(
550
+ Link,
551
+ {
552
+ to: link,
553
+ 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",
554
+ children: [
555
+ /* @__PURE__ */ jsx5(Avatar, { size: "2xsmall", fallback: fallback.toUpperCase() }),
556
+ /* @__PURE__ */ jsx5(Text4, { size: "small", leading: "compact", weight: "regular", children: name || email })
557
+ ]
558
+ }
559
+ );
560
+ };
561
+ var By = ({ id }) => {
562
+ const { user } = useMember(id);
563
+ if (!user) {
564
+ return null;
565
+ }
566
+ return /* @__PURE__ */ jsx5(UserLink, { ...user });
567
+ };
568
+
569
+ // src/pages/orders/[id]/_components/order-activity-section/change-details-tooltip.tsx
570
+ import { Popover, Text as Text5 } from "@medusajs/ui";
571
+ import { useState } from "react";
572
+ import { useTranslation as useTranslation5 } from "react-i18next";
573
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
574
+ function ChangeDetailsTooltip(props) {
575
+ const { t } = useTranslation5();
576
+ const [open, setOpen] = useState(false);
577
+ const previous = props.previous;
578
+ const next = props.next;
579
+ const title = props.title;
580
+ const handleMouseEnter = () => {
581
+ setOpen(true);
582
+ };
583
+ const handleMouseLeave = () => {
584
+ setOpen(false);
585
+ };
586
+ if (!previous && !next) {
587
+ return null;
588
+ }
589
+ return /* @__PURE__ */ jsxs6(Popover, { open, children: [
590
+ /* @__PURE__ */ jsx6(
591
+ Popover.Trigger,
592
+ {
593
+ onMouseEnter: handleMouseEnter,
594
+ onMouseLeave: handleMouseLeave,
595
+ autoFocus: false,
596
+ className: "focus-visible:outline-none",
597
+ children: /* @__PURE__ */ jsx6(Text5, { size: "small", leading: "compact", weight: "plus", children: title })
598
+ }
599
+ ),
600
+ /* @__PURE__ */ jsx6(
601
+ Popover.Content,
602
+ {
603
+ align: "center",
604
+ side: "top",
605
+ className: "bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",
606
+ children: /* @__PURE__ */ jsxs6("div", { className: "flex flex-col", children: [
607
+ !!previous && /* @__PURE__ */ jsxs6("div", { className: "p-3", children: [
608
+ /* @__PURE__ */ jsx6("div", { className: "txt-compact-small-plus mb-1", children: t("labels.from") }),
609
+ /* @__PURE__ */ jsx6("p", { className: "txt-compact-small text-ui-fg-subtle", children: previous })
610
+ ] }),
611
+ !!next && /* @__PURE__ */ jsxs6("div", { className: "border-t-2 border-dotted p-3", children: [
612
+ /* @__PURE__ */ jsx6("div", { className: "txt-compact-small-plus mb-1", children: t("labels.to") }),
613
+ /* @__PURE__ */ jsx6("p", { className: "txt-compact-small text-ui-fg-subtle", children: next })
614
+ ] })
615
+ ] })
616
+ }
617
+ )
618
+ ] });
619
+ }
620
+ var change_details_tooltip_default = ChangeDetailsTooltip;
621
+
622
+ // src/pages/orders/[id]/_components/order-activity-section/components/fulfillment-created-body.tsx
623
+ import { Text as Text6 } from "@medusajs/ui";
624
+ import { useTranslation as useTranslation6 } from "react-i18next";
625
+ import { jsx as jsx7 } from "react/jsx-runtime";
626
+ var FulfillmentCreatedBody = ({
627
+ fulfillment
628
+ }) => {
629
+ const { t } = useTranslation6();
630
+ const numberOfItems = (fulfillment.items || []).reduce((acc, item) => {
631
+ return acc + (item.quantity || 0);
632
+ }, 0);
633
+ return /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(Text6, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.fulfillment.items", {
634
+ count: numberOfItems
635
+ }) }) });
636
+ };
637
+
638
+ // src/pages/orders/[id]/_components/order-activity-section/components/return-body.tsx
639
+ import { Button as Button5, Text as Text7, usePrompt } from "@medusajs/ui";
640
+ import { useTranslation as useTranslation7 } from "react-i18next";
641
+ import { Fragment, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
642
+ var ReturnBody = ({
643
+ orderReturn,
644
+ isCreated,
645
+ isReceived
646
+ }) => {
647
+ const prompt = usePrompt();
648
+ const { t } = useTranslation7();
649
+ const { mutateAsync: cancelReturnRequest } = useCancelReturn(
650
+ orderReturn.id,
651
+ orderReturn.order_id
652
+ );
653
+ const onCancel = async () => {
654
+ const res = await prompt({
655
+ title: t("orders.returns.cancel.title"),
656
+ description: t("orders.returns.cancel.description"),
657
+ confirmText: t("actions.confirm"),
658
+ cancelText: t("actions.cancel")
659
+ });
660
+ if (!res) {
661
+ return;
662
+ }
663
+ await cancelReturnRequest();
664
+ };
665
+ const numberOfItems = (orderReturn.items ?? []).reduce((acc, item) => {
666
+ return acc + (isReceived ? item.received_quantity : item.quantity);
667
+ }, 0);
668
+ return /* @__PURE__ */ jsxs7("div", { className: "flex items-start gap-1", children: [
669
+ /* @__PURE__ */ jsx8(Text7, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.return.items", {
670
+ count: numberOfItems
671
+ }) }),
672
+ isCreated && /* @__PURE__ */ jsxs7(Fragment, { children: [
673
+ /* @__PURE__ */ jsx8("div", { className: "mt-[2px] flex items-center leading-none", children: "\u22C5" }),
674
+ /* @__PURE__ */ jsx8(
675
+ Button5,
676
+ {
677
+ onClick: onCancel,
678
+ className: "text-ui-fg-subtle h-auto px-0 leading-none hover:bg-transparent",
679
+ variant: "transparent",
680
+ size: "small",
681
+ children: t("actions.cancel")
682
+ }
683
+ )
684
+ ] })
685
+ ] });
686
+ };
687
+
688
+ // src/pages/orders/[id]/_components/order-activity-section/components/claim-body.tsx
689
+ import { Text as Text8 } from "@medusajs/ui";
690
+ import { useTranslation as useTranslation8 } from "react-i18next";
691
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
692
+ var ClaimBody = ({
693
+ claim,
694
+ claimReturn
695
+ }) => {
696
+ const { t } = useTranslation8();
697
+ const outboundItems = (claim.additional_items || []).reduce(
698
+ (acc, item) => acc + item.quantity,
699
+ 0
700
+ );
701
+ const inboundItems = (claimReturn?.items || []).reduce(
702
+ (acc, item) => acc + item.quantity,
703
+ 0
704
+ );
705
+ return /* @__PURE__ */ jsxs8("div", { children: [
706
+ outboundItems > 0 && /* @__PURE__ */ jsx9(Text8, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.claim.itemsInbound", {
707
+ count: outboundItems
708
+ }) }),
709
+ inboundItems > 0 && /* @__PURE__ */ jsx9(Text8, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.claim.itemsOutbound", {
710
+ count: inboundItems
711
+ }) })
712
+ ] });
713
+ };
714
+
715
+ // src/pages/orders/[id]/_components/order-activity-section/components/exchange-body.tsx
716
+ import { Text as Text9 } from "@medusajs/ui";
717
+ import { useTranslation as useTranslation9 } from "react-i18next";
718
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
719
+ var ExchangeBody = ({
720
+ exchange,
721
+ exchangeReturn
722
+ }) => {
723
+ const { t } = useTranslation9();
724
+ const outboundItems = (exchange.additional_items || []).reduce(
725
+ (acc, item) => acc + item.quantity,
726
+ 0
727
+ );
728
+ const inboundItems = (exchangeReturn?.items || []).reduce(
729
+ (acc, item) => acc + item.quantity,
730
+ 0
731
+ );
732
+ return /* @__PURE__ */ jsxs9("div", { children: [
733
+ outboundItems > 0 && /* @__PURE__ */ jsx10(Text9, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.exchange.itemsInbound", {
734
+ count: outboundItems
735
+ }) }),
736
+ inboundItems > 0 && /* @__PURE__ */ jsx10(Text9, { size: "small", className: "text-ui-fg-subtle", children: t("orders.activity.events.exchange.itemsOutbound", {
737
+ count: inboundItems
738
+ }) })
739
+ ] });
740
+ };
741
+
742
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-edit-body.tsx
743
+ import { Text as Text10 } from "@medusajs/ui";
744
+ import { useTranslation as useTranslation10 } from "react-i18next";
745
+ import { useMemo as useMemo2 } from "react";
746
+
747
+ // src/pages/orders/[id]/_components/order-activity-section/utils/count-items-change.ts
748
+ function countItemsChange(actions) {
749
+ let added = 0;
750
+ let removed = 0;
751
+ actions.forEach((action) => {
752
+ if (action.action === "ITEM_ADD") {
753
+ added += action.details.quantity;
754
+ }
755
+ if (action.action === "ITEM_UPDATE") {
756
+ const quantityDiff = action.details.quantity_diff;
757
+ if (quantityDiff > 0) {
758
+ added += quantityDiff;
759
+ } else {
760
+ removed += Math.abs(quantityDiff);
761
+ }
762
+ }
763
+ });
764
+ return [added, removed];
765
+ }
766
+
767
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-edit-body.tsx
768
+ import { jsxs as jsxs10 } from "react/jsx-runtime";
769
+ var OrderEditBody = ({ edit }) => {
770
+ const { t } = useTranslation10();
771
+ const [itemsAdded, itemsRemoved] = useMemo2(
772
+ () => countItemsChange(edit.actions),
773
+ [edit]
774
+ );
775
+ return /* @__PURE__ */ jsxs10("div", { children: [
776
+ itemsAdded > 0 && /* @__PURE__ */ jsxs10(Text10, { size: "small", className: "text-ui-fg-subtle", children: [
777
+ t("labels.added"),
778
+ ": ",
779
+ itemsAdded
780
+ ] }),
781
+ itemsRemoved > 0 && /* @__PURE__ */ jsxs10(Text10, { size: "small", className: "text-ui-fg-subtle", children: [
782
+ t("labels.removed"),
783
+ ": ",
784
+ itemsRemoved
785
+ ] })
786
+ ] });
787
+ };
788
+
789
+ // src/pages/orders/[id]/_components/order-activity-section/components/transfer-order-request-body.tsx
790
+ import { Text as Text11 } from "@medusajs/ui";
791
+ import { useTranslation as useTranslation11 } from "react-i18next";
792
+ import { jsxs as jsxs11 } from "react/jsx-runtime";
793
+ var TransferOrderRequestBody = ({
794
+ transfer
795
+ }) => {
796
+ const { t } = useTranslation11();
797
+ const action = transfer.actions[0];
798
+ const { customer } = useCustomer(action.reference_id);
799
+ return /* @__PURE__ */ jsxs11("div", { children: [
800
+ /* @__PURE__ */ jsxs11(Text11, { size: "small", className: "text-ui-fg-subtle", children: [
801
+ t("orders.activity.from"),
802
+ ": ",
803
+ String(action.details?.original_email || "")
804
+ ] }),
805
+ /* @__PURE__ */ jsxs11(Text11, { size: "small", className: "text-ui-fg-subtle", children: [
806
+ t("orders.activity.to"),
807
+ ":",
808
+ " ",
809
+ customer?.first_name ? `${customer?.first_name} ${customer?.last_name}` : customer?.email
810
+ ] })
811
+ ] });
812
+ };
813
+
814
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-activity-item.tsx
815
+ import { Text as Text13, Tooltip, clx } from "@medusajs/ui";
816
+
817
+ // src/pages/orders/[id]/_components/order-activity-section/activity-items.tsx
818
+ import { Popover as Popover2, Text as Text12 } from "@medusajs/ui";
819
+ import { useState as useState2 } from "react";
820
+ import { useTranslation as useTranslation12 } from "react-i18next";
821
+ import { jsx as jsx11, jsxs as jsxs12 } from "react/jsx-runtime";
822
+ function ActivityItems(props) {
823
+ const { t } = useTranslation12();
824
+ const [open, setOpen] = useState2(false);
825
+ const itemsToSend = props.itemsToSend;
826
+ const itemsToReturn = props.itemsToReturn;
827
+ const itemsMap = props.itemsMap;
828
+ const title = props.title;
829
+ const handleMouseEnter = () => {
830
+ setOpen(true);
831
+ };
832
+ const handleMouseLeave = () => {
833
+ setOpen(false);
834
+ };
835
+ if (!itemsToSend?.length && !itemsToReturn?.length) {
836
+ return;
837
+ }
838
+ return /* @__PURE__ */ jsxs12(Popover2, { open, children: [
839
+ /* @__PURE__ */ jsx11(
840
+ Popover2.Trigger,
841
+ {
842
+ onMouseEnter: handleMouseEnter,
843
+ onMouseLeave: handleMouseLeave,
844
+ autoFocus: false,
845
+ className: "focus-visible:outline-none",
846
+ children: /* @__PURE__ */ jsx11(Text12, { size: "small", leading: "compact", weight: "plus", children: title })
847
+ }
848
+ ),
849
+ /* @__PURE__ */ jsx11(
850
+ Popover2.Content,
851
+ {
852
+ align: "center",
853
+ side: "top",
854
+ className: "bg-ui-bg-component max-w-[200px] p-0 focus-visible:outline-none",
855
+ children: /* @__PURE__ */ jsxs12("div", { className: "flex flex-col", children: [
856
+ !!itemsToSend?.length && /* @__PURE__ */ jsxs12("div", { className: "p-3", children: [
857
+ /* @__PURE__ */ jsx11("div", { className: "txt-compact-small-plus mb-1", children: t("orders.activity.events.common.toSend") }),
858
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-col", children: [
859
+ itemsToSend?.map((item) => {
860
+ const originalItem = itemsMap?.get(item.item_id);
861
+ return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-3", children: [
862
+ /* @__PURE__ */ jsxs12(Text12, { size: "small", className: "text-ui-fg-subtle", children: [
863
+ item.quantity,
864
+ "x"
865
+ ] }),
866
+ /* @__PURE__ */ jsx11(Thumbnail, { src: originalItem?.thumbnail }),
867
+ /* @__PURE__ */ jsx11(Text12, { className: "txt-compact-small text-ui-fg-subtle truncate", children: `${originalItem?.variant_title} \xB7 ${originalItem?.product_title}` })
868
+ ] }, item.id);
869
+ }),
870
+ /* @__PURE__ */ jsx11("div", { className: "flex flex-1 flex-row items-center gap-2" })
871
+ ] })
872
+ ] }),
873
+ !!itemsToReturn?.length && /* @__PURE__ */ jsxs12("div", { className: "border-t-2 border-dotted p-3", children: [
874
+ /* @__PURE__ */ jsx11("div", { className: "txt-compact-small-plus mb-1", children: t("orders.activity.events.common.toReturn") }),
875
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-col", children: [
876
+ itemsToReturn?.map((item) => {
877
+ const originalItem = itemsMap?.get(item.item_id);
878
+ return /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-x-3", children: [
879
+ /* @__PURE__ */ jsxs12(Text12, { size: "small", className: "text-ui-fg-subtle", children: [
880
+ item.quantity,
881
+ "x"
882
+ ] }),
883
+ /* @__PURE__ */ jsx11(Thumbnail, { src: originalItem?.thumbnail }),
884
+ /* @__PURE__ */ jsx11(Text12, { className: "txt-compact-small text-ui-fg-subtle truncate", children: `${originalItem?.variant_title} \xB7 ${originalItem?.product_title}` })
885
+ ] }, item.id);
886
+ }),
887
+ /* @__PURE__ */ jsx11("div", { className: "flex flex-1 flex-row items-center gap-2" })
888
+ ] })
889
+ ] })
890
+ ] })
891
+ }
892
+ )
893
+ ] });
894
+ }
895
+ var activity_items_default = ActivityItems;
896
+
897
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-activity-item.tsx
898
+ import { jsx as jsx12, jsxs as jsxs13 } from "react/jsx-runtime";
899
+ var OrderActivityItem = ({
900
+ title,
901
+ timestamp,
902
+ isFirst = false,
903
+ children,
904
+ itemsToSend,
905
+ itemsToReturn,
906
+ itemsMap
907
+ }) => {
908
+ const { getFullDate, getRelativeDate } = useDate();
909
+ return /* @__PURE__ */ jsxs13("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
910
+ /* @__PURE__ */ jsxs13("div", { className: "flex size-full flex-col items-center gap-y-0.5", children: [
911
+ /* @__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" }) }) }),
912
+ !isFirst && /* @__PURE__ */ jsx12("div", { className: "bg-ui-border-base w-px flex-1" })
913
+ ] }),
914
+ /* @__PURE__ */ jsxs13(
915
+ "div",
916
+ {
917
+ className: clx({
918
+ "pb-4": !isFirst
919
+ }),
920
+ children: [
921
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between", children: [
922
+ itemsToSend?.length || itemsToReturn?.length ? /* @__PURE__ */ jsx12(
923
+ activity_items_default,
924
+ {
925
+ title,
926
+ itemsToSend,
927
+ itemsToReturn,
928
+ itemsMap
929
+ }
930
+ ) : /* @__PURE__ */ jsx12(Text13, { size: "small", leading: "compact", weight: "plus", children: title }),
931
+ timestamp && /* @__PURE__ */ jsx12(
932
+ Tooltip,
933
+ {
934
+ content: getFullDate({
935
+ date: timestamp,
936
+ includeTime: true
937
+ }),
938
+ children: /* @__PURE__ */ jsx12(
939
+ Text13,
940
+ {
941
+ size: "small",
942
+ leading: "compact",
943
+ className: "text-ui-fg-subtle text-right",
944
+ children: getRelativeDate(timestamp)
945
+ }
946
+ )
947
+ }
948
+ )
949
+ ] }),
950
+ /* @__PURE__ */ jsx12("div", { children })
951
+ ]
952
+ }
953
+ )
954
+ ] });
955
+ };
956
+
957
+ // src/pages/orders/[id]/_components/order-activity-section/components/order-activity-collapsible.tsx
958
+ import { Text as Text14 } from "@medusajs/ui";
959
+ import { Collapsible as RadixCollapsible } from "radix-ui";
960
+ import { useState as useState3 } from "react";
961
+ import { useTranslation as useTranslation13 } from "react-i18next";
962
+ import { jsx as jsx13, jsxs as jsxs14 } from "react/jsx-runtime";
963
+ var OrderActivityCollapsible = ({
964
+ activities
965
+ }) => {
966
+ const [open, setOpen] = useState3(false);
967
+ const { t } = useTranslation13();
968
+ if (!activities.length) {
969
+ return null;
970
+ }
971
+ return /* @__PURE__ */ jsxs14(RadixCollapsible.Root, { open, onOpenChange: setOpen, children: [
972
+ !open && /* @__PURE__ */ jsxs14("div", { className: "grid grid-cols-[20px_1fr] items-start gap-2", children: [
973
+ /* @__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" }) }),
974
+ /* @__PURE__ */ jsx13("div", { className: "pb-4", children: /* @__PURE__ */ jsx13(RadixCollapsible.Trigger, { className: "text-left", children: /* @__PURE__ */ jsx13(
975
+ Text14,
976
+ {
977
+ size: "small",
978
+ leading: "compact",
979
+ weight: "plus",
980
+ className: "text-ui-fg-muted",
981
+ children: t("orders.activity.showMoreActivities", {
982
+ count: activities.length
983
+ })
984
+ }
985
+ ) }) })
986
+ ] }),
987
+ /* @__PURE__ */ jsx13(RadixCollapsible.Content, { children: /* @__PURE__ */ jsx13("div", { className: "flex flex-col gap-y-0.5", children: activities.map((item, index) => {
988
+ return /* @__PURE__ */ jsx13(
989
+ OrderActivityItem,
990
+ {
991
+ title: item.title,
992
+ timestamp: item.timestamp,
993
+ itemsToSend: item.itemsToSend,
994
+ itemsToReturn: item.itemsToReturn,
995
+ itemsMap: item.itemsMap,
996
+ children: item.children
997
+ },
998
+ index
999
+ );
1000
+ }) }) })
1001
+ ] });
1002
+ };
1003
+
1004
+ // src/pages/orders/[id]/_components/order-activity-section/hooks/use-activity-items.tsx
1005
+ import { jsx as jsx14, jsxs as jsxs15 } from "react/jsx-runtime";
1006
+ var useActivityItems = (order) => {
1007
+ const { t } = useTranslation14();
1008
+ const { order_changes: orderChanges = [] } = useOrderChanges(order.id);
1009
+ const itemsMap = useMemo3(() => {
1010
+ return new Map(
1011
+ order?.items?.map((i) => [i.id, i])
1012
+ );
1013
+ }, [order.items]);
1014
+ const { returns: returnsList = [] } = useReturns({
1015
+ order_id: order.id,
1016
+ fields: "+received_at,*items"
1017
+ });
1018
+ const { claims: claimsList = [] } = useClaims({
1019
+ order_id: order.id,
1020
+ fields: "*additional_items"
1021
+ });
1022
+ const { exchanges: exchangesList = [] } = useExchanges({
1023
+ order_id: order.id,
1024
+ fields: "*additional_items"
1025
+ });
1026
+ const returns = returnsList;
1027
+ const claims = claimsList;
1028
+ const exchanges = exchangesList;
1029
+ const isLoading = false;
1030
+ const payments = useMemo3(
1031
+ () => (order.payment_collections ?? []).flatMap(
1032
+ (pc) => pc.payments ?? []
1033
+ ),
1034
+ [order.payment_collections]
1035
+ );
1036
+ return useMemo3(() => {
1037
+ if (isLoading) {
1038
+ return [];
1039
+ }
1040
+ const items = [];
1041
+ for (const payment of payments) {
1042
+ const amount = payment.amount ?? payment.authorized_amount ?? 0;
1043
+ if (!payment.captured_at && !payment.canceled_at && payment.created_at) {
1044
+ items.push({
1045
+ title: t("orders.activity.events.payment.awaiting"),
1046
+ timestamp: payment.created_at,
1047
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
1048
+ });
1049
+ }
1050
+ if (payment.captured_at) {
1051
+ items.push({
1052
+ title: t("orders.activity.events.payment.captured"),
1053
+ timestamp: payment.captured_at,
1054
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
1055
+ });
1056
+ }
1057
+ if (payment.canceled_at) {
1058
+ items.push({
1059
+ title: t("orders.activity.events.payment.canceled"),
1060
+ timestamp: payment.canceled_at,
1061
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(amount, payment.currency_code) })
1062
+ });
1063
+ }
1064
+ for (const refund of payment.refunds ?? []) {
1065
+ items.push({
1066
+ title: t("orders.activity.events.payment.refunded"),
1067
+ timestamp: refund.created_at,
1068
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(
1069
+ refund.amount,
1070
+ payment.currency_code
1071
+ ) })
1072
+ });
1073
+ }
1074
+ }
1075
+ for (const fulfillment of order.fulfillments || []) {
1076
+ items.push({
1077
+ title: t("orders.activity.events.fulfillment.created"),
1078
+ timestamp: fulfillment.created_at,
1079
+ children: /* @__PURE__ */ jsx14(FulfillmentCreatedBody, { fulfillment })
1080
+ });
1081
+ if (fulfillment.delivered_at) {
1082
+ items.push({
1083
+ title: t("orders.activity.events.fulfillment.delivered"),
1084
+ timestamp: fulfillment.delivered_at,
1085
+ children: /* @__PURE__ */ jsx14(FulfillmentCreatedBody, { fulfillment })
1086
+ });
1087
+ }
1088
+ if (fulfillment.shipped_at) {
1089
+ items.push({
1090
+ title: t("orders.activity.events.fulfillment.shipped"),
1091
+ timestamp: fulfillment.shipped_at,
1092
+ children: /* @__PURE__ */ jsx14(FulfillmentCreatedBody, { fulfillment, isShipment: true })
1093
+ });
1094
+ }
1095
+ if (fulfillment.canceled_at) {
1096
+ items.push({
1097
+ title: t("orders.activity.events.fulfillment.canceled"),
1098
+ timestamp: fulfillment.canceled_at
1099
+ });
1100
+ }
1101
+ }
1102
+ const returnMap = /* @__PURE__ */ new Map();
1103
+ for (const ret of returns) {
1104
+ returnMap.set(ret.id, ret);
1105
+ if (ret.claim_id || ret.exchange_id) {
1106
+ continue;
1107
+ }
1108
+ items.push({
1109
+ title: t("orders.activity.events.return.created", {
1110
+ returnId: ret.id.slice(-7)
1111
+ }),
1112
+ timestamp: ret.created_at,
1113
+ itemsToReturn: ret?.items,
1114
+ itemsMap,
1115
+ children: /* @__PURE__ */ jsx14(ReturnBody, { orderReturn: ret, isCreated: !ret.canceled_at })
1116
+ });
1117
+ if (ret.canceled_at) {
1118
+ items.push({
1119
+ title: t("orders.activity.events.return.canceled", {
1120
+ returnId: ret.id.slice(-7)
1121
+ }),
1122
+ timestamp: ret.canceled_at
1123
+ });
1124
+ }
1125
+ if (ret.status === "received" || ret.status === "partially_received") {
1126
+ items.push({
1127
+ title: t("orders.activity.events.return.received", {
1128
+ returnId: ret.id.slice(-7)
1129
+ }),
1130
+ timestamp: ret.received_at,
1131
+ itemsToReturn: ret?.items,
1132
+ itemsMap,
1133
+ children: /* @__PURE__ */ jsx14(ReturnBody, { orderReturn: ret, isCreated: false, isReceived: true })
1134
+ });
1135
+ }
1136
+ }
1137
+ for (const claim of claims) {
1138
+ const claimReturn = returnMap.get(claim.return_id);
1139
+ items.push({
1140
+ title: t(
1141
+ claim.canceled_at ? "orders.activity.events.claim.canceled" : "orders.activity.events.claim.created",
1142
+ {
1143
+ claimId: claim.id.slice(-7)
1144
+ }
1145
+ ),
1146
+ timestamp: claim.canceled_at || claim.created_at,
1147
+ itemsToSend: claim.additional_items,
1148
+ itemsToReturn: claimReturn?.items,
1149
+ itemsMap,
1150
+ children: /* @__PURE__ */ jsx14(ClaimBody, { claim, claimReturn })
1151
+ });
1152
+ }
1153
+ for (const exchange of exchanges) {
1154
+ const exchangeReturn = returnMap.get(exchange.return_id);
1155
+ items.push({
1156
+ title: t(
1157
+ exchange.canceled_at ? "orders.activity.events.exchange.canceled" : "orders.activity.events.exchange.created",
1158
+ {
1159
+ exchangeId: exchange.id.slice(-7)
1160
+ }
1161
+ ),
1162
+ timestamp: exchange.canceled_at || exchange.created_at,
1163
+ itemsToSend: exchange.additional_items,
1164
+ itemsToReturn: exchangeReturn?.items,
1165
+ itemsMap,
1166
+ children: /* @__PURE__ */ jsx14(ExchangeBody, { exchange, exchangeReturn })
1167
+ });
1168
+ }
1169
+ for (const edit of orderChanges.filter((oc) => oc.change_type === "edit")) {
1170
+ const isConfirmed = edit.status === "confirmed";
1171
+ const isPending = edit.status === "pending";
1172
+ if (isPending) {
1173
+ continue;
1174
+ }
1175
+ const translationKey = `orders.activity.events.edit.${edit.status}`;
1176
+ items.push({
1177
+ title: t(translationKey, {
1178
+ editId: edit.id.slice(-7)
1179
+ }),
1180
+ 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,
1181
+ children: isConfirmed ? /* @__PURE__ */ jsx14(OrderEditBody, { edit }) : null
1182
+ });
1183
+ }
1184
+ for (const transfer of orderChanges.filter(
1185
+ (oc) => oc.change_type === "transfer"
1186
+ )) {
1187
+ if (transfer.requested_at) {
1188
+ items.push({
1189
+ title: t(`orders.activity.events.transfer.requested`, {
1190
+ transferId: transfer.id.slice(-7)
1191
+ }),
1192
+ timestamp: transfer.requested_at,
1193
+ children: /* @__PURE__ */ jsx14(TransferOrderRequestBody, { transfer })
1194
+ });
1195
+ }
1196
+ if (transfer.confirmed_at) {
1197
+ items.push({
1198
+ title: t(`orders.activity.events.transfer.confirmed`, {
1199
+ transferId: transfer.id.slice(-7)
1200
+ }),
1201
+ timestamp: transfer.confirmed_at
1202
+ });
1203
+ }
1204
+ if (transfer.declined_at) {
1205
+ items.push({
1206
+ title: t(`orders.activity.events.transfer.declined`, {
1207
+ transferId: transfer.id.slice(-7)
1208
+ }),
1209
+ timestamp: transfer.declined_at
1210
+ });
1211
+ }
1212
+ }
1213
+ for (const update of orderChanges.filter(
1214
+ (oc) => oc.change_type === "edit"
1215
+ )) {
1216
+ const updateType = update.actions[0]?.details?.type;
1217
+ if (updateType === "shipping_address") {
1218
+ const oldAddress = update?.actions[0]?.details?.old;
1219
+ const newAddress = update?.actions[0]?.details?.new;
1220
+ items.push({
1221
+ title: /* @__PURE__ */ jsx14(
1222
+ change_details_tooltip_default,
1223
+ {
1224
+ title: t(`orders.activity.events.update_order.shipping_address`),
1225
+ previous: getFormattedAddress({
1226
+ address: oldAddress
1227
+ }).join(", "),
1228
+ next: getFormattedAddress({
1229
+ address: newAddress
1230
+ }).join(", ")
1231
+ }
1232
+ ),
1233
+ timestamp: update.created_at,
1234
+ children: update.created_by ? /* @__PURE__ */ jsxs15("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
1235
+ t("fields.by"),
1236
+ " ",
1237
+ /* @__PURE__ */ jsx14(By, { id: update.created_by })
1238
+ ] }) : null
1239
+ });
1240
+ }
1241
+ if (updateType === "billing_address") {
1242
+ const oldAddress = update?.actions[0]?.details?.old;
1243
+ const newAddress = update?.actions[0]?.details?.new;
1244
+ items.push({
1245
+ title: /* @__PURE__ */ jsx14(
1246
+ change_details_tooltip_default,
1247
+ {
1248
+ title: t(`orders.activity.events.update_order.billing_address`),
1249
+ previous: getFormattedAddress({
1250
+ address: oldAddress
1251
+ }).join(", "),
1252
+ next: getFormattedAddress({
1253
+ address: newAddress
1254
+ }).join(", ")
1255
+ }
1256
+ ),
1257
+ timestamp: update.created_at,
1258
+ children: update.created_by ? /* @__PURE__ */ jsxs15("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
1259
+ t("fields.by"),
1260
+ " ",
1261
+ /* @__PURE__ */ jsx14(By, { id: update.created_by })
1262
+ ] }) : null
1263
+ });
1264
+ }
1265
+ if (updateType === "email") {
1266
+ const oldEmail = update.actions[0]?.details?.old;
1267
+ const newEmail = update.actions[0]?.details?.new;
1268
+ items.push({
1269
+ title: /* @__PURE__ */ jsx14(
1270
+ change_details_tooltip_default,
1271
+ {
1272
+ title: t(`orders.activity.events.update_order.email`),
1273
+ previous: oldEmail,
1274
+ next: newEmail
1275
+ }
1276
+ ),
1277
+ timestamp: update.created_at,
1278
+ children: update.created_by ? /* @__PURE__ */ jsxs15("div", { className: "text-ui-fg-subtle mt-2 flex gap-x-2 text-sm", children: [
1279
+ t("fields.by"),
1280
+ " ",
1281
+ /* @__PURE__ */ jsx14(By, { id: update.created_by })
1282
+ ] }) : null
1283
+ });
1284
+ }
1285
+ }
1286
+ if (order.canceled_at) {
1287
+ items.push({
1288
+ title: t("orders.activity.events.canceled.title"),
1289
+ timestamp: order.canceled_at
1290
+ });
1291
+ }
1292
+ const sortedActivities = items.sort((a, b) => {
1293
+ return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
1294
+ });
1295
+ const createdAt = {
1296
+ title: t("orders.activity.events.placed.title"),
1297
+ timestamp: order.created_at,
1298
+ children: /* @__PURE__ */ jsx14(Text15, { size: "small", className: "text-ui-fg-subtle", children: getStylizedAmount(order.total, order.currency_code) })
1299
+ };
1300
+ return [...sortedActivities, createdAt];
1301
+ }, [
1302
+ order,
1303
+ exchanges,
1304
+ orderChanges,
1305
+ payments,
1306
+ isLoading,
1307
+ itemsMap
1308
+ ]);
1309
+ };
1310
+
1311
+ // src/pages/orders/[id]/_components/order-activity-section/order-timeline.tsx
1312
+ import { jsx as jsx15, jsxs as jsxs16 } from "react/jsx-runtime";
1313
+ var OrderTimeline = ({ order }) => {
1314
+ const items = useActivityItems(order);
1315
+ if (items.length <= 3) {
1316
+ return /* @__PURE__ */ jsx15("div", { className: "flex flex-col gap-y-0.5", children: items.map((item, index) => {
1317
+ return /* @__PURE__ */ jsx15(
1318
+ OrderActivityItem,
1319
+ {
1320
+ title: item.title,
1321
+ timestamp: item.timestamp,
1322
+ isFirst: index === items.length - 1,
1323
+ itemsToSend: item.itemsToSend,
1324
+ itemsToReturn: item.itemsToReturn,
1325
+ itemsMap: item.itemsMap,
1326
+ children: item.children
1327
+ },
1328
+ index
1329
+ );
1330
+ }) });
1331
+ }
1332
+ const lastItems = items.slice(0, 2);
1333
+ const collapsibleItems = items.slice(2, items.length - 1);
1334
+ const firstItem = items[items.length - 1];
1335
+ return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-y-0.5", children: [
1336
+ lastItems.map((item, index) => {
1337
+ return /* @__PURE__ */ jsx15(
1338
+ OrderActivityItem,
1339
+ {
1340
+ title: item.title,
1341
+ timestamp: item.timestamp,
1342
+ itemsToSend: item.itemsToSend,
1343
+ itemsToReturn: item.itemsToReturn,
1344
+ itemsMap: item.itemsMap,
1345
+ children: item.children
1346
+ },
1347
+ index
1348
+ );
1349
+ }),
1350
+ /* @__PURE__ */ jsx15(OrderActivityCollapsible, { activities: collapsibleItems }),
1351
+ /* @__PURE__ */ jsx15(
1352
+ OrderActivityItem,
1353
+ {
1354
+ title: firstItem.title,
1355
+ timestamp: firstItem.timestamp,
1356
+ isFirst: true,
1357
+ itemsToSend: firstItem.itemsToSend,
1358
+ itemsToReturn: firstItem.itemsToReturn,
1359
+ itemsMap: firstItem.itemsMap,
1360
+ children: firstItem.children
1361
+ }
1362
+ )
1363
+ ] });
1364
+ };
1365
+
1366
+ // src/pages/orders/[id]/_components/order-activity-section/order-activity-section.tsx
1367
+ import { jsx as jsx16, jsxs as jsxs17 } from "react/jsx-runtime";
1368
+ var OrderActivitySection = ({ order }) => {
1369
+ const { t } = useTranslation15();
1370
+ return /* @__PURE__ */ jsxs17(Container5, { className: "flex flex-col gap-y-8 px-6 py-4", children: [
1371
+ /* @__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") }) }) }),
1372
+ /* @__PURE__ */ jsx16(OrderTimeline, { order })
1373
+ ] });
1374
+ };
1375
+
1376
+ // src/pages/orders/[id]/_components/order-commission-section/order-commission-section.tsx
1377
+ import { Container as Container6, Heading as Heading6, Text as Text16 } from "@medusajs/ui";
1378
+ import { useMemo as useMemo4 } from "react";
1379
+ import { useTranslation as useTranslation16 } from "react-i18next";
1380
+ import { jsx as jsx17, jsxs as jsxs18 } from "react/jsx-runtime";
1381
+ var OrderCommissionSection = ({
1382
+ order
1383
+ }) => {
1384
+ const { t } = useTranslation16();
1385
+ const { commission_lines, isLoading } = useOrderCommissionLines(order.id);
1386
+ const itemTitleById = useMemo4(() => {
1387
+ const map = /* @__PURE__ */ new Map();
1388
+ order.items?.forEach((item) => {
1389
+ map.set(item.id, item.product_title ?? item.title);
1390
+ });
1391
+ return map;
1392
+ }, [order.items]);
1393
+ if (isLoading || !commission_lines.length) {
1394
+ return null;
1395
+ }
1396
+ const total = commission_lines.reduce(
1397
+ (acc, line) => acc + (line.amount ?? 0),
1398
+ 0
1399
+ );
1400
+ return /* @__PURE__ */ jsxs18(Container6, { className: "divide-y p-0", "data-testid": "order-commission-section", children: [
1401
+ /* @__PURE__ */ jsx17("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsx17(Heading6, { level: "h2", children: t("fields.commission", "Commission") }) }),
1402
+ /* @__PURE__ */ jsx17("div", { className: "divide-y", children: commission_lines.map((line) => {
1403
+ const label = line.shipping_method_id ? t("fields.shipping") : itemTitleById.get(line.item_id ?? "") ?? line.code;
1404
+ return /* @__PURE__ */ jsxs18(
1405
+ "div",
1406
+ {
1407
+ className: "text-ui-fg-subtle grid grid-cols-2 items-center gap-4 px-6 py-4",
1408
+ children: [
1409
+ /* @__PURE__ */ jsx17(Text16, { size: "small", leading: "compact", children: label }),
1410
+ /* @__PURE__ */ jsx17(Text16, { size: "small", leading: "compact", className: "text-right", children: getLocaleAmount(line.amount, order.currency_code) })
1411
+ ]
1412
+ },
1413
+ line.id
1414
+ );
1415
+ }) }),
1416
+ /* @__PURE__ */ jsxs18("div", { className: "flex items-center justify-between px-6 py-4", children: [
1417
+ /* @__PURE__ */ jsx17(Text16, { size: "small", weight: "plus", leading: "compact", children: t("orders.commission.total", "Total") }),
1418
+ /* @__PURE__ */ jsx17(Text16, { size: "small", weight: "plus", leading: "compact", children: getLocaleAmount(total, order.currency_code) })
1419
+ ] })
1420
+ ] });
1421
+ };
1422
+
1423
+ // src/pages/orders/[id]/_components/order-customer-section/order-customer-section.tsx
1424
+ import { Container as Container7, Heading as Heading7 } from "@medusajs/ui";
1425
+ import { useTranslation as useTranslation18 } from "react-i18next";
1426
+
1427
+ // src/components/common/customer-info/customer-info.tsx
1428
+ import { Avatar as Avatar2, Copy as Copy2, Text as Text17 } from "@medusajs/ui";
1429
+ import { useTranslation as useTranslation17 } from "react-i18next";
1430
+ import { Link as Link2 } from "react-router-dom";
1431
+ import { jsx as jsx18, jsxs as jsxs19 } from "react/jsx-runtime";
1432
+ var ID = ({ data }) => {
1433
+ const { t } = useTranslation17();
1434
+ const id = data.customer_id;
1435
+ const name = getOrderCustomer(data);
1436
+ const email = data.email;
1437
+ const fallback = (name || email || "").charAt(0).toUpperCase();
1438
+ return /* @__PURE__ */ jsxs19("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1439
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", weight: "plus", children: t("fields.id") }),
1440
+ /* @__PURE__ */ jsx18(
1441
+ Link2,
1442
+ {
1443
+ to: `/customers/${id}`,
1444
+ className: "focus:shadow-borders-focus rounded-[4px] outline-none transition-shadow",
1445
+ children: /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-x-2 overflow-hidden", children: [
1446
+ /* @__PURE__ */ jsx18(Avatar2, { size: "2xsmall", fallback }),
1447
+ /* @__PURE__ */ jsx18(
1448
+ Text17,
1449
+ {
1450
+ size: "small",
1451
+ leading: "compact",
1452
+ className: "text-ui-fg-subtle hover:text-ui-fg-base transition-fg truncate",
1453
+ children: name || email
1454
+ }
1455
+ )
1456
+ ] })
1457
+ }
1458
+ )
1459
+ ] });
1460
+ };
1461
+ var Company = ({ data }) => {
1462
+ const { t } = useTranslation17();
1463
+ const company = data.shipping_address?.company || data.billing_address?.company;
1464
+ if (!company) {
1465
+ return null;
1466
+ }
1467
+ return /* @__PURE__ */ jsxs19("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
1468
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", weight: "plus", children: t("fields.company") }),
1469
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", className: "truncate", children: company })
1470
+ ] });
1471
+ };
1472
+ var Contact = ({ data }) => {
1473
+ const { t } = useTranslation17();
1474
+ const phone = data.shipping_address?.phone || data.billing_address?.phone;
1475
+ const email = data.email || "";
1476
+ return /* @__PURE__ */ jsxs19("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1477
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", weight: "plus", children: t("orders.customer.contactLabel") }),
1478
+ /* @__PURE__ */ jsxs19("div", { className: "flex flex-col gap-y-2", children: [
1479
+ /* @__PURE__ */ jsxs19("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
1480
+ /* @__PURE__ */ jsx18(
1481
+ Text17,
1482
+ {
1483
+ size: "small",
1484
+ leading: "compact",
1485
+ className: "text-pretty break-all",
1486
+ children: email
1487
+ }
1488
+ ),
1489
+ /* @__PURE__ */ jsx18("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx18(Copy2, { content: email, className: "text-ui-fg-muted" }) })
1490
+ ] }),
1491
+ phone && /* @__PURE__ */ jsxs19("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
1492
+ /* @__PURE__ */ jsx18(
1493
+ Text17,
1494
+ {
1495
+ size: "small",
1496
+ leading: "compact",
1497
+ className: "text-pretty break-all",
1498
+ children: phone
1499
+ }
1500
+ ),
1501
+ /* @__PURE__ */ jsx18("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx18(Copy2, { content: phone, className: "text-ui-fg-muted" }) })
1502
+ ] })
1503
+ ] })
1504
+ ] });
1505
+ };
1506
+ var AddressPrint = ({
1507
+ address,
1508
+ type
1509
+ }) => {
1510
+ const { t } = useTranslation17();
1511
+ return /* @__PURE__ */ jsxs19("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4", children: [
1512
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", weight: "plus", children: type === "shipping" ? t("addresses.shippingAddress.label") : t("addresses.billingAddress.label") }),
1513
+ address ? /* @__PURE__ */ jsxs19("div", { className: "grid grid-cols-[1fr_20px] items-start gap-x-2", children: [
1514
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", children: getFormattedAddress({ address }).map((line, i) => {
1515
+ return /* @__PURE__ */ jsxs19("span", { className: "break-words", children: [
1516
+ line,
1517
+ /* @__PURE__ */ jsx18("br", {})
1518
+ ] }, i);
1519
+ }) }),
1520
+ /* @__PURE__ */ jsx18("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx18(
1521
+ Copy2,
1522
+ {
1523
+ content: getFormattedAddress({ address }).join("\n"),
1524
+ className: "text-ui-fg-muted"
1525
+ }
1526
+ ) })
1527
+ ] }) : /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", children: "-" })
1528
+ ] });
1529
+ };
1530
+ var Addresses = ({ data }) => {
1531
+ const { t } = useTranslation17();
1532
+ return /* @__PURE__ */ jsxs19("div", { className: "divide-y", children: [
1533
+ /* @__PURE__ */ jsx18(AddressPrint, { address: data.shipping_address, type: "shipping" }),
1534
+ !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: [
1535
+ /* @__PURE__ */ jsx18(
1536
+ Text17,
1537
+ {
1538
+ size: "small",
1539
+ leading: "compact",
1540
+ weight: "plus",
1541
+ className: "text-ui-fg-subtle",
1542
+ children: t("addresses.billingAddress.label")
1543
+ }
1544
+ ),
1545
+ /* @__PURE__ */ jsx18(Text17, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: t("addresses.billingAddress.sameAsShipping") })
1546
+ ] })
1547
+ ] });
1548
+ };
1549
+ var CustomerInfo = Object.assign(
1550
+ {},
1551
+ {
1552
+ ID,
1553
+ Company,
1554
+ Contact,
1555
+ Addresses
1556
+ }
1557
+ );
1558
+ var getOrderCustomer = (obj) => {
1559
+ const { first_name: sFirstName, last_name: sLastName } = obj.shipping_address || {};
1560
+ const { first_name: bFirstName, last_name: bLastName } = obj.billing_address || {};
1561
+ const { first_name: cFirstName, last_name: cLastName } = obj.customer || {};
1562
+ const customerName = [cFirstName, cLastName].filter(Boolean).join(" ");
1563
+ const shippingName = [sFirstName, sLastName].filter(Boolean).join(" ");
1564
+ const billingName = [bFirstName, bLastName].filter(Boolean).join(" ");
1565
+ const name = customerName || shippingName || billingName;
1566
+ return name;
1567
+ };
1568
+
1569
+ // src/pages/orders/[id]/_components/order-customer-section/order-customer-section.tsx
1570
+ import { jsx as jsx19, jsxs as jsxs20 } from "react/jsx-runtime";
1571
+ var OrderCustomerSection = ({ order }) => {
1572
+ return /* @__PURE__ */ jsxs20(Container7, { className: "divide-y p-0", children: [
1573
+ /* @__PURE__ */ jsx19(Header, {}),
1574
+ /* @__PURE__ */ jsx19(CustomerInfo.ID, { data: order }),
1575
+ /* @__PURE__ */ jsx19(CustomerInfo.Contact, { data: order }),
1576
+ /* @__PURE__ */ jsx19(CustomerInfo.Company, { data: order }),
1577
+ /* @__PURE__ */ jsx19(CustomerInfo.Addresses, { data: order })
1578
+ ] });
1579
+ };
1580
+ var Header = () => {
1581
+ const { t } = useTranslation18();
1582
+ return /* @__PURE__ */ jsx19("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsx19(Heading7, { level: "h2", children: t("fields.customer") }) });
1583
+ };
1584
+
1585
+ // src/pages/orders/[id]/_components/order-fulfillment-section/order-fulfillment-section.tsx
1586
+ import { DocumentText, XCircle } from "@medusajs/icons";
1587
+ import {
1588
+ Button as Button6,
1589
+ Container as Container8,
1590
+ Copy as Copy3,
1591
+ Heading as Heading8,
1592
+ StatusBadge,
1593
+ Text as Text18,
1594
+ Tooltip as Tooltip2,
1595
+ toast as toast5,
1596
+ usePrompt as usePrompt2
1597
+ } from "@medusajs/ui";
1598
+ import { format } from "date-fns";
1599
+ import { useTranslation as useTranslation19 } from "react-i18next";
1600
+ import { Link as Link3, useNavigate as useNavigate5 } from "react-router-dom";
1601
+ import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs21 } from "react/jsx-runtime";
1602
+ var OrderFulfillmentSection = ({
1603
+ order
1604
+ }) => {
1605
+ const fulfillments = order.fulfillments || [];
1606
+ return /* @__PURE__ */ jsxs21("div", { className: "flex flex-col gap-y-3", children: [
1607
+ /* @__PURE__ */ jsx20(UnfulfilledItemBreakdown, { order }),
1608
+ fulfillments.map((f, index) => /* @__PURE__ */ jsx20(Fulfillment, { index, fulfillment: f, order }, f.id))
1609
+ ] });
1610
+ };
1611
+ var UnfulfilledItem = ({
1612
+ item,
1613
+ currencyCode
1614
+ }) => {
1615
+ return /* @__PURE__ */ jsxs21(
1616
+ "div",
1617
+ {
1618
+ className: "text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4",
1619
+ children: [
1620
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-start gap-x-4", children: [
1621
+ /* @__PURE__ */ jsx20(Thumbnail, { src: item.thumbnail }),
1622
+ /* @__PURE__ */ jsxs21("div", { children: [
1623
+ /* @__PURE__ */ jsx20(
1624
+ Text18,
1625
+ {
1626
+ size: "small",
1627
+ leading: "compact",
1628
+ weight: "plus",
1629
+ className: "text-ui-fg-base",
1630
+ children: item.title
1631
+ }
1632
+ ),
1633
+ item.variant_sku && /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-x-1", children: [
1634
+ /* @__PURE__ */ jsx20(Text18, { size: "small", children: item.variant_sku }),
1635
+ /* @__PURE__ */ jsx20(Copy3, { content: item.variant_sku, className: "text-ui-fg-muted" })
1636
+ ] }),
1637
+ /* @__PURE__ */ jsx20(Text18, { size: "small", children: item.variant?.options?.map((o) => o.value).join(" \xB7 ") })
1638
+ ] })
1639
+ ] }),
1640
+ /* @__PURE__ */ jsxs21("div", { className: "grid grid-cols-3 items-center gap-x-4", children: [
1641
+ /* @__PURE__ */ jsx20("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx20(Text18, { size: "small", children: getLocaleAmount(item.unit_price, currencyCode) }) }),
1642
+ /* @__PURE__ */ jsx20("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsxs21(Text18, { children: [
1643
+ /* @__PURE__ */ jsx20("span", { className: "tabular-nums", children: item.quantity - item.detail.fulfilled_quantity }),
1644
+ "x"
1645
+ ] }) }),
1646
+ /* @__PURE__ */ jsx20("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx20(Text18, { size: "small", children: getLocaleAmount(item.subtotal || 0, currencyCode) }) })
1647
+ ] })
1648
+ ]
1649
+ },
1650
+ item.id
1651
+ );
1652
+ };
1653
+ var UnfulfilledItemBreakdown = ({ order }) => {
1654
+ const unfulfilledItemsWithShipping = order.items.filter(
1655
+ (i) => i.requires_shipping && i.detail && i.quantity && i.detail.fulfilled_quantity < i.quantity
1656
+ );
1657
+ const unfulfilledItemsWithoutShipping = order.items.filter(
1658
+ (i) => !i.requires_shipping && i.detail && i.quantity && i.detail.fulfilled_quantity < i.quantity
1659
+ );
1660
+ return /* @__PURE__ */ jsxs21(Fragment2, { children: [
1661
+ !!unfulfilledItemsWithShipping.length && /* @__PURE__ */ jsx20(
1662
+ UnfulfilledItemDisplay,
1663
+ {
1664
+ order,
1665
+ unfulfilledItems: unfulfilledItemsWithShipping,
1666
+ requiresShipping: true
1667
+ }
1668
+ ),
1669
+ !!unfulfilledItemsWithoutShipping.length && /* @__PURE__ */ jsx20(
1670
+ UnfulfilledItemDisplay,
1671
+ {
1672
+ order,
1673
+ unfulfilledItems: unfulfilledItemsWithoutShipping,
1674
+ requiresShipping: false
1675
+ }
1676
+ )
1677
+ ] });
1678
+ };
1679
+ var UnfulfilledItemDisplay = ({
1680
+ order,
1681
+ unfulfilledItems,
1682
+ requiresShipping = false
1683
+ }) => {
1684
+ const { t } = useTranslation19();
1685
+ if (order.status === "canceled") {
1686
+ return;
1687
+ }
1688
+ return /* @__PURE__ */ jsxs21(Container8, { className: "divide-y p-0", children: [
1689
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between px-6 py-4", children: [
1690
+ /* @__PURE__ */ jsx20(Heading8, { level: "h2", children: t("orders.fulfillment.unfulfilledItems") }),
1691
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-x-4", children: [
1692
+ requiresShipping && /* @__PURE__ */ jsx20(StatusBadge, { color: "red", className: "text-nowrap", children: t("orders.fulfillment.requiresShipping") }),
1693
+ /* @__PURE__ */ jsx20(StatusBadge, { color: "red", className: "text-nowrap", children: t("orders.fulfillment.awaitingFulfillmentBadge") }),
1694
+ /* @__PURE__ */ jsx20(
1695
+ ActionMenu,
1696
+ {
1697
+ groups: [
1698
+ {
1699
+ actions: [
1700
+ {
1701
+ label: t("orders.fulfillment.fulfillItems"),
1702
+ icon: /* @__PURE__ */ jsx20(DocumentText, {}),
1703
+ to: `/orders/${order.id}/fulfillment?requires_shipping=${requiresShipping}`
1704
+ }
1705
+ ]
1706
+ }
1707
+ ]
1708
+ }
1709
+ )
1710
+ ] })
1711
+ ] }),
1712
+ /* @__PURE__ */ jsx20("div", { children: unfulfilledItems.map((item) => /* @__PURE__ */ jsx20(
1713
+ UnfulfilledItem,
1714
+ {
1715
+ item,
1716
+ currencyCode: order.currency_code
1717
+ },
1718
+ item.id
1719
+ )) })
1720
+ ] });
1721
+ };
1722
+ var Fulfillment = ({
1723
+ fulfillment,
1724
+ order,
1725
+ index
1726
+ }) => {
1727
+ const { t } = useTranslation19();
1728
+ const prompt = usePrompt2();
1729
+ const navigate = useNavigate5();
1730
+ const showLocation = !!fulfillment.location_id;
1731
+ const isPickUpFulfillment = fulfillment.shipping_option?.service_zone.fulfillment_set.type === "pickup" /* Pickup */;
1732
+ const { stock_location, isError, error } = useStockLocation(
1733
+ fulfillment.location_id,
1734
+ void 0,
1735
+ {
1736
+ enabled: showLocation
1737
+ }
1738
+ );
1739
+ let statusText = fulfillment.requires_shipping ? isPickUpFulfillment ? t("orders.fulfillment.status.awaitingPickup") : t("orders.fulfillment.status.awaitingShipping") : t("orders.fulfillment.status.awaitingDelivery");
1740
+ let statusColor = "blue";
1741
+ let statusTimestamp = fulfillment.created_at;
1742
+ if (fulfillment.canceled_at) {
1743
+ statusText = t("orders.fulfillment.status.canceled");
1744
+ statusColor = "red";
1745
+ statusTimestamp = fulfillment.canceled_at;
1746
+ } else if (fulfillment.delivered_at) {
1747
+ statusText = t("orders.fulfillment.status.delivered");
1748
+ statusColor = "green";
1749
+ statusTimestamp = fulfillment.delivered_at;
1750
+ } else if (fulfillment.shipped_at) {
1751
+ statusText = t("orders.fulfillment.status.shipped");
1752
+ statusColor = "green";
1753
+ statusTimestamp = fulfillment.shipped_at;
1754
+ }
1755
+ const { mutateAsync } = useCancelOrderFulfillment(order.id, fulfillment.id);
1756
+ const { mutateAsync: markAsDelivered } = useMarkOrderFulfillmentAsDelivered(
1757
+ order.id,
1758
+ fulfillment.id
1759
+ );
1760
+ const showShippingButton = !fulfillment.canceled_at && !fulfillment.shipped_at && !fulfillment.delivered_at && fulfillment.requires_shipping && !isPickUpFulfillment;
1761
+ const showDeliveryButton = !fulfillment.canceled_at && !fulfillment.delivered_at;
1762
+ const cancelDisabled = !!fulfillment.canceled_at || !!fulfillment.shipped_at || !!fulfillment.delivered_at;
1763
+ const handleMarkAsDelivered = async () => {
1764
+ const res = await prompt({
1765
+ title: t("general.areYouSure"),
1766
+ description: t("orders.fulfillment.markAsDeliveredWarning"),
1767
+ confirmText: t("actions.continue"),
1768
+ cancelText: t("actions.cancel"),
1769
+ variant: "confirmation"
1770
+ });
1771
+ if (res) {
1772
+ await markAsDelivered(void 0, {
1773
+ onSuccess: () => {
1774
+ toast5.success(
1775
+ t(
1776
+ isPickUpFulfillment ? "orders.fulfillment.toast.fulfillmentPickedUp" : "orders.fulfillment.toast.fulfillmentDelivered"
1777
+ )
1778
+ );
1779
+ },
1780
+ onError: (e) => {
1781
+ toast5.error(e.message);
1782
+ }
1783
+ });
1784
+ }
1785
+ };
1786
+ const handleCancel = async () => {
1787
+ if (fulfillment.shipped_at) {
1788
+ toast5.warning(t("orders.fulfillment.toast.fulfillmentShipped"));
1789
+ return;
1790
+ }
1791
+ const res = await prompt({
1792
+ title: t("general.areYouSure"),
1793
+ description: t("orders.fulfillment.cancelWarning"),
1794
+ confirmText: t("actions.continue"),
1795
+ cancelText: t("actions.cancel")
1796
+ });
1797
+ if (res) {
1798
+ await mutateAsync(void 0, {
1799
+ onSuccess: () => {
1800
+ toast5.success(t("orders.fulfillment.toast.canceled"));
1801
+ },
1802
+ onError: (e) => {
1803
+ toast5.error(e.message);
1804
+ }
1805
+ });
1806
+ }
1807
+ };
1808
+ if (isError) {
1809
+ throw error;
1810
+ }
1811
+ return /* @__PURE__ */ jsxs21(Container8, { className: "divide-y p-0", children: [
1812
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center justify-between px-6 py-4", children: [
1813
+ /* @__PURE__ */ jsx20(Heading8, { level: "h2", children: t("orders.fulfillment.number", {
1814
+ number: index + 1
1815
+ }) }),
1816
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-x-4", children: [
1817
+ /* @__PURE__ */ jsx20(
1818
+ Tooltip2,
1819
+ {
1820
+ content: format(
1821
+ new Date(statusTimestamp),
1822
+ "dd MMM, yyyy, HH:mm:ss"
1823
+ ),
1824
+ children: /* @__PURE__ */ jsx20(StatusBadge, { color: statusColor, className: "text-nowrap", children: statusText })
1825
+ }
1826
+ ),
1827
+ /* @__PURE__ */ jsx20(
1828
+ ActionMenu,
1829
+ {
1830
+ groups: [
1831
+ {
1832
+ actions: [
1833
+ {
1834
+ label: t("actions.cancel"),
1835
+ icon: /* @__PURE__ */ jsx20(XCircle, {}),
1836
+ onClick: handleCancel,
1837
+ disabled: cancelDisabled,
1838
+ disabledTooltip: fulfillment.shipped_at ? t("orders.fulfillment.cancelDisabledTooltip") : void 0
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 as DocumentText2 } 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 { label: "Canceled", color: "red" };
2111
+ }
2112
+ if (refundedAmount > 0 && refundedAmount >= payment.amount) {
2113
+ return { label: "Refunded", color: "grey" };
2114
+ }
2115
+ if (refundedAmount > 0) {
2116
+ return { label: "Partly refunded", color: "orange" };
2117
+ }
2118
+ if (payment.captured_at) {
2119
+ return { label: "Captured", color: "green" };
2120
+ }
2121
+ return { label: "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: status.label }),
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(DocumentText2, { 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 DocumentText3,
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/lib/orders.ts
2256
+ function getReservationsLimitCount(order) {
2257
+ if (!order?.items?.length) {
2258
+ return 0;
2259
+ }
2260
+ return order.items.reduce(
2261
+ (acc, item) => acc + (item.variant?.inventory_items?.length || 1),
2262
+ 0
2263
+ );
2264
+ }
2265
+
2266
+ // src/pages/orders/[id]/_components/order-summary-section/return-info-popover.tsx
2267
+ import { useState as useState4 } from "react";
2268
+ import { useTranslation as useTranslation22 } from "react-i18next";
2269
+ import { InformationCircleSolid } from "@medusajs/icons";
2270
+ import { Badge as Badge2, Popover as Popover3, Text as Text21 } from "@medusajs/ui";
2271
+ import { jsx as jsx23, jsxs as jsxs24 } from "react/jsx-runtime";
2272
+ function ReturnInfoPopover({ orderReturn }) {
2273
+ const { t } = useTranslation22();
2274
+ const { getFullDate } = useDate();
2275
+ const [open, setOpen] = useState4(false);
2276
+ if (typeof orderReturn !== "object") {
2277
+ return null;
2278
+ }
2279
+ let returnType = "Return";
2280
+ let returnTypeId = orderReturn.id;
2281
+ if (orderReturn.claim_id) {
2282
+ returnType = "Claim";
2283
+ returnTypeId = orderReturn.claim_id;
2284
+ }
2285
+ if (orderReturn.exchange_id) {
2286
+ returnType = "Exchange";
2287
+ returnTypeId = orderReturn.exchange_id;
2288
+ }
2289
+ return /* @__PURE__ */ jsxs24(Popover3, { open, children: [
2290
+ /* @__PURE__ */ jsx23(
2291
+ Popover3.Trigger,
2292
+ {
2293
+ onMouseEnter: () => setOpen(true),
2294
+ onMouseLeave: () => setOpen(false),
2295
+ autoFocus: false,
2296
+ className: "align-sub focus-visible:outline-none",
2297
+ "data-testid": "order-summary-return-info-trigger",
2298
+ children: /* @__PURE__ */ jsx23(InformationCircleSolid, {})
2299
+ }
2300
+ ),
2301
+ /* @__PURE__ */ jsx23(
2302
+ Popover3.Content,
2303
+ {
2304
+ align: "center",
2305
+ side: "top",
2306
+ className: "bg-ui-bg-component p-2 focus-visible:outline-none",
2307
+ children: /* @__PURE__ */ jsxs24("div", { children: [
2308
+ /* @__PURE__ */ jsxs24(Badge2, { size: "2xsmall", className: "mb-2", rounded: "full", children: [
2309
+ returnType,
2310
+ ": #",
2311
+ returnTypeId.slice(-7)
2312
+ ] }),
2313
+ /* @__PURE__ */ jsxs24(Text21, { size: "xsmall", children: [
2314
+ /* @__PURE__ */ jsx23("span", { className: "text-ui-fg-subtle", children: t("orders.returns.returnRequested") }),
2315
+ " \xB7 ",
2316
+ getFullDate({
2317
+ date: orderReturn.requested_at,
2318
+ includeTime: true
2319
+ })
2320
+ ] }),
2321
+ /* @__PURE__ */ jsxs24(Text21, { size: "xsmall", children: [
2322
+ /* @__PURE__ */ jsx23("span", { className: "text-ui-fg-subtle", children: t("orders.returns.itemReceived") }),
2323
+ " \xB7 ",
2324
+ orderReturn.received_at ? getFullDate({
2325
+ date: orderReturn.received_at,
2326
+ includeTime: true
2327
+ }) : "-"
2328
+ ] })
2329
+ ] })
2330
+ }
2331
+ )
2332
+ ] });
2333
+ }
2334
+ var return_info_popover_default = ReturnInfoPopover;
2335
+
2336
+ // src/pages/orders/[id]/_components/order-summary-section/shipping-info-popover.tsx
2337
+ import { InformationCircleSolid as InformationCircleSolid2 } from "@medusajs/icons";
2338
+ import { Badge as Badge3, Tooltip as Tooltip4 } from "@medusajs/ui";
2339
+ import { useTranslation as useTranslation23 } from "react-i18next";
2340
+ import { jsx as jsx24, jsxs as jsxs25 } from "react/jsx-runtime";
2341
+ function ShippingInfoPopover({ shippingMethod }) {
2342
+ const { t } = useTranslation23();
2343
+ const shippingDetail = shippingMethod?.detail;
2344
+ if (!shippingDetail) {
2345
+ return;
2346
+ }
2347
+ let rmaType = t("orders.return");
2348
+ let rmaId = shippingDetail.return_id;
2349
+ if (shippingDetail.claim_id) {
2350
+ rmaType = t("orders.claim");
2351
+ rmaId = shippingDetail.claim_id;
2352
+ }
2353
+ if (shippingDetail.exchange_id) {
2354
+ rmaType = t("orders.exchange");
2355
+ rmaId = shippingDetail.exchange_id;
2356
+ }
2357
+ if (!rmaId) {
2358
+ return;
2359
+ }
2360
+ return /* @__PURE__ */ jsx24(
2361
+ Tooltip4,
2362
+ {
2363
+ content: /* @__PURE__ */ jsxs25(Badge3, { size: "2xsmall", rounded: "full", children: [
2364
+ rmaType,
2365
+ ": #",
2366
+ rmaId.slice(-7)
2367
+ ] }),
2368
+ children: /* @__PURE__ */ jsx24(InformationCircleSolid2, { className: "inline-block text-ui-fg-muted ml-1" })
2369
+ }
2370
+ );
2371
+ }
2372
+ var shipping_info_popover_default = ShippingInfoPopover;
2373
+
2374
+ // src/pages/orders/[id]/_components/order-summary-section/order-summary-section.tsx
2375
+ import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs26 } from "react/jsx-runtime";
2376
+ var OrderSummarySection = ({
2377
+ order
2378
+ }) => {
2379
+ const { t } = useTranslation24();
2380
+ const { reservations } = useReservationItems(
2381
+ {
2382
+ line_item_id: order?.items?.map((i) => i.id),
2383
+ limit: getReservationsLimitCount(order)
2384
+ },
2385
+ { enabled: Array.isArray(order?.items) }
2386
+ );
2387
+ const { order: orderPreview } = useOrderPreview(order.id);
2388
+ const reservationList = useMemo5(
2389
+ () => reservations ?? [],
2390
+ [reservations]
2391
+ );
2392
+ const { returns: receivableReturnsList = [] } = useReturns({
2393
+ status: "requested",
2394
+ order_id: order.id,
2395
+ fields: "+received_at"
2396
+ });
2397
+ const receivableReturns = useMemo5(
2398
+ () => receivableReturnsList.filter((r) => !r.canceled_at),
2399
+ [receivableReturnsList]
2400
+ );
2401
+ const showReturns = !!receivableReturns.length;
2402
+ const showAllocateButton = useMemo5(() => {
2403
+ if (!reservations) {
2404
+ return false;
2405
+ }
2406
+ const reservationsMap = new Map(
2407
+ reservationList.map((r) => [r.line_item_id, r.id])
2408
+ );
2409
+ return order.items?.some((item) => {
2410
+ const offerLinks = item.offer?.inventory_item_link;
2411
+ if (!offerLinks?.length) {
2412
+ return false;
2413
+ }
2414
+ const fulfilled = item.detail?.fulfilled_quantity ?? 0;
2415
+ if (item.quantity - fulfilled <= 0) {
2416
+ return false;
2417
+ }
2418
+ return !reservationsMap.has(item.id);
2419
+ }) ?? false;
2420
+ }, [order.items, reservations, reservationList]);
2421
+ const unpaidPaymentCollection = order.payment_collections?.find(
2422
+ (pc) => pc.status !== "captured" && pc.status !== "canceled"
2423
+ );
2424
+ const pendingDifference = order.summary?.pending_difference || 0;
2425
+ const isAmountSignificant = !isAmountLessThenRoundingError(
2426
+ pendingDifference,
2427
+ order.currency_code
2428
+ );
2429
+ const showRefund = unpaidPaymentCollection && pendingDifference < 0 && isAmountSignificant;
2430
+ return /* @__PURE__ */ jsxs26(Container11, { className: "divide-y p-0", children: [
2431
+ /* @__PURE__ */ jsx25(Header3, { order, orderPreview }),
2432
+ /* @__PURE__ */ jsx25(ItemBreakdown, { order, reservations: reservationList }),
2433
+ /* @__PURE__ */ jsx25(CostBreakdown, { order }),
2434
+ /* @__PURE__ */ jsx25(Total2, { order }),
2435
+ (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: [
2436
+ showReturns && (receivableReturns.length === 1 ? /* @__PURE__ */ jsx25(Button7, { asChild: true, variant: "secondary", size: "small", children: /* @__PURE__ */ jsx25(
2437
+ Link4,
2438
+ {
2439
+ to: `/orders/${order.id}/returns/${receivableReturns[0].id}/receive`,
2440
+ children: t("orders.returns.receive.action")
2441
+ }
2442
+ ) }) : /* @__PURE__ */ jsx25(
2443
+ ActionMenu,
2444
+ {
2445
+ groups: [
2446
+ {
2447
+ actions: receivableReturns.map((r) => {
2448
+ let id = r.id;
2449
+ let returnType = "Return";
2450
+ if (r.exchange_id) {
2451
+ id = r.exchange_id;
2452
+ returnType = "Exchange";
2453
+ }
2454
+ if (r.claim_id) {
2455
+ id = r.claim_id;
2456
+ returnType = "Claim";
2457
+ }
2458
+ return {
2459
+ label: t("orders.returns.receive.receiveItems", {
2460
+ id: `#${id?.slice(-7)}`,
2461
+ returnType
2462
+ }),
2463
+ icon: /* @__PURE__ */ jsx25(ArrowLongRight, {}),
2464
+ to: `/orders/${order.id}/returns/${r.id}/receive`
2465
+ };
2466
+ })
2467
+ }
2468
+ ],
2469
+ children: /* @__PURE__ */ jsx25(Button7, { variant: "secondary", size: "small", children: t("orders.returns.receive.action") })
2470
+ }
2471
+ )),
2472
+ showAllocateButton && /* @__PURE__ */ jsx25(
2473
+ Button7,
2474
+ {
2475
+ asChild: true,
2476
+ variant: "secondary",
2477
+ size: "small",
2478
+ "data-testid": "order-summary-allocate-items-cta",
2479
+ children: /* @__PURE__ */ jsx25(Link4, { to: "allocate-items", children: t("orders.allocateItems.action") })
2480
+ }
2481
+ ),
2482
+ showRefund && /* @__PURE__ */ jsx25(Button7, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx25(Link4, { to: `/orders/${order.id}/refund`, children: t("orders.payment.refundAmount", {
2483
+ amount: getStylizedAmount(
2484
+ pendingDifference * -1,
2485
+ order?.currency_code
2486
+ )
2487
+ }) }) })
2488
+ ] }),
2489
+ /* @__PURE__ */ jsx25(OutstandingActions, { order })
2490
+ ] });
2491
+ };
2492
+ var Header3 = ({
2493
+ order,
2494
+ orderPreview
2495
+ }) => {
2496
+ const { t } = useTranslation24();
2497
+ const isCanceled = !!order.canceled_at;
2498
+ const returnOutOfPolicy = isOutsidePolicyWindow(order, RETURN_POLICY_DAYS);
2499
+ const exchangeOutOfPolicy = isOutsidePolicyWindow(
2500
+ order,
2501
+ EXCHANGE_POLICY_DAYS
2502
+ );
2503
+ const claimOutOfPolicy = isOutsidePolicyWindow(order, CLAIM_POLICY_DAYS);
2504
+ const shouldDisableReturn = (order.items || []).every(
2505
+ (i) => !(getReturnableQuantity(i) > 0)
2506
+ );
2507
+ const orderChange = orderPreview?.order_change;
2508
+ const isOrderEditActive = orderChange?.change_type === "edit";
2509
+ const isOrderEditPending = orderChange?.change_type === "edit" && orderChange?.status === "pending";
2510
+ const editDisabled = isCanceled || !!orderChange && orderChange.change_type !== "edit" || orderChange?.change_type === "edit" && orderChange?.status === "requested";
2511
+ const returnDisabledByChange = isOrderEditActive || !!orderChange?.exchange_id || !!orderChange?.claim_id;
2512
+ const exchangeDisabledByChange = isOrderEditActive || !!orderChange?.return_id && !orderChange?.exchange_id || !!orderChange?.claim_id;
2513
+ const claimDisabledByChange = isOrderEditActive || !!orderChange?.return_id && !orderChange?.claim_id || !!orderChange?.exchange_id;
2514
+ return /* @__PURE__ */ jsxs26("div", { className: "flex items-center justify-between px-6 py-4", children: [
2515
+ /* @__PURE__ */ jsx25(Heading11, { level: "h2", children: t("fields.summary") }),
2516
+ /* @__PURE__ */ jsx25(
2517
+ ActionMenu,
2518
+ {
2519
+ groups: [
2520
+ {
2521
+ actions: [
2522
+ {
2523
+ label: t(
2524
+ isOrderEditPending ? "orders.summary.editOrderContinue" : "orders.edits.create"
2525
+ ),
2526
+ to: "edit",
2527
+ disabled: editDisabled,
2528
+ icon: /* @__PURE__ */ jsx25(PencilSquare, {})
2529
+ }
2530
+ ]
2531
+ },
2532
+ {
2533
+ actions: [
2534
+ {
2535
+ label: t("orders.returns.create"),
2536
+ to: "returns/create",
2537
+ disabled: isCanceled || returnOutOfPolicy || shouldDisableReturn || returnDisabledByChange,
2538
+ disabledTooltip: returnOutOfPolicy ? t("orders.returns.outOfPolicy", {
2539
+ days: RETURN_POLICY_DAYS
2540
+ }) : void 0,
2541
+ icon: /* @__PURE__ */ jsx25(ArrowUturnLeft3, {})
2542
+ },
2543
+ {
2544
+ label: orderChange?.id && orderChange?.exchange_id ? t("orders.exchanges.manage") : t("orders.exchanges.create"),
2545
+ to: "exchanges/create",
2546
+ disabled: isCanceled || exchangeOutOfPolicy || shouldDisableReturn || exchangeDisabledByChange,
2547
+ disabledTooltip: exchangeOutOfPolicy ? t("orders.exchanges.outOfPolicy", {
2548
+ days: EXCHANGE_POLICY_DAYS
2549
+ }) : void 0,
2550
+ icon: /* @__PURE__ */ jsx25(ArrowPath2, {})
2551
+ },
2552
+ {
2553
+ label: orderChange?.id && orderChange?.claim_id ? t("orders.claims.manage") : t("orders.claims.create"),
2554
+ to: "claims/create",
2555
+ disabled: isCanceled || claimOutOfPolicy || shouldDisableReturn || claimDisabledByChange,
2556
+ disabledTooltip: claimOutOfPolicy ? t("orders.claims.outOfPolicy", {
2557
+ days: CLAIM_POLICY_DAYS
2558
+ }) : void 0,
2559
+ icon: /* @__PURE__ */ jsx25(ExclamationCircle2, {})
2560
+ }
2561
+ ]
2562
+ }
2563
+ ]
2564
+ }
2565
+ )
2566
+ ] });
2567
+ };
2568
+ var Item = ({
2569
+ item,
2570
+ currencyCode,
2571
+ returns,
2572
+ reservation
2573
+ }) => {
2574
+ const { t } = useTranslation24();
2575
+ const original_price = item.variant?.prices?.find((price2) => price2.currency_code === currencyCode)?.amount || 0;
2576
+ const price = item.unit_price;
2577
+ const offerInventoryLinks = item.offer?.inventory_item_link ?? [];
2578
+ const isInventoryManaged = !!offerInventoryLinks.length;
2579
+ const hasUnfulfilledItems = item.quantity - (item.detail?.fulfilled_quantity ?? 0) > 0;
2580
+ const offerSku = item.offer?.sku ?? null;
2581
+ const captionSku = offerSku ?? item.variant_sku ?? null;
2582
+ return /* @__PURE__ */ jsxs26(Fragment3, { children: [
2583
+ /* @__PURE__ */ jsxs26(
2584
+ "div",
2585
+ {
2586
+ className: "text-ui-fg-subtle grid grid-cols-2 items-center gap-x-4 px-6 py-4",
2587
+ children: [
2588
+ /* @__PURE__ */ jsxs26("div", { className: "flex items-start gap-x-4", children: [
2589
+ /* @__PURE__ */ jsx25(Thumbnail, { src: item.thumbnail }),
2590
+ /* @__PURE__ */ jsxs26("div", { children: [
2591
+ /* @__PURE__ */ jsx25(
2592
+ Text22,
2593
+ {
2594
+ size: "small",
2595
+ leading: "compact",
2596
+ weight: "plus",
2597
+ className: "text-ui-fg-base",
2598
+ children: item.title || item.product_title
2599
+ }
2600
+ ),
2601
+ captionSku && /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-x-1", children: [
2602
+ /* @__PURE__ */ jsx25(Text22, { size: "small", children: captionSku }),
2603
+ /* @__PURE__ */ jsx25(Copy5, { content: captionSku, className: "text-ui-fg-muted" })
2604
+ ] }),
2605
+ /* @__PURE__ */ jsx25(Text22, { size: "small", children: item.variant?.options?.map((o) => o.value).join(" \xB7 ") })
2606
+ ] })
2607
+ ] }),
2608
+ /* @__PURE__ */ jsxs26("div", { className: "grid grid-cols-3 items-center gap-x-4", children: [
2609
+ /* @__PURE__ */ jsx25("div", { className: "flex items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs26(Text22, { size: "small", children: [
2610
+ original_price !== price && /* @__PURE__ */ jsx25("span", { className: "line-through text-ui-fg-muted text-xs mr-1", children: getLocaleAmount(original_price, currencyCode) }),
2611
+ getLocaleAmount(price, currencyCode)
2612
+ ] }) }),
2613
+ /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-x-2", children: [
2614
+ /* @__PURE__ */ jsx25("div", { className: "w-fit min-w-[27px]", children: /* @__PURE__ */ jsxs26(Text22, { size: "small", children: [
2615
+ /* @__PURE__ */ jsx25("span", { className: "tabular-nums", children: item.quantity }),
2616
+ "x"
2617
+ ] }) }),
2618
+ /* @__PURE__ */ jsx25("div", { className: "overflow-visible", children: isInventoryManaged && hasUnfulfilledItems && /* @__PURE__ */ jsx25(
2619
+ StatusBadge4,
2620
+ {
2621
+ color: reservation ? "green" : "orange",
2622
+ className: "text-nowrap",
2623
+ children: reservation ? t("orders.reservations.allocatedLabel") : t("orders.reservations.notAllocatedLabel")
2624
+ }
2625
+ ) })
2626
+ ] }),
2627
+ /* @__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) }) })
2628
+ ] })
2629
+ ]
2630
+ },
2631
+ item.id
2632
+ ),
2633
+ returns.map((r) => /* @__PURE__ */ jsx25(ReturnBreakdown, { orderReturn: r, itemId: item.id }, r.id))
2634
+ ] });
2635
+ };
2636
+ var ItemBreakdown = ({
2637
+ order,
2638
+ reservations
2639
+ }) => {
2640
+ const { returns: returnsList = [] } = useReturns({
2641
+ order_id: order.id,
2642
+ fields: "*items,*items.reason"
2643
+ });
2644
+ const returns = useMemo5(
2645
+ () => returnsList.filter((r) => !r.canceled_at),
2646
+ [returnsList]
2647
+ );
2648
+ const reservationsMap = useMemo5(
2649
+ () => new Map(reservations.map((r) => [r.line_item_id, r])),
2650
+ [reservations]
2651
+ );
2652
+ return /* @__PURE__ */ jsx25("div", { children: order.items?.map((item) => {
2653
+ return /* @__PURE__ */ jsx25(
2654
+ Item,
2655
+ {
2656
+ item,
2657
+ currencyCode: order.currency_code,
2658
+ returns,
2659
+ reservation: reservationsMap.get(item.id)
2660
+ },
2661
+ item.id
2662
+ );
2663
+ }) });
2664
+ };
2665
+ var ReturnBreakdownWithDamages = ({
2666
+ orderReturn,
2667
+ itemId
2668
+ }) => {
2669
+ const { t } = useTranslation24();
2670
+ const item = orderReturn.items?.find((ri) => ri.item_id === itemId);
2671
+ const damagedQuantity = item?.damaged_quantity || 0;
2672
+ if (!item || damagedQuantity <= 0) {
2673
+ return null;
2674
+ }
2675
+ return /* @__PURE__ */ jsxs26(
2676
+ "div",
2677
+ {
2678
+ 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",
2679
+ children: [
2680
+ /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-2", children: [
2681
+ /* @__PURE__ */ jsx25(ArrowDownRightMini, { className: "text-ui-fg-muted" }),
2682
+ /* @__PURE__ */ jsx25(Text22, { size: "small", children: t("orders.returns.damagedItemsReturned", {
2683
+ quantity: damagedQuantity
2684
+ }) }),
2685
+ item.note && /* @__PURE__ */ jsx25(Tooltip5, { content: item.note, children: /* @__PURE__ */ jsx25(DocumentText3, { className: "text-ui-tag-neutral-icon ml-1 inline" }) }),
2686
+ item.reason && /* @__PURE__ */ jsx25(
2687
+ Badge4,
2688
+ {
2689
+ size: "2xsmall",
2690
+ className: "cursor-default select-none capitalize",
2691
+ rounded: "full",
2692
+ children: item.reason.label
2693
+ }
2694
+ )
2695
+ ] }),
2696
+ /* @__PURE__ */ jsxs26(Text22, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
2697
+ t("orders.returns.damagedItemReceived"),
2698
+ /* @__PURE__ */ jsx25("span", { className: "ml-2", children: /* @__PURE__ */ jsx25(return_info_popover_default, { orderReturn }) })
2699
+ ] })
2700
+ ]
2701
+ },
2702
+ `${orderReturn.id}-damaged`
2703
+ );
2704
+ };
2705
+ var ReturnBreakdown = ({
2706
+ orderReturn,
2707
+ itemId
2708
+ }) => {
2709
+ const { t } = useTranslation24();
2710
+ const { getRelativeDate } = useDate();
2711
+ if (!["requested", "received", "partially_received"].includes(
2712
+ orderReturn.status || ""
2713
+ )) {
2714
+ return null;
2715
+ }
2716
+ const isRequested = orderReturn.status === "requested";
2717
+ const item = orderReturn.items?.find((ri) => ri.item_id === itemId);
2718
+ if (!item) {
2719
+ return null;
2720
+ }
2721
+ const damagedQuantity = item.damaged_quantity || 0;
2722
+ return /* @__PURE__ */ jsxs26(Fragment3, { children: [
2723
+ damagedQuantity > 0 && /* @__PURE__ */ jsx25(
2724
+ ReturnBreakdownWithDamages,
2725
+ {
2726
+ orderReturn,
2727
+ itemId
2728
+ }
2729
+ ),
2730
+ /* @__PURE__ */ jsxs26(
2731
+ "div",
2732
+ {
2733
+ 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",
2734
+ children: [
2735
+ /* @__PURE__ */ jsxs26("div", { className: "flex items-center gap-2", children: [
2736
+ /* @__PURE__ */ jsx25(ArrowDownRightMini, { className: "text-ui-fg-muted" }),
2737
+ /* @__PURE__ */ jsx25(Text22, { size: "small", children: t(
2738
+ `orders.returns.${isRequested ? "returnRequestedInfo" : "returnReceivedInfo"}`,
2739
+ {
2740
+ requestedItemsCount: isRequested ? item.quantity : item.received_quantity
2741
+ }
2742
+ ) }),
2743
+ item.note && /* @__PURE__ */ jsx25(Tooltip5, { content: item.note, children: /* @__PURE__ */ jsx25(DocumentText3, { className: "text-ui-tag-neutral-icon ml-1 inline" }) }),
2744
+ item.reason && /* @__PURE__ */ jsx25(
2745
+ Badge4,
2746
+ {
2747
+ size: "2xsmall",
2748
+ className: "cursor-default select-none capitalize",
2749
+ rounded: "full",
2750
+ children: item.reason.label
2751
+ }
2752
+ )
2753
+ ] }),
2754
+ isRequested ? /* @__PURE__ */ jsxs26(Text22, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
2755
+ getRelativeDate(orderReturn.created_at),
2756
+ /* @__PURE__ */ jsx25("span", { className: "ml-2", children: /* @__PURE__ */ jsx25(return_info_popover_default, { orderReturn }) })
2757
+ ] }) : /* @__PURE__ */ jsxs26(Text22, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: [
2758
+ t("orders.returns.itemReceived"),
2759
+ /* @__PURE__ */ jsx25("span", { className: "ml-2", children: /* @__PURE__ */ jsx25(return_info_popover_default, { orderReturn }) })
2760
+ ] })
2761
+ ]
2762
+ },
2763
+ item.id
2764
+ )
2765
+ ] });
2766
+ };
2767
+ var Cost = ({
2768
+ label,
2769
+ value,
2770
+ secondaryValue,
2771
+ tooltip
2772
+ }) => /* @__PURE__ */ jsxs26("div", { className: "grid grid-cols-3 items-center", children: [
2773
+ /* @__PURE__ */ jsxs26(Text22, { size: "small", leading: "compact", children: [
2774
+ label,
2775
+ " ",
2776
+ tooltip
2777
+ ] }),
2778
+ /* @__PURE__ */ jsx25("div", { className: "text-right", children: /* @__PURE__ */ jsx25(Text22, { size: "small", leading: "compact", children: secondaryValue }) }),
2779
+ /* @__PURE__ */ jsx25("div", { className: "text-right", children: /* @__PURE__ */ jsx25(Text22, { size: "small", leading: "compact", children: value }) })
2780
+ ] });
2781
+ var CostBreakdown = ({
2782
+ order
2783
+ }) => {
2784
+ const { t } = useTranslation24();
2785
+ const [isTaxOpen, setIsTaxOpen] = useState5(false);
2786
+ const [isShippingOpen, setIsShippingOpen] = useState5(false);
2787
+ const discountCodes = useMemo5(() => {
2788
+ const codes = /* @__PURE__ */ new Set();
2789
+ order.items.forEach(
2790
+ (item) => item.adjustments?.forEach((adj) => {
2791
+ codes.add(adj.code);
2792
+ })
2793
+ );
2794
+ return Array.from(codes).sort();
2795
+ }, [order]);
2796
+ const taxCodes = useMemo5(() => {
2797
+ const taxCodeMap = {};
2798
+ order.items.forEach((item) => {
2799
+ item.tax_lines?.forEach((line) => {
2800
+ taxCodeMap[line.code] = (taxCodeMap[line.code] || 0) + line.total;
2801
+ });
2802
+ });
2803
+ order.shipping_methods.forEach((sm) => {
2804
+ sm.tax_lines?.forEach((line) => {
2805
+ taxCodeMap[line.code] = (taxCodeMap[line.code] || 0) + line.total;
2806
+ });
2807
+ });
2808
+ return taxCodeMap;
2809
+ }, [order]);
2810
+ const automaticTaxesOn = !!order.region?.automatic_taxes;
2811
+ const hasTaxLines = !!Object.keys(taxCodes).length;
2812
+ const discountTotal = automaticTaxesOn ? order.discount_total : order.discount_subtotal;
2813
+ return /* @__PURE__ */ jsxs26("div", { className: "text-ui-fg-subtle flex flex-col gap-y-2 px-6 py-4", children: [
2814
+ /* @__PURE__ */ jsx25(
2815
+ Cost,
2816
+ {
2817
+ label: t(
2818
+ automaticTaxesOn ? "orders.summary.itemTotal" : "orders.summary.itemSubtotal"
2819
+ ),
2820
+ value: getLocaleAmount(order.item_total, order.currency_code)
2821
+ }
2822
+ ),
2823
+ /* @__PURE__ */ jsx25(
2824
+ Cost,
2825
+ {
2826
+ label: (
2827
+ // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
2828
+ /* @__PURE__ */ jsxs26(
2829
+ "span",
2830
+ {
2831
+ onClick: () => setIsShippingOpen((o) => !o),
2832
+ className: "flex cursor-pointer items-center gap-1",
2833
+ children: [
2834
+ /* @__PURE__ */ jsx25("span", { children: t(
2835
+ automaticTaxesOn ? "orders.summary.shippingTotal" : "orders.summary.shippingSubtotal"
2836
+ ) }),
2837
+ /* @__PURE__ */ jsx25(
2838
+ TriangleDownMini,
2839
+ {
2840
+ style: {
2841
+ transform: `rotate(${isShippingOpen ? 0 : -90}deg)`
2842
+ }
2843
+ }
2844
+ )
2845
+ ]
2846
+ }
2847
+ )
2848
+ ),
2849
+ value: getLocaleAmount(
2850
+ automaticTaxesOn ? order.shipping_total : order.shipping_subtotal,
2851
+ order.currency_code
2852
+ )
2853
+ }
2854
+ ),
2855
+ isShippingOpen && /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1 pl-5", children: (order.shipping_methods || []).sort(
2856
+ (m1, m2) => m1.created_at.localeCompare(m2.created_at)
2857
+ ).map((sm, i) => {
2858
+ return /* @__PURE__ */ jsxs26(
2859
+ "div",
2860
+ {
2861
+ className: "flex items-center justify-between gap-x-2",
2862
+ children: [
2863
+ /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsxs26("span", { className: "txt-small text-ui-fg-subtle font-medium", children: [
2864
+ sm.name,
2865
+ sm.detail?.return_id && ` (${t("fields.returnShipping")})`,
2866
+ " ",
2867
+ /* @__PURE__ */ jsx25(shipping_info_popover_default, { shippingMethod: sm }, i)
2868
+ ] }) }),
2869
+ /* @__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" }) }),
2870
+ /* @__PURE__ */ jsx25("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(
2871
+ automaticTaxesOn ? sm.total : sm.subtotal,
2872
+ order.currency_code
2873
+ ) })
2874
+ ]
2875
+ },
2876
+ sm.id
2877
+ );
2878
+ }) }),
2879
+ /* @__PURE__ */ jsx25(
2880
+ Cost,
2881
+ {
2882
+ label: t(
2883
+ automaticTaxesOn ? "orders.summary.discountTotal" : "orders.summary.discountSubtotal"
2884
+ ),
2885
+ secondaryValue: discountCodes.join(", "),
2886
+ value: discountTotal > 0 ? `- ${getLocaleAmount(discountTotal, order.currency_code)}` : "-"
2887
+ }
2888
+ ),
2889
+ /* @__PURE__ */ jsxs26(Fragment3, { children: [
2890
+ /* @__PURE__ */ jsxs26("div", { className: "flex justify-between", children: [
2891
+ /* @__PURE__ */ jsxs26(
2892
+ "div",
2893
+ {
2894
+ onClick: () => hasTaxLines && setIsTaxOpen((o) => !o),
2895
+ className: clx2("flex items-center gap-1", {
2896
+ "cursor-pointer": hasTaxLines
2897
+ }),
2898
+ children: [
2899
+ /* @__PURE__ */ jsx25("span", { className: "txt-small select-none", children: t(
2900
+ automaticTaxesOn ? "orders.summary.taxTotalIncl" : "orders.summary.taxTotal"
2901
+ ) }),
2902
+ hasTaxLines && /* @__PURE__ */ jsx25(
2903
+ TriangleDownMini,
2904
+ {
2905
+ style: {
2906
+ transform: `rotate(${isTaxOpen ? 0 : -90}deg)`
2907
+ }
2908
+ }
2909
+ )
2910
+ ]
2911
+ }
2912
+ ),
2913
+ /* @__PURE__ */ jsx25("div", { className: "text-right", children: /* @__PURE__ */ jsx25(Text22, { size: "small", leading: "compact", children: getLocaleAmount(order.tax_total, order.currency_code) }) })
2914
+ ] }),
2915
+ isTaxOpen && /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1 pl-5", children: Object.entries(taxCodes).map(([code, total]) => {
2916
+ return /* @__PURE__ */ jsxs26(
2917
+ "div",
2918
+ {
2919
+ className: "flex items-center justify-between gap-x-2",
2920
+ children: [
2921
+ /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25("span", { className: "txt-small text-ui-fg-subtle font-medium", children: code }) }),
2922
+ /* @__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" }) }),
2923
+ /* @__PURE__ */ jsx25("span", { className: "txt-small text-ui-fg-muted", children: getLocaleAmount(total, order.currency_code) })
2924
+ ]
2925
+ },
2926
+ code
2927
+ );
2928
+ }) })
2929
+ ] })
2930
+ ] });
2931
+ };
2932
+ var Total2 = ({ order }) => {
2933
+ const { t } = useTranslation24();
2934
+ const totalCaptured = getTotalCaptured(order.payment_collections || []);
2935
+ const outstanding = Math.max(0, order.total - totalCaptured);
2936
+ return /* @__PURE__ */ jsxs26("div", { className: " flex flex-col gap-y-2 px-6 py-4", children: [
2937
+ /* @__PURE__ */ jsxs26("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
2938
+ /* @__PURE__ */ jsx25(
2939
+ Text22,
2940
+ {
2941
+ weight: "plus",
2942
+ className: "text-ui-fg-subtle",
2943
+ size: "small",
2944
+ leading: "compact",
2945
+ children: t("fields.total")
2946
+ }
2947
+ ),
2948
+ /* @__PURE__ */ jsx25(
2949
+ Text22,
2950
+ {
2951
+ weight: "plus",
2952
+ className: "text-ui-fg-subtle",
2953
+ size: "small",
2954
+ leading: "compact",
2955
+ children: getStylizedAmount(order.total, order.currency_code)
2956
+ }
2957
+ )
2958
+ ] }),
2959
+ /* @__PURE__ */ jsxs26("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
2960
+ /* @__PURE__ */ jsx25(
2961
+ Text22,
2962
+ {
2963
+ weight: "plus",
2964
+ className: "text-ui-fg-subtle",
2965
+ size: "small",
2966
+ leading: "compact",
2967
+ children: t("fields.paidTotal")
2968
+ }
2969
+ ),
2970
+ /* @__PURE__ */ jsx25(
2971
+ Text22,
2972
+ {
2973
+ weight: "plus",
2974
+ className: "text-ui-fg-subtle",
2975
+ size: "small",
2976
+ leading: "compact",
2977
+ children: getStylizedAmount(totalCaptured, order.currency_code)
2978
+ }
2979
+ )
2980
+ ] }),
2981
+ /* @__PURE__ */ jsxs26("div", { className: "text-ui-fg-base flex items-center justify-between", children: [
2982
+ /* @__PURE__ */ jsx25(Text22, { weight: "plus", size: "small", leading: "compact", children: t("orders.payment.outstandingAmount") }),
2983
+ /* @__PURE__ */ jsx25(Text22, { weight: "plus", size: "small", leading: "compact", children: getStylizedAmount(outstanding, order.currency_code) })
2984
+ ] })
2985
+ ] });
2986
+ };
2987
+ var OutstandingActions = ({ order }) => {
2988
+ const { t } = useTranslation24();
2989
+ const unpaidCollection = order.payment_collections?.find(
2990
+ (pc) => pc.status !== "captured" && pc.status !== "canceled"
2991
+ );
2992
+ const pendingDifference = order.summary?.pending_difference || 0;
2993
+ const isOutstanding = pendingDifference > 5e-3 && order.status !== "canceled" && !!unpaidCollection;
2994
+ const markAsPaid = useMarkPaymentCollectionAsPaid(
2995
+ order.id,
2996
+ unpaidCollection?.id ?? ""
2997
+ );
2998
+ if (!isOutstanding || !unpaidCollection) {
2999
+ return null;
3000
+ }
3001
+ const paymentLink = unpaidCollection.payment_sessions?.[0]?.data?.url ?? null;
3002
+ const handleCopyLink = async () => {
3003
+ if (!paymentLink) {
3004
+ toast7.error(t("orders.payment.copyLinkMissing"));
3005
+ return;
3006
+ }
3007
+ try {
3008
+ await navigator.clipboard.writeText(paymentLink);
3009
+ toast7.success(t("orders.payment.copyLinkSuccess"));
3010
+ } catch {
3011
+ toast7.error(t("orders.payment.copyLinkError"));
3012
+ }
3013
+ };
3014
+ const handleMarkAsPaid = () => {
3015
+ markAsPaid.mutate(
3016
+ { order_id: order.id },
3017
+ {
3018
+ onSuccess: () => toast7.success(t("orders.payment.markAsPaidSuccess")),
3019
+ onError: (e) => toast7.error(e.message)
3020
+ }
3021
+ );
3022
+ };
3023
+ return /* @__PURE__ */ jsxs26("div", { className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-4 py-4", children: [
3024
+ paymentLink && /* @__PURE__ */ jsx25(Button7, { size: "small", variant: "secondary", onClick: handleCopyLink, children: t("orders.payment.copyPaymentLink", {
3025
+ amount: getStylizedAmount(pendingDifference, order.currency_code)
3026
+ }) }),
3027
+ /* @__PURE__ */ jsx25(
3028
+ Button7,
3029
+ {
3030
+ size: "small",
3031
+ variant: "secondary",
3032
+ onClick: handleMarkAsPaid,
3033
+ isLoading: markAsPaid.isPending,
3034
+ children: t("orders.payment.markAsPaid")
3035
+ }
3036
+ )
3037
+ ] });
3038
+ };
3039
+
3040
+ // src/pages/orders/[id]/order-detail-page.tsx
3041
+ import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs27 } from "react/jsx-runtime";
3042
+ var Root = ({ children }) => {
3043
+ const initialData = useLoaderData();
3044
+ const { id } = useParams();
3045
+ const { order, isLoading, isError, error } = useOrder(
3046
+ id,
3047
+ {
3048
+ fields: DEFAULT_FIELDS
3049
+ },
3050
+ {
3051
+ initialData
3052
+ }
3053
+ );
3054
+ const { order: orderPreview, isLoading: isPreviewLoading } = useOrderPreview(
3055
+ id
3056
+ );
3057
+ if (order) {
3058
+ order.items = order.items.sort((itemA, itemB) => {
3059
+ if (itemA.created_at > itemB.created_at) {
3060
+ return 1;
3061
+ }
3062
+ if (itemA.created_at < itemB.created_at) {
3063
+ return -1;
3064
+ }
3065
+ return 0;
3066
+ });
3067
+ }
3068
+ if (isLoading || !order || isPreviewLoading) {
3069
+ return /* @__PURE__ */ jsx26(TwoColumnPageSkeleton, { mainSections: 4, sidebarSections: 2, showJSON: true });
3070
+ }
3071
+ if (isError) {
3072
+ throw error;
3073
+ }
3074
+ return /* @__PURE__ */ jsx26(Fragment4, { children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs27(TwoColumnPage, { data: order, hasOutlet: true, showMetadata: true, showJSON: true, children: [
3075
+ /* @__PURE__ */ jsxs27(TwoColumnPage.Main, { children: [
3076
+ /* @__PURE__ */ jsx26(OrderActiveEditSection, { order }),
3077
+ orderPreview && /* @__PURE__ */ jsxs27(Fragment4, { children: [
3078
+ /* @__PURE__ */ jsx26(ActiveOrderClaimSection, { orderPreview }),
3079
+ /* @__PURE__ */ jsx26(ActiveOrderExchangeSection, { orderPreview }),
3080
+ /* @__PURE__ */ jsx26(ActiveOrderReturnSection, { orderPreview })
3081
+ ] }),
3082
+ /* @__PURE__ */ jsx26(OrderGeneralSection, { order }),
3083
+ /* @__PURE__ */ jsx26(OrderSummarySection, { order }),
3084
+ /* @__PURE__ */ jsx26(OrderCommissionSection, { order }),
3085
+ /* @__PURE__ */ jsx26(OrderPaymentSection, { order }),
3086
+ /* @__PURE__ */ jsx26(OrderFulfillmentSection, { order })
3087
+ ] }),
3088
+ /* @__PURE__ */ jsxs27(TwoColumnPage.Sidebar, { children: [
3089
+ /* @__PURE__ */ jsx26(OrderCustomerSection, { order }),
3090
+ /* @__PURE__ */ jsx26(OrderActivitySection, { order })
3091
+ ] })
3092
+ ] }) });
3093
+ };
3094
+ var OrderDetailPage = Object.assign(Root, {
3095
+ Main: TwoColumnPage.Main,
3096
+ Sidebar: TwoColumnPage.Sidebar,
3097
+ MainActiveEditSection: OrderActiveEditSection,
3098
+ MainActiveClaimSection: ActiveOrderClaimSection,
3099
+ MainActiveExchangeSection: ActiveOrderExchangeSection,
3100
+ MainActiveReturnSection: ActiveOrderReturnSection,
3101
+ MainGeneralSection: OrderGeneralSection,
3102
+ MainSummarySection: OrderSummarySection,
3103
+ MainPaymentSection: OrderPaymentSection,
3104
+ MainFulfillmentSection: OrderFulfillmentSection,
3105
+ SidebarCustomerSection: OrderCustomerSection,
3106
+ SidebarActivitySection: OrderActivitySection
3107
+ });
3108
+ export {
3109
+ OrderDetailPage,
3110
+ loader
3111
+ };