@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,1179 @@
1
+ import {
2
+ getOfferRestockPreview
3
+ } from "./chunk-J6XCRFBW.js";
4
+ import {
5
+ ReturnShippingPlaceholder
6
+ } from "./chunk-YBF45CX5.js";
7
+ import {
8
+ useReturnReasons
9
+ } from "./chunk-LHKHQAAY.js";
10
+ import {
11
+ RETURN_POLICY_DAYS
12
+ } from "./chunk-VCUUITW6.js";
13
+ import {
14
+ useAddReturnItem,
15
+ useAddReturnShipping,
16
+ useCancelReturnRequest,
17
+ useConfirmReturnRequest,
18
+ useDeleteReturnShipping,
19
+ useInitiateReturn,
20
+ useRemoveReturnItem,
21
+ useUpdateReturn,
22
+ useUpdateReturnItem,
23
+ useUpdateReturnShipping
24
+ } from "./chunk-CHBURL76.js";
25
+ import {
26
+ MoneyAmountCell
27
+ } from "./chunk-L57USMYC.js";
28
+ import {
29
+ getStylizedAmount
30
+ } from "./chunk-3BXCPHN6.js";
31
+ import "./chunk-FQERBIVS.js";
32
+ import {
33
+ PlaceholderCell
34
+ } from "./chunk-PHOCVOZ5.js";
35
+ import {
36
+ _DataTable,
37
+ useDataTable
38
+ } from "./chunk-WKRW5OPL.js";
39
+ import "./chunk-YN3FGNJM.js";
40
+ import "./chunk-KCHYLLVG.js";
41
+ import "./chunk-3EF54XFY.js";
42
+ import {
43
+ currencies
44
+ } from "./chunk-IQPN4PZJ.js";
45
+ import {
46
+ Combobox
47
+ } from "./chunk-VBRTC2VU.js";
48
+ import "./chunk-TKGWSUEI.js";
49
+ import {
50
+ KeyboundForm
51
+ } from "./chunk-SITRHMZZ.js";
52
+ import {
53
+ RouteFocusModal,
54
+ StackedFocusModal,
55
+ useRouteModal,
56
+ useStackedModal
57
+ } from "./chunk-GDWBOQI5.js";
58
+ import {
59
+ Form
60
+ } from "./chunk-3QSRE5LS.js";
61
+ import "./chunk-LRD242C7.js";
62
+ import {
63
+ Thumbnail
64
+ } from "./chunk-WIYFXWRI.js";
65
+ import "./chunk-INNFZYX2.js";
66
+ import {
67
+ useShippingOptions
68
+ } from "./chunk-VXMOPVRH.js";
69
+ import {
70
+ useStockLocations
71
+ } from "./chunk-NBPMNUKZ.js";
72
+ import {
73
+ useOrder,
74
+ useOrderPreview
75
+ } from "./chunk-7RGUD6PI.js";
76
+ import {
77
+ ActionMenu
78
+ } from "./chunk-BDGZ4EQO.js";
79
+ import "./chunk-LAVHRER2.js";
80
+ import "./chunk-QHQWEERJ.js";
81
+ import "./chunk-Y7QKP6QU.js";
82
+ import "./chunk-TSTUAL6N.js";
83
+ import "./chunk-A5DJIOHN.js";
84
+ import "./chunk-RHKRREUU.js";
85
+ import "./chunk-ZA2KFUFR.js";
86
+ import "./chunk-RIN4CBRB.js";
87
+ import "./chunk-NBMM2TZK.js";
88
+
89
+ // src/pages/orders/[id]/returns/create/index.tsx
90
+ import { useEffect as useEffect2, useRef, useState as useState3 } from "react";
91
+ import { useNavigate, useParams } from "react-router-dom";
92
+ import { toast as toast2 } from "@medusajs/ui";
93
+ import { useTranslation as useTranslation5 } from "react-i18next";
94
+
95
+ // src/pages/orders/[id]/returns/create/_components/return-create-form/return-create-form.tsx
96
+ import { zodResolver } from "@hookform/resolvers/zod";
97
+ import { PencilSquare } from "@medusajs/icons";
98
+ import {
99
+ Button,
100
+ CurrencyInput,
101
+ Heading,
102
+ IconButton as IconButton2,
103
+ Switch,
104
+ Text as Text3,
105
+ toast,
106
+ usePrompt
107
+ } from "@medusajs/ui";
108
+ import { useEffect, useMemo as useMemo3, useState as useState2 } from "react";
109
+ import { useFieldArray, useForm } from "react-hook-form";
110
+ import { useTranslation as useTranslation4 } from "react-i18next";
111
+
112
+ // src/pages/orders/[id]/returns/create/_components/add-return-items-table/add-return-items-table.tsx
113
+ import { useMemo as useMemo2, useState } from "react";
114
+ import { useTranslation as useTranslation2 } from "react-i18next";
115
+
116
+ // src/pages/orders/[id]/returns/create/_components/add-return-items-table/use-return-item-table-columns.tsx
117
+ import { Checkbox, Text } from "@medusajs/ui";
118
+ import { createColumnHelper } from "@tanstack/react-table";
119
+ import { useMemo } from "react";
120
+ import { useTranslation } from "react-i18next";
121
+ import { jsx, jsxs } from "react/jsx-runtime";
122
+ var columnHelper = createColumnHelper();
123
+ var useReturnItemTableColumns = () => {
124
+ const { t } = useTranslation();
125
+ return useMemo(
126
+ () => [
127
+ columnHelper.display({
128
+ id: "select",
129
+ header: ({ table }) => /* @__PURE__ */ jsx(
130
+ Checkbox,
131
+ {
132
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
133
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
134
+ }
135
+ ),
136
+ cell: ({ row }) => {
137
+ const isSelectable = row.getCanSelect();
138
+ return /* @__PURE__ */ jsx(
139
+ Checkbox,
140
+ {
141
+ disabled: !isSelectable,
142
+ checked: row.getIsSelected(),
143
+ onCheckedChange: (value) => row.toggleSelected(!!value),
144
+ onClick: (e) => {
145
+ e.stopPropagation();
146
+ }
147
+ }
148
+ );
149
+ }
150
+ }),
151
+ columnHelper.display({
152
+ id: "product",
153
+ header: t("fields.product"),
154
+ cell: ({ row }) => {
155
+ const title = row.original.product_title ?? row.original.title;
156
+ if (!title) {
157
+ return /* @__PURE__ */ jsx(PlaceholderCell, {});
158
+ }
159
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full max-w-[300px] items-center gap-x-3 overflow-hidden", children: [
160
+ /* @__PURE__ */ jsx(Thumbnail, { src: row.original.thumbnail }),
161
+ /* @__PURE__ */ jsx(
162
+ Text,
163
+ {
164
+ size: "small",
165
+ leading: "compact",
166
+ className: "truncate",
167
+ title,
168
+ children: title
169
+ }
170
+ )
171
+ ] });
172
+ }
173
+ }),
174
+ columnHelper.accessor("variant_sku", {
175
+ header: t("fields.sku"),
176
+ cell: ({ getValue }) => {
177
+ const sku = getValue();
178
+ if (!sku) return /* @__PURE__ */ jsx(PlaceholderCell, {});
179
+ return /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "truncate", children: sku });
180
+ }
181
+ }),
182
+ columnHelper.display({
183
+ id: "variant_title",
184
+ header: t("fields.title"),
185
+ cell: ({ row }) => {
186
+ const title = row.original.variant_title;
187
+ if (!title) return /* @__PURE__ */ jsx(PlaceholderCell, {});
188
+ return /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "truncate", children: title });
189
+ }
190
+ }),
191
+ columnHelper.accessor("remainingQuantity", {
192
+ header: t("orders.returns.remainingQuantity", {
193
+ defaultValue: "Remaining"
194
+ }),
195
+ cell: ({ getValue }) => /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "tabular-nums", children: getValue() })
196
+ })
197
+ ],
198
+ [t]
199
+ );
200
+ };
201
+
202
+ // src/pages/orders/[id]/returns/create/_components/add-return-items-table/add-return-items-table.tsx
203
+ import { jsx as jsx2 } from "react/jsx-runtime";
204
+ var PAGE_SIZE = 50;
205
+ var getRemainingQuantity = (item) => {
206
+ const detail = item.detail ?? {};
207
+ const fulfilled = detail.fulfilled_quantity ?? 0;
208
+ const requested = detail.return_requested_quantity ?? 0;
209
+ const returned = detail.returned_quantity ?? 0;
210
+ return fulfilled - requested - returned;
211
+ };
212
+ var AddReturnItemsTable = ({
213
+ order,
214
+ onSelectionChange,
215
+ selectedItems = []
216
+ }) => {
217
+ const { t } = useTranslation2();
218
+ const [rowSelection, setRowSelection] = useState(
219
+ selectedItems.reduce((acc, id) => {
220
+ acc[id] = true;
221
+ return acc;
222
+ }, {})
223
+ );
224
+ const updater = (fn) => {
225
+ const newState = typeof fn === "function" ? fn(rowSelection) : fn;
226
+ setRowSelection(newState);
227
+ onSelectionChange(Object.keys(newState));
228
+ };
229
+ const rows = useMemo2(() => {
230
+ return (order.items ?? []).map((item) => {
231
+ const remainingQuantity = getRemainingQuantity(item);
232
+ if (remainingQuantity <= 0) {
233
+ return null;
234
+ }
235
+ return {
236
+ id: item.id,
237
+ title: item.title,
238
+ product_title: item.product_title,
239
+ variant_sku: item.variant_sku,
240
+ variant_title: item.variant_title,
241
+ thumbnail: item.thumbnail,
242
+ remainingQuantity
243
+ };
244
+ }).filter((r) => r !== null);
245
+ }, [order.items]);
246
+ const count = rows.length;
247
+ const columns = useReturnItemTableColumns();
248
+ const { table } = useDataTable({
249
+ data: rows,
250
+ columns,
251
+ count,
252
+ enablePagination: true,
253
+ // Row id = order line item id; `onSelectionChange` yields the ids the
254
+ // vendor add-return-items route accepts.
255
+ getRowId: (row) => row.id,
256
+ pageSize: PAGE_SIZE,
257
+ enableRowSelection: () => true,
258
+ rowSelection: {
259
+ state: rowSelection,
260
+ updater
261
+ }
262
+ });
263
+ return /* @__PURE__ */ jsx2(
264
+ "div",
265
+ {
266
+ className: "flex size-full flex-col overflow-hidden",
267
+ "data-testid": "add-return-items-picker",
268
+ children: /* @__PURE__ */ jsx2(
269
+ _DataTable,
270
+ {
271
+ table,
272
+ columns,
273
+ pageSize: PAGE_SIZE,
274
+ count,
275
+ pagination: true,
276
+ layout: "fill",
277
+ search: false,
278
+ orderBy: [
279
+ { key: "product_title", label: t("fields.product") },
280
+ { key: "variant_title", label: t("fields.title") }
281
+ ]
282
+ }
283
+ )
284
+ }
285
+ );
286
+ };
287
+
288
+ // src/pages/orders/[id]/returns/create/_components/return-create-form/return-item.tsx
289
+ import { ChatBubble, DocumentText, XCircle, XMark } from "@medusajs/icons";
290
+ import { IconButton, Input, Text as Text2 } from "@medusajs/ui";
291
+ import { useTranslation as useTranslation3 } from "react-i18next";
292
+ import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
293
+ function ReturnItem({
294
+ item,
295
+ previewItem,
296
+ currencyCode,
297
+ form,
298
+ onRemove,
299
+ onUpdate,
300
+ index,
301
+ locationId,
302
+ locationName
303
+ }) {
304
+ const { t } = useTranslation3();
305
+ const { return_reasons: returnReasons = [] } = useReturnReasons({
306
+ fields: "+label"
307
+ });
308
+ const formItem = form.watch(`items.${index}`);
309
+ const showReturnReason = typeof formItem?.reason_id === "string";
310
+ const showNote = typeof formItem?.note === "string";
311
+ const restockRows = locationId ? getOfferRestockPreview(
312
+ item,
313
+ formItem?.quantity ?? 0
314
+ ) : [];
315
+ const offerSku = item.offer?.sku ?? item.variant_sku ?? null;
316
+ return /* @__PURE__ */ jsxs2(
317
+ "div",
318
+ {
319
+ className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl",
320
+ "data-testid": `return-item-${item.id}`,
321
+ children: [
322
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-x-2 gap-y-2 border-b p-3 text-sm md:flex-row", children: [
323
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-1 items-center gap-x-3", children: [
324
+ /* @__PURE__ */ jsx3(Thumbnail, { src: item.thumbnail }),
325
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
326
+ /* @__PURE__ */ jsxs2("div", { children: [
327
+ /* @__PURE__ */ jsxs2(Text2, { className: "txt-small", as: "span", weight: "plus", children: [
328
+ item.title,
329
+ " "
330
+ ] }),
331
+ item.variant_sku && /* @__PURE__ */ jsxs2("span", { children: [
332
+ "(",
333
+ item.variant_sku,
334
+ ")"
335
+ ] })
336
+ ] }),
337
+ /* @__PURE__ */ jsx3(Text2, { as: "div", className: "text-ui-fg-subtle txt-small", children: item.product_title })
338
+ ] })
339
+ ] }),
340
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-1 justify-between", children: [
341
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-grow items-center gap-2", children: [
342
+ /* @__PURE__ */ jsx3(
343
+ Form.Field,
344
+ {
345
+ control: form.control,
346
+ name: `items.${index}.quantity`,
347
+ render: ({ field }) => {
348
+ return /* @__PURE__ */ jsxs2(Form.Item, { children: [
349
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
350
+ Input,
351
+ {
352
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
353
+ min: 1,
354
+ max: item.quantity,
355
+ type: "number",
356
+ "data-testid": `return-item-${item.id}-qty`,
357
+ ...field,
358
+ onChange: (e) => {
359
+ const val = e.target.value;
360
+ const payload = val === "" ? null : Number(val);
361
+ field.onChange(payload);
362
+ if (payload) {
363
+ onUpdate({ quantity: payload });
364
+ }
365
+ }
366
+ }
367
+ ) }),
368
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
369
+ ] });
370
+ }
371
+ }
372
+ ),
373
+ /* @__PURE__ */ jsx3(Text2, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
374
+ ] }),
375
+ /* @__PURE__ */ jsx3("div", { className: "text-ui-fg-subtle txt-small mr-2 flex flex-shrink-0", children: /* @__PURE__ */ jsx3(
376
+ MoneyAmountCell,
377
+ {
378
+ currencyCode,
379
+ amount: previewItem.return_requested_total
380
+ }
381
+ ) }),
382
+ /* @__PURE__ */ jsx3(
383
+ ActionMenu,
384
+ {
385
+ groups: [
386
+ {
387
+ actions: [
388
+ !showReturnReason && {
389
+ label: t("actions.addReason"),
390
+ onClick: () => form.setValue(`items.${index}.reason_id`, ""),
391
+ icon: /* @__PURE__ */ jsx3(ChatBubble, {})
392
+ },
393
+ !showNote && {
394
+ label: t("actions.addNote"),
395
+ onClick: () => form.setValue(`items.${index}.note`, ""),
396
+ icon: /* @__PURE__ */ jsx3(DocumentText, {})
397
+ },
398
+ {
399
+ label: t("actions.remove"),
400
+ onClick: onRemove,
401
+ icon: /* @__PURE__ */ jsx3(XCircle, {})
402
+ }
403
+ ].filter(Boolean)
404
+ }
405
+ ]
406
+ }
407
+ )
408
+ ] })
409
+ ] }),
410
+ restockRows.length > 0 && /* @__PURE__ */ jsx3("div", { className: "bg-ui-bg-subtle flex flex-col gap-y-1 rounded-md px-3 py-2", children: restockRows.map((row) => /* @__PURE__ */ jsx3(
411
+ Text2,
412
+ {
413
+ size: "xsmall",
414
+ className: "text-ui-fg-subtle",
415
+ "data-testid": `return-item-${item.id}-restock-${row.inventoryItemId}`,
416
+ children: t("orders.returns.restockPreview", {
417
+ quantity: formItem?.quantity ?? 0,
418
+ offerSku: offerSku ?? "\u2014",
419
+ delta: row.delta,
420
+ inventoryItem: row.inventoryItemLabel,
421
+ location: locationName ?? "\u2014"
422
+ })
423
+ },
424
+ row.inventoryItemId
425
+ )) }),
426
+ /* @__PURE__ */ jsxs2(Fragment, { children: [
427
+ showReturnReason && /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
428
+ /* @__PURE__ */ jsxs2("div", { children: [
429
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.reason") }),
430
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.reasonHint") })
431
+ ] }),
432
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-1", children: [
433
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
434
+ Form.Field,
435
+ {
436
+ control: form.control,
437
+ name: `items.${index}.reason_id`,
438
+ render: ({ field: { ref, value, onChange, ...field } }) => {
439
+ void ref;
440
+ return /* @__PURE__ */ jsxs2(Form.Item, { children: [
441
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
442
+ Combobox,
443
+ {
444
+ value: value ?? void 0,
445
+ onChange: (v) => {
446
+ onUpdate({ reason_id: v });
447
+ onChange(v);
448
+ },
449
+ ...field,
450
+ options: returnReasons.map(
451
+ (reason) => ({
452
+ label: reason.label ?? reason.value ?? reason.id,
453
+ value: reason.id
454
+ })
455
+ ),
456
+ "data-testid": `return-item-${item.id}-reason`
457
+ }
458
+ ) }),
459
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
460
+ ] });
461
+ }
462
+ }
463
+ ) }),
464
+ /* @__PURE__ */ jsx3(
465
+ IconButton,
466
+ {
467
+ type: "button",
468
+ className: "flex-shrink",
469
+ variant: "transparent",
470
+ onClick: () => {
471
+ onUpdate({ reason_id: null });
472
+ form.setValue(`items.${index}.reason_id`, null);
473
+ },
474
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
475
+ }
476
+ )
477
+ ] })
478
+ ] }),
479
+ showNote && /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
480
+ /* @__PURE__ */ jsxs2("div", { children: [
481
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.note") }),
482
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.noteHint") })
483
+ ] }),
484
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-1", children: [
485
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
486
+ Form.Field,
487
+ {
488
+ control: form.control,
489
+ name: `items.${index}.note`,
490
+ render: ({ field: { ref, value, onChange, ...field } }) => {
491
+ void ref;
492
+ return /* @__PURE__ */ jsxs2(Form.Item, { children: [
493
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
494
+ Input,
495
+ {
496
+ value: value ?? "",
497
+ onChange,
498
+ ...field,
499
+ onBlur: () => onUpdate({ internal_note: value ?? null }),
500
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
501
+ "data-testid": `return-item-${item.id}-note`
502
+ }
503
+ ) }),
504
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
505
+ ] });
506
+ }
507
+ }
508
+ ) }),
509
+ /* @__PURE__ */ jsx3(
510
+ IconButton,
511
+ {
512
+ type: "button",
513
+ className: "flex-shrink",
514
+ variant: "transparent",
515
+ onClick: () => {
516
+ form.setValue(`items.${index}.note`, null);
517
+ onUpdate({ internal_note: null });
518
+ },
519
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
520
+ }
521
+ )
522
+ ] })
523
+ ] })
524
+ ] })
525
+ ]
526
+ }
527
+ );
528
+ }
529
+
530
+ // src/pages/orders/[id]/returns/create/_components/return-create-form/schema.ts
531
+ import { z } from "zod";
532
+ var ReturnCreateSchema = z.object({
533
+ items: z.array(
534
+ z.object({
535
+ item_id: z.string(),
536
+ quantity: z.number(),
537
+ reason_id: z.string().optional().nullable(),
538
+ note: z.string().optional().nullable()
539
+ })
540
+ ),
541
+ location_id: z.string().optional(),
542
+ option_id: z.string(),
543
+ send_notification: z.boolean().optional(),
544
+ // TODO: receive flow happens on a separate route — left here for parity
545
+ // with the admin schema and possible future inline-receive support.
546
+ receive_now: z.boolean().optional()
547
+ });
548
+
549
+ // src/pages/orders/[id]/returns/create/_components/return-create-form/return-create-form.tsx
550
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
551
+ var selectedLineItemIds = [];
552
+ var ReturnCreateForm = ({
553
+ order,
554
+ preview,
555
+ activeReturn
556
+ }) => {
557
+ const { t } = useTranslation4();
558
+ const { handleSuccess } = useRouteModal();
559
+ const itemsMap = useMemo3(
560
+ () => new Map((order.items || []).map((i) => [i.id, i])),
561
+ [order.items]
562
+ );
563
+ const previewItems = useMemo3(
564
+ () => preview.items.filter(
565
+ (i) => !!i.actions?.find(
566
+ (a) => a.return_id === activeReturn.id
567
+ )
568
+ ),
569
+ // eslint-disable-next-line react-hooks/exhaustive-deps
570
+ [preview.items, activeReturn.id]
571
+ );
572
+ const previewItemsMap = useMemo3(
573
+ () => new Map(previewItems.map((i) => [i.id, i])),
574
+ [previewItems]
575
+ );
576
+ const { setIsOpen } = useStackedModal();
577
+ const [isShippingPriceEdit, setIsShippingPriceEdit] = useState2(false);
578
+ const [customShippingAmount, setCustomShippingAmount] = useState2({
579
+ value: "0",
580
+ float: 0
581
+ });
582
+ const { stock_locations: stockLocations = [] } = useStockLocations({
583
+ limit: 999
584
+ });
585
+ const { shipping_options: shippingOptions = [] } = useShippingOptions({
586
+ limit: 999,
587
+ fields: "*prices,+service_zone.fulfillment_set.location.id"
588
+ });
589
+ const { mutateAsync: confirmReturnRequest, isPending: isConfirming } = useConfirmReturnRequest(activeReturn.id, order.id);
590
+ const { mutateAsync: cancelReturnRequest, isPending: isCanceling } = useCancelReturnRequest(activeReturn.id, order.id);
591
+ const { mutateAsync: updateReturnRequest, isPending: isUpdating } = useUpdateReturn(activeReturn.id, order.id);
592
+ const { mutateAsync: addReturnShipping, isPending: isAddingReturnShipping } = useAddReturnShipping(activeReturn.id, order.id);
593
+ const {
594
+ mutateAsync: updateReturnShipping,
595
+ isPending: isUpdatingReturnShipping
596
+ } = useUpdateReturnShipping(activeReturn.id, order.id);
597
+ const {
598
+ mutateAsync: deleteReturnShipping,
599
+ isPending: isDeletingReturnShipping
600
+ } = useDeleteReturnShipping(activeReturn.id, order.id);
601
+ const { mutateAsync: addReturnItem, isPending: isAddingReturnItem } = useAddReturnItem(activeReturn.id, order.id);
602
+ const { mutateAsync: removeReturnItem, isPending: isRemovingReturnItem } = useRemoveReturnItem(activeReturn.id, order.id);
603
+ const { mutateAsync: updateReturnItem, isPending: isUpdatingReturnItem } = useUpdateReturnItem(activeReturn.id, order.id);
604
+ const isRequestLoading = isConfirming || isCanceling || isAddingReturnShipping || isUpdatingReturnShipping || isDeletingReturnShipping || isAddingReturnItem || isRemovingReturnItem || isUpdatingReturnItem || isUpdating;
605
+ const form = useForm({
606
+ defaultValues: () => {
607
+ const method = preview.shipping_methods.find(
608
+ (s) => !!s.actions?.find(
609
+ (a) => a.action === "SHIPPING_ADD"
610
+ )
611
+ );
612
+ return Promise.resolve({
613
+ items: previewItems.map((i) => {
614
+ const actions = i.actions ?? [];
615
+ const returnAction = actions.find((a) => a.action === "RETURN_ITEM");
616
+ return {
617
+ item_id: i.id,
618
+ quantity: i.detail.return_requested_quantity,
619
+ note: returnAction?.internal_note ?? void 0,
620
+ reason_id: returnAction?.details?.reason_id
621
+ };
622
+ }),
623
+ option_id: method ? method.shipping_option_id ?? "" : "",
624
+ location_id: activeReturn?.location_id ?? void 0,
625
+ send_notification: false
626
+ });
627
+ },
628
+ resolver: zodResolver(ReturnCreateSchema)
629
+ });
630
+ const {
631
+ fields: items,
632
+ append,
633
+ remove,
634
+ update
635
+ } = useFieldArray({
636
+ name: "items",
637
+ control: form.control
638
+ });
639
+ useEffect(() => {
640
+ const existingItemsMap = {};
641
+ previewItems.forEach((i) => {
642
+ const ind = items.findIndex((field) => field.item_id === i.id);
643
+ if (!i.detail.return_requested_quantity) {
644
+ return;
645
+ }
646
+ existingItemsMap[i.id] = true;
647
+ if (ind > -1) {
648
+ if (items[ind].quantity !== i.detail.return_requested_quantity) {
649
+ const actions = i.actions ?? [];
650
+ const returnItemAction = actions.find(
651
+ (a) => a.action === "RETURN_ITEM"
652
+ );
653
+ update(ind, {
654
+ ...items[ind],
655
+ quantity: i.detail.return_requested_quantity,
656
+ note: returnItemAction?.internal_note ?? void 0,
657
+ reason_id: returnItemAction?.details?.reason_id
658
+ });
659
+ }
660
+ } else {
661
+ append({
662
+ item_id: i.id,
663
+ quantity: i.detail.return_requested_quantity
664
+ });
665
+ }
666
+ });
667
+ items.forEach((i, ind) => {
668
+ if (!(i.item_id in existingItemsMap)) {
669
+ remove(ind);
670
+ }
671
+ });
672
+ }, [previewItems]);
673
+ useEffect(() => {
674
+ const method = preview.shipping_methods?.find(
675
+ (s) => !!s.actions?.find(
676
+ (a) => a.action === "SHIPPING_ADD"
677
+ )
678
+ );
679
+ if (method) {
680
+ form.setValue("option_id", method.shipping_option_id ?? "");
681
+ } else {
682
+ form.setValue("option_id", "");
683
+ }
684
+ }, [preview.shipping_methods]);
685
+ useEffect(() => {
686
+ form.setValue("location_id", activeReturn?.location_id || "");
687
+ }, [activeReturn]);
688
+ useEffect(() => {
689
+ if (isShippingPriceEdit) {
690
+ document.getElementById("js-shipping-input")?.focus();
691
+ }
692
+ }, [isShippingPriceEdit]);
693
+ const showPlaceholder = !items.length;
694
+ const locationId = form.watch("location_id");
695
+ const shippingOptionId = form.watch("option_id");
696
+ const prompt = usePrompt();
697
+ const locationName = useMemo3(() => {
698
+ if (!locationId) return null;
699
+ return stockLocations.find((l) => l.id === locationId)?.name ?? null;
700
+ }, [locationId, stockLocations]);
701
+ const returnTotal = preview.return_requested_total;
702
+ const shippingTotal = useMemo3(() => {
703
+ const method = preview.shipping_methods.find(
704
+ (sm) => !!sm.actions?.find(
705
+ (a) => a.action === "SHIPPING_ADD"
706
+ )
707
+ );
708
+ return method?.total || 0;
709
+ }, [preview.shipping_methods]);
710
+ const estimatedDifference = (preview.summary?.pending_difference || 0) - previewItems.reduce(
711
+ (acc, item) => acc + (item.total ?? 0),
712
+ 0
713
+ );
714
+ const handleSubmit = form.handleSubmit(async (data) => {
715
+ try {
716
+ const res = await prompt({
717
+ title: t("general.areYouSure"),
718
+ description: t("orders.returns.confirmText"),
719
+ confirmText: t("actions.continue"),
720
+ cancelText: t("actions.cancel"),
721
+ variant: "confirmation"
722
+ });
723
+ if (!res) {
724
+ return;
725
+ }
726
+ await confirmReturnRequest({ no_notification: !data.send_notification });
727
+ toast.success(t("orders.returns.toast.confirmedSuccessfully"));
728
+ handleSuccess(`/orders/${order.id}`);
729
+ } catch (e) {
730
+ toast.error(t("general.error"), {
731
+ description: e instanceof Error ? e.message : void 0
732
+ });
733
+ }
734
+ });
735
+ const onItemsSelected = async () => {
736
+ const existingIds = new Set(items.map((i) => i.item_id));
737
+ const newIds = selectedLineItemIds.filter((id) => !existingIds.has(id));
738
+ if (newIds.length === 0) {
739
+ setIsOpen("items", false);
740
+ return;
741
+ }
742
+ try {
743
+ await addReturnItem({
744
+ items: newIds.map((id) => ({
745
+ id,
746
+ quantity: 1
747
+ }))
748
+ });
749
+ } catch (e) {
750
+ toast.error(
751
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
752
+ );
753
+ } finally {
754
+ selectedLineItemIds = [];
755
+ setIsOpen("items", false);
756
+ }
757
+ };
758
+ const onLocationChange = async (selectedLocationId) => {
759
+ await updateReturnRequest({ location_id: selectedLocationId });
760
+ };
761
+ const onShippingOptionChange = async (selectedOptionId) => {
762
+ const promises = preview.shipping_methods.map(
763
+ (s) => s.actions?.find(
764
+ (a) => a.action === "SHIPPING_ADD"
765
+ )?.id
766
+ ).filter((id) => !!id).map((id) => deleteReturnShipping(id));
767
+ await Promise.all(promises);
768
+ if (selectedOptionId) {
769
+ await addReturnShipping({ shipping_option_id: selectedOptionId });
770
+ }
771
+ };
772
+ return /* @__PURE__ */ jsx4(
773
+ RouteFocusModal.Form,
774
+ {
775
+ form,
776
+ onClose: (isSubmitSuccessful) => {
777
+ if (!isSubmitSuccessful) {
778
+ cancelReturnRequest();
779
+ }
780
+ },
781
+ children: /* @__PURE__ */ jsxs3(KeyboundForm, { onSubmit: handleSubmit, className: "flex h-full flex-col", children: [
782
+ /* @__PURE__ */ jsx4(RouteFocusModal.Header, {}),
783
+ /* @__PURE__ */ jsx4(RouteFocusModal.Body, { className: "flex size-full justify-center overflow-y-auto", children: /* @__PURE__ */ jsxs3("div", { className: "mt-16 w-[720px] max-w-[100%] px-4 md:p-0", children: [
784
+ /* @__PURE__ */ jsx4(Heading, { level: "h1", children: t("orders.returns.create") }),
785
+ /* @__PURE__ */ jsx4(Text3, { size: "small", className: "text-ui-fg-subtle mt-2", children: t("orders.returns.policyHint", { days: RETURN_POLICY_DAYS }) }),
786
+ /* @__PURE__ */ jsxs3("div", { className: "mt-8 flex items-center justify-between", children: [
787
+ /* @__PURE__ */ jsx4(Heading, { level: "h2", children: t("orders.returns.inbound") }),
788
+ /* @__PURE__ */ jsxs3(StackedFocusModal, { id: "items", children: [
789
+ /* @__PURE__ */ jsx4(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx4(
790
+ "a",
791
+ {
792
+ href: "#",
793
+ onClick: (e) => e.preventDefault(),
794
+ className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400",
795
+ "data-testid": "return-create-add-items-trigger",
796
+ children: t("actions.addItems")
797
+ }
798
+ ) }),
799
+ /* @__PURE__ */ jsxs3(StackedFocusModal.Content, { children: [
800
+ /* @__PURE__ */ jsx4(StackedFocusModal.Header, {}),
801
+ /* @__PURE__ */ jsx4(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx4("span", { className: "sr-only", children: t("actions.addItems") }) }),
802
+ /* @__PURE__ */ jsx4(StackedFocusModal.Description, { className: "sr-only", children: t("orders.returns.create") }),
803
+ /* @__PURE__ */ jsx4(StackedFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsx4(
804
+ AddReturnItemsTable,
805
+ {
806
+ order,
807
+ selectedItems: items.map((i) => i.item_id),
808
+ onSelectionChange: (s) => selectedLineItemIds = s
809
+ }
810
+ ) }),
811
+ /* @__PURE__ */ jsx4(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsx4("div", { className: "flex w-full items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-x-2", children: [
812
+ /* @__PURE__ */ jsx4(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx4(
813
+ Button,
814
+ {
815
+ type: "button",
816
+ variant: "secondary",
817
+ size: "small",
818
+ "data-testid": "return-create-add-items-cancel",
819
+ children: t("actions.cancel")
820
+ }
821
+ ) }),
822
+ /* @__PURE__ */ jsx4(
823
+ Button,
824
+ {
825
+ type: "button",
826
+ variant: "primary",
827
+ size: "small",
828
+ onClick: onItemsSelected,
829
+ "data-testid": "return-create-add-items-save",
830
+ children: t("actions.save")
831
+ },
832
+ "submit-button"
833
+ )
834
+ ] }) }) })
835
+ ] })
836
+ ] })
837
+ ] }),
838
+ showPlaceholder && /* @__PURE__ */ jsx4(
839
+ "div",
840
+ {
841
+ style: {
842
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
843
+ },
844
+ className: "bg-ui-bg-field mt-4 block h-[56px] w-full rounded-lg border border-dashed"
845
+ }
846
+ ),
847
+ items.filter((item) => !!previewItemsMap.get(item.item_id)).map((item, index) => {
848
+ const previewItem = previewItemsMap.get(item.item_id);
849
+ if (!previewItem) {
850
+ return null;
851
+ }
852
+ const orderItem = itemsMap.get(item.item_id);
853
+ if (!orderItem) {
854
+ return null;
855
+ }
856
+ return /* @__PURE__ */ jsx4(
857
+ ReturnItem,
858
+ {
859
+ item: orderItem,
860
+ previewItem,
861
+ currencyCode: order.currency_code,
862
+ form,
863
+ locationId,
864
+ locationName,
865
+ onRemove: () => {
866
+ const actions = previewItems.find((i) => i.id === item.item_id)?.actions ?? [];
867
+ const actionId = actions.find(
868
+ (a) => a.action === "RETURN_ITEM"
869
+ )?.id;
870
+ if (actionId) {
871
+ removeReturnItem(actionId);
872
+ }
873
+ },
874
+ onUpdate: (payload) => {
875
+ const actions = previewItems.find((i) => i.id === item.item_id)?.actions ?? [];
876
+ const action = actions.find(
877
+ (a) => a.action === "RETURN_ITEM"
878
+ );
879
+ if (action) {
880
+ updateReturnItem(
881
+ { actionId: action.id, ...payload },
882
+ {
883
+ onError: (error) => {
884
+ if (action.details?.quantity && payload.quantity) {
885
+ form.setValue(
886
+ `items.${index}.quantity`,
887
+ action.details.quantity
888
+ );
889
+ }
890
+ toast.error(error.message);
891
+ }
892
+ }
893
+ );
894
+ }
895
+ },
896
+ index
897
+ },
898
+ item.id
899
+ );
900
+ }),
901
+ !showPlaceholder && /* @__PURE__ */ jsxs3("div", { className: "mt-8 flex flex-col gap-y-4", children: [
902
+ /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
903
+ /* @__PURE__ */ jsxs3("div", { children: [
904
+ /* @__PURE__ */ jsx4(Form.Label, { children: t("orders.returns.location") }),
905
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.locationHint") })
906
+ ] }),
907
+ /* @__PURE__ */ jsx4(
908
+ Form.Field,
909
+ {
910
+ control: form.control,
911
+ name: "location_id",
912
+ render: ({ field: { value, onChange, ...field } }) => {
913
+ return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(
914
+ Combobox,
915
+ {
916
+ value: value ?? void 0,
917
+ onChange: (v) => {
918
+ onChange(v);
919
+ onLocationChange(v ?? "");
920
+ },
921
+ ...field,
922
+ options: (stockLocations ?? []).map(
923
+ (loc) => ({
924
+ label: loc.name,
925
+ value: loc.id
926
+ })
927
+ ),
928
+ "data-testid": "return-create-location"
929
+ }
930
+ ) }) });
931
+ }
932
+ }
933
+ )
934
+ ] }),
935
+ /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
936
+ /* @__PURE__ */ jsxs3("div", { children: [
937
+ /* @__PURE__ */ jsxs3(Form.Label, { children: [
938
+ t("orders.returns.inboundShipping"),
939
+ /* @__PURE__ */ jsxs3(
940
+ Text3,
941
+ {
942
+ size: "small",
943
+ leading: "compact",
944
+ className: "text-ui-fg-muted ml-1 inline",
945
+ children: [
946
+ "(",
947
+ t("fields.optional"),
948
+ ")"
949
+ ]
950
+ }
951
+ )
952
+ ] }),
953
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.inboundShippingHint") })
954
+ ] }),
955
+ /* @__PURE__ */ jsx4(
956
+ Form.Field,
957
+ {
958
+ control: form.control,
959
+ name: "option_id",
960
+ render: ({ field: { value, onChange, ...field } }) => {
961
+ return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(
962
+ Combobox,
963
+ {
964
+ allowClear: true,
965
+ value,
966
+ onChange: (v) => {
967
+ onChange(v ?? "");
968
+ onShippingOptionChange(v);
969
+ },
970
+ ...field,
971
+ options: (shippingOptions ?? []).filter(
972
+ (so) => (locationId ? so.service_zone?.fulfillment_set?.location?.id === locationId : true) && !!so.rules?.find(
973
+ (r) => r.attribute === "is_return" && r.value === "true"
974
+ )
975
+ ).map((so) => ({
976
+ label: so.name,
977
+ value: so.id
978
+ })),
979
+ disabled: !locationId,
980
+ noResultsPlaceholder: /* @__PURE__ */ jsx4(ReturnShippingPlaceholder, {}),
981
+ "data-testid": "return-create-shipping-option"
982
+ }
983
+ ) }) });
984
+ }
985
+ }
986
+ )
987
+ ] })
988
+ ] }),
989
+ /* @__PURE__ */ jsxs3("div", { className: "mt-8 border-y border-dotted py-4", children: [
990
+ /* @__PURE__ */ jsxs3("div", { className: "mb-2 flex items-center justify-between", children: [
991
+ /* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.returnTotal") }),
992
+ /* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(
993
+ returnTotal ? -1 * returnTotal : returnTotal ?? 0,
994
+ order.currency_code
995
+ ) })
996
+ ] }),
997
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between", children: [
998
+ /* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.inboundShipping") }),
999
+ /* @__PURE__ */ jsxs3("span", { className: "txt-small text-ui-fg-subtle flex items-center", children: [
1000
+ !isShippingPriceEdit && /* @__PURE__ */ jsx4(
1001
+ IconButton2,
1002
+ {
1003
+ onClick: () => setIsShippingPriceEdit(true),
1004
+ variant: "transparent",
1005
+ className: "text-ui-fg-muted",
1006
+ disabled: showPlaceholder || !shippingOptionId,
1007
+ children: /* @__PURE__ */ jsx4(PencilSquare, {})
1008
+ }
1009
+ ),
1010
+ isShippingPriceEdit ? /* @__PURE__ */ jsx4(
1011
+ CurrencyInput,
1012
+ {
1013
+ id: "js-shipping-input",
1014
+ onBlur: () => {
1015
+ let actionId;
1016
+ preview.shipping_methods.forEach((s) => {
1017
+ const actions = s.actions;
1018
+ if (actions) {
1019
+ for (const a of actions) {
1020
+ if (a.action === "SHIPPING_ADD") {
1021
+ actionId = a.id;
1022
+ }
1023
+ }
1024
+ }
1025
+ });
1026
+ if (actionId) {
1027
+ updateReturnShipping({
1028
+ actionId,
1029
+ custom_amount: customShippingAmount.float ?? void 0
1030
+ });
1031
+ }
1032
+ setIsShippingPriceEdit(false);
1033
+ },
1034
+ symbol: currencies[order.currency_code.toUpperCase()]?.symbol_native ?? "",
1035
+ code: order.currency_code,
1036
+ onValueChange: (_value, _name, values) => setCustomShippingAmount({
1037
+ value: values?.value ?? "",
1038
+ float: values?.float ?? null
1039
+ }),
1040
+ value: customShippingAmount.value,
1041
+ disabled: showPlaceholder
1042
+ }
1043
+ ) : getStylizedAmount(shippingTotal, order.currency_code)
1044
+ ] })
1045
+ ] }),
1046
+ /* @__PURE__ */ jsxs3("div", { className: "mt-4 flex items-center justify-between border-t border-dotted pt-4", children: [
1047
+ /* @__PURE__ */ jsx4("span", { className: "txt-small font-medium", children: t("orders.returns.estDifference") }),
1048
+ /* @__PURE__ */ jsx4("span", { className: "txt-small font-medium", children: getStylizedAmount(estimatedDifference, order.currency_code) })
1049
+ ] })
1050
+ ] }),
1051
+ /* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-field mt-8 rounded-lg border py-2 pl-2 pr-4", children: /* @__PURE__ */ jsx4(
1052
+ Form.Field,
1053
+ {
1054
+ control: form.control,
1055
+ name: "send_notification",
1056
+ render: ({ field: { onChange, value, ...field } }) => {
1057
+ return /* @__PURE__ */ jsxs3(Form.Item, { children: [
1058
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center", children: [
1059
+ /* @__PURE__ */ jsx4(Form.Control, { className: "mr-4 self-start", children: /* @__PURE__ */ jsx4(
1060
+ Switch,
1061
+ {
1062
+ dir: "ltr",
1063
+ className: "mt-[2px] rtl:rotate-180",
1064
+ checked: !!value,
1065
+ onCheckedChange: onChange,
1066
+ ...field,
1067
+ "data-testid": "return-create-notify"
1068
+ }
1069
+ ) }),
1070
+ /* @__PURE__ */ jsxs3("div", { className: "block", children: [
1071
+ /* @__PURE__ */ jsx4(Form.Label, { children: t("orders.returns.sendNotification") }),
1072
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.sendNotificationHint") })
1073
+ ] })
1074
+ ] }),
1075
+ /* @__PURE__ */ jsx4(Form.ErrorMessage, {})
1076
+ ] });
1077
+ }
1078
+ }
1079
+ ) }),
1080
+ /* @__PURE__ */ jsx4("div", { className: "p-8" })
1081
+ ] }) }),
1082
+ /* @__PURE__ */ jsx4(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx4("div", { className: "flex w-full items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-x-2", children: [
1083
+ /* @__PURE__ */ jsx4(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx4(
1084
+ Button,
1085
+ {
1086
+ type: "button",
1087
+ variant: "secondary",
1088
+ size: "small",
1089
+ "data-testid": "return-create-cancel",
1090
+ children: t("orders.returns.cancel.title")
1091
+ }
1092
+ ) }),
1093
+ /* @__PURE__ */ jsx4(
1094
+ Button,
1095
+ {
1096
+ type: "submit",
1097
+ variant: "primary",
1098
+ size: "small",
1099
+ isLoading: isRequestLoading,
1100
+ "data-testid": "return-create-confirm",
1101
+ children: t("orders.returns.confirm")
1102
+ },
1103
+ "submit-button"
1104
+ )
1105
+ ] }) }) })
1106
+ ] })
1107
+ }
1108
+ );
1109
+ };
1110
+
1111
+ // src/pages/orders/[id]/returns/create/index.tsx
1112
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1113
+ var Component = () => {
1114
+ const { t } = useTranslation5();
1115
+ return /* @__PURE__ */ jsxs4(RouteFocusModal, { children: [
1116
+ /* @__PURE__ */ jsx5(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx5("span", { className: "sr-only", children: t("orders.returns.create") }) }),
1117
+ /* @__PURE__ */ jsx5(RouteFocusModal.Description, { className: "sr-only", children: t("orders.returns.confirmText") }),
1118
+ /* @__PURE__ */ jsx5(ReturnCreateContent, {})
1119
+ ] });
1120
+ };
1121
+ var create_default = Component;
1122
+ var ReturnCreateContent = () => {
1123
+ const { id } = useParams();
1124
+ const { t } = useTranslation5();
1125
+ const navigate = useNavigate();
1126
+ const orderId = id ?? "";
1127
+ const { order } = useOrder(orderId, {
1128
+ // Use `<rel>.*` and bare scalar names. Combining `*foo` with
1129
+ // `*foo.bar` (or `+foo.bar.baz`) makes the Medusa query parser look
1130
+ // up a literal `*items` / `+items` on Order and 500s. See
1131
+ // packages/core/src/api/vendor/orders/query-config.ts.
1132
+ fields: "currency_code,total,items.*,items.variant.*,items.offer.*,items.offer.inventory_item_link.*,items.offer.inventory_item_link.required_quantity,items.offer.inventory_item_link.inventory_item.*,items.offer.inventory_item_link.inventory_item.location_levels.*"
1133
+ });
1134
+ const { order: preview } = useOrderPreview(orderId);
1135
+ const [activeReturn, setActiveReturn] = useState3(
1136
+ void 0
1137
+ );
1138
+ const isInitiatingRef = useRef(false);
1139
+ const { mutateAsync: initiateReturn } = useInitiateReturn(orderId);
1140
+ useEffect2(() => {
1141
+ async function run() {
1142
+ if (isInitiatingRef.current || activeReturn || !order || !preview) {
1143
+ return;
1144
+ }
1145
+ isInitiatingRef.current = true;
1146
+ try {
1147
+ const res = await initiateReturn({ order_id: orderId });
1148
+ const r = res?.return;
1149
+ if (r) {
1150
+ setActiveReturn(r);
1151
+ }
1152
+ } catch (e) {
1153
+ toast2.error(
1154
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
1155
+ );
1156
+ navigate(`/orders/${orderId}`, { replace: true });
1157
+ } finally {
1158
+ isInitiatingRef.current = false;
1159
+ }
1160
+ }
1161
+ run();
1162
+ }, [order, preview, activeReturn, initiateReturn, orderId, navigate, t]);
1163
+ const ready = !!(order && preview && activeReturn);
1164
+ if (!ready) {
1165
+ return null;
1166
+ }
1167
+ return /* @__PURE__ */ jsx5(
1168
+ ReturnCreateForm,
1169
+ {
1170
+ order,
1171
+ preview,
1172
+ activeReturn
1173
+ }
1174
+ );
1175
+ };
1176
+ export {
1177
+ Component,
1178
+ create_default as default
1179
+ };