@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,1784 @@
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-IBEUR3J7.js";
22
+ import {
23
+ useReturn,
24
+ useUpdateReturn
25
+ } from "./chunk-TF6V3TFG.js";
26
+ import {
27
+ getReturnableQuantity
28
+ } from "./chunk-UM7ZR3VU.js";
29
+ import {
30
+ DEFAULT_FIELDS
31
+ } from "./chunk-L4KBTV57.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-SSUUT5LK.js";
50
+ import "./chunk-YN3FGNJM.js";
51
+ import "./chunk-6OUPJNYO.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-U2ZFCAPX.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-UORPTGV2.js";
87
+ import {
88
+ useOrder,
89
+ useOrderPreview
90
+ } from "./chunk-Y2MQ5EMD.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-JAUZ73XE.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, 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, ...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 rawOffers = offersResponse.offers ?? [];
872
+ const offers = useMemo4(() => {
873
+ return rawOffers.filter((offer) => {
874
+ if (currencyCode) {
875
+ const hasPrice = (offer.prices ?? []).some(
876
+ (p) => p.currency_code === currencyCode
877
+ );
878
+ if (!hasPrice) return false;
879
+ }
880
+ return offerHasInventory(offer);
881
+ });
882
+ }, [rawOffers, currencyCode]);
883
+ useMemo4(() => {
884
+ if (!offers.length) return;
885
+ setOfferLookup((prev) => {
886
+ let changed = false;
887
+ const next = { ...prev };
888
+ for (const offer of offers) {
889
+ if (!next[offer.id]) {
890
+ next[offer.id] = offer;
891
+ changed = true;
892
+ }
893
+ }
894
+ return changed ? next : prev;
895
+ });
896
+ }, [offers]);
897
+ const count = offers.length;
898
+ const columns = useClaimOutboundItemTableColumns();
899
+ const filters = useClaimOutboundItemTableFilters();
900
+ const { table } = useDataTable({
901
+ data: offers,
902
+ columns,
903
+ count,
904
+ enablePagination: true,
905
+ // Row id = offer id so onSelectionChange yields offer_ids that the form
906
+ // layer sends to `useAddClaimOutboundItems` (which accepts `offer_id` and
907
+ // resolves to variant_id + unit_price server-side).
908
+ getRowId: (row) => row.id,
909
+ pageSize: PAGE_SIZE2,
910
+ enableRowSelection: () => true,
911
+ rowSelection: {
912
+ state: rowSelection,
913
+ updater
914
+ }
915
+ });
916
+ return /* @__PURE__ */ jsx5(
917
+ "div",
918
+ {
919
+ className: "flex size-full flex-col overflow-hidden",
920
+ "data-testid": "add-claim-outbound-picker",
921
+ children: /* @__PURE__ */ jsx5(
922
+ _DataTable,
923
+ {
924
+ table,
925
+ columns,
926
+ pageSize: PAGE_SIZE2,
927
+ count,
928
+ filters,
929
+ pagination: true,
930
+ layout: "fill",
931
+ search: true,
932
+ orderBy: [
933
+ { key: "sku", label: t("fields.sku") },
934
+ { key: "created_at", label: t("fields.createdAt") },
935
+ { key: "updated_at", label: t("fields.updatedAt") }
936
+ ],
937
+ prefix: PREFIX2,
938
+ queryObject: raw
939
+ }
940
+ )
941
+ }
942
+ );
943
+ };
944
+
945
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/claim-outbound-item.tsx
946
+ import { XCircle as XCircle2 } from "@medusajs/icons";
947
+ import { Input as Input2, Text as Text3 } from "@medusajs/ui";
948
+ import { useTranslation as useTranslation8 } from "react-i18next";
949
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
950
+ function ClaimOutboundItem({
951
+ form,
952
+ onRemove,
953
+ index
954
+ }) {
955
+ const { t } = useTranslation8();
956
+ const row = form.watch(`outbound_items.${index}`);
957
+ const productTitle = row?.product_title ?? row?.variant_title ?? row?.offer_id;
958
+ return /* @__PURE__ */ jsx6(
959
+ "div",
960
+ {
961
+ className: "bg-ui-bg-subtle shadow-elevation-card-rest my-2 rounded-xl",
962
+ "data-testid": `claim-outbound-item-${row?.offer_id ?? index}`,
963
+ 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: [
964
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 items-center gap-x-3", children: [
965
+ /* @__PURE__ */ jsx6(Thumbnail, { src: row?.thumbnail ?? void 0 }),
966
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col", children: [
967
+ /* @__PURE__ */ jsxs3("div", { children: [
968
+ /* @__PURE__ */ jsxs3(Text3, { className: "txt-small", as: "span", weight: "plus", children: [
969
+ productTitle,
970
+ " "
971
+ ] }),
972
+ row?.sku && /* @__PURE__ */ jsxs3("span", { children: [
973
+ "(",
974
+ row.sku,
975
+ ")"
976
+ ] })
977
+ ] }),
978
+ row?.variant_title && /* @__PURE__ */ jsx6(Text3, { as: "div", className: "text-ui-fg-subtle txt-small", children: row.variant_title })
979
+ ] })
980
+ ] }),
981
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 justify-between", children: [
982
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-grow items-center gap-2", children: [
983
+ /* @__PURE__ */ jsx6(
984
+ Form.Field,
985
+ {
986
+ control: form.control,
987
+ name: `outbound_items.${index}.quantity`,
988
+ render: ({ field }) => {
989
+ return /* @__PURE__ */ jsxs3(Form.Item, { children: [
990
+ /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(
991
+ Input2,
992
+ {
993
+ ...field,
994
+ className: "bg-ui-bg-base txt-small w-[67px] rounded-lg",
995
+ min: 1,
996
+ type: "number",
997
+ onBlur: (e) => {
998
+ const val = e.target.value;
999
+ const payload = val === "" ? null : Number(val);
1000
+ field.onChange(payload);
1001
+ }
1002
+ }
1003
+ ) }),
1004
+ /* @__PURE__ */ jsx6(Form.ErrorMessage, {})
1005
+ ] });
1006
+ }
1007
+ }
1008
+ ),
1009
+ /* @__PURE__ */ jsx6(Text3, { className: "txt-small text-ui-fg-subtle", children: t("fields.qty") })
1010
+ ] }),
1011
+ /* @__PURE__ */ jsx6(
1012
+ ActionMenu,
1013
+ {
1014
+ groups: [
1015
+ {
1016
+ actions: [
1017
+ {
1018
+ label: t("actions.remove"),
1019
+ onClick: onRemove,
1020
+ icon: /* @__PURE__ */ jsx6(XCircle2, {})
1021
+ }
1022
+ ]
1023
+ }
1024
+ ]
1025
+ }
1026
+ )
1027
+ ] })
1028
+ ] })
1029
+ }
1030
+ );
1031
+ }
1032
+
1033
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/claim-outbound-section.tsx
1034
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1035
+ var STACKED_MODAL_ID = "claim-add-outbound-items";
1036
+ var ClaimOutboundSection = ({
1037
+ form,
1038
+ currencyCode,
1039
+ disabled
1040
+ }) => {
1041
+ const { t } = useTranslation9();
1042
+ const { setIsOpen } = useStackedModal();
1043
+ const {
1044
+ fields: outboundItems,
1045
+ append,
1046
+ remove
1047
+ } = useFieldArray({
1048
+ name: "outbound_items",
1049
+ control: form.control
1050
+ });
1051
+ const showOutboundItemsPlaceholder = !outboundItems.length;
1052
+ const onItemsSelected = (selectedOfferIds, offerLookup) => {
1053
+ const existing = new Set(outboundItems.map((row) => row.offer_id));
1054
+ selectedOfferIds.filter((id) => !existing.has(id)).forEach((id) => {
1055
+ const offer = offerLookup[id];
1056
+ const variant = offer?.product_variant;
1057
+ append(
1058
+ {
1059
+ offer_id: id,
1060
+ variant_id: offer?.variant_id ?? variant?.id ?? null,
1061
+ product_title: variant?.product?.title ?? null,
1062
+ variant_title: variant?.title ?? null,
1063
+ thumbnail: variant?.product?.thumbnail ?? null,
1064
+ sku: offer?.sku ?? null,
1065
+ quantity: 1
1066
+ },
1067
+ { shouldFocus: false }
1068
+ );
1069
+ });
1070
+ setIsOpen(STACKED_MODAL_ID, false);
1071
+ };
1072
+ return /* @__PURE__ */ jsxs4("div", { children: [
1073
+ /* @__PURE__ */ jsxs4("div", { className: "mt-8 flex items-center justify-between", children: [
1074
+ /* @__PURE__ */ jsx7(Heading, { level: "h2", children: t("orders.claims.outboundItems") }),
1075
+ /* @__PURE__ */ jsxs4(StackedFocusModal, { id: STACKED_MODAL_ID, children: [
1076
+ /* @__PURE__ */ jsx7(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx7(
1077
+ "a",
1078
+ {
1079
+ className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400",
1080
+ "data-testid": "claim-add-outbound-trigger",
1081
+ children: t("orders.claims.addOutboundItems")
1082
+ }
1083
+ ) }),
1084
+ /* @__PURE__ */ jsxs4(StackedFocusModal.Content, { children: [
1085
+ /* @__PURE__ */ jsx7(StackedFocusModal.Header, {}),
1086
+ /* @__PURE__ */ jsx7(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx7("span", { className: "sr-only", children: t("orders.claims.addOutboundItems") }) }),
1087
+ /* @__PURE__ */ jsx7(StackedFocusModal.Description, { className: "sr-only", children: t("orders.claims.addOutboundItemsDescription") }),
1088
+ /* @__PURE__ */ jsx7(StackedFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsx7(
1089
+ PickerBody,
1090
+ {
1091
+ currencyCode,
1092
+ onSubmit: onItemsSelected
1093
+ }
1094
+ ) })
1095
+ ] })
1096
+ ] })
1097
+ ] }),
1098
+ showOutboundItemsPlaceholder && /* @__PURE__ */ jsx7(ItemPlaceholder, {}),
1099
+ outboundItems.map((item, index) => /* @__PURE__ */ jsx7(
1100
+ ClaimOutboundItem,
1101
+ {
1102
+ form,
1103
+ index,
1104
+ onRemove: () => remove(index)
1105
+ },
1106
+ item.id
1107
+ )),
1108
+ /* @__PURE__ */ jsx7("span", { className: "sr-only", children: disabled ? "" : "" })
1109
+ ] });
1110
+ };
1111
+ var PickerBody = ({
1112
+ currencyCode,
1113
+ onSubmit
1114
+ }) => {
1115
+ const { t } = useTranslation9();
1116
+ let selectedOfferIds = [];
1117
+ let selectedOfferLookup = {};
1118
+ return /* @__PURE__ */ jsxs4("div", { className: "flex h-full flex-col", children: [
1119
+ /* @__PURE__ */ jsx7("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx7(
1120
+ AddClaimOutboundItemsTable,
1121
+ {
1122
+ currencyCode,
1123
+ onSelectionChange: (ids, lookup) => {
1124
+ selectedOfferIds = ids;
1125
+ selectedOfferLookup = lookup;
1126
+ }
1127
+ }
1128
+ ) }),
1129
+ /* @__PURE__ */ jsx7(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs4("div", { className: "flex w-full items-center justify-end gap-x-2", children: [
1130
+ /* @__PURE__ */ jsx7(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx7(
1131
+ Button,
1132
+ {
1133
+ type: "button",
1134
+ variant: "secondary",
1135
+ size: "small",
1136
+ "data-testid": "claim-add-outbound-cancel",
1137
+ children: t("actions.cancel")
1138
+ }
1139
+ ) }),
1140
+ /* @__PURE__ */ jsx7(
1141
+ Button,
1142
+ {
1143
+ type: "button",
1144
+ variant: "primary",
1145
+ size: "small",
1146
+ role: "button",
1147
+ "data-testid": "claim-add-outbound-save",
1148
+ onClick: () => onSubmit(selectedOfferIds, selectedOfferLookup),
1149
+ children: t("actions.save")
1150
+ },
1151
+ "submit-button"
1152
+ )
1153
+ ] }) })
1154
+ ] });
1155
+ };
1156
+
1157
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/schema.ts
1158
+ import { z } from "zod";
1159
+ var ClaimCreateSchema = z.object({
1160
+ inbound_items: z.array(
1161
+ z.object({
1162
+ item_id: z.string(),
1163
+ variant_id: z.string().nullish(),
1164
+ quantity: z.number(),
1165
+ reason_id: z.string().nullish(),
1166
+ note: z.string().nullish()
1167
+ })
1168
+ ),
1169
+ outbound_items: z.array(
1170
+ z.object({
1171
+ offer_id: z.string(),
1172
+ variant_id: z.string().nullish(),
1173
+ product_title: z.string().nullish(),
1174
+ variant_title: z.string().nullish(),
1175
+ thumbnail: z.string().nullish(),
1176
+ sku: z.string().nullish(),
1177
+ quantity: z.number()
1178
+ })
1179
+ ),
1180
+ location_id: z.string().nullish(),
1181
+ inbound_option_id: z.string().nullish(),
1182
+ outbound_option_id: z.string().nullish(),
1183
+ send_notification: z.boolean().optional()
1184
+ });
1185
+
1186
+ // src/pages/orders/[id]/claims/create/_components/claim-create-form/claim-create-form.tsx
1187
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1188
+ var itemsToAdd = [];
1189
+ var itemsToRemove = [];
1190
+ var IS_CANCELING = false;
1191
+ var ClaimCreateForm = ({
1192
+ order,
1193
+ preview,
1194
+ claim,
1195
+ orderReturn
1196
+ }) => {
1197
+ const { t } = useTranslation10();
1198
+ const { handleSuccess } = useRouteModal();
1199
+ const { setIsOpen } = useStackedModal();
1200
+ const [_inventoryMap, setInventoryMap] = useState3({});
1201
+ const { mutateAsync: confirmClaimRequest, isPending: isConfirming } = useClaimConfirmRequest(claim.id, order.id);
1202
+ const { mutateAsync: cancelClaimRequest, isPending: isCanceling } = useCancelClaimRequest(claim.id, order.id);
1203
+ const { mutateAsync: updateReturn, isPending: isUpdating } = useUpdateReturn(
1204
+ preview?.order_change?.return_id ?? "",
1205
+ order.id
1206
+ );
1207
+ const {
1208
+ mutateAsync: addInboundShipping,
1209
+ isPending: isAddingInboundShipping
1210
+ } = useAddClaimInboundShipping(claim.id, order.id);
1211
+ const {
1212
+ mutateAsync: updateInboundShipping,
1213
+ isPending: isUpdatingInboundShipping
1214
+ } = useUpdateClaimInboundShipping(claim.id, order.id);
1215
+ const {
1216
+ mutateAsync: deleteInboundShipping,
1217
+ isPending: isDeletingInboundShipping
1218
+ } = useDeleteClaimInboundShipping(claim.id, order.id);
1219
+ const { mutateAsync: addInboundItem, isPending: isAddingInboundItem } = useAddClaimInboundItems(claim.id, order.id);
1220
+ const { mutateAsync: updateInboundItem, isPending: isUpdatingInboundItem } = useUpdateClaimInboundItem(claim.id, order.id);
1221
+ const { mutateAsync: removeInboundItem, isPending: isRemovingInboundItem } = useRemoveClaimInboundItem(claim.id, order.id);
1222
+ const isRequestLoading = isConfirming || isCanceling || isAddingInboundShipping || isUpdatingInboundShipping || isDeletingInboundShipping || isAddingInboundItem || isRemovingInboundItem || isUpdatingInboundItem || isUpdating;
1223
+ const previewItems = useMemo5(
1224
+ () => preview?.items?.filter(
1225
+ (i) => !!i.actions?.find((a) => a.claim_id === claim.id)
1226
+ ) ?? [],
1227
+ [preview.items, claim.id]
1228
+ );
1229
+ const inboundPreviewItems = useMemo5(
1230
+ () => previewItems.filter(
1231
+ (item) => !!item.actions?.find((a) => a.action === "RETURN_ITEM")
1232
+ ),
1233
+ [previewItems]
1234
+ );
1235
+ const itemsMap = useMemo5(
1236
+ () => new Map(order?.items?.map((i) => [i.id, i])),
1237
+ [order.items]
1238
+ );
1239
+ const form = useForm({
1240
+ defaultValues: () => {
1241
+ const inboundShippingMethod = preview.shipping_methods?.find((s) => {
1242
+ return !!s.actions?.find(
1243
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1244
+ );
1245
+ });
1246
+ return Promise.resolve({
1247
+ inbound_items: inboundPreviewItems.map((i) => {
1248
+ const inboundAction = i.actions?.find(
1249
+ (a) => a.action === "RETURN_ITEM"
1250
+ );
1251
+ return {
1252
+ item_id: i.id,
1253
+ variant_id: i.variant_id,
1254
+ quantity: i.detail?.return_requested_quantity ?? 1,
1255
+ note: inboundAction?.internal_note,
1256
+ reason_id: inboundAction?.details?.reason_id
1257
+ };
1258
+ }),
1259
+ outbound_items: [],
1260
+ inbound_option_id: inboundShippingMethod ? inboundShippingMethod.shipping_option_id : null,
1261
+ outbound_option_id: null,
1262
+ location_id: orderReturn?.location_id ?? null,
1263
+ send_notification: false
1264
+ });
1265
+ },
1266
+ resolver: zodResolver(ClaimCreateSchema)
1267
+ });
1268
+ const locationId = form.watch("location_id");
1269
+ const { stock_locations: stockLocations = [] } = useStockLocations({
1270
+ limit: 999
1271
+ });
1272
+ const { shipping_options: shippingOptions = [] } = useShippingOptions(
1273
+ locationId ? {
1274
+ limit: 999,
1275
+ fields: "*prices,+service_zone.fulfillment_set.location.id",
1276
+ stock_location_id: locationId
1277
+ } : void 0,
1278
+ { enabled: !!locationId }
1279
+ );
1280
+ const inboundShippingOptions = (shippingOptions ?? []).filter(
1281
+ (so) => !!so.rules?.find(
1282
+ (r) => r.attribute === "is_return" && r.value === "true"
1283
+ )
1284
+ );
1285
+ const {
1286
+ fields: inboundItems,
1287
+ append,
1288
+ remove,
1289
+ update
1290
+ } = useFieldArray2({
1291
+ name: "inbound_items",
1292
+ control: form.control
1293
+ });
1294
+ const previewItemsMap = useMemo5(
1295
+ () => new Map(previewItems.map((i) => [i.id, i])),
1296
+ [previewItems, inboundItems]
1297
+ );
1298
+ useEffect(() => {
1299
+ const existingItemsMap = {};
1300
+ inboundPreviewItems.forEach((i) => {
1301
+ const ind = inboundItems.findIndex((field) => field.item_id === i.id);
1302
+ const requested = i.detail?.return_requested_quantity ?? 0;
1303
+ existingItemsMap[i.id] = true;
1304
+ if (ind > -1) {
1305
+ if (inboundItems[ind].quantity !== requested) {
1306
+ const returnItemAction = i.actions?.find(
1307
+ (a) => a.action === "RETURN_ITEM"
1308
+ );
1309
+ update(ind, {
1310
+ ...inboundItems[ind],
1311
+ quantity: requested,
1312
+ note: returnItemAction?.internal_note,
1313
+ reason_id: returnItemAction?.details?.reason_id
1314
+ });
1315
+ }
1316
+ } else {
1317
+ append(
1318
+ { item_id: i.id, quantity: requested },
1319
+ { shouldFocus: false }
1320
+ );
1321
+ }
1322
+ });
1323
+ inboundItems.forEach((i, ind) => {
1324
+ if (!(i.item_id in existingItemsMap)) {
1325
+ remove(ind);
1326
+ }
1327
+ });
1328
+ }, [previewItems]);
1329
+ useEffect(() => {
1330
+ const inboundShipping = preview.shipping_methods?.find(
1331
+ (s) => !!s.actions?.find((a) => a.action === "SHIPPING_ADD" && !!a.return_id)
1332
+ );
1333
+ if (inboundShipping) {
1334
+ form.setValue("inbound_option_id", inboundShipping.shipping_option_id);
1335
+ } else {
1336
+ form.setValue("inbound_option_id", null);
1337
+ }
1338
+ }, [preview.shipping_methods]);
1339
+ useEffect(() => {
1340
+ form.setValue("location_id", orderReturn?.location_id ?? null);
1341
+ }, [orderReturn]);
1342
+ const showInboundItemsPlaceholder = !inboundPreviewItems.length;
1343
+ const prompt = usePrompt();
1344
+ const handleSubmit = form.handleSubmit(async (data) => {
1345
+ const res = await prompt({
1346
+ title: t("general.areYouSure"),
1347
+ description: t("orders.claims.confirmText"),
1348
+ confirmText: t("actions.continue"),
1349
+ cancelText: t("actions.cancel"),
1350
+ variant: "confirmation"
1351
+ });
1352
+ if (!res) {
1353
+ return;
1354
+ }
1355
+ await confirmClaimRequest(
1356
+ { no_notification: !data.send_notification },
1357
+ {
1358
+ onSuccess: () => {
1359
+ toast.success(t("orders.claims.toast.confirmedSuccessfully"));
1360
+ handleSuccess();
1361
+ },
1362
+ onError: (error) => {
1363
+ toast.error(error.message);
1364
+ }
1365
+ }
1366
+ );
1367
+ });
1368
+ const onItemsSelected = async () => {
1369
+ itemsToAdd.length && await addInboundItem(
1370
+ {
1371
+ items: itemsToAdd.map((id) => ({
1372
+ id,
1373
+ quantity: 1
1374
+ }))
1375
+ },
1376
+ {
1377
+ onError: (error) => {
1378
+ toast.error(error.message);
1379
+ }
1380
+ }
1381
+ );
1382
+ for (const itemToRemove of itemsToRemove) {
1383
+ const actionId = previewItems.find((i) => i.id === itemToRemove)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
1384
+ if (actionId) {
1385
+ await removeInboundItem(actionId, {
1386
+ onError: (error) => {
1387
+ toast.error(error.message);
1388
+ }
1389
+ });
1390
+ }
1391
+ }
1392
+ setIsOpen("inbound-items", false);
1393
+ };
1394
+ const onLocationChange = async (selectedLocationId) => {
1395
+ if (!preview?.order_change?.return_id) return;
1396
+ await updateReturn({ location_id: selectedLocationId ?? null });
1397
+ };
1398
+ const onShippingOptionChange = async (selectedOptionId) => {
1399
+ const inboundShippingMethods = (preview.shipping_methods ?? []).filter(
1400
+ (s) => {
1401
+ const action = s.actions?.find(
1402
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1403
+ );
1404
+ return action && !!action?.return_id;
1405
+ }
1406
+ );
1407
+ const promises = inboundShippingMethods.filter(Boolean).map((inboundShippingMethod) => {
1408
+ const action = inboundShippingMethod.actions?.find(
1409
+ (a) => a.action === "SHIPPING_ADD" && !!a.return_id
1410
+ );
1411
+ if (action) {
1412
+ return deleteInboundShipping(action.id);
1413
+ }
1414
+ return Promise.resolve();
1415
+ });
1416
+ await Promise.all(promises);
1417
+ if (selectedOptionId) {
1418
+ await addInboundShipping(
1419
+ { shipping_option_id: selectedOptionId },
1420
+ {
1421
+ onError: (error) => {
1422
+ toast.error(error.message);
1423
+ }
1424
+ }
1425
+ );
1426
+ }
1427
+ };
1428
+ useEffect(() => {
1429
+ return () => {
1430
+ if (IS_CANCELING) {
1431
+ cancelClaimRequest(void 0, {
1432
+ onSuccess: () => {
1433
+ toast.success(t("orders.claims.toast.canceledSuccessfully"));
1434
+ },
1435
+ onError: (error) => {
1436
+ toast.error(error.message);
1437
+ }
1438
+ });
1439
+ IS_CANCELING = false;
1440
+ }
1441
+ };
1442
+ }, []);
1443
+ useEffect(() => {
1444
+ setInventoryMap({});
1445
+ }, [inboundItems.length]);
1446
+ const estimatedDifference = (preview.summary?.pending_difference ?? 0) - inboundPreviewItems.reduce(
1447
+ (acc, item) => acc + (item.total ?? 0),
1448
+ 0
1449
+ );
1450
+ const currencyCode = order.currency_code;
1451
+ return /* @__PURE__ */ jsx8(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs5(KeyboundForm, { onSubmit: handleSubmit, className: "flex h-full flex-col", children: [
1452
+ /* @__PURE__ */ jsx8(RouteFocusModal.Header, {}),
1453
+ /* @__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: [
1454
+ /* @__PURE__ */ jsx8(Heading2, { level: "h1", children: t("orders.claims.create") }),
1455
+ /* @__PURE__ */ jsxs5("div", { className: "mt-8 flex items-center justify-between", children: [
1456
+ /* @__PURE__ */ jsx8(Heading2, { level: "h2", children: t("orders.returns.inbound") }),
1457
+ /* @__PURE__ */ jsxs5(StackedFocusModal, { id: "inbound-items", children: [
1458
+ /* @__PURE__ */ jsx8(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx8("a", { className: "focus-visible:shadow-borders-focus transition-fg txt-compact-small-plus cursor-pointer text-blue-500 outline-none hover:text-blue-400", children: t("actions.addItems") }) }),
1459
+ /* @__PURE__ */ jsxs5(StackedFocusModal.Content, { children: [
1460
+ /* @__PURE__ */ jsx8(StackedFocusModal.Header, {}),
1461
+ /* @__PURE__ */ jsx8(
1462
+ AddClaimItemsTable,
1463
+ {
1464
+ items: order.items,
1465
+ selectedItems: inboundItems.map((i) => i.item_id),
1466
+ currencyCode,
1467
+ onSelectionChange: (finalSelection) => {
1468
+ const alreadySelected = inboundItems.map(
1469
+ (i) => i.item_id
1470
+ );
1471
+ itemsToAdd = finalSelection.filter(
1472
+ (selection) => !alreadySelected.includes(selection)
1473
+ );
1474
+ itemsToRemove = alreadySelected.filter(
1475
+ (selection) => !finalSelection.includes(selection)
1476
+ );
1477
+ }
1478
+ }
1479
+ ),
1480
+ /* @__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: [
1481
+ /* @__PURE__ */ jsx8(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx8(
1482
+ Button2,
1483
+ {
1484
+ type: "button",
1485
+ variant: "secondary",
1486
+ size: "small",
1487
+ children: t("actions.cancel")
1488
+ }
1489
+ ) }),
1490
+ /* @__PURE__ */ jsx8(
1491
+ Button2,
1492
+ {
1493
+ type: "submit",
1494
+ variant: "primary",
1495
+ size: "small",
1496
+ role: "button",
1497
+ onClick: async () => await onItemsSelected(),
1498
+ children: t("actions.save")
1499
+ },
1500
+ "submit-button"
1501
+ )
1502
+ ] }) }) })
1503
+ ] })
1504
+ ] })
1505
+ ] }),
1506
+ showInboundItemsPlaceholder && /* @__PURE__ */ jsx8(ItemPlaceholder, {}),
1507
+ inboundItems.map(
1508
+ (item, index) => previewItemsMap.get(item.item_id) && itemsMap.get(item.item_id) && /* @__PURE__ */ jsx8(
1509
+ ClaimInboundItem,
1510
+ {
1511
+ item: itemsMap.get(item.item_id),
1512
+ previewItem: previewItemsMap.get(item.item_id),
1513
+ currencyCode,
1514
+ form,
1515
+ onRemove: () => {
1516
+ const actionId = previewItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM")?.id;
1517
+ if (actionId) {
1518
+ removeInboundItem(actionId, {
1519
+ onError: (error) => {
1520
+ toast.error(error.message);
1521
+ }
1522
+ });
1523
+ }
1524
+ },
1525
+ onUpdate: (payload) => {
1526
+ const action = previewItems.find((i) => i.id === item.item_id)?.actions?.find((a) => a.action === "RETURN_ITEM");
1527
+ if (action) {
1528
+ updateInboundItem(
1529
+ { ...payload, actionId: action.id },
1530
+ {
1531
+ onError: (error) => {
1532
+ if (action.details?.quantity && payload.quantity) {
1533
+ form.setValue(
1534
+ `inbound_items.${index}.quantity`,
1535
+ action.details?.quantity
1536
+ );
1537
+ }
1538
+ toast.error(error.message);
1539
+ }
1540
+ }
1541
+ );
1542
+ }
1543
+ },
1544
+ index
1545
+ },
1546
+ item.id
1547
+ )
1548
+ ),
1549
+ !showInboundItemsPlaceholder && /* @__PURE__ */ jsxs5("div", { className: "mt-8 flex flex-col gap-y-4", children: [
1550
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
1551
+ /* @__PURE__ */ jsxs5("div", { children: [
1552
+ /* @__PURE__ */ jsx8(Form.Label, { children: t("orders.returns.location") }),
1553
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.returns.locationHint") })
1554
+ ] }),
1555
+ /* @__PURE__ */ jsx8(
1556
+ Form.Field,
1557
+ {
1558
+ control: form.control,
1559
+ name: "location_id",
1560
+ render: ({ field: { value, onChange, ...field } }) => {
1561
+ return /* @__PURE__ */ jsx8(Form.Item, { children: /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(
1562
+ Combobox,
1563
+ {
1564
+ ...field,
1565
+ value: value ?? void 0,
1566
+ onChange: (v) => {
1567
+ onChange(v);
1568
+ onLocationChange(v);
1569
+ },
1570
+ options: (stockLocations ?? []).map(
1571
+ (stockLocation) => ({
1572
+ label: stockLocation.name,
1573
+ value: stockLocation.id
1574
+ })
1575
+ )
1576
+ }
1577
+ ) }) });
1578
+ }
1579
+ }
1580
+ )
1581
+ ] }),
1582
+ /* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-1 gap-2 md:grid-cols-2", children: [
1583
+ /* @__PURE__ */ jsxs5("div", { children: [
1584
+ /* @__PURE__ */ jsxs5(Form.Label, { children: [
1585
+ t("orders.returns.inboundShipping"),
1586
+ /* @__PURE__ */ jsxs5(
1587
+ Text4,
1588
+ {
1589
+ size: "small",
1590
+ leading: "compact",
1591
+ className: "text-ui-fg-muted ml-1 inline",
1592
+ children: [
1593
+ "(",
1594
+ t("fields.optional"),
1595
+ ")"
1596
+ ]
1597
+ }
1598
+ )
1599
+ ] }),
1600
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.returns.inboundShippingHint") })
1601
+ ] }),
1602
+ /* @__PURE__ */ jsx8(
1603
+ Form.Field,
1604
+ {
1605
+ control: form.control,
1606
+ name: "inbound_option_id",
1607
+ render: ({ field: { value, onChange, ...field } }) => {
1608
+ return /* @__PURE__ */ jsx8(Form.Item, { children: /* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(
1609
+ Combobox,
1610
+ {
1611
+ allowClear: true,
1612
+ value: value ?? void 0,
1613
+ onChange: (val) => {
1614
+ onChange(val);
1615
+ onShippingOptionChange(val);
1616
+ },
1617
+ ...field,
1618
+ options: inboundShippingOptions.map(
1619
+ (so) => ({
1620
+ label: so.name,
1621
+ value: so.id
1622
+ })
1623
+ ),
1624
+ disabled: !locationId,
1625
+ noResultsPlaceholder: /* @__PURE__ */ jsx8(ReturnShippingPlaceholder, {})
1626
+ }
1627
+ ) }) });
1628
+ }
1629
+ }
1630
+ )
1631
+ ] })
1632
+ ] }),
1633
+ /* @__PURE__ */ jsx8(
1634
+ ClaimOutboundSection,
1635
+ {
1636
+ form,
1637
+ currencyCode,
1638
+ disabled: isRequestLoading
1639
+ }
1640
+ ),
1641
+ /* @__PURE__ */ jsxs5("div", { className: "mt-8 border-y border-dotted py-4", children: [
1642
+ /* @__PURE__ */ jsxs5("div", { className: "mb-2 flex items-center justify-between", children: [
1643
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: t("orders.returns.inboundTotal") }),
1644
+ /* @__PURE__ */ jsx8("span", { className: "txt-small text-ui-fg-subtle", children: getStylizedAmount(
1645
+ inboundPreviewItems.reduce((acc, item) => {
1646
+ const action = item.actions?.find(
1647
+ (act) => act.action === "RETURN_ITEM"
1648
+ );
1649
+ return acc + Number(action?.amount || 0);
1650
+ }, 0) * -1,
1651
+ currencyCode
1652
+ ) })
1653
+ ] }),
1654
+ /* @__PURE__ */ jsxs5("div", { className: "mt-4 flex items-center justify-between border-t border-dotted pt-4", children: [
1655
+ /* @__PURE__ */ jsx8("span", { className: "txt-small font-medium", children: t("orders.claims.refundAmount") }),
1656
+ /* @__PURE__ */ jsx8("span", { className: "txt-small font-medium", children: getStylizedAmount(estimatedDifference, currencyCode) })
1657
+ ] })
1658
+ ] }),
1659
+ /* @__PURE__ */ jsx8("div", { className: "bg-ui-bg-field mt-8 rounded-lg border py-2 pl-2 pr-4", children: /* @__PURE__ */ jsx8(
1660
+ Form.Field,
1661
+ {
1662
+ control: form.control,
1663
+ name: "send_notification",
1664
+ render: ({ field: { onChange, value, ...field } }) => {
1665
+ return /* @__PURE__ */ jsxs5(Form.Item, { children: [
1666
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center", children: [
1667
+ /* @__PURE__ */ jsx8(Form.Control, { className: "mr-4 self-start", children: /* @__PURE__ */ jsx8(
1668
+ Switch,
1669
+ {
1670
+ dir: "ltr",
1671
+ className: "mt-[2px] rtl:rotate-180",
1672
+ checked: !!value,
1673
+ onCheckedChange: onChange,
1674
+ ...field
1675
+ }
1676
+ ) }),
1677
+ /* @__PURE__ */ jsxs5("div", { className: "block", children: [
1678
+ /* @__PURE__ */ jsx8(Form.Label, { children: t("orders.returns.sendNotification") }),
1679
+ /* @__PURE__ */ jsx8(Form.Hint, { className: "!mt-1", children: t("orders.returns.sendNotificationHint") })
1680
+ ] })
1681
+ ] }),
1682
+ /* @__PURE__ */ jsx8(Form.ErrorMessage, {})
1683
+ ] });
1684
+ }
1685
+ }
1686
+ ) }),
1687
+ /* @__PURE__ */ jsx8("div", { className: "p-8" })
1688
+ ] }) }),
1689
+ /* @__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: [
1690
+ /* @__PURE__ */ jsx8(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx8(
1691
+ Button2,
1692
+ {
1693
+ type: "button",
1694
+ onClick: () => IS_CANCELING = true,
1695
+ variant: "secondary",
1696
+ size: "small",
1697
+ children: t("orders.claims.cancel.title")
1698
+ }
1699
+ ) }),
1700
+ /* @__PURE__ */ jsx8(
1701
+ Button2,
1702
+ {
1703
+ type: "submit",
1704
+ variant: "primary",
1705
+ size: "small",
1706
+ isLoading: isRequestLoading,
1707
+ children: t("orders.claims.confirm")
1708
+ },
1709
+ "submit-button"
1710
+ )
1711
+ ] }) }) })
1712
+ ] }) });
1713
+ };
1714
+
1715
+ // src/pages/orders/[id]/claims/create/index.tsx
1716
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1717
+ var IS_REQUEST_RUNNING = false;
1718
+ var Component = () => {
1719
+ const { id } = useParams();
1720
+ const navigate = useNavigate();
1721
+ const { t } = useTranslation11();
1722
+ const { order } = useOrder(id, {
1723
+ fields: DEFAULT_FIELDS
1724
+ });
1725
+ const { order: preview } = useOrderPreview(id);
1726
+ const [activeClaimId, setActiveClaimId] = useState4();
1727
+ const { mutateAsync: createClaim } = useCreateClaim(order?.id ?? "");
1728
+ const { claim } = useClaim(activeClaimId, void 0, {
1729
+ enabled: !!activeClaimId
1730
+ });
1731
+ const { return: orderReturn } = useReturn(claim?.return_id, void 0, {
1732
+ enabled: !!claim?.return_id
1733
+ });
1734
+ useEffect2(() => {
1735
+ async function run() {
1736
+ if (IS_REQUEST_RUNNING || !preview) {
1737
+ return;
1738
+ }
1739
+ if (preview.order_change) {
1740
+ if (preview.order_change.change_type === "claim") {
1741
+ setActiveClaimId(preview.order_change.claim_id);
1742
+ } else {
1743
+ navigate(`/orders/${preview.id}`, { replace: true });
1744
+ toast2.error(t("orders.claims.activeChangeError"));
1745
+ }
1746
+ return;
1747
+ }
1748
+ IS_REQUEST_RUNNING = true;
1749
+ try {
1750
+ const { claim: createdClaim } = await createClaim({
1751
+ order_id: preview.id,
1752
+ type: "replace"
1753
+ });
1754
+ setActiveClaimId(createdClaim.id);
1755
+ } catch (e) {
1756
+ toast2.error(
1757
+ e instanceof Error ? e.message : t("errorBoundary.defaultTitle")
1758
+ );
1759
+ navigate(`/orders/${preview.id}`, { replace: true });
1760
+ } finally {
1761
+ IS_REQUEST_RUNNING = false;
1762
+ }
1763
+ }
1764
+ run();
1765
+ }, [preview]);
1766
+ return /* @__PURE__ */ jsxs6(RouteFocusModal, { children: [
1767
+ /* @__PURE__ */ jsx9(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx9("span", { className: "sr-only", children: t("orders.claims.title") }) }),
1768
+ /* @__PURE__ */ jsx9(RouteFocusModal.Description, { className: "sr-only", children: t("orders.claims.title") }),
1769
+ claim && preview && order && /* @__PURE__ */ jsx9(
1770
+ ClaimCreateForm,
1771
+ {
1772
+ order,
1773
+ claim,
1774
+ preview,
1775
+ orderReturn
1776
+ }
1777
+ )
1778
+ ] });
1779
+ };
1780
+ var create_default = Component;
1781
+ export {
1782
+ Component,
1783
+ create_default as default
1784
+ };