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

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