@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,1798 @@
1
+ import {
2
+ ReturnShippingPlaceholder
3
+ } from "./chunk-YBF45CX5.js";
4
+ import {
5
+ ItemPlaceholder
6
+ } from "./chunk-ZHFFTT3I.js";
7
+ import {
8
+ useReturnReasons
9
+ } from "./chunk-LHKHQAAY.js";
10
+ import {
11
+ useAddClaimInboundItems,
12
+ useAddClaimInboundShipping,
13
+ useCancelClaimRequest,
14
+ useClaim,
15
+ useClaimConfirmRequest,
16
+ useCreateClaim,
17
+ useDeleteClaimInboundShipping,
18
+ useRemoveClaimInboundItem,
19
+ useUpdateClaimInboundItem,
20
+ useUpdateClaimInboundShipping
21
+ } from "./chunk-T6DSYOY5.js";
22
+ import {
23
+ useReturn,
24
+ useUpdateReturn
25
+ } from "./chunk-CHBURL76.js";
26
+ import {
27
+ getReturnableQuantity
28
+ } from "./chunk-UM7ZR3VU.js";
29
+ import {
30
+ DEFAULT_FIELDS
31
+ } from "./chunk-IMJ62GAP.js";
32
+ import {
33
+ MoneyAmountCell
34
+ } from "./chunk-L57USMYC.js";
35
+ import {
36
+ getStylizedAmount
37
+ } from "./chunk-3BXCPHN6.js";
38
+ import {
39
+ ProductCell,
40
+ ProductHeader
41
+ } from "./chunk-FWPGOIFA.js";
42
+ import "./chunk-FQERBIVS.js";
43
+ import {
44
+ PlaceholderCell
45
+ } from "./chunk-PHOCVOZ5.js";
46
+ import {
47
+ _DataTable,
48
+ useDataTable
49
+ } from "./chunk-WKRW5OPL.js";
50
+ import "./chunk-YN3FGNJM.js";
51
+ import "./chunk-KCHYLLVG.js";
52
+ import "./chunk-3EF54XFY.js";
53
+ import "./chunk-IQPN4PZJ.js";
54
+ import {
55
+ Combobox
56
+ } from "./chunk-VBRTC2VU.js";
57
+ import "./chunk-TKGWSUEI.js";
58
+ import {
59
+ KeyboundForm
60
+ } from "./chunk-SITRHMZZ.js";
61
+ import {
62
+ RouteFocusModal,
63
+ StackedFocusModal,
64
+ useRouteModal,
65
+ useStackedModal
66
+ } from "./chunk-GDWBOQI5.js";
67
+ import {
68
+ Form
69
+ } from "./chunk-3QSRE5LS.js";
70
+ import {
71
+ useQueryParams
72
+ } from "./chunk-THHRRYRS.js";
73
+ import "./chunk-LRD242C7.js";
74
+ import {
75
+ Thumbnail
76
+ } from "./chunk-WIYFXWRI.js";
77
+ import "./chunk-INNFZYX2.js";
78
+ import {
79
+ useShippingOptions
80
+ } from "./chunk-VXMOPVRH.js";
81
+ import {
82
+ useStockLocations
83
+ } from "./chunk-NBPMNUKZ.js";
84
+ import {
85
+ useOffers
86
+ } from "./chunk-4R5GESED.js";
87
+ import {
88
+ useOrder,
89
+ useOrderPreview
90
+ } from "./chunk-7RGUD6PI.js";
91
+ import {
92
+ ActionMenu
93
+ } from "./chunk-BDGZ4EQO.js";
94
+ import "./chunk-LAVHRER2.js";
95
+ import "./chunk-QHQWEERJ.js";
96
+ import "./chunk-Y7QKP6QU.js";
97
+ import "./chunk-TSTUAL6N.js";
98
+ import "./chunk-A5DJIOHN.js";
99
+ import "./chunk-RHKRREUU.js";
100
+ import "./chunk-ZA2KFUFR.js";
101
+ import "./chunk-RIN4CBRB.js";
102
+ import "./chunk-NBMM2TZK.js";
103
+
104
+ // src/pages/orders/[id]/claims/create/index.tsx
105
+ import { toast as toast2 } from "@medusajs/ui";
106
+ import { useEffect as useEffect2, useState as useState4 } from "react";
107
+ import { useTranslation as useTranslation11 } from "react-i18next";
108
+ import { useNavigate, useParams } from "react-router-dom";
109
+
110
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/claim-create-form.tsx
111
+ import { zodResolver } from "@hookform/resolvers/zod";
112
+ import { Alert, Button as Button2, Heading as Heading2, Switch, Text as Text4, toast, usePrompt } from "@medusajs/ui";
113
+ import { useEffect, useMemo as useMemo5, useState as useState3 } from "react";
114
+ import { useFieldArray as useFieldArray2, useForm } from "react-hook-form";
115
+ import { useTranslation as useTranslation10 } from "react-i18next";
116
+
117
+ // src/pages/orders/[id]/claims/create/_components/add-claim-items-table/add-claim-items-table.tsx
118
+ import { useMemo as useMemo2, useState } from "react";
119
+ import { useTranslation as useTranslation3 } from "react-i18next";
120
+
121
+ // src/pages/orders/[id]/claims/create/_components/add-claim-items-table/use-claim-item-table-columns.tsx
122
+ import { Checkbox } from "@medusajs/ui";
123
+ import { createColumnHelper } from "@tanstack/react-table";
124
+ import { useMemo } from "react";
125
+ import { useTranslation } from "react-i18next";
126
+ import { jsx } from "react/jsx-runtime";
127
+ var columnHelper = createColumnHelper();
128
+ var useClaimItemTableColumns = (currencyCode) => {
129
+ const { t } = useTranslation();
130
+ return useMemo(
131
+ () => [
132
+ columnHelper.display({
133
+ id: "select",
134
+ header: ({ table }) => {
135
+ return /* @__PURE__ */ jsx(
136
+ Checkbox,
137
+ {
138
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
139
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
140
+ }
141
+ );
142
+ },
143
+ cell: ({ row }) => {
144
+ const isSelectable = row.getCanSelect();
145
+ return /* @__PURE__ */ jsx(
146
+ Checkbox,
147
+ {
148
+ disabled: !isSelectable,
149
+ checked: row.getIsSelected(),
150
+ onCheckedChange: (value) => row.toggleSelected(!!value),
151
+ onClick: (e) => {
152
+ e.stopPropagation();
153
+ }
154
+ }
155
+ );
156
+ }
157
+ }),
158
+ columnHelper.display({
159
+ id: "product",
160
+ header: () => /* @__PURE__ */ jsx(ProductHeader, {}),
161
+ cell: ({ row }) => /* @__PURE__ */ jsx(
162
+ ProductCell,
163
+ {
164
+ product: {
165
+ thumbnail: row.original.thumbnail,
166
+ title: row.original.product_title
167
+ }
168
+ }
169
+ )
170
+ }),
171
+ columnHelper.accessor("variant.sku", {
172
+ header: t("fields.sku"),
173
+ cell: ({ getValue }) => {
174
+ return getValue() || "-";
175
+ }
176
+ }),
177
+ columnHelper.accessor("variant.title", {
178
+ header: t("fields.variant")
179
+ }),
180
+ columnHelper.accessor("quantity", {
181
+ header: () => /* @__PURE__ */ jsx("div", { className: "flex size-full items-center overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t("fields.quantity") }) }),
182
+ cell: ({ row }) => {
183
+ return getReturnableQuantity(row.original);
184
+ }
185
+ }),
186
+ columnHelper.accessor("refundable_total", {
187
+ header: () => /* @__PURE__ */ jsx("div", { className: "flex size-full items-center justify-end overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t("fields.price") }) }),
188
+ cell: ({ getValue }) => {
189
+ const amount = getValue() || 0;
190
+ const stylized = getStylizedAmount(amount, currencyCode);
191
+ return /* @__PURE__ */ jsx("div", { className: "flex size-full items-center justify-end overflow-hidden text-right", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: stylized }) });
192
+ }
193
+ })
194
+ ],
195
+ [t, currencyCode]
196
+ );
197
+ };
198
+
199
+ // src/pages/orders/[id]/claims/create/_components/add-claim-items-table/use-claim-item-table-filters.tsx
200
+ import { useTranslation as useTranslation2 } from "react-i18next";
201
+ var useClaimItemTableFilters = () => {
202
+ const { t } = useTranslation2();
203
+ const filters = [
204
+ {
205
+ key: "returnable_quantity",
206
+ label: t("orders.returns.returnableQuantityLabel"),
207
+ type: "number"
208
+ },
209
+ {
210
+ key: "refundable_amount",
211
+ label: t("orders.returns.refundableAmountLabel"),
212
+ type: "number"
213
+ },
214
+ {
215
+ key: "created_at",
216
+ label: t("fields.createdAt"),
217
+ type: "date"
218
+ },
219
+ {
220
+ key: "updated_at",
221
+ label: t("fields.updatedAt"),
222
+ type: "date"
223
+ }
224
+ ];
225
+ return filters;
226
+ };
227
+
228
+ // src/pages/orders/[id]/claims/create/_components/add-claim-items-table/use-claim-item-table-query.tsx
229
+ var useClaimItemTableQuery = ({
230
+ pageSize = 50,
231
+ prefix
232
+ }) => {
233
+ const raw = useQueryParams(
234
+ [
235
+ "q",
236
+ "offset",
237
+ "order",
238
+ "created_at",
239
+ "updated_at",
240
+ "returnable_quantity",
241
+ "refundable_amount"
242
+ ],
243
+ prefix
244
+ );
245
+ const {
246
+ offset,
247
+ created_at,
248
+ updated_at,
249
+ refundable_amount,
250
+ returnable_quantity,
251
+ ...rest
252
+ } = raw;
253
+ const searchParams = {
254
+ ...rest,
255
+ limit: pageSize,
256
+ offset: offset ? Number(offset) : 0,
257
+ created_at: created_at ? JSON.parse(created_at) : void 0,
258
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0,
259
+ refundable_amount: refundable_amount ? JSON.parse(refundable_amount) : void 0,
260
+ returnable_quantity: returnable_quantity ? JSON.parse(returnable_quantity) : void 0
261
+ };
262
+ return { searchParams, raw };
263
+ };
264
+
265
+ // src/pages/orders/[id]/claims/create/_components/add-claim-items-table/add-claim-items-table.tsx
266
+ import { jsx as jsx2 } from "react/jsx-runtime";
267
+ var PAGE_SIZE = 50;
268
+ var PREFIX = "rit";
269
+ var AddClaimItemsTable = ({
270
+ onSelectionChange,
271
+ selectedItems,
272
+ items,
273
+ currencyCode
274
+ }) => {
275
+ const { t } = useTranslation3();
276
+ const [rowSelection, setRowSelection] = useState(
277
+ selectedItems.reduce((acc, id) => {
278
+ acc[id] = true;
279
+ return acc;
280
+ }, {})
281
+ );
282
+ const updater = (fn) => {
283
+ const newState = typeof fn === "function" ? fn(rowSelection) : fn;
284
+ setRowSelection(newState);
285
+ onSelectionChange(Object.keys(newState));
286
+ };
287
+ const { searchParams, raw } = useClaimItemTableQuery({
288
+ pageSize: PAGE_SIZE,
289
+ prefix: PREFIX
290
+ });
291
+ const queriedItems = useMemo2(() => {
292
+ const {
293
+ order,
294
+ offset,
295
+ limit,
296
+ q,
297
+ created_at,
298
+ updated_at,
299
+ refundable_amount,
300
+ returnable_quantity
301
+ } = searchParams;
302
+ let results = items;
303
+ if (q) {
304
+ const needle = q.toLowerCase();
305
+ results = results.filter((i) => {
306
+ return i.product_title?.toLowerCase().includes(needle) || i.variant_title?.toLowerCase().includes(needle) || i.variant_sku?.toLowerCase().includes(needle);
307
+ });
308
+ }
309
+ if (order) {
310
+ const direction = order[0] === "-" ? "desc" : "asc";
311
+ const field = order.replace("-", "");
312
+ results = sortItems(results, field, direction);
313
+ }
314
+ if (created_at) {
315
+ results = filterByDate(results, created_at, "created_at");
316
+ }
317
+ if (updated_at) {
318
+ results = filterByDate(results, updated_at, "updated_at");
319
+ }
320
+ if (returnable_quantity) {
321
+ results = filterByNumber(
322
+ results,
323
+ returnable_quantity,
324
+ "returnable_quantity",
325
+ currencyCode
326
+ );
327
+ }
328
+ if (refundable_amount) {
329
+ results = filterByNumber(
330
+ results,
331
+ refundable_amount,
332
+ "refundable_amount",
333
+ currencyCode
334
+ );
335
+ }
336
+ return results.slice(offset, offset + limit);
337
+ }, [items, currencyCode, searchParams]);
338
+ const columns = useClaimItemTableColumns(currencyCode);
339
+ const filters = useClaimItemTableFilters();
340
+ const { table } = useDataTable({
341
+ data: queriedItems,
342
+ columns,
343
+ count: queriedItems.length,
344
+ enablePagination: true,
345
+ getRowId: (row) => row.id,
346
+ pageSize: PAGE_SIZE,
347
+ enableRowSelection: (row) => {
348
+ return getReturnableQuantity(row.original) > 0;
349
+ },
350
+ rowSelection: {
351
+ state: rowSelection,
352
+ updater
353
+ }
354
+ });
355
+ return /* @__PURE__ */ jsx2(
356
+ "div",
357
+ {
358
+ className: "flex size-full flex-col overflow-hidden",
359
+ "data-testid": "add-claim-items-picker",
360
+ children: /* @__PURE__ */ jsx2(
361
+ _DataTable,
362
+ {
363
+ table,
364
+ columns,
365
+ pageSize: PAGE_SIZE,
366
+ count: queriedItems.length,
367
+ filters,
368
+ pagination: true,
369
+ layout: "fill",
370
+ search: true,
371
+ orderBy: [
372
+ { key: "product_title", label: t("fields.product") },
373
+ { key: "variant_title", label: t("fields.variant") },
374
+ { key: "sku", label: t("fields.sku") },
375
+ {
376
+ key: "returnable_quantity",
377
+ label: t("orders.fields.returnableQuantity")
378
+ },
379
+ {
380
+ key: "refundable_amount",
381
+ label: t("orders.fields.refundableAmount")
382
+ }
383
+ ],
384
+ prefix: PREFIX,
385
+ queryObject: raw
386
+ }
387
+ )
388
+ }
389
+ );
390
+ };
391
+ var sortItems = (items, field, direction) => {
392
+ return [...items].sort((a, b) => {
393
+ let aValue;
394
+ let bValue;
395
+ if (field === "product_title") {
396
+ aValue = a.product_title;
397
+ bValue = b.product_title;
398
+ } else if (field === "variant_title") {
399
+ aValue = a.variant_title;
400
+ bValue = b.variant_title;
401
+ } else if (field === "sku") {
402
+ aValue = a.variant_sku;
403
+ bValue = b.variant_sku;
404
+ } else if (field === "returnable_quantity") {
405
+ aValue = getReturnableQuantity(a);
406
+ bValue = getReturnableQuantity(b);
407
+ } else if (field === "refundable_amount") {
408
+ aValue = a.refundable_total ?? 0;
409
+ bValue = b.refundable_total ?? 0;
410
+ }
411
+ if (aValue === void 0 || aValue === null) return 1;
412
+ if (bValue === void 0 || bValue === null) return -1;
413
+ if (aValue < bValue) {
414
+ return direction === "asc" ? -1 : 1;
415
+ }
416
+ if (aValue > bValue) {
417
+ return direction === "asc" ? 1 : -1;
418
+ }
419
+ return 0;
420
+ });
421
+ };
422
+ var filterByDate = (items, date, field) => {
423
+ const { gt, gte, lt, lte } = date;
424
+ return items.filter((i) => {
425
+ const itemDate = new Date(i[field]);
426
+ let isValid = true;
427
+ if (gt) {
428
+ isValid = isValid && itemDate > new Date(gt);
429
+ }
430
+ if (gte) {
431
+ isValid = isValid && itemDate >= new Date(gte);
432
+ }
433
+ if (lt) {
434
+ isValid = isValid && itemDate < new Date(lt);
435
+ }
436
+ if (lte) {
437
+ isValid = isValid && itemDate <= new Date(lte);
438
+ }
439
+ return isValid;
440
+ });
441
+ };
442
+ var defaultOperators = {
443
+ eq: void 0,
444
+ gt: void 0,
445
+ gte: void 0,
446
+ lt: void 0,
447
+ lte: void 0
448
+ };
449
+ var filterByNumber = (items, value, field, currency_code) => {
450
+ const { eq, gt, lt, gte, lte } = typeof value === "object" ? { ...defaultOperators, ...value } : { ...defaultOperators, eq: value };
451
+ return items.filter((i) => {
452
+ const returnableQuantity = getReturnableQuantity(i);
453
+ const refundableAmount = getStylizedAmount(
454
+ i.refundable_total ?? 0,
455
+ currency_code
456
+ );
457
+ const itemValue = field === "returnable_quantity" ? returnableQuantity : refundableAmount;
458
+ if (eq !== void 0) {
459
+ return itemValue === eq;
460
+ }
461
+ let isValid = true;
462
+ if (gt !== void 0) {
463
+ isValid = isValid && Number(itemValue) > gt;
464
+ }
465
+ if (gte !== void 0) {
466
+ isValid = isValid && Number(itemValue) >= gte;
467
+ }
468
+ if (lt !== void 0) {
469
+ isValid = isValid && Number(itemValue) < lt;
470
+ }
471
+ if (lte !== void 0) {
472
+ isValid = isValid && Number(itemValue) <= lte;
473
+ }
474
+ return isValid;
475
+ });
476
+ };
477
+
478
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/claim-inbound-item.tsx
479
+ import { ChatBubble, DocumentText, XCircle, XMark } from "@medusajs/icons";
480
+ import { IconButton, Input, Text } from "@medusajs/ui";
481
+ import { useTranslation as useTranslation4 } from "react-i18next";
482
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
483
+ function ClaimInboundItem({
484
+ item,
485
+ previewItem,
486
+ currencyCode,
487
+ form,
488
+ onRemove,
489
+ onUpdate,
490
+ index
491
+ }) {
492
+ const { t } = useTranslation4();
493
+ const { return_reasons = [] } = useReturnReasons({ fields: "+label" });
494
+ const formItem = form.watch(`inbound_items.${index}`);
495
+ const showReturnReason = typeof formItem.reason_id === "string";
496
+ const showNote = typeof formItem.note === "string";
497
+ return /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl ", children: [
498
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-x-2 gap-y-2 border-b p-3 text-sm md:flex-row", children: [
499
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center gap-x-3", children: [
500
+ /* @__PURE__ */ jsx3(Thumbnail, { src: item.thumbnail }),
501
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
502
+ /* @__PURE__ */ jsxs("div", { children: [
503
+ /* @__PURE__ */ jsxs(Text, { className: "txt-small", as: "span", weight: "plus", children: [
504
+ item.title,
505
+ " "
506
+ ] }),
507
+ item.variant_sku && /* @__PURE__ */ jsxs("span", { children: [
508
+ "(",
509
+ item.variant_sku,
510
+ ")"
511
+ ] })
512
+ ] }),
513
+ /* @__PURE__ */ jsx3(Text, { as: "div", className: "text-ui-fg-subtle txt-small", children: item.product_title })
514
+ ] })
515
+ ] }),
516
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 justify-between", children: [
517
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-grow items-center gap-2", children: [
518
+ /* @__PURE__ */ jsx3(
519
+ Form.Field,
520
+ {
521
+ control: form.control,
522
+ name: `inbound_items.${index}.quantity`,
523
+ render: ({ field }) => {
524
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
525
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
526
+ Input,
527
+ {
528
+ ...field,
529
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
530
+ min: 1,
531
+ max: item.quantity,
532
+ type: "number",
533
+ onBlur: (e) => {
534
+ const val = e.target.value;
535
+ const payload = val === "" ? null : Number(val);
536
+ field.onChange(payload);
537
+ if (payload) {
538
+ onUpdate({ quantity: payload });
539
+ }
540
+ }
541
+ }
542
+ ) }),
543
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
544
+ ] });
545
+ }
546
+ }
547
+ ),
548
+ /* @__PURE__ */ jsx3(Text, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
549
+ ] }),
550
+ /* @__PURE__ */ jsx3("div", { className: "text-ui-fg-subtle txt-small mr-2 flex flex-shrink-0", children: /* @__PURE__ */ jsx3(
551
+ MoneyAmountCell,
552
+ {
553
+ currencyCode,
554
+ amount: previewItem.return_requested_total
555
+ }
556
+ ) }),
557
+ /* @__PURE__ */ jsx3(
558
+ ActionMenu,
559
+ {
560
+ groups: [
561
+ {
562
+ actions: [
563
+ !showReturnReason && {
564
+ label: t("actions.addReason"),
565
+ onClick: () => form.setValue(`inbound_items.${index}.reason_id`, ""),
566
+ icon: /* @__PURE__ */ jsx3(ChatBubble, {})
567
+ },
568
+ !showNote && {
569
+ label: t("actions.addNote"),
570
+ onClick: () => form.setValue(`inbound_items.${index}.note`, ""),
571
+ icon: /* @__PURE__ */ jsx3(DocumentText, {})
572
+ },
573
+ {
574
+ label: t("actions.remove"),
575
+ onClick: onRemove,
576
+ icon: /* @__PURE__ */ jsx3(XCircle, {})
577
+ }
578
+ ].filter(Boolean)
579
+ }
580
+ ]
581
+ }
582
+ )
583
+ ] })
584
+ ] }),
585
+ /* @__PURE__ */ jsxs(Fragment, { children: [
586
+ showReturnReason && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
587
+ /* @__PURE__ */ jsxs("div", { children: [
588
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.reason") }),
589
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.reasonHint") })
590
+ ] }),
591
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
592
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
593
+ Form.Field,
594
+ {
595
+ control: form.control,
596
+ name: `inbound_items.${index}.reason_id`,
597
+ render: ({ field: { ref: _ref, value, onChange, ...field } }) => {
598
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
599
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
600
+ Combobox,
601
+ {
602
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
603
+ value,
604
+ onChange: (v) => {
605
+ onUpdate({ reason_id: v });
606
+ onChange(v);
607
+ },
608
+ ...field,
609
+ options: return_reasons.map((reason) => ({
610
+ label: reason.label ?? "",
611
+ value: reason.id
612
+ }))
613
+ }
614
+ ) }),
615
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
616
+ ] });
617
+ }
618
+ }
619
+ ) }),
620
+ /* @__PURE__ */ jsx3(
621
+ IconButton,
622
+ {
623
+ type: "button",
624
+ className: "flex-shrink",
625
+ variant: "transparent",
626
+ onClick: () => {
627
+ form.setValue(`inbound_items.${index}.reason_id`, null);
628
+ onUpdate({ reason_id: null });
629
+ },
630
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
631
+ }
632
+ )
633
+ ] })
634
+ ] }),
635
+ showNote && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2 p-3 md:grid-cols-2", children: [
636
+ /* @__PURE__ */ jsxs("div", { children: [
637
+ /* @__PURE__ */ jsx3(Form.Label, { children: t("orders.returns.note") }),
638
+ /* @__PURE__ */ jsx3(Form.Hint, { className: "!mt-1", children: t("orders.returns.noteHint") })
639
+ ] }),
640
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
641
+ /* @__PURE__ */ jsx3("div", { className: "flex-grow", children: /* @__PURE__ */ jsx3(
642
+ Form.Field,
643
+ {
644
+ control: form.control,
645
+ name: `inbound_items.${index}.note`,
646
+ render: ({ field: { ref: _ref, ...field } }) => {
647
+ return /* @__PURE__ */ jsxs(Form.Item, { children: [
648
+ /* @__PURE__ */ jsx3(Form.Control, { children: /* @__PURE__ */ jsx3(
649
+ Input,
650
+ {
651
+ ...field,
652
+ value: field.value ?? "",
653
+ onBlur: () => {
654
+ field.onChange(field.value);
655
+ onUpdate({ internal_note: field.value });
656
+ },
657
+ className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover"
658
+ }
659
+ ) }),
660
+ /* @__PURE__ */ jsx3(Form.ErrorMessage, {})
661
+ ] });
662
+ }
663
+ }
664
+ ) }),
665
+ /* @__PURE__ */ jsx3(
666
+ IconButton,
667
+ {
668
+ type: "button",
669
+ className: "flex-shrink",
670
+ variant: "transparent",
671
+ onClick: () => {
672
+ form.setValue(`inbound_items.${index}.note`, null);
673
+ onUpdate({ internal_note: null });
674
+ },
675
+ children: /* @__PURE__ */ jsx3(XMark, { className: "text-ui-fg-muted" })
676
+ }
677
+ )
678
+ ] })
679
+ ] })
680
+ ] })
681
+ ] });
682
+ }
683
+
684
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/claim-outbound-section.tsx
685
+ import { Button, Heading } from "@medusajs/ui";
686
+ import { useFieldArray } from "react-hook-form";
687
+ import { useTranslation as useTranslation9 } from "react-i18next";
688
+
689
+ // src/pages/orders/[id]/claims/create/_components/add-claim-outbound-items-table/add-claim-outbound-items-table.tsx
690
+ import { useMemo as useMemo4, useState as useState2 } from "react";
691
+ import { useTranslation as useTranslation7 } from "react-i18next";
692
+
693
+ // src/pages/orders/[id]/claims/create/_components/add-claim-outbound-items-table/use-claim-outbound-item-table-columns.tsx
694
+ import { Checkbox as Checkbox2, Text as Text2 } from "@medusajs/ui";
695
+ import { createColumnHelper as createColumnHelper2 } from "@tanstack/react-table";
696
+ import { useMemo as useMemo3 } from "react";
697
+ import { useTranslation as useTranslation5 } from "react-i18next";
698
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
699
+ var columnHelper2 = createColumnHelper2();
700
+ var useClaimOutboundItemTableColumns = () => {
701
+ const { t } = useTranslation5();
702
+ return useMemo3(
703
+ () => [
704
+ columnHelper2.display({
705
+ id: "select",
706
+ header: ({ table }) => /* @__PURE__ */ jsx4(
707
+ Checkbox2,
708
+ {
709
+ checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
710
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
711
+ }
712
+ ),
713
+ cell: ({ row }) => {
714
+ const isSelectable = row.getCanSelect();
715
+ return /* @__PURE__ */ jsx4(
716
+ Checkbox2,
717
+ {
718
+ disabled: !isSelectable,
719
+ checked: row.getIsSelected(),
720
+ onCheckedChange: (value) => row.toggleSelected(!!value),
721
+ onClick: (e) => {
722
+ e.stopPropagation();
723
+ }
724
+ }
725
+ );
726
+ }
727
+ }),
728
+ columnHelper2.display({
729
+ id: "product",
730
+ header: t("fields.product"),
731
+ cell: ({ row }) => {
732
+ const variant = row.original.product_variant;
733
+ const productTitle = variant?.product?.title;
734
+ if (!productTitle) {
735
+ return /* @__PURE__ */ jsx4(PlaceholderCell, {});
736
+ }
737
+ return /* @__PURE__ */ jsxs2("div", { className: "flex h-full w-full max-w-[300px] items-center gap-x-3 overflow-hidden", children: [
738
+ /* @__PURE__ */ jsx4(Thumbnail, { src: variant?.product?.thumbnail }),
739
+ /* @__PURE__ */ jsx4(
740
+ Text2,
741
+ {
742
+ size: "small",
743
+ leading: "compact",
744
+ className: "truncate",
745
+ title: productTitle,
746
+ children: productTitle
747
+ }
748
+ )
749
+ ] });
750
+ }
751
+ }),
752
+ columnHelper2.accessor("sku", {
753
+ header: t("fields.sku"),
754
+ cell: ({ getValue }) => {
755
+ const sku = getValue();
756
+ if (!sku) return /* @__PURE__ */ jsx4(PlaceholderCell, {});
757
+ return /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", className: "truncate", children: sku });
758
+ }
759
+ }),
760
+ columnHelper2.display({
761
+ id: "variant_title",
762
+ header: t("fields.title"),
763
+ cell: ({ row }) => {
764
+ const title = row.original.product_variant?.title;
765
+ if (!title) return /* @__PURE__ */ jsx4(PlaceholderCell, {});
766
+ return /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", className: "truncate", children: title });
767
+ }
768
+ })
769
+ ],
770
+ [t]
771
+ );
772
+ };
773
+
774
+ // src/pages/orders/[id]/claims/create/_components/add-claim-outbound-items-table/use-claim-outbound-item-table-filters.tsx
775
+ import { useTranslation as useTranslation6 } from "react-i18next";
776
+ var useClaimOutboundItemTableFilters = () => {
777
+ const { t } = useTranslation6();
778
+ const filters = [
779
+ {
780
+ key: "created_at",
781
+ label: t("fields.createdAt"),
782
+ type: "date"
783
+ },
784
+ {
785
+ key: "updated_at",
786
+ label: t("fields.updatedAt"),
787
+ type: "date"
788
+ }
789
+ ];
790
+ return filters;
791
+ };
792
+
793
+ // src/pages/orders/[id]/claims/create/_components/add-claim-outbound-items-table/use-claim-outbound-item-table-query.tsx
794
+ var useClaimOutboundItemTableQuery = ({
795
+ pageSize = 50,
796
+ prefix
797
+ }) => {
798
+ const raw = useQueryParams(
799
+ ["q", "offset", "order", "created_at", "updated_at"],
800
+ prefix
801
+ );
802
+ const { offset, created_at, updated_at, ...rest } = raw;
803
+ const searchParams = {
804
+ ...rest,
805
+ limit: pageSize,
806
+ offset: offset ? Number(offset) : 0,
807
+ created_at: created_at ? JSON.parse(created_at) : void 0,
808
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0
809
+ };
810
+ return { searchParams, raw };
811
+ };
812
+
813
+ // src/pages/orders/[id]/claims/create/_components/add-claim-outbound-items-table/add-claim-outbound-items-table.tsx
814
+ import { jsx as jsx5 } from "react/jsx-runtime";
815
+ var PAGE_SIZE2 = 50;
816
+ var PREFIX2 = "rit";
817
+ var OFFER_PICKER_FIELDS = [
818
+ "id",
819
+ "sku",
820
+ "variant_id",
821
+ "seller_id",
822
+ "prices.amount",
823
+ "prices.currency_code",
824
+ "product_variant.id",
825
+ "product_variant.title",
826
+ "product_variant.product.id",
827
+ "product_variant.product.title",
828
+ "product_variant.product.thumbnail",
829
+ "product_variant.manage_inventory",
830
+ "product_variant.inventory_quantity",
831
+ "product_variant.inventory_items.required_quantity",
832
+ "product_variant.inventory_items.inventory.location_levels.available_quantity"
833
+ ].join(",");
834
+ var offerHasInventory = (offer) => {
835
+ const variant = offer.product_variant;
836
+ if (!variant) return false;
837
+ if (variant.manage_inventory === false) return true;
838
+ const links = variant.inventory_items ?? [];
839
+ if (!links.length) {
840
+ return (variant.inventory_quantity ?? 0) > 0;
841
+ }
842
+ return links.every((link) => {
843
+ const available = (link.inventory?.location_levels ?? []).reduce(
844
+ (acc, lvl) => acc + (lvl.available_quantity ?? 0),
845
+ 0
846
+ );
847
+ const required = link.required_quantity ?? 1;
848
+ return required > 0 && available >= required;
849
+ });
850
+ };
851
+ var AddClaimOutboundItemsTable = ({
852
+ currencyCode,
853
+ onSelectionChange
854
+ }) => {
855
+ const { t } = useTranslation7();
856
+ const [rowSelection, setRowSelection] = useState2({});
857
+ const [offerLookup, setOfferLookup] = useState2({});
858
+ const updater = (fn) => {
859
+ const newState = typeof fn === "function" ? fn(rowSelection) : fn;
860
+ setRowSelection(newState);
861
+ onSelectionChange(Object.keys(newState), offerLookup);
862
+ };
863
+ const { searchParams, raw } = useClaimOutboundItemTableQuery({
864
+ pageSize: PAGE_SIZE2,
865
+ prefix: PREFIX2
866
+ });
867
+ const offersResponse = useOffers({
868
+ ...searchParams,
869
+ fields: OFFER_PICKER_FIELDS
870
+ });
871
+ const rawOffersSource = offersResponse.offers;
872
+ const rawOffers = useMemo4(
873
+ () => rawOffersSource ?? [],
874
+ [rawOffersSource]
875
+ );
876
+ const offers = useMemo4(() => {
877
+ return rawOffers.filter((offer) => {
878
+ if (currencyCode) {
879
+ const hasPrice = (offer.prices ?? []).some(
880
+ (p) => p.currency_code === currencyCode
881
+ );
882
+ if (!hasPrice) return false;
883
+ }
884
+ return offerHasInventory(offer);
885
+ });
886
+ }, [rawOffers, currencyCode]);
887
+ useMemo4(() => {
888
+ if (!offers.length) return;
889
+ setOfferLookup((prev) => {
890
+ let changed = false;
891
+ const next = { ...prev };
892
+ for (const offer of offers) {
893
+ if (!next[offer.id]) {
894
+ next[offer.id] = offer;
895
+ changed = true;
896
+ }
897
+ }
898
+ return changed ? next : prev;
899
+ });
900
+ }, [offers]);
901
+ const count = offers.length;
902
+ const columns = useClaimOutboundItemTableColumns();
903
+ const filters = useClaimOutboundItemTableFilters();
904
+ const { table } = useDataTable({
905
+ data: offers,
906
+ columns,
907
+ count,
908
+ enablePagination: true,
909
+ // Row id = offer id so onSelectionChange yields offer_ids that the form
910
+ // layer sends to `useAddClaimOutboundItems` (which accepts `offer_id` and
911
+ // resolves to variant_id + unit_price server-side).
912
+ getRowId: (row) => row.id,
913
+ pageSize: PAGE_SIZE2,
914
+ enableRowSelection: () => true,
915
+ rowSelection: {
916
+ state: rowSelection,
917
+ updater
918
+ }
919
+ });
920
+ return /* @__PURE__ */ jsx5(
921
+ "div",
922
+ {
923
+ className: "flex size-full flex-col overflow-hidden",
924
+ "data-testid": "add-claim-outbound-picker",
925
+ children: /* @__PURE__ */ jsx5(
926
+ _DataTable,
927
+ {
928
+ table,
929
+ columns,
930
+ pageSize: PAGE_SIZE2,
931
+ count,
932
+ filters,
933
+ pagination: true,
934
+ layout: "fill",
935
+ search: true,
936
+ orderBy: [
937
+ { key: "sku", label: t("fields.sku") },
938
+ { key: "created_at", label: t("fields.createdAt") },
939
+ { key: "updated_at", label: t("fields.updatedAt") }
940
+ ],
941
+ prefix: PREFIX2,
942
+ queryObject: raw
943
+ }
944
+ )
945
+ }
946
+ );
947
+ };
948
+
949
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/claim-outbound-item.tsx
950
+ import { XCircle as XCircle2 } from "@medusajs/icons";
951
+ import { Input as Input2, Text as Text3 } from "@medusajs/ui";
952
+ import { useTranslation as useTranslation8 } from "react-i18next";
953
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
954
+ function ClaimOutboundItem({
955
+ form,
956
+ onRemove,
957
+ index
958
+ }) {
959
+ const { t } = useTranslation8();
960
+ const row = form.watch(`outbound_items.${index}`);
961
+ const productTitle = row?.product_title ?? row?.variant_title ?? row?.offer_id;
962
+ return /* @__PURE__ */ jsx6(
963
+ "div",
964
+ {
965
+ className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl",
966
+ "data-testid": `claim-outbound-item-${row?.offer_id ?? index}`,
967
+ children: /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-center gap-x-2 gap-y-2 border-b p-3 text-sm md:flex-row", children: [
968
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 items-center gap-x-3", children: [
969
+ /* @__PURE__ */ jsx6(Thumbnail, { src: row?.thumbnail ?? void 0 }),
970
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col", children: [
971
+ /* @__PURE__ */ jsxs3("div", { children: [
972
+ /* @__PURE__ */ jsxs3(Text3, { className: "txt-small", as: "span", weight: "plus", children: [
973
+ productTitle,
974
+ " "
975
+ ] }),
976
+ row?.sku && /* @__PURE__ */ jsxs3("span", { children: [
977
+ "(",
978
+ row.sku,
979
+ ")"
980
+ ] })
981
+ ] }),
982
+ row?.variant_title && /* @__PURE__ */ jsx6(Text3, { as: "div", className: "text-ui-fg-subtle txt-small", children: row.variant_title })
983
+ ] })
984
+ ] }),
985
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 justify-between", children: [
986
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-grow items-center gap-2", children: [
987
+ /* @__PURE__ */ jsx6(
988
+ Form.Field,
989
+ {
990
+ control: form.control,
991
+ name: `outbound_items.${index}.quantity`,
992
+ render: ({ field }) => {
993
+ return /* @__PURE__ */ jsxs3(Form.Item, { children: [
994
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(
995
+ Input2,
996
+ {
997
+ ...field,
998
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
999
+ min: 1,
1000
+ type: "number",
1001
+ onBlur: (e) => {
1002
+ const val = e.target.value;
1003
+ const payload = val === "" ? null : Number(val);
1004
+ field.onChange(payload);
1005
+ }
1006
+ }
1007
+ ) }),
1008
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
1009
+ ] });
1010
+ }
1011
+ }
1012
+ ),
1013
+ /* @__PURE__ */ jsx6(Text3, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
1014
+ ] }),
1015
+ /* @__PURE__ */ jsx6(
1016
+ ActionMenu,
1017
+ {
1018
+ groups: [
1019
+ {
1020
+ actions: [
1021
+ {
1022
+ label: t("actions.remove"),
1023
+ onClick: onRemove,
1024
+ icon: /* @__PURE__ */ jsx6(XCircle2, {})
1025
+ }
1026
+ ]
1027
+ }
1028
+ ]
1029
+ }
1030
+ )
1031
+ ] })
1032
+ ] })
1033
+ }
1034
+ );
1035
+ }
1036
+
1037
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/claim-outbound-section.tsx
1038
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1039
+ var STACKED_MODAL_ID = "claim-add-outbound-items";
1040
+ var ClaimOutboundSection = ({
1041
+ form,
1042
+ currencyCode,
1043
+ disabled
1044
+ }) => {
1045
+ const { t } = useTranslation9();
1046
+ const { setIsOpen } = useStackedModal();
1047
+ const {
1048
+ fields: outboundItems,
1049
+ append,
1050
+ remove
1051
+ } = useFieldArray({
1052
+ name: "outbound_items",
1053
+ control: form.control
1054
+ });
1055
+ const showOutboundItemsPlaceholder = !outboundItems.length;
1056
+ const onItemsSelected = (selectedOfferIds, offerLookup) => {
1057
+ const existing = new Set(outboundItems.map((row) => row.offer_id));
1058
+ selectedOfferIds.filter((id) => !existing.has(id)).forEach((id) => {
1059
+ const offer = offerLookup[id];
1060
+ const variant = offer?.product_variant;
1061
+ append(
1062
+ {
1063
+ offer_id: id,
1064
+ variant_id: offer?.variant_id ?? variant?.id ?? null,
1065
+ product_title: variant?.product?.title ?? null,
1066
+ variant_title: variant?.title ?? null,
1067
+ thumbnail: variant?.product?.thumbnail ?? null,
1068
+ sku: offer?.sku ?? null,
1069
+ quantity: 1
1070
+ },
1071
+ { shouldFocus: false }
1072
+ );
1073
+ });
1074
+ setIsOpen(STACKED_MODAL_ID, false);
1075
+ };
1076
+ return /* @__PURE__ */ jsxs4("div", { children: [
1077
+ /* @__PURE__ */ jsxs4("div", { className: "mt-8 flex items-center justify-between", children: [
1078
+ /* @__PURE__ */ jsx7(Heading, { level: "h2", children: t("orders.claims.outboundItems") }),
1079
+ /* @__PURE__ */ jsxs4(StackedFocusModal, { id: STACKED_MODAL_ID, children: [
1080
+ /* @__PURE__ */ jsx7(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx7(
1081
+ "a",
1082
+ {
1083
+ href: "#",
1084
+ onClick: (e) => e.preventDefault(),
1085
+ className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400",
1086
+ "data-testid": "claim-add-outbound-trigger",
1087
+ children: t("orders.claims.addOutboundItems")
1088
+ }
1089
+ ) }),
1090
+ /* @__PURE__ */ jsxs4(StackedFocusModal.Content, { children: [
1091
+ /* @__PURE__ */ jsx7(StackedFocusModal.Header, {}),
1092
+ /* @__PURE__ */ jsx7(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx7("span", { className: "sr-only", children: t("orders.claims.addOutboundItems") }) }),
1093
+ /* @__PURE__ */ jsx7(StackedFocusModal.Description, { className: "sr-only", children: t("orders.claims.addOutboundItemsDescription") }),
1094
+ /* @__PURE__ */ jsx7(StackedFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsx7(
1095
+ PickerBody,
1096
+ {
1097
+ currencyCode,
1098
+ onSubmit: onItemsSelected
1099
+ }
1100
+ ) })
1101
+ ] })
1102
+ ] })
1103
+ ] }),
1104
+ showOutboundItemsPlaceholder && /* @__PURE__ */ jsx7(ItemPlaceholder, {}),
1105
+ outboundItems.map((item, index) => /* @__PURE__ */ jsx7(
1106
+ ClaimOutboundItem,
1107
+ {
1108
+ form,
1109
+ index,
1110
+ onRemove: () => remove(index)
1111
+ },
1112
+ item.id
1113
+ )),
1114
+ /* @__PURE__ */ jsx7("span", { className: "sr-only", children: disabled ? "" : "" })
1115
+ ] });
1116
+ };
1117
+ var PickerBody = ({
1118
+ currencyCode,
1119
+ onSubmit
1120
+ }) => {
1121
+ const { t } = useTranslation9();
1122
+ let selectedOfferIds = [];
1123
+ let selectedOfferLookup = {};
1124
+ return /* @__PURE__ */ jsxs4("div", { className: "flex h-full flex-col", children: [
1125
+ /* @__PURE__ */ jsx7("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx7(
1126
+ AddClaimOutboundItemsTable,
1127
+ {
1128
+ currencyCode,
1129
+ onSelectionChange: (ids, lookup) => {
1130
+ selectedOfferIds = ids;
1131
+ selectedOfferLookup = lookup;
1132
+ }
1133
+ }
1134
+ ) }),
1135
+ /* @__PURE__ */ jsx7(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs4("div", { className: "flex w-full items-center justify-end gap-x-2", children: [
1136
+ /* @__PURE__ */ jsx7(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx7(
1137
+ Button,
1138
+ {
1139
+ type: "button",
1140
+ variant: "secondary",
1141
+ size: "small",
1142
+ "data-testid": "claim-add-outbound-cancel",
1143
+ children: t("actions.cancel")
1144
+ }
1145
+ ) }),
1146
+ /* @__PURE__ */ jsx7(
1147
+ Button,
1148
+ {
1149
+ type: "button",
1150
+ variant: "primary",
1151
+ size: "small",
1152
+ "data-testid": "claim-add-outbound-save",
1153
+ onClick: () => onSubmit(selectedOfferIds, selectedOfferLookup),
1154
+ children: t("actions.save")
1155
+ },
1156
+ "submit-button"
1157
+ )
1158
+ ] }) })
1159
+ ] });
1160
+ };
1161
+
1162
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/schema.ts
1163
+ import { z } from "zod";
1164
+ var ClaimCreateSchema = z.object({
1165
+ inbound_items: z.array(
1166
+ z.object({
1167
+ item_id: z.string(),
1168
+ variant_id: z.string().nullish(),
1169
+ quantity: z.number(),
1170
+ reason_id: z.string().nullish(),
1171
+ note: z.string().nullish()
1172
+ })
1173
+ ),
1174
+ outbound_items: z.array(
1175
+ z.object({
1176
+ offer_id: z.string(),
1177
+ variant_id: z.string().nullish(),
1178
+ product_title: z.string().nullish(),
1179
+ variant_title: z.string().nullish(),
1180
+ thumbnail: z.string().nullish(),
1181
+ sku: z.string().nullish(),
1182
+ quantity: z.number()
1183
+ })
1184
+ ),
1185
+ location_id: z.string().nullish(),
1186
+ inbound_option_id: z.string().nullish(),
1187
+ outbound_option_id: z.string().nullish(),
1188
+ send_notification: z.boolean().optional()
1189
+ });
1190
+
1191
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/claim-create-form.tsx
1192
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1193
+ var itemsToAdd = [];
1194
+ var itemsToRemove = [];
1195
+ var IS_CANCELING = false;
1196
+ var ClaimCreateForm = ({
1197
+ order,
1198
+ preview,
1199
+ claim,
1200
+ orderReturn
1201
+ }) => {
1202
+ const { t } = useTranslation10();
1203
+ const { handleSuccess } = useRouteModal();
1204
+ const { setIsOpen } = useStackedModal();
1205
+ const [_inventoryMap, setInventoryMap] = useState3({});
1206
+ const { mutateAsync: confirmClaimRequest, isPending: isConfirming } = useClaimConfirmRequest(claim.id, order.id);
1207
+ const { mutateAsync: cancelClaimRequest, isPending: isCanceling } = useCancelClaimRequest(claim.id, order.id);
1208
+ const { mutateAsync: updateReturn, isPending: isUpdating } = useUpdateReturn(
1209
+ preview?.order_change?.return_id ?? "",
1210
+ order.id
1211
+ );
1212
+ const {
1213
+ mutateAsync: addInboundShipping,
1214
+ isPending: isAddingInboundShipping
1215
+ } = useAddClaimInboundShipping(claim.id, order.id);
1216
+ const {
1217
+ mutateAsync: _updateInboundShipping,
1218
+ isPending: isUpdatingInboundShipping
1219
+ } = useUpdateClaimInboundShipping(claim.id, order.id);
1220
+ const {
1221
+ mutateAsync: deleteInboundShipping,
1222
+ isPending: isDeletingInboundShipping
1223
+ } = useDeleteClaimInboundShipping(claim.id, order.id);
1224
+ const { mutateAsync: addInboundItem, isPending: isAddingInboundItem } = useAddClaimInboundItems(claim.id, order.id);
1225
+ const { mutateAsync: updateInboundItem, isPending: isUpdatingInboundItem } = useUpdateClaimInboundItem(claim.id, order.id);
1226
+ const { mutateAsync: removeInboundItem, isPending: isRemovingInboundItem } = useRemoveClaimInboundItem(claim.id, order.id);
1227
+ const isRequestLoading = isConfirming || isCanceling || isAddingInboundShipping || isUpdatingInboundShipping || isDeletingInboundShipping || isAddingInboundItem || isRemovingInboundItem || isUpdatingInboundItem || isUpdating;
1228
+ const previewItems = useMemo5(
1229
+ () => preview?.items?.filter(
1230
+ (i) => !!i.actions?.find((a) => a.claim_id === claim.id)
1231
+ ) ?? [],
1232
+ [preview.items, claim.id]
1233
+ );
1234
+ const inboundPreviewItems = useMemo5(
1235
+ () => previewItems.filter(
1236
+ (item) => !!item.actions?.find((a) => a.action === "RETURN_ITEM")
1237
+ ),
1238
+ [previewItems]
1239
+ );
1240
+ const itemsMap = useMemo5(
1241
+ () => new Map(order?.items?.map((i) => [i.id, i])),
1242
+ [order.items]
1243
+ );
1244
+ const form = useForm({
1245
+ defaultValues: () => {
1246
+ const inboundShippingMethod = preview.shipping_methods?.find((s) => {
1247
+ return !!s.actions?.find(
1248
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1249
+ );
1250
+ });
1251
+ return Promise.resolve({
1252
+ inbound_items: inboundPreviewItems.map((i) => {
1253
+ const inboundAction = i.actions?.find(
1254
+ (a) => a.action === "RETURN_ITEM"
1255
+ );
1256
+ return {
1257
+ item_id: i.id,
1258
+ variant_id: i.variant_id,
1259
+ quantity: i.detail?.return_requested_quantity ?? 1,
1260
+ note: inboundAction?.internal_note,
1261
+ reason_id: inboundAction?.details?.reason_id
1262
+ };
1263
+ }),
1264
+ outbound_items: [],
1265
+ inbound_option_id: inboundShippingMethod ? inboundShippingMethod.shipping_option_id : null,
1266
+ outbound_option_id: null,
1267
+ location_id: orderReturn?.location_id ?? null,
1268
+ send_notification: false
1269
+ });
1270
+ },
1271
+ resolver: zodResolver(ClaimCreateSchema)
1272
+ });
1273
+ const locationId = form.watch("location_id");
1274
+ const { stock_locations: stockLocations = [] } = useStockLocations({
1275
+ limit: 999
1276
+ });
1277
+ const { shipping_options: shippingOptions = [] } = useShippingOptions(
1278
+ locationId ? {
1279
+ limit: 999,
1280
+ fields: "*prices,+service_zone.fulfillment_set.location.id",
1281
+ stock_location_id: locationId
1282
+ } : void 0,
1283
+ { enabled: !!locationId }
1284
+ );
1285
+ const inboundShippingOptions = (shippingOptions ?? []).filter(
1286
+ (so) => !!so.rules?.find(
1287
+ (r) => r.attribute === "is_return" && r.value === "true"
1288
+ )
1289
+ );
1290
+ const {
1291
+ fields: inboundItems,
1292
+ append,
1293
+ remove,
1294
+ update
1295
+ } = useFieldArray2({
1296
+ name: "inbound_items",
1297
+ control: form.control
1298
+ });
1299
+ const previewItemsMap = useMemo5(
1300
+ () => new Map(previewItems.map((i) => [i.id, i])),
1301
+ [previewItems]
1302
+ );
1303
+ useEffect(() => {
1304
+ const existingItemsMap = {};
1305
+ inboundPreviewItems.forEach((i) => {
1306
+ const ind = inboundItems.findIndex((field) => field.item_id === i.id);
1307
+ const requested = i.detail?.return_requested_quantity ?? 0;
1308
+ existingItemsMap[i.id] = true;
1309
+ if (ind > -1) {
1310
+ if (inboundItems[ind].quantity !== requested) {
1311
+ const returnItemAction = i.actions?.find(
1312
+ (a) => a.action === "RETURN_ITEM"
1313
+ );
1314
+ update(ind, {
1315
+ ...inboundItems[ind],
1316
+ quantity: requested,
1317
+ note: returnItemAction?.internal_note,
1318
+ reason_id: returnItemAction?.details?.reason_id
1319
+ });
1320
+ }
1321
+ } else {
1322
+ append(
1323
+ { item_id: i.id, quantity: requested },
1324
+ { shouldFocus: false }
1325
+ );
1326
+ }
1327
+ });
1328
+ inboundItems.forEach((i, ind) => {
1329
+ if (!(i.item_id in existingItemsMap)) {
1330
+ remove(ind);
1331
+ }
1332
+ });
1333
+ }, [previewItems]);
1334
+ useEffect(() => {
1335
+ const inboundShipping = preview.shipping_methods?.find(
1336
+ (s) => !!s.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
1337
+ );
1338
+ if (inboundShipping) {
1339
+ form.setValue("inbound_option_id", inboundShipping.shipping_option_id);
1340
+ } else {
1341
+ form.setValue("inbound_option_id", null);
1342
+ }
1343
+ }, [preview.shipping_methods]);
1344
+ useEffect(() => {
1345
+ form.setValue("location_id", orderReturn?.location_id ?? null);
1346
+ }, [orderReturn]);
1347
+ const showInboundItemsPlaceholder = !inboundPreviewItems.length;
1348
+ const prompt = usePrompt();
1349
+ const handleSubmit = form.handleSubmit(async (data) => {
1350
+ const res = await prompt({
1351
+ title: t("general.areYouSure"),
1352
+ description: t("orders.claims.confirmText"),
1353
+ confirmText: t("actions.continue"),
1354
+ cancelText: t("actions.cancel"),
1355
+ variant: "confirmation"
1356
+ });
1357
+ if (!res) {
1358
+ return;
1359
+ }
1360
+ await confirmClaimRequest(
1361
+ { no_notification: !data.send_notification },
1362
+ {
1363
+ onSuccess: () => {
1364
+ toast.success(t("orders.claims.toast.confirmedSuccessfully"));
1365
+ handleSuccess();
1366
+ },
1367
+ onError: (error) => {
1368
+ toast.error(error.message);
1369
+ }
1370
+ }
1371
+ );
1372
+ });
1373
+ const onItemsSelected = async () => {
1374
+ if (itemsToAdd.length) {
1375
+ await addInboundItem(
1376
+ {
1377
+ items: itemsToAdd.map((id) => ({
1378
+ id,
1379
+ quantity: 1
1380
+ }))
1381
+ },
1382
+ {
1383
+ onError: (error) => {
1384
+ toast.error(error.message);
1385
+ }
1386
+ }
1387
+ );
1388
+ }
1389
+ for (const itemToRemove of itemsToRemove) {
1390
+ const actionId = previewItems.find((i) => i.id === itemToRemove)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
1391
+ if (actionId) {
1392
+ await removeInboundItem(actionId, {
1393
+ onError: (error) => {
1394
+ toast.error(error.message);
1395
+ }
1396
+ });
1397
+ }
1398
+ }
1399
+ setIsOpen("inbound-items", false);
1400
+ };
1401
+ const onLocationChange = async (selectedLocationId) => {
1402
+ if (!preview?.order_change?.return_id) return;
1403
+ await updateReturn({ location_id: selectedLocationId ?? null });
1404
+ };
1405
+ const onShippingOptionChange = async (selectedOptionId) => {
1406
+ const inboundShippingMethods = (preview.shipping_methods ?? []).filter(
1407
+ (s) => {
1408
+ const action = s.actions?.find(
1409
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1410
+ );
1411
+ return action && !!action?.return_id;
1412
+ }
1413
+ );
1414
+ const promises = inboundShippingMethods.filter(Boolean).map((inboundShippingMethod) => {
1415
+ const action = inboundShippingMethod.actions?.find(
1416
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1417
+ );
1418
+ if (action) {
1419
+ return deleteInboundShipping(action.id);
1420
+ }
1421
+ return Promise.resolve();
1422
+ });
1423
+ await Promise.all(promises);
1424
+ if (selectedOptionId) {
1425
+ await addInboundShipping(
1426
+ { shipping_option_id: selectedOptionId },
1427
+ {
1428
+ onError: (error) => {
1429
+ toast.error(error.message);
1430
+ }
1431
+ }
1432
+ );
1433
+ }
1434
+ };
1435
+ useEffect(() => {
1436
+ return () => {
1437
+ if (IS_CANCELING) {
1438
+ cancelClaimRequest(void 0, {
1439
+ onSuccess: () => {
1440
+ toast.success(t("orders.claims.toast.canceledSuccessfully"));
1441
+ },
1442
+ onError: (error) => {
1443
+ toast.error(error.message);
1444
+ }
1445
+ });
1446
+ IS_CANCELING = false;
1447
+ }
1448
+ };
1449
+ }, []);
1450
+ useEffect(() => {
1451
+ setInventoryMap({});
1452
+ }, [inboundItems.length]);
1453
+ const estimatedDifference = (preview.summary?.pending_difference ?? 0) - inboundPreviewItems.reduce(
1454
+ (acc, item) => acc + (item.total ?? 0),
1455
+ 0
1456
+ );
1457
+ const currencyCode = order.currency_code;
1458
+ return /* @__PURE__ */ jsx8(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs5(KeyboundForm, { onSubmit: handleSubmit, className: "flex h-full flex-col", children: [
1459
+ /* @__PURE__ */ jsx8(RouteFocusModal.Header, {}),
1460
+ /* @__PURE__ */ jsx8(RouteFocusModal.Body, { className: "flex size-full justify-center overflow-y-auto", children: /* @__PURE__ */ jsxs5("div", { className: "mt-16 w-[720px] max-w-[100%] px-4 md:p-0", children: [
1461
+ /* @__PURE__ */ jsx8(Heading2, { level: "h1", children: t("orders.claims.create") }),
1462
+ /* @__PURE__ */ jsxs5("div", { className: "mt-8 flex items-center justify-between", children: [
1463
+ /* @__PURE__ */ jsx8(Heading2, { level: "h2", children: t("orders.returns.inbound") }),
1464
+ /* @__PURE__ */ jsxs5(StackedFocusModal, { id: "inbound-items", children: [
1465
+ /* @__PURE__ */ jsx8(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx8(
1466
+ "a",
1467
+ {
1468
+ href: "#",
1469
+ onClick: (e) => e.preventDefault(),
1470
+ className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400",
1471
+ children: t("actions.addItems")
1472
+ }
1473
+ ) }),
1474
+ /* @__PURE__ */ jsxs5(StackedFocusModal.Content, { children: [
1475
+ /* @__PURE__ */ jsx8(StackedFocusModal.Header, {}),
1476
+ /* @__PURE__ */ jsx8(
1477
+ AddClaimItemsTable,
1478
+ {
1479
+ items: order.items,
1480
+ selectedItems: inboundItems.map((i) => i.item_id),
1481
+ currencyCode,
1482
+ onSelectionChange: (finalSelection) => {
1483
+ const alreadySelected = inboundItems.map(
1484
+ (i) => i.item_id
1485
+ );
1486
+ itemsToAdd = finalSelection.filter(
1487
+ (selection) => !alreadySelected.includes(selection)
1488
+ );
1489
+ itemsToRemove = alreadySelected.filter(
1490
+ (selection) => !finalSelection.includes(selection)
1491
+ );
1492
+ }
1493
+ }
1494
+ ),
1495
+ /* @__PURE__ */ jsx8(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsx8("div", { className: "flex w-full items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-end gap-x-2", children: [
1496
+ /* @__PURE__ */ jsx8(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx8(
1497
+ Button2,
1498
+ {
1499
+ type: "button",
1500
+ variant: "secondary",
1501
+ size: "small",
1502
+ children: t("actions.cancel")
1503
+ }
1504
+ ) }),
1505
+ /* @__PURE__ */ jsx8(
1506
+ Button2,
1507
+ {
1508
+ type: "submit",
1509
+ variant: "primary",
1510
+ size: "small",
1511
+ onClick: async () => await onItemsSelected(),
1512
+ children: t("actions.save")
1513
+ },
1514
+ "submit-button"
1515
+ )
1516
+ ] }) }) })
1517
+ ] })
1518
+ ] })
1519
+ ] }),
1520
+ showInboundItemsPlaceholder && /* @__PURE__ */ jsx8(ItemPlaceholder, {}),
1521
+ inboundItems.map(
1522
+ (item, index) => previewItemsMap.get(item.item_id) && itemsMap.get(item.item_id) && /* @__PURE__ */ jsx8(
1523
+ ClaimInboundItem,
1524
+ {
1525
+ item: itemsMap.get(item.item_id),
1526
+ previewItem: previewItemsMap.get(item.item_id),
1527
+ currencyCode,
1528
+ form,
1529
+ onRemove: () => {
1530
+ const actionId = previewItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
1531
+ if (actionId) {
1532
+ removeInboundItem(actionId, {
1533
+ onError: (error) => {
1534
+ toast.error(error.message);
1535
+ }
1536
+ });
1537
+ }
1538
+ },
1539
+ onUpdate: (payload) => {
1540
+ const action = previewItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM");
1541
+ if (action) {
1542
+ updateInboundItem(
1543
+ { ...payload, actionId: action.id },
1544
+ {
1545
+ onError: (error) => {
1546
+ if (action.details?.quantity && payload.quantity) {
1547
+ form.setValue(
1548
+ `inbound_items.${index}.quantity`,
1549
+ action.details?.quantity
1550
+ );
1551
+ }
1552
+ toast.error(error.message);
1553
+ }
1554
+ }
1555
+ );
1556
+ }
1557
+ },
1558
+ index
1559
+ },
1560
+ item.id
1561
+ )
1562
+ ),
1563
+ !showInboundItemsPlaceholder && /* @__PURE__ */ jsxs5("div", { className: "mt-8 flex flex-col gap-y-4", children: [
1564
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
1565
+ /* @__PURE__ */ jsxs5("div", { children: [
1566
+ /* @__PURE__ */ jsx8(Form.Label, { children: t("orders.returns.location") }),
1567
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.returns.locationHint") })
1568
+ ] }),
1569
+ /* @__PURE__ */ jsx8(
1570
+ Form.Field,
1571
+ {
1572
+ control: form.control,
1573
+ name: "location_id",
1574
+ render: ({ field: { value, onChange, ...field } }) => {
1575
+ return /* @__PURE__ */ jsx8(Form.Item, { children: /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(
1576
+ Combobox,
1577
+ {
1578
+ ...field,
1579
+ value: value ?? void 0,
1580
+ onChange: (v) => {
1581
+ onChange(v);
1582
+ onLocationChange(v);
1583
+ },
1584
+ options: (stockLocations ?? []).map(
1585
+ (stockLocation) => ({
1586
+ label: stockLocation.name,
1587
+ value: stockLocation.id
1588
+ })
1589
+ )
1590
+ }
1591
+ ) }) });
1592
+ }
1593
+ }
1594
+ )
1595
+ ] }),
1596
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
1597
+ /* @__PURE__ */ jsxs5("div", { children: [
1598
+ /* @__PURE__ */ jsxs5(Form.Label, { children: [
1599
+ t("orders.returns.inboundShipping"),
1600
+ /* @__PURE__ */ jsxs5(
1601
+ Text4,
1602
+ {
1603
+ size: "small",
1604
+ leading: "compact",
1605
+ className: "text-ui-fg-muted ml-1 inline",
1606
+ children: [
1607
+ "(",
1608
+ t("fields.optional"),
1609
+ ")"
1610
+ ]
1611
+ }
1612
+ )
1613
+ ] }),
1614
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.returns.inboundShippingHint") })
1615
+ ] }),
1616
+ /* @__PURE__ */ jsx8(
1617
+ Form.Field,
1618
+ {
1619
+ control: form.control,
1620
+ name: "inbound_option_id",
1621
+ render: ({ field: { value, onChange, ...field } }) => {
1622
+ return /* @__PURE__ */ jsx8(Form.Item, { children: /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(
1623
+ Combobox,
1624
+ {
1625
+ allowClear: true,
1626
+ value: value ?? void 0,
1627
+ onChange: (val) => {
1628
+ onChange(val);
1629
+ onShippingOptionChange(val);
1630
+ },
1631
+ ...field,
1632
+ options: inboundShippingOptions.map(
1633
+ (so) => ({
1634
+ label: so.name,
1635
+ value: so.id
1636
+ })
1637
+ ),
1638
+ disabled: !locationId,
1639
+ noResultsPlaceholder: /* @__PURE__ */ jsx8(ReturnShippingPlaceholder, {})
1640
+ }
1641
+ ) }) });
1642
+ }
1643
+ }
1644
+ )
1645
+ ] })
1646
+ ] }),
1647
+ /* @__PURE__ */ jsx8(
1648
+ ClaimOutboundSection,
1649
+ {
1650
+ form,
1651
+ currencyCode,
1652
+ disabled: isRequestLoading
1653
+ }
1654
+ ),
1655
+ /* @__PURE__ */ jsxs5("div", { className: "mt-8 border-y border-dotted py-4", children: [
1656
+ /* @__PURE__ */ jsxs5("div", { className: "mb-2 flex items-center justify-between", children: [
1657
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.inboundTotal") }),
1658
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(
1659
+ inboundPreviewItems.reduce((acc, item) => {
1660
+ const action = item.actions?.find(
1661
+ (act) => act.action === "RETURN_ITEM"
1662
+ );
1663
+ return acc + Number(action?.amount || 0);
1664
+ }, 0) * -1,
1665
+ currencyCode
1666
+ ) })
1667
+ ] }),
1668
+ /* @__PURE__ */ jsxs5("div", { className: "mt-4 flex items-center justify-between border-t border-dotted pt-4", children: [
1669
+ /* @__PURE__ */ jsx8("span", { className: "txt-small font-medium", children: t("orders.claims.refundAmount") }),
1670
+ /* @__PURE__ */ jsx8("span", { className: "txt-small font-medium", children: getStylizedAmount(estimatedDifference, currencyCode) })
1671
+ ] })
1672
+ ] }),
1673
+ /* @__PURE__ */ jsx8("div", { className: "bg-ui-bg-field mt-8 rounded-lg border py-2 pl-2 pr-4", children: /* @__PURE__ */ jsx8(
1674
+ Form.Field,
1675
+ {
1676
+ control: form.control,
1677
+ name: "send_notification",
1678
+ render: ({ field: { onChange, value, ...field } }) => {
1679
+ return /* @__PURE__ */ jsxs5(Form.Item, { children: [
1680
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center", children: [
1681
+ /* @__PURE__ */ jsx8(Form.Control, { className: "mr-4 self-start", children: /* @__PURE__ */ jsx8(
1682
+ Switch,
1683
+ {
1684
+ dir: "ltr",
1685
+ className: "mt-[2px] rtl:rotate-180",
1686
+ checked: !!value,
1687
+ onCheckedChange: onChange,
1688
+ ...field
1689
+ }
1690
+ ) }),
1691
+ /* @__PURE__ */ jsxs5("div", { className: "block", children: [
1692
+ /* @__PURE__ */ jsx8(Form.Label, { children: t("orders.returns.sendNotification") }),
1693
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.returns.sendNotificationHint") })
1694
+ ] })
1695
+ ] }),
1696
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
1697
+ ] });
1698
+ }
1699
+ }
1700
+ ) }),
1701
+ /* @__PURE__ */ jsx8("div", { className: "p-8" })
1702
+ ] }) }),
1703
+ /* @__PURE__ */ jsx8(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx8("div", { className: "flex w-full items-center justify-end gap-x-4", children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-end gap-x-2", children: [
1704
+ /* @__PURE__ */ jsx8(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx8(
1705
+ Button2,
1706
+ {
1707
+ type: "button",
1708
+ onClick: () => IS_CANCELING = true,
1709
+ variant: "secondary",
1710
+ size: "small",
1711
+ children: t("orders.claims.cancel.title")
1712
+ }
1713
+ ) }),
1714
+ /* @__PURE__ */ jsx8(
1715
+ Button2,
1716
+ {
1717
+ type: "submit",
1718
+ variant: "primary",
1719
+ size: "small",
1720
+ isLoading: isRequestLoading,
1721
+ children: t("orders.claims.confirm")
1722
+ },
1723
+ "submit-button"
1724
+ )
1725
+ ] }) }) })
1726
+ ] }) });
1727
+ };
1728
+
1729
+ // src/pages/orders/[id]/claims/create/index.tsx
1730
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1731
+ var IS_REQUEST_RUNNING = false;
1732
+ var Component = () => {
1733
+ const { id } = useParams();
1734
+ const navigate = useNavigate();
1735
+ const { t } = useTranslation11();
1736
+ const { order } = useOrder(id, {
1737
+ fields: DEFAULT_FIELDS
1738
+ });
1739
+ const { order: preview } = useOrderPreview(id);
1740
+ const [activeClaimId, setActiveClaimId] = useState4();
1741
+ const { mutateAsync: createClaim } = useCreateClaim(order?.id ?? "");
1742
+ const { claim } = useClaim(activeClaimId, void 0, {
1743
+ enabled: !!activeClaimId
1744
+ });
1745
+ const { return: orderReturn } = useReturn(claim?.return_id, void 0, {
1746
+ enabled: !!claim?.return_id
1747
+ });
1748
+ useEffect2(() => {
1749
+ async function run() {
1750
+ if (IS_REQUEST_RUNNING || !preview) {
1751
+ return;
1752
+ }
1753
+ if (preview.order_change) {
1754
+ if (preview.order_change.change_type === "claim") {
1755
+ setActiveClaimId(preview.order_change.claim_id);
1756
+ } else {
1757
+ navigate(`/orders/${preview.id}`, { replace: true });
1758
+ toast2.error(t("orders.claims.activeChangeError"));
1759
+ }
1760
+ return;
1761
+ }
1762
+ IS_REQUEST_RUNNING = true;
1763
+ try {
1764
+ const { claim: createdClaim } = await createClaim({
1765
+ order_id: preview.id,
1766
+ type: "replace"
1767
+ });
1768
+ setActiveClaimId(createdClaim.id);
1769
+ } catch (e) {
1770
+ toast2.error(
1771
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
1772
+ );
1773
+ navigate(`/orders/${preview.id}`, { replace: true });
1774
+ } finally {
1775
+ IS_REQUEST_RUNNING = false;
1776
+ }
1777
+ }
1778
+ run();
1779
+ }, [preview]);
1780
+ return /* @__PURE__ */ jsxs6(RouteFocusModal, { children: [
1781
+ /* @__PURE__ */ jsx9(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx9("span", { className: "sr-only", children: t("orders.claims.title") }) }),
1782
+ /* @__PURE__ */ jsx9(RouteFocusModal.Description, { className: "sr-only", children: t("orders.claims.title") }),
1783
+ claim && preview && order && /* @__PURE__ */ jsx9(
1784
+ ClaimCreateForm,
1785
+ {
1786
+ order,
1787
+ claim,
1788
+ preview,
1789
+ orderReturn
1790
+ }
1791
+ )
1792
+ ] });
1793
+ };
1794
+ var create_default = Component;
1795
+ export {
1796
+ Component,
1797
+ create_default as default
1798
+ };