@mercurjs/vendor 2.1.6 → 2.2.0-canary.11

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 (259) hide show
  1. package/dist/[id]-A55T2ORL.js +3066 -0
  2. package/dist/[id]-B4YZTANM.js +1571 -0
  3. package/dist/{[id]-UTKO3VG4.js → [id]-EKLRGVBA.js} +10 -10
  4. package/dist/{[id]-TO6KT3ZE.js → [id]-FE5GYYVZ.js} +28 -25
  5. package/dist/{[id]-4VCL3MMM.js → [id]-GBT6VB4S.js} +29 -23
  6. package/dist/{[id]-3G5G7ZFV.js → [id]-GC3ZYPK4.js} +25 -22
  7. package/dist/{[id]-6PXEWRG7.js → [id]-J6BZG5PU.js} +14 -14
  8. package/dist/{[id]-B3LHVQM5.js → [id]-QOEO3JOV.js} +29 -23
  9. package/dist/{[id]-H3C3ZSC6.js → [id]-QQU5HVFU.js} +29 -23
  10. package/dist/{[id]-PDGHF5J2.js → [id]-SHAJTJNZ.js} +43 -36
  11. package/dist/{[id]-X4DDKOMQ.js → [id]-T5ECVBPF.js} +30 -24
  12. package/dist/{[id]-T2ROPEGY.js → [id]-U5KZEQDR.js} +7 -7
  13. package/dist/{[id]-7RUAH3TI.js → [id]-YPCO3DJV.js} +5 -5
  14. package/dist/{[id]-Y7GAMNC5.js → [id]-ZCMSBEVM.js} +4 -4
  15. package/dist/{[location_id]-D55RQOXT.js → [location_id]-NUBXDDJC.js} +9 -9
  16. package/dist/{[province_id]-OFH2ZOFQ.js → [province_id]-6GUA4PV5.js} +23 -20
  17. package/dist/{add-C6OX5C54.js → add-NTRYWOJF.js} +42 -35
  18. package/dist/add-RU3WL4YB.js +428 -0
  19. package/dist/{add-customer-groups-PJRJUWS2.js → add-customer-groups-U5RZWW4B.js} +19 -16
  20. package/dist/{add-products-INOLNPO6.js → add-products-Q4MMDQKT.js} +26 -20
  21. package/dist/{add-promotions-AHDOP52Q.js → add-promotions-3AYXQXTP.js} +8 -8
  22. package/dist/{add-to-campaign-HL6NGRR4.js → add-to-campaign-QKYQCSR2.js} +4 -4
  23. package/dist/{address-KRENKSLP.js → address-77Y3AOQ3.js} +19 -16
  24. package/dist/{adjust-inventory-H4EUP7J3.js → adjust-inventory-AFJLWF5R.js} +2 -2
  25. package/dist/{allocate-items-SUCUZU4D.js → allocate-items-TCM5A55Y.js} +141 -126
  26. package/dist/{areas-UUMZDXLX.js → areas-XUC5V5UO.js} +8 -8
  27. package/dist/{attributes-CALEHJJG.js → attributes-SZP2MM5L.js} +3 -3
  28. package/dist/{breadcrumb-KQSFIXQ4.js → breadcrumb-2XA2WOK7.js} +1 -1
  29. package/dist/{breadcrumb-IG7VZGW2.js → breadcrumb-5NP23D6X.js} +15 -12
  30. package/dist/{breadcrumb-TW5JEOYS.js → breadcrumb-EVZIOB2G.js} +14 -11
  31. package/dist/{breadcrumb-OIGGCB3L.js → breadcrumb-FPWBT76A.js} +8 -2
  32. package/dist/{breadcrumb-BS7Y5OKF.js → breadcrumb-IK6XCQOQ.js} +2 -2
  33. package/dist/{breadcrumb-M5Z5WA6I.js → breadcrumb-KTARIL65.js} +2 -2
  34. package/dist/{breadcrumb-VNNZ3TTW.js → breadcrumb-PBR27GGX.js} +3 -3
  35. package/dist/breadcrumb-THJ2HPRB.js +26 -0
  36. package/dist/{breadcrumb-6W2VP3OZ.js → breadcrumb-TNJSGX4T.js} +15 -12
  37. package/dist/{campaigns-HS6MIO7X.js → campaigns-JAQTSA4Z.js} +6 -6
  38. package/dist/{categories-PKWR3FM3.js → categories-T4QJYX4R.js} +8 -8
  39. package/dist/{chunk-4URLUCTD.js → chunk-25E4KME5.js} +3 -3
  40. package/dist/chunk-27KRIXMQ.js +71 -0
  41. package/dist/{chunk-SFQKKIHA.js → chunk-27WLUOI2.js} +1 -1
  42. package/dist/{chunk-ZYOXKUKZ.js → chunk-2QTNCGKX.js} +1 -1
  43. package/dist/{chunk-5UD4P6YL.js → chunk-2USXZSTK.js} +4 -4
  44. package/dist/{chunk-PXYDR7WQ.js → chunk-3BXCPHN6.js} +3 -2
  45. package/dist/{chunk-VQ5EKDA3.js → chunk-3PMM6AMP.js} +3 -3
  46. package/dist/{chunk-J6BRLL3F.js → chunk-463CNCJC.js} +3 -3
  47. package/dist/{chunk-Y2QI7KWS.js → chunk-4LVP635F.js} +408 -664
  48. package/dist/{chunk-UL4O5M4S.js → chunk-4S6XGIC6.js} +1 -18
  49. package/dist/{chunk-RUE5BPC2.js → chunk-5QI3NDJG.js} +1 -1
  50. package/dist/{chunk-PPLC4IKI.js → chunk-5T6UWTRU.js} +10 -5
  51. package/dist/{chunk-WITQNQXN.js → chunk-6FUIK3PX.js} +4 -4
  52. package/dist/{chunk-HGQTL7NX.js → chunk-6K6EQOJF.js} +3 -3
  53. package/dist/{chunk-KAZ5BYTQ.js → chunk-6OUPJNYO.js} +5 -3
  54. package/dist/{chunk-PEKANQ3T.js → chunk-6UZERVBI.js} +2 -2
  55. package/dist/{chunk-RTAWYMQP.js → chunk-7CMRFP5Q.js} +2 -2
  56. package/dist/{chunk-I2IKYOZX.js → chunk-7IPCLQ5V.js} +19 -19
  57. package/dist/chunk-ADGVQVHP.js +101 -0
  58. package/dist/{chunk-IZ5RG5XI.js → chunk-AJLGY3LQ.js} +1 -21
  59. package/dist/chunk-BER45EYD.js +82 -0
  60. package/dist/{chunk-PCMNEUMV.js → chunk-BXRNZS5K.js} +1 -1
  61. package/dist/chunk-CFRWIQIZ.js +43 -0
  62. package/dist/{chunk-RL7SFZOF.js → chunk-DDJQRV6E.js} +1 -1
  63. package/dist/{chunk-D2MA5TAP.js → chunk-DO4F5FIO.js} +2 -2
  64. package/dist/{chunk-X4FLOQ45.js → chunk-DQKK43PR.js} +3 -3
  65. package/dist/{chunk-6WY5X4PE.js → chunk-E6W57UP3.js} +35 -125
  66. package/dist/chunk-FP6U6BPH.js +61 -0
  67. package/dist/chunk-FWPGOIFA.js +22 -0
  68. package/dist/{chunk-BLVJAKBA.js → chunk-FWS4YJ4B.js} +1 -1
  69. package/dist/chunk-GAE6TKOR.js +811 -0
  70. package/dist/{chunk-3CK6OINO.js → chunk-GDWBOQI5.js} +3 -5
  71. package/dist/{chunk-PDQSPKG5.js → chunk-GN6KB75Z.js} +1 -1
  72. package/dist/chunk-HDEOZN2Q.js +60 -0
  73. package/dist/chunk-IBEUR3J7.js +173 -0
  74. package/dist/chunk-J6XCRFBW.js +30 -0
  75. package/dist/{chunk-ZEVYT6IX.js → chunk-JAUZ73XE.js} +151 -266
  76. package/dist/{chunk-CNLP35S7.js → chunk-K6LOZ4S3.js} +54 -18
  77. package/dist/{chunk-JQP7MOFH.js → chunk-KIFSQOM2.js} +2 -2
  78. package/dist/{chunk-DARJTN4I.js → chunk-L4KBTV57.js} +9 -2
  79. package/dist/chunk-L57USMYC.js +39 -0
  80. package/dist/chunk-LARLBYU6.js +127 -0
  81. package/dist/chunk-LDZCCWJB.js +518 -0
  82. package/dist/chunk-LEWA4BPH.js +18 -0
  83. package/dist/chunk-LFX6WU4A.js +36 -0
  84. package/dist/{chunk-ITI54CII.js → chunk-LKUW5SV4.js} +6 -6
  85. package/dist/{chunk-LPOAVK6Y.js → chunk-LQD232FW.js} +47 -12
  86. package/dist/{chunk-4MFMCZEJ.js → chunk-MJCL3WID.js} +2 -2
  87. package/dist/{chunk-32RYSB2V.js → chunk-NBKWY6XN.js} +2 -2
  88. package/dist/{chunk-GYV6SKY7.js → chunk-O7VOGTLX.js} +4 -6
  89. package/dist/{chunk-KQGVSLUI.js → chunk-OYKUQXJX.js} +1926 -957
  90. package/dist/{chunk-CYTNBXWF.js → chunk-OZ44ATGE.js} +8 -8
  91. package/dist/{chunk-7Q5SDEK7.js → chunk-PAVZ6FPK.js} +7 -7
  92. package/dist/{chunk-2RHAI7WK.js → chunk-QLBIBLOY.js} +2 -2
  93. package/dist/chunk-RXV7INUV.js +426 -0
  94. package/dist/chunk-S23FD6FA.js +210 -0
  95. package/dist/{chunk-NYDJTWRL.js → chunk-SGR4DMCW.js} +4 -4
  96. package/dist/{chunk-OXXL4WQU.js → chunk-SPOHNK4X.js} +6 -6
  97. package/dist/{chunk-AIF2KTEE.js → chunk-SSUUT5LK.js} +12 -2
  98. package/dist/{chunk-QX45GVAL.js → chunk-SZBERGA4.js} +8 -8
  99. package/dist/{chunk-6SBMVLJ2.js → chunk-T5MJWWDX.js} +2 -2
  100. package/dist/chunk-T6LHVNWO.js +27 -0
  101. package/dist/chunk-TBYCZRZ7.js +248 -0
  102. package/dist/chunk-TF6V3TFG.js +438 -0
  103. package/dist/chunk-TW324MAT.js +185 -0
  104. package/dist/{chunk-4ZGFODSC.js → chunk-TYESCFYW.js} +1 -1
  105. package/dist/chunk-U5G3AVED.js +64 -0
  106. package/dist/chunk-U6PBLMXD.js +14 -0
  107. package/dist/{chunk-GZMXTNDN.js → chunk-UCYSCKZV.js} +1432 -1380
  108. package/dist/{chunk-P3ZTO6T2.js → chunk-UFFVRF4V.js} +2 -2
  109. package/dist/chunk-UM7ZR3VU.js +14 -0
  110. package/dist/chunk-UORPTGV2.js +114 -0
  111. package/dist/{chunk-5M3SL4UZ.js → chunk-VCOQ7WQ2.js} +30 -106
  112. package/dist/chunk-VCUUITW6.js +35 -0
  113. package/dist/{chunk-PTW7JNAP.js → chunk-VDHW6H5F.js} +5 -5
  114. package/dist/chunk-VZUA5SRD.js +62 -0
  115. package/dist/{chunk-DKQ4XMSN.js → chunk-X4GWB6AT.js} +6 -6
  116. package/dist/{chunk-6YA3C4NB.js → chunk-XCIMOIX6.js} +3 -12
  117. package/dist/chunk-XP23ZVQT.js +2183 -0
  118. package/dist/{chunk-WBI7FEGI.js → chunk-Y2MQ5EMD.js} +29 -24
  119. package/dist/chunk-YBF45CX5.js +23 -0
  120. package/dist/{chunk-N7OVXN72.js → chunk-YGJCJBPM.js} +1 -1
  121. package/dist/{chunk-WNVEMFIK.js → chunk-YHIJCI4U.js} +3 -3
  122. package/dist/{chunk-WFE6CT6M.js → chunk-YQZBAP3S.js} +22 -76
  123. package/dist/chunk-ZHFFTT3I.js +17 -0
  124. package/dist/{collections-DJZI2RM2.js → collections-URH2TCWJ.js} +28 -24
  125. package/dist/{configuration-GN3TO77H.js → configuration-7IYZ6GNP.js} +3 -3
  126. package/dist/{configuration-RHPIO2QT.js → configuration-C4IGBNXH.js} +1 -1
  127. package/dist/{create-7S7CZWEN.js → create-5PSOIHIT.js} +4 -4
  128. package/dist/create-7R6CZU53.js +215 -0
  129. package/dist/{create-3EK5CNNX.js → create-A7B3MLJX.js} +41 -34
  130. package/dist/create-F5R76QML.js +1178 -0
  131. package/dist/create-FKRYB7ZS.js +1784 -0
  132. package/dist/create-GGACODDN.js +1914 -0
  133. package/dist/{create-YO55Z3YD.js → create-HVZYJ3YC.js} +35 -38
  134. package/dist/{create-IDVCZHIX.js → create-JF2OUZQA.js} +16 -13
  135. package/dist/{create-3ZVXEPX5.js → create-JGYG5SBM.js} +29 -23
  136. package/dist/{create-G4T2PAJH.js → create-MS6KKFSV.js} +21 -18
  137. package/dist/{create-OCFPLNNY.js → create-MZYXMGKP.js} +6 -6
  138. package/dist/{create-HKJVSFB7.js → create-O35JRZEF.js} +25 -22
  139. package/dist/{create-OGLPDVOI.js → create-ODOFJF5N.js} +40 -37
  140. package/dist/{create-GHM7OTCR.js → create-R7K3ECN6.js} +1 -1
  141. package/dist/{create-D6EW3EWC.js → create-SFU3W3ZH.js} +1 -1
  142. package/dist/create-TKXH5KQY.js +239 -0
  143. package/dist/{create-33TRLASX.js → create-UPYB65PD.js} +1 -1
  144. package/dist/{create-KGYL7FBM.js → create-XVHOCZHJ.js} +1 -1
  145. package/dist/{create-4AE3VTWN.js → create-YBF4YGWG.js} +2 -2
  146. package/dist/{customers-6ZLE65UX.js → customers-SOLJ2KQQ.js} +5 -5
  147. package/dist/{edit-QBISX7D3.js → edit-2R5QCPTB.js} +16 -13
  148. package/dist/{edit-IR6V2IDN.js → edit-3E4ZO7HT.js} +21 -18
  149. package/dist/{edit-ZSOI56BQ.js → edit-4G5D7TES.js} +52 -40
  150. package/dist/{edit-B5B3XKDM.js → edit-522DG3BY.js} +1 -1
  151. package/dist/{edit-B75KK5ZX.js → edit-5CROKEJE.js} +41 -34
  152. package/dist/{edit-ATXE6CM5.js → edit-C4OCKQVU.js} +1 -1
  153. package/dist/{edit-7HTH2UJF.js → edit-FXNXTVIW.js} +3 -3
  154. package/dist/{edit-RNT555GP.js → edit-G2E5SNGU.js} +15 -12
  155. package/dist/{edit-4HZHLYI3.js → edit-GQNIINRR.js} +1 -1
  156. package/dist/{edit-2KRJIPRK.js → edit-HTLLYECP.js} +21 -18
  157. package/dist/{edit-LRRJTHV2.js → edit-KAKVPHZZ.js} +1 -1
  158. package/dist/{edit-GIJXLMC3.js → edit-O4JLGKQR.js} +2 -2
  159. package/dist/{edit-FNDDSSMT.js → edit-OKU6FMHJ.js} +60 -9
  160. package/dist/{edit-5CJZRHAA.js → edit-ORXS3A2Y.js} +1 -1
  161. package/dist/{edit-FC64DWB2.js → edit-Q3UQIOLS.js} +1 -1
  162. package/dist/edit-VVLITC2E.js +910 -0
  163. package/dist/edit-XSICGAVO.js +176 -0
  164. package/dist/{edit-7GVP6SRA.js → edit-ZAHCMF5U.js} +1 -1
  165. package/dist/{edit-MYSWY6W4.js → edit-ZMERG3L7.js} +1 -1
  166. package/dist/{edit-budget-J27CSEZH.js → edit-budget-L3CCEWNF.js} +1 -1
  167. package/dist/{edit-inventory-item-US77M2FF.js → edit-inventory-item-ZKXXL3QK.js} +2 -2
  168. package/dist/{edit-inventory-item-attributes-UGAE2NAZ.js → edit-inventory-item-attributes-GSKUMORD.js} +3 -3
  169. package/dist/{fulfillment-DCS67LTK.js → fulfillment-76IVZ266.js} +32 -22
  170. package/dist/{fulfillment-providers-GM5PO6N3.js → fulfillment-providers-G2L6LEVO.js} +24 -20
  171. package/dist/index.css +104 -65
  172. package/dist/index.d.ts +3 -10
  173. package/dist/index.js +549 -456
  174. package/dist/{inventory-OPZ2FSEE.js → inventory-WSFLTA6Z.js} +7 -7
  175. package/dist/{invite-KEJLNXEZ.js → invite-2673PU4I.js} +17 -13
  176. package/dist/{invite-CQCKEQW2.js → invite-HRXZ5YBP.js} +28 -24
  177. package/dist/loader-VDYPD3RI.js +31 -0
  178. package/dist/{locations-ZVPTQCQY.js → locations-INS6FTMJ.js} +4 -4
  179. package/dist/{login-OUHRNNXA.js → login-TWUBU6I6.js} +14 -11
  180. package/dist/{manage-locations-YUKEFCBJ.js → manage-locations-XHH5DVIR.js} +2 -2
  181. package/dist/{media-4KYFHB5V.js → media-Z4N5MKFG.js} +42 -9
  182. package/dist/{metadata-AWUKZ25V.js → metadata-5BPOBBU2.js} +3 -3
  183. package/dist/{metadata-OCE6A3JE.js → metadata-D6M66NQK.js} +17 -14
  184. package/dist/{metadata-PYY4IB7K.js → metadata-NIDIBXJT.js} +17 -14
  185. package/dist/{metadata-XP3ZYW2M.js → metadata-Q74OJWUD.js} +18 -15
  186. package/dist/{metadata-NYYL26MQ.js → metadata-REQIFWWH.js} +18 -15
  187. package/dist/{metadata-G7KZXVNE.js → metadata-YVHJPDLD.js} +17 -14
  188. package/dist/offer-create-page-E4FLSDJQ.js +743 -0
  189. package/dist/offer-detail-page-6SIBQTLP.js +492 -0
  190. package/dist/offer-edit-page-3MO566RP.js +151 -0
  191. package/dist/offer-inventory-batch-page-BD6PMDLW.js +290 -0
  192. package/dist/offer-pricing-edit-page-4TINK42V.js +199 -0
  193. package/dist/offers-GVN5LCK6.js +32 -0
  194. package/dist/{onboarding-WXZHW62K.js → onboarding-MK2RIFD4.js} +24 -21
  195. package/dist/{orders-LWJ472VM.js → orders-TVQDR4OJ.js} +30 -26
  196. package/dist/organization-XO3T2K2X.js +340 -0
  197. package/dist/{organize-RFOMQCBG.js → organize-5XRZWD5C.js} +4 -4
  198. package/dist/{organize-OVKJ3HZO.js → organize-Z7JTTDH4.js} +4 -4
  199. package/dist/pages/index.d.ts +439 -758
  200. package/dist/pages/index.js +85 -78
  201. package/dist/{payment-details-UVXYCTUK.js → payment-details-CFTX3QDL.js} +19 -16
  202. package/dist/{payouts-TR7K5I37.js → payouts-7Q7D4FET.js} +8 -8
  203. package/dist/{price-lists-S2WNELFZ.js → price-lists-6TFLA53G.js} +9 -9
  204. package/dist/{pricing-UF27DAXA.js → pricing-ECXV6K7G.js} +41 -37
  205. package/dist/{product-tags-2CKH2M6D.js → product-tags-5O7ZG6SA.js} +40 -33
  206. package/dist/{product-types-FX43JEO2.js → product-types-PKUEL7X5.js} +6 -6
  207. package/dist/product-variant-detail-PUWOMVHQ.js +210 -0
  208. package/dist/{product-variant-edit-P3DSIFE3.js → product-variant-edit-WZNO4CQX.js} +134 -66
  209. package/dist/{products-H5EMRJYS.js → products-BM3IIH5P.js} +27 -21
  210. package/dist/{products-2LHGS7X3.js → products-CPTRYL2Z.js} +44 -45
  211. package/dist/{professional-details-HYKTH44B.js → professional-details-ED4HNYXY.js} +18 -15
  212. package/dist/{profile-PB27WIRW.js → profile-6TGCNNUU.js} +21 -18
  213. package/dist/{promotions-5EYPGHJP.js → promotions-4336KI7E.js} +9 -9
  214. package/dist/receive-224KLULH.js +578 -0
  215. package/dist/refund-IGMSXQNX.js +268 -0
  216. package/dist/{register-X45K325N.js → register-OZ5CRANZ.js} +18 -15
  217. package/dist/{reset-password-GTWLBOFK.js → reset-password-5UHZU4D3.js} +1 -1
  218. package/dist/{return-reasons-LOKYRGMI.js → return-reasons-QJRA2ZX6.js} +21 -17
  219. package/dist/{sales-channels-Y4LRP7JC.js → sales-channels-CZDU7VTE.js} +7 -6
  220. package/dist/{sales-channels-7R2IY3KG.js → sales-channels-U55MUDQP.js} +7 -6
  221. package/dist/{settings-2XDLFYMS.js → settings-2GCQQTO6.js} +47 -40
  222. package/dist/shipment-HWQHMX2L.js +242 -0
  223. package/dist/{shipping-profile-R3NABPQF.js → shipping-profile-ZP7M6VSS.js} +2 -2
  224. package/dist/{shipping-profiles-QVKNFLCW.js → shipping-profiles-C5WBXWZ2.js} +21 -18
  225. package/dist/{stock-5RXNUPUT.js → stock-MQA7PRO6.js} +21 -18
  226. package/dist/{store-MPYOWMZT.js → store-5ZHZR4JI.js} +84 -149
  227. package/dist/{store-closure-DNMCHUXD.js → store-closure-H5WHV3LA.js} +24 -16
  228. package/dist/{store-select-UTPJ7DM7.js → store-select-PZS556FB.js} +19 -16
  229. package/dist/{tax-regions-UD6P5FVC.js → tax-regions-HDLBFZVG.js} +6 -6
  230. package/dist/{team-IMS66MVP.js → team-CLKJCZNH.js} +29 -26
  231. package/dist/types-CtCEtTE6.d.ts +16 -0
  232. package/package.json +5 -5
  233. package/dist/[id]-BYP37PU4.js +0 -1314
  234. package/dist/[id]-INOFZHL7.js +0 -1219
  235. package/dist/add-KRAGFFBJ.js +0 -158
  236. package/dist/bulk-edit-3SMBLIOA.js +0 -244
  237. package/dist/chunk-47SXTGLN.js +0 -397
  238. package/dist/chunk-4KX6CBJ4.js +0 -178
  239. package/dist/chunk-DLNNTQRY.js +0 -217
  240. package/dist/chunk-FX4V5JCF.js +0 -37
  241. package/dist/chunk-GC33DBKG.js +0 -143
  242. package/dist/chunk-LQYMBSRQ.js +0 -66
  243. package/dist/chunk-NK4NR6MN.js +0 -173
  244. package/dist/chunk-PFU6FSXY.js +0 -430
  245. package/dist/chunk-QJEOPT2P.js +0 -330
  246. package/dist/chunk-QSGR43JM.js +0 -30
  247. package/dist/chunk-STR3NGWE.js +0 -3736
  248. package/dist/create-3DOO3RNH.js +0 -716
  249. package/dist/create-I7HV3RM6.js +0 -150
  250. package/dist/edit-K2AD335I.js +0 -237
  251. package/dist/edit-VO5XLIEL.js +0 -362
  252. package/dist/edit-stocks-and-prices-MHHQFWFA.js +0 -408
  253. package/dist/organization-LPYQRTQC.js +0 -303
  254. package/dist/prices-3OXV5RGY.js +0 -270
  255. package/dist/product-variant-detail-WV4KXVXR.js +0 -590
  256. package/dist/shipment-4GW2JFWB.js +0 -174
  257. package/dist/stock-GPC3BCL6.js +0 -500
  258. package/dist/{chunk-SDSEW72R.js → chunk-E2HQPY32.js} +3 -3
  259. /package/dist/{chunk-CAS74NLJ.js → chunk-YV6MK4PZ.js} +0 -0
@@ -0,0 +1,1178 @@
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-TF6V3TFG.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-SSUUT5LK.js";
39
+ import "./chunk-YN3FGNJM.js";
40
+ import "./chunk-6OUPJNYO.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-U2ZFCAPX.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-Y2MQ5EMD.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-JAUZ73XE.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
+ className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400",
793
+ "data-testid": "return-create-add-items-trigger",
794
+ children: t("actions.addItems")
795
+ }
796
+ ) }),
797
+ /* @__PURE__ */ jsxs3(StackedFocusModal.Content, { children: [
798
+ /* @__PURE__ */ jsx4(StackedFocusModal.Header, {}),
799
+ /* @__PURE__ */ jsx4(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx4("span", { className: "sr-only", children: t("actions.addItems") }) }),
800
+ /* @__PURE__ */ jsx4(StackedFocusModal.Description, { className: "sr-only", children: t("orders.returns.create") }),
801
+ /* @__PURE__ */ jsx4(StackedFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsx4(
802
+ AddReturnItemsTable,
803
+ {
804
+ order,
805
+ selectedItems: items.map((i) => i.item_id),
806
+ onSelectionChange: (s) => selectedLineItemIds = s
807
+ }
808
+ ) }),
809
+ /* @__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: [
810
+ /* @__PURE__ */ jsx4(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx4(
811
+ Button,
812
+ {
813
+ type: "button",
814
+ variant: "secondary",
815
+ size: "small",
816
+ "data-testid": "return-create-add-items-cancel",
817
+ children: t("actions.cancel")
818
+ }
819
+ ) }),
820
+ /* @__PURE__ */ jsx4(
821
+ Button,
822
+ {
823
+ type: "button",
824
+ variant: "primary",
825
+ size: "small",
826
+ role: "button",
827
+ onClick: onItemsSelected,
828
+ "data-testid": "return-create-add-items-save",
829
+ children: t("actions.save")
830
+ },
831
+ "submit-button"
832
+ )
833
+ ] }) }) })
834
+ ] })
835
+ ] })
836
+ ] }),
837
+ showPlaceholder && /* @__PURE__ */ jsx4(
838
+ "div",
839
+ {
840
+ style: {
841
+ background: "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)"
842
+ },
843
+ className: "bg-ui-bg-field mt-4 block h-[56px] w-full rounded-lg border border-dashed"
844
+ }
845
+ ),
846
+ items.filter((item) => !!previewItemsMap.get(item.item_id)).map((item, index) => {
847
+ const previewItem = previewItemsMap.get(item.item_id);
848
+ if (!previewItem) {
849
+ return null;
850
+ }
851
+ const orderItem = itemsMap.get(item.item_id);
852
+ if (!orderItem) {
853
+ return null;
854
+ }
855
+ return /* @__PURE__ */ jsx4(
856
+ ReturnItem,
857
+ {
858
+ item: orderItem,
859
+ previewItem,
860
+ currencyCode: order.currency_code,
861
+ form,
862
+ locationId,
863
+ locationName,
864
+ onRemove: () => {
865
+ const actions = previewItems.find((i) => i.id === item.item_id)?.actions ?? [];
866
+ const actionId = actions.find(
867
+ (a) => a.action === "RETURN_ITEM"
868
+ )?.id;
869
+ if (actionId) {
870
+ removeReturnItem(actionId);
871
+ }
872
+ },
873
+ onUpdate: (payload) => {
874
+ const actions = previewItems.find((i) => i.id === item.item_id)?.actions ?? [];
875
+ const action = actions.find(
876
+ (a) => a.action === "RETURN_ITEM"
877
+ );
878
+ if (action) {
879
+ updateReturnItem(
880
+ { actionId: action.id, ...payload },
881
+ {
882
+ onError: (error) => {
883
+ if (action.details?.quantity && payload.quantity) {
884
+ form.setValue(
885
+ `items.${index}.quantity`,
886
+ action.details.quantity
887
+ );
888
+ }
889
+ toast.error(error.message);
890
+ }
891
+ }
892
+ );
893
+ }
894
+ },
895
+ index
896
+ },
897
+ item.id
898
+ );
899
+ }),
900
+ !showPlaceholder && /* @__PURE__ */ jsxs3("div", { className: "mt-8 flex flex-col gap-y-4", children: [
901
+ /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
902
+ /* @__PURE__ */ jsxs3("div", { children: [
903
+ /* @__PURE__ */ jsx4(Form.Label, { children: t("orders.returns.location") }),
904
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.locationHint") })
905
+ ] }),
906
+ /* @__PURE__ */ jsx4(
907
+ Form.Field,
908
+ {
909
+ control: form.control,
910
+ name: "location_id",
911
+ render: ({ field: { value, onChange, ...field } }) => {
912
+ return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(
913
+ Combobox,
914
+ {
915
+ value: value ?? void 0,
916
+ onChange: (v) => {
917
+ onChange(v);
918
+ onLocationChange(v ?? "");
919
+ },
920
+ ...field,
921
+ options: (stockLocations ?? []).map(
922
+ (loc) => ({
923
+ label: loc.name,
924
+ value: loc.id
925
+ })
926
+ ),
927
+ "data-testid": "return-create-location"
928
+ }
929
+ ) }) });
930
+ }
931
+ }
932
+ )
933
+ ] }),
934
+ /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
935
+ /* @__PURE__ */ jsxs3("div", { children: [
936
+ /* @__PURE__ */ jsxs3(Form.Label, { children: [
937
+ t("orders.returns.inboundShipping"),
938
+ /* @__PURE__ */ jsxs3(
939
+ Text3,
940
+ {
941
+ size: "small",
942
+ leading: "compact",
943
+ className: "text-ui-fg-muted ml-1 inline",
944
+ children: [
945
+ "(",
946
+ t("fields.optional"),
947
+ ")"
948
+ ]
949
+ }
950
+ )
951
+ ] }),
952
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.inboundShippingHint") })
953
+ ] }),
954
+ /* @__PURE__ */ jsx4(
955
+ Form.Field,
956
+ {
957
+ control: form.control,
958
+ name: "option_id",
959
+ render: ({ field: { value, onChange, ...field } }) => {
960
+ return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(
961
+ Combobox,
962
+ {
963
+ allowClear: true,
964
+ value,
965
+ onChange: (v) => {
966
+ onChange(v ?? "");
967
+ onShippingOptionChange(v);
968
+ },
969
+ ...field,
970
+ options: (shippingOptions ?? []).filter(
971
+ (so) => (locationId ? so.service_zone?.fulfillment_set?.location?.id === locationId : true) && !!so.rules?.find(
972
+ (r) => r.attribute === "is_return" && r.value === "true"
973
+ )
974
+ ).map((so) => ({
975
+ label: so.name,
976
+ value: so.id
977
+ })),
978
+ disabled: !locationId,
979
+ noResultsPlaceholder: /* @__PURE__ */ jsx4(ReturnShippingPlaceholder, {}),
980
+ "data-testid": "return-create-shipping-option"
981
+ }
982
+ ) }) });
983
+ }
984
+ }
985
+ )
986
+ ] })
987
+ ] }),
988
+ /* @__PURE__ */ jsxs3("div", { className: "mt-8 border-y border-dotted py-4", children: [
989
+ /* @__PURE__ */ jsxs3("div", { className: "mb-2 flex items-center justify-between", children: [
990
+ /* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.returnTotal") }),
991
+ /* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(
992
+ returnTotal ? -1 * returnTotal : returnTotal ?? 0,
993
+ order.currency_code
994
+ ) })
995
+ ] }),
996
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between", children: [
997
+ /* @__PURE__ */ jsx4("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.inboundShipping") }),
998
+ /* @__PURE__ */ jsxs3("span", { className: "txt-small text-ui-fg-subtle flex items-center", children: [
999
+ !isShippingPriceEdit && /* @__PURE__ */ jsx4(
1000
+ IconButton2,
1001
+ {
1002
+ onClick: () => setIsShippingPriceEdit(true),
1003
+ variant: "transparent",
1004
+ className: "text-ui-fg-muted",
1005
+ disabled: showPlaceholder || !shippingOptionId,
1006
+ children: /* @__PURE__ */ jsx4(PencilSquare, {})
1007
+ }
1008
+ ),
1009
+ isShippingPriceEdit ? /* @__PURE__ */ jsx4(
1010
+ CurrencyInput,
1011
+ {
1012
+ id: "js-shipping-input",
1013
+ onBlur: () => {
1014
+ let actionId;
1015
+ preview.shipping_methods.forEach((s) => {
1016
+ const actions = s.actions;
1017
+ if (actions) {
1018
+ for (const a of actions) {
1019
+ if (a.action === "SHIPPING_ADD") {
1020
+ actionId = a.id;
1021
+ }
1022
+ }
1023
+ }
1024
+ });
1025
+ if (actionId) {
1026
+ updateReturnShipping({
1027
+ actionId,
1028
+ custom_amount: customShippingAmount.float ?? void 0
1029
+ });
1030
+ }
1031
+ setIsShippingPriceEdit(false);
1032
+ },
1033
+ symbol: currencies[order.currency_code.toUpperCase()]?.symbol_native ?? "",
1034
+ code: order.currency_code,
1035
+ onValueChange: (_value, _name, values) => setCustomShippingAmount({
1036
+ value: values?.value ?? "",
1037
+ float: values?.float ?? null
1038
+ }),
1039
+ value: customShippingAmount.value,
1040
+ disabled: showPlaceholder
1041
+ }
1042
+ ) : getStylizedAmount(shippingTotal, order.currency_code)
1043
+ ] })
1044
+ ] }),
1045
+ /* @__PURE__ */ jsxs3("div", { className: "mt-4 flex items-center justify-between border-t border-dotted pt-4", children: [
1046
+ /* @__PURE__ */ jsx4("span", { className: "txt-small font-medium", children: t("orders.returns.estDifference") }),
1047
+ /* @__PURE__ */ jsx4("span", { className: "txt-small font-medium", children: getStylizedAmount(estimatedDifference, order.currency_code) })
1048
+ ] })
1049
+ ] }),
1050
+ /* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-field mt-8 rounded-lg border py-2 pl-2 pr-4", children: /* @__PURE__ */ jsx4(
1051
+ Form.Field,
1052
+ {
1053
+ control: form.control,
1054
+ name: "send_notification",
1055
+ render: ({ field: { onChange, value, ...field } }) => {
1056
+ return /* @__PURE__ */ jsxs3(Form.Item, { children: [
1057
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center", children: [
1058
+ /* @__PURE__ */ jsx4(Form.Control, { className: "mr-4 self-start", children: /* @__PURE__ */ jsx4(
1059
+ Switch,
1060
+ {
1061
+ dir: "ltr",
1062
+ className: "mt-[2px] rtl:rotate-180",
1063
+ checked: !!value,
1064
+ onCheckedChange: onChange,
1065
+ ...field,
1066
+ "data-testid": "return-create-notify"
1067
+ }
1068
+ ) }),
1069
+ /* @__PURE__ */ jsxs3("div", { className: "block", children: [
1070
+ /* @__PURE__ */ jsx4(Form.Label, { children: t("orders.returns.sendNotification") }),
1071
+ /* @__PURE__ */ jsx4(Form.Hint, { className: "!mt-1", children: t("orders.returns.sendNotificationHint") })
1072
+ ] })
1073
+ ] }),
1074
+ /* @__PURE__ */ jsx4(Form.ErrorMessage, {})
1075
+ ] });
1076
+ }
1077
+ }
1078
+ ) }),
1079
+ /* @__PURE__ */ jsx4("div", { className: "p-8" })
1080
+ ] }) }),
1081
+ /* @__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: [
1082
+ /* @__PURE__ */ jsx4(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx4(
1083
+ Button,
1084
+ {
1085
+ type: "button",
1086
+ variant: "secondary",
1087
+ size: "small",
1088
+ "data-testid": "return-create-cancel",
1089
+ children: t("orders.returns.cancel.title")
1090
+ }
1091
+ ) }),
1092
+ /* @__PURE__ */ jsx4(
1093
+ Button,
1094
+ {
1095
+ type: "submit",
1096
+ variant: "primary",
1097
+ size: "small",
1098
+ isLoading: isRequestLoading,
1099
+ "data-testid": "return-create-confirm",
1100
+ children: t("orders.returns.confirm")
1101
+ },
1102
+ "submit-button"
1103
+ )
1104
+ ] }) }) })
1105
+ ] })
1106
+ }
1107
+ );
1108
+ };
1109
+
1110
+ // src/pages/orders/[id]/returns/create/index.tsx
1111
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1112
+ var Component = () => {
1113
+ const { t } = useTranslation5();
1114
+ return /* @__PURE__ */ jsxs4(RouteFocusModal, { children: [
1115
+ /* @__PURE__ */ jsx5(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx5("span", { className: "sr-only", children: t("orders.returns.create") }) }),
1116
+ /* @__PURE__ */ jsx5(RouteFocusModal.Description, { className: "sr-only", children: t("orders.returns.confirmText") }),
1117
+ /* @__PURE__ */ jsx5(ReturnCreateContent, {})
1118
+ ] });
1119
+ };
1120
+ var create_default = Component;
1121
+ var ReturnCreateContent = () => {
1122
+ const { id } = useParams();
1123
+ const { t } = useTranslation5();
1124
+ const navigate = useNavigate();
1125
+ const orderId = id ?? "";
1126
+ const { order } = useOrder(orderId, {
1127
+ // Use `<rel>.*` and bare scalar names. Combining `*foo` with
1128
+ // `*foo.bar` (or `+foo.bar.baz`) makes the Medusa query parser look
1129
+ // up a literal `*items` / `+items` on Order and 500s. See
1130
+ // packages/core/src/api/vendor/orders/query-config.ts.
1131
+ 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.*"
1132
+ });
1133
+ const { order: preview } = useOrderPreview(orderId);
1134
+ const [activeReturn, setActiveReturn] = useState3(
1135
+ void 0
1136
+ );
1137
+ const isInitiatingRef = useRef(false);
1138
+ const { mutateAsync: initiateReturn } = useInitiateReturn(orderId);
1139
+ useEffect2(() => {
1140
+ async function run() {
1141
+ if (isInitiatingRef.current || activeReturn || !order || !preview) {
1142
+ return;
1143
+ }
1144
+ isInitiatingRef.current = true;
1145
+ try {
1146
+ const res = await initiateReturn({ order_id: orderId });
1147
+ const r = res?.return;
1148
+ if (r) {
1149
+ setActiveReturn(r);
1150
+ }
1151
+ } catch (e) {
1152
+ toast2.error(
1153
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
1154
+ );
1155
+ navigate(`/orders/${orderId}`, { replace: true });
1156
+ } finally {
1157
+ isInitiatingRef.current = false;
1158
+ }
1159
+ }
1160
+ run();
1161
+ }, [order, preview, activeReturn, initiateReturn, orderId, navigate, t]);
1162
+ const ready = !!(order && preview && activeReturn);
1163
+ if (!ready) {
1164
+ return null;
1165
+ }
1166
+ return /* @__PURE__ */ jsx5(
1167
+ ReturnCreateForm,
1168
+ {
1169
+ order,
1170
+ preview,
1171
+ activeReturn
1172
+ }
1173
+ );
1174
+ };
1175
+ export {
1176
+ Component,
1177
+ create_default as default
1178
+ };