@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,1571 @@
1
+ import {
2
+ SectionRow
3
+ } from "./chunk-4TLP3TAA.js";
4
+ import {
5
+ useDataTableDateColumns
6
+ } from "./chunk-FP6U6BPH.js";
7
+ import {
8
+ SidebarLink
9
+ } from "./chunk-4GPAS5GW.js";
10
+ import "./chunk-U2EI2ZLM.js";
11
+ import {
12
+ TwoColumnPage
13
+ } from "./chunk-YV6MK4PZ.js";
14
+ import {
15
+ useDataTableDateFilters
16
+ } from "./chunk-HFRHHT36.js";
17
+ import {
18
+ DataTable
19
+ } from "./chunk-5T6UWTRU.js";
20
+ import {
21
+ useQueryParams
22
+ } from "./chunk-THHRRYRS.js";
23
+ import "./chunk-LRD242C7.js";
24
+ import {
25
+ require_dist
26
+ } from "./chunk-UCYSCKZV.js";
27
+ import {
28
+ Thumbnail
29
+ } from "./chunk-WIYFXWRI.js";
30
+ import {
31
+ TwoColumnPageSkeleton
32
+ } from "./chunk-INNFZYX2.js";
33
+ import {
34
+ useProductTag
35
+ } from "./chunk-TBYCZRZ7.js";
36
+ import "./chunk-F4OJN2F2.js";
37
+ import "./chunk-LRARA622.js";
38
+ import "./chunk-M6N4ISXL.js";
39
+ import "./chunk-S7EKBD2C.js";
40
+ import {
41
+ useProductType
42
+ } from "./chunk-VV6IKGCN.js";
43
+ import "./chunk-BXRNZS5K.js";
44
+ import "./chunk-BOZJOOGW.js";
45
+ import "./chunk-T6LHVNWO.js";
46
+ import "./chunk-4S6XGIC6.js";
47
+ import "./chunk-S23FD6FA.js";
48
+ import "./chunk-IQWK723D.js";
49
+ import {
50
+ useCollection
51
+ } from "./chunk-DDJQRV6E.js";
52
+ import "./chunk-LWJF63JW.js";
53
+ import "./chunk-VXWN37PT.js";
54
+ import {
55
+ useProductCategory
56
+ } from "./chunk-5QI3NDJG.js";
57
+ import "./chunk-VZUA5SRD.js";
58
+ import "./chunk-VXMOPVRH.js";
59
+ import "./chunk-NBPMNUKZ.js";
60
+ import "./chunk-UORPTGV2.js";
61
+ import "./chunk-Y2MQ5EMD.js";
62
+ import {
63
+ useSalesChannels
64
+ } from "./chunk-3B34B2M2.js";
65
+ import {
66
+ ActionMenu
67
+ } from "./chunk-BDGZ4EQO.js";
68
+ import "./chunk-LAVHRER2.js";
69
+ import "./chunk-QHQWEERJ.js";
70
+ import "./chunk-Y7QKP6QU.js";
71
+ import {
72
+ PRODUCT_DETAIL_QUERY
73
+ } from "./chunk-U6PBLMXD.js";
74
+ import {
75
+ productAttributesQueryKeys,
76
+ productsQueryKeys,
77
+ useCancelProductEdit,
78
+ useDeleteProduct,
79
+ useDeleteVariantLazy,
80
+ useProduct,
81
+ useProductAttribute,
82
+ useProductChange,
83
+ useProductVariants,
84
+ useRemoveProductAttribute,
85
+ useUpdateProduct
86
+ } from "./chunk-JAUZ73XE.js";
87
+ import "./chunk-A5DJIOHN.js";
88
+ import {
89
+ queryClient
90
+ } from "./chunk-RHKRREUU.js";
91
+ import "./chunk-ZA2KFUFR.js";
92
+ import {
93
+ sdk
94
+ } from "./chunk-RIN4CBRB.js";
95
+ import {
96
+ __toESM
97
+ } from "./chunk-NBMM2TZK.js";
98
+
99
+ // src/pages/products/[id]/loader.tsx
100
+ var productDetailQuery = (id) => ({
101
+ queryKey: productsQueryKeys.detail(id, PRODUCT_DETAIL_QUERY),
102
+ queryFn: async () => sdk.vendor.products.$id.query({
103
+ $id: id,
104
+ ...PRODUCT_DETAIL_QUERY
105
+ })
106
+ });
107
+ var loader = async ({ params }) => {
108
+ const id = params.id;
109
+ const query = productDetailQuery(id);
110
+ const response = await queryClient.ensureQueryData({
111
+ ...query,
112
+ staleTime: 9e4
113
+ });
114
+ return response;
115
+ };
116
+
117
+ // src/pages/products/[id]/product-detail-page.tsx
118
+ import { Children } from "react";
119
+ import { useLoaderData, useParams } from "react-router-dom";
120
+
121
+ // src/pages/products/[id]/_components/product-active-edit-section/product-active-edit-section.tsx
122
+ var import_types = __toESM(require_dist(), 1);
123
+ import { ExclamationCircleSolid } from "@medusajs/icons";
124
+ import { Button, Container, Heading, Text, toast, usePrompt } from "@medusajs/ui";
125
+ import {
126
+ describeProductChangeAction,
127
+ extractReferenceIds,
128
+ formatFieldValue,
129
+ humanizeFieldName,
130
+ isImageList,
131
+ isReferenceField,
132
+ partitionProductChangeActions
133
+ } from "@mercurjs/dashboard-shared";
134
+ import { useQueries } from "@tanstack/react-query";
135
+ import { Fragment, useMemo } from "react";
136
+ import { useTranslation } from "react-i18next";
137
+ import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
138
+ var ImageStrip = ({
139
+ images,
140
+ faded
141
+ }) => /* @__PURE__ */ jsx("div", { className: faded ? "flex items-center gap-1.5 opacity-50" : "flex items-center gap-1.5", children: images.map((image, idx) => /* @__PURE__ */ jsx(Thumbnail, { src: image.url, size: "base" }, `${image.url}-${idx}`)) });
142
+ var TypeName = ({ id }) => {
143
+ const { product_type } = useProductType(id);
144
+ return /* @__PURE__ */ jsx(Fragment2, { children: product_type?.value ?? id });
145
+ };
146
+ var CollectionName = ({ id }) => {
147
+ const { collection } = useCollection(id);
148
+ return /* @__PURE__ */ jsx(Fragment2, { children: collection?.title ?? id });
149
+ };
150
+ var CategoryName = ({ id }) => {
151
+ const { product_category } = useProductCategory(id);
152
+ return /* @__PURE__ */ jsx(Fragment2, { children: product_category?.name ?? id });
153
+ };
154
+ var TagName = ({ id }) => {
155
+ const { product_tag } = useProductTag(id);
156
+ return /* @__PURE__ */ jsx(Fragment2, { children: product_tag?.value ?? id });
157
+ };
158
+ var ReferenceName = ({
159
+ field,
160
+ id
161
+ }) => {
162
+ switch (field) {
163
+ case "type_id":
164
+ return /* @__PURE__ */ jsx(TypeName, { id });
165
+ case "collection_id":
166
+ return /* @__PURE__ */ jsx(CollectionName, { id });
167
+ case "categories":
168
+ return /* @__PURE__ */ jsx(CategoryName, { id });
169
+ case "tags":
170
+ return /* @__PURE__ */ jsx(TagName, { id });
171
+ }
172
+ };
173
+ var ReferenceList = ({
174
+ field,
175
+ ids
176
+ }) => {
177
+ if (!ids.length) return /* @__PURE__ */ jsx(Fragment2, { children: "-" });
178
+ return /* @__PURE__ */ jsx(Fragment2, { children: ids.map((id, idx) => /* @__PURE__ */ jsxs(Fragment, { children: [
179
+ idx > 0 && ", ",
180
+ /* @__PURE__ */ jsx(ReferenceName, { field, id })
181
+ ] }, `${field}-${id}`)) });
182
+ };
183
+ var FieldRow = ({ diff }) => {
184
+ const { t } = useTranslation();
185
+ const hasPrevious = diff.previous !== void 0 && diff.previous !== null && diff.previous !== "" && !(Array.isArray(diff.previous) && diff.previous.length === 0);
186
+ const nextIsImages = isImageList(diff.next);
187
+ const previousIsImages = isImageList(diff.previous);
188
+ const renderAsImages = nextIsImages || previousIsImages;
189
+ const renderAsReference = isReferenceField(diff.field);
190
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-4", children: [
191
+ /* @__PURE__ */ jsx(
192
+ Text,
193
+ {
194
+ size: "small",
195
+ weight: "plus",
196
+ leading: "compact",
197
+ className: "text-ui-fg-subtle w-[160px] shrink-0",
198
+ children: t(`fields.${diff.field}`, {
199
+ defaultValue: humanizeFieldName(diff.field)
200
+ })
201
+ }
202
+ ),
203
+ renderAsImages ? /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-wrap items-center gap-2", children: [
204
+ hasPrevious && previousIsImages && /* @__PURE__ */ jsx(ImageStrip, { images: diff.previous, faded: true }),
205
+ hasPrevious && /* @__PURE__ */ jsx(
206
+ Text,
207
+ {
208
+ size: "small",
209
+ leading: "compact",
210
+ className: "text-ui-fg-subtle",
211
+ children: "\u2192"
212
+ }
213
+ ),
214
+ nextIsImages ? /* @__PURE__ */ jsx(ImageStrip, { images: diff.next }) : /* @__PURE__ */ jsx(
215
+ Text,
216
+ {
217
+ size: "small",
218
+ leading: "compact",
219
+ className: "text-ui-fg-subtle",
220
+ children: formatFieldValue(diff.next, diff.field)
221
+ }
222
+ )
223
+ ] }) : renderAsReference ? /* @__PURE__ */ jsxs(
224
+ Text,
225
+ {
226
+ size: "small",
227
+ leading: "compact",
228
+ className: "text-ui-fg-subtle flex-1 whitespace-pre-line text-pretty",
229
+ children: [
230
+ hasPrevious && /* @__PURE__ */ jsx("span", { className: "line-through", children: /* @__PURE__ */ jsx(
231
+ ReferenceList,
232
+ {
233
+ field: diff.field,
234
+ ids: extractReferenceIds(
235
+ diff.field,
236
+ diff.previous
237
+ )
238
+ }
239
+ ) }),
240
+ hasPrevious && " \u2192 ",
241
+ /* @__PURE__ */ jsx(
242
+ ReferenceList,
243
+ {
244
+ field: diff.field,
245
+ ids: extractReferenceIds(diff.field, diff.next)
246
+ }
247
+ )
248
+ ]
249
+ }
250
+ ) : /* @__PURE__ */ jsxs(
251
+ Text,
252
+ {
253
+ size: "small",
254
+ leading: "compact",
255
+ className: "text-ui-fg-subtle flex-1 whitespace-pre-line text-pretty",
256
+ children: [
257
+ hasPrevious && /* @__PURE__ */ jsx("span", { className: "line-through", children: formatFieldValue(diff.previous, diff.field) }),
258
+ hasPrevious && " \u2192 ",
259
+ formatFieldValue(diff.next, diff.field)
260
+ ]
261
+ }
262
+ )
263
+ ] });
264
+ };
265
+ var AttributeActionLine = ({
266
+ attributeId,
267
+ valueIds
268
+ }) => {
269
+ const { product_attribute } = useProductAttribute(attributeId);
270
+ const name = product_attribute?.name ?? attributeId;
271
+ const values = product_attribute?.values ?? [];
272
+ const selectedNames = valueIds && valueIds.length ? valueIds.map((id) => {
273
+ const match = values.find((v) => v.id === id);
274
+ return match?.name ?? id;
275
+ }) : [];
276
+ return /* @__PURE__ */ jsxs(Text, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: [
277
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: name }),
278
+ selectedNames.length > 0 && `: ${selectedNames.join(", ")}`
279
+ ] });
280
+ };
281
+ var VariantActionLine = ({
282
+ title,
283
+ images
284
+ }) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
285
+ images && images.length > 0 && /* @__PURE__ */ jsx(ImageStrip, { images }),
286
+ /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: /* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: title }) })
287
+ ] });
288
+ var ActionLine = ({
289
+ action,
290
+ variantsById
291
+ }) => {
292
+ const { t } = useTranslation();
293
+ const details = action.details ?? {};
294
+ if (action.action === import_types.ProductChangeActionType.ATTRIBUTE_ADD || action.action === import_types.ProductChangeActionType.ATTRIBUTE_REMOVE) {
295
+ if (!details.attribute_id) return null;
296
+ return /* @__PURE__ */ jsx(
297
+ AttributeActionLine,
298
+ {
299
+ attributeId: details.attribute_id,
300
+ valueIds: action.action === import_types.ProductChangeActionType.ATTRIBUTE_ADD ? details.attribute_value_ids : void 0
301
+ }
302
+ );
303
+ }
304
+ const variantFallback = t("fields.variant", { defaultValue: "Variant" });
305
+ if (action.action === import_types.ProductChangeActionType.VARIANT_ADD) {
306
+ const title = details.variant?.title || details.variant?.sku || variantFallback;
307
+ return /* @__PURE__ */ jsx(VariantActionLine, { title });
308
+ }
309
+ if (action.action === import_types.ProductChangeActionType.VARIANT_REMOVE) {
310
+ const variantId = details.variant_id ?? "";
311
+ const found = variantId ? variantsById.get(variantId) : void 0;
312
+ const title = found?.title || found?.sku || variantId || variantFallback;
313
+ const images = isImageList(found?.images) ? found?.images : void 0;
314
+ return /* @__PURE__ */ jsx(VariantActionLine, { title, images });
315
+ }
316
+ const label = describeProductChangeAction(action, {
317
+ variant: variantFallback
318
+ });
319
+ return /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: label });
320
+ };
321
+ var VariantUpdateBlock = ({
322
+ variantId,
323
+ diffs,
324
+ variantsById
325
+ }) => {
326
+ const { t } = useTranslation();
327
+ const found = variantsById.get(variantId);
328
+ const title = found?.title || found?.sku || variantId || t("fields.variant", { defaultValue: "Variant" });
329
+ const images = isImageList(found?.images) ? found?.images : void 0;
330
+ return /* @__PURE__ */ jsxs(
331
+ "div",
332
+ {
333
+ className: "flex flex-col gap-y-3",
334
+ "data-testid": `product-active-edit-variant-${variantId}`,
335
+ children: [
336
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
337
+ images && images.length > 0 && /* @__PURE__ */ jsx(ImageStrip, { images }),
338
+ /* @__PURE__ */ jsxs(Text, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: [
339
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-ui-fg-base", children: t("products.edits.panel.variantUpdated", {
340
+ defaultValue: "Variant updated"
341
+ }) }),
342
+ ": ",
343
+ title
344
+ ] })
345
+ ] }),
346
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-4 pl-1", children: diffs.map((diff, idx) => /* @__PURE__ */ jsx(FieldRow, { diff }, `${variantId}-${diff.field}-${idx}`)) })
347
+ ]
348
+ }
349
+ );
350
+ };
351
+ var ProductActiveEditSection = ({
352
+ product
353
+ }) => {
354
+ const { t } = useTranslation();
355
+ const prompt = usePrompt();
356
+ const productId = product.id;
357
+ const variantsById = useMemo(() => {
358
+ const map = /* @__PURE__ */ new Map();
359
+ for (const variant of product.variants ?? []) {
360
+ if (variant?.id) map.set(variant.id, variant);
361
+ }
362
+ return map;
363
+ }, [product.variants]);
364
+ const { product_change, isError } = useProductChange(productId, {
365
+ retry: false
366
+ });
367
+ const { mutateAsync: cancelEdit, isPending: isCanceling } = useCancelProductEdit(productId);
368
+ const { updated, added, removed, deleteRequested } = useMemo(
369
+ () => partitionProductChangeActions(product_change?.actions ?? []),
370
+ [product_change]
371
+ );
372
+ const productUpdated = useMemo(
373
+ () => updated.filter((d) => !d.variant_id),
374
+ [updated]
375
+ );
376
+ const variantsUpdated = useMemo(() => {
377
+ const groups = /* @__PURE__ */ new Map();
378
+ for (const diff of updated) {
379
+ if (!diff.variant_id) continue;
380
+ const bucket = groups.get(diff.variant_id) ?? [];
381
+ bucket.push(diff);
382
+ groups.set(diff.variant_id, bucket);
383
+ }
384
+ return groups;
385
+ }, [updated]);
386
+ const attributeIds = useMemo(() => {
387
+ const ids = /* @__PURE__ */ new Set();
388
+ for (const action of [...added, ...removed]) {
389
+ if (action.action === import_types.ProductChangeActionType.ATTRIBUTE_ADD || action.action === import_types.ProductChangeActionType.ATTRIBUTE_REMOVE) {
390
+ const details = action.details ?? {};
391
+ if (details.attribute_id) ids.add(details.attribute_id);
392
+ }
393
+ }
394
+ return Array.from(ids);
395
+ }, [added, removed]);
396
+ const attributeQueries = useQueries({
397
+ queries: attributeIds.map((id) => ({
398
+ queryKey: productAttributesQueryKeys.detail(id),
399
+ queryFn: () => sdk.vendor.productAttributes.$id.query({ $id: id })
400
+ }))
401
+ });
402
+ const isLoadingAttributes = attributeQueries.some((q) => q.isPending);
403
+ const onCancel = async () => {
404
+ const confirmed = await prompt({
405
+ title: t("products.edits.panel.cancelTitle"),
406
+ description: t("products.edits.panel.cancelDescription"),
407
+ confirmText: t("actions.confirm"),
408
+ cancelText: t("actions.cancel")
409
+ });
410
+ if (!confirmed) return;
411
+ try {
412
+ await cancelEdit();
413
+ toast.success(t("products.edits.toast.canceledSuccessfully"));
414
+ } catch (e) {
415
+ toast.error(e.message);
416
+ }
417
+ };
418
+ if (isError || !product_change) {
419
+ return null;
420
+ }
421
+ if (product_change.status !== import_types.ProductChangeStatus.PENDING) {
422
+ return null;
423
+ }
424
+ if (isLoadingAttributes) {
425
+ return null;
426
+ }
427
+ const hasContent = productUpdated.length > 0 || variantsUpdated.size > 0 || added.length > 0 || removed.length > 0 || deleteRequested;
428
+ return /* @__PURE__ */ jsxs(
429
+ Container,
430
+ {
431
+ className: "divide-y p-0",
432
+ "data-testid": "product-active-edit-section",
433
+ children: [
434
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-6 py-4", children: [
435
+ /* @__PURE__ */ jsx(ExclamationCircleSolid, { className: "text-ui-fg-interactive" }),
436
+ /* @__PURE__ */ jsx(Heading, { level: "h2", "data-testid": "product-active-edit-heading", children: t("products.edits.panel.title") })
437
+ ] }),
438
+ hasContent && /* @__PURE__ */ jsxs(Fragment2, { children: [
439
+ productUpdated.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-4 px-6 py-4", children: [
440
+ /* @__PURE__ */ jsx(
441
+ Text,
442
+ {
443
+ size: "small",
444
+ weight: "plus",
445
+ leading: "compact",
446
+ className: "text-ui-fg-subtle w-[160px] shrink-0",
447
+ children: t("labels.updated")
448
+ }
449
+ ),
450
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col gap-y-4", children: productUpdated.map((diff, idx) => /* @__PURE__ */ jsx(FieldRow, { diff }, `${diff.field}-${idx}`)) })
451
+ ] }),
452
+ variantsUpdated.size > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-4 px-6 py-4", children: [
453
+ /* @__PURE__ */ jsx(
454
+ Text,
455
+ {
456
+ size: "small",
457
+ weight: "plus",
458
+ leading: "compact",
459
+ className: "text-ui-fg-subtle w-[160px] shrink-0",
460
+ children: t("labels.updated")
461
+ }
462
+ ),
463
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col gap-y-6", children: Array.from(variantsUpdated.entries()).map(
464
+ ([variantId, diffs]) => /* @__PURE__ */ jsx(
465
+ VariantUpdateBlock,
466
+ {
467
+ variantId,
468
+ diffs,
469
+ variantsById
470
+ },
471
+ variantId
472
+ )
473
+ ) })
474
+ ] }),
475
+ added.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-4 px-6 py-4", children: [
476
+ /* @__PURE__ */ jsx(
477
+ Text,
478
+ {
479
+ size: "small",
480
+ weight: "plus",
481
+ leading: "compact",
482
+ className: "text-ui-fg-subtle w-[160px] shrink-0",
483
+ children: t("labels.added")
484
+ }
485
+ ),
486
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col gap-y-2", children: added.map((action) => /* @__PURE__ */ jsx(
487
+ ActionLine,
488
+ {
489
+ action,
490
+ variantsById
491
+ },
492
+ action.id
493
+ )) })
494
+ ] }),
495
+ removed.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-4 px-6 py-4", children: [
496
+ /* @__PURE__ */ jsx(
497
+ Text,
498
+ {
499
+ size: "small",
500
+ weight: "plus",
501
+ leading: "compact",
502
+ className: "text-ui-fg-subtle w-[160px] shrink-0",
503
+ children: t("labels.removed")
504
+ }
505
+ ),
506
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col gap-y-2", children: removed.map((action) => /* @__PURE__ */ jsx(
507
+ ActionLine,
508
+ {
509
+ action,
510
+ variantsById
511
+ },
512
+ action.id
513
+ )) })
514
+ ] }),
515
+ deleteRequested && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-4 px-6 py-4", children: [
516
+ /* @__PURE__ */ jsx(
517
+ Text,
518
+ {
519
+ size: "small",
520
+ weight: "plus",
521
+ leading: "compact",
522
+ className: "text-ui-fg-subtle w-[160px] shrink-0",
523
+ children: t("labels.removed")
524
+ }
525
+ ),
526
+ /* @__PURE__ */ jsx(
527
+ Text,
528
+ {
529
+ size: "small",
530
+ leading: "compact",
531
+ className: "text-ui-fg-subtle flex-1",
532
+ children: t("products.edits.panel.deleteRequested")
533
+ }
534
+ )
535
+ ] })
536
+ ] }),
537
+ /* @__PURE__ */ jsx(
538
+ "div",
539
+ {
540
+ className: "bg-ui-bg-subtle flex items-center justify-end gap-x-2 rounded-b-xl px-6 py-4",
541
+ "data-testid": "product-active-edit-actions",
542
+ children: /* @__PURE__ */ jsx(
543
+ Button,
544
+ {
545
+ size: "small",
546
+ variant: "secondary",
547
+ onClick: onCancel,
548
+ disabled: isCanceling,
549
+ isLoading: isCanceling,
550
+ "data-testid": "product-active-edit-cancel-button",
551
+ children: t("actions.cancel")
552
+ }
553
+ )
554
+ }
555
+ )
556
+ ]
557
+ }
558
+ );
559
+ };
560
+
561
+ // src/pages/products/[id]/_components/product-general-section/product-general-section.tsx
562
+ import { PencilSquare, Trash } from "@medusajs/icons";
563
+ import { Container as Container2, Heading as Heading2, StatusBadge, usePrompt as usePrompt2 } from "@medusajs/ui";
564
+ import { useTranslation as useTranslation2 } from "react-i18next";
565
+ import { useNavigate } from "react-router-dom";
566
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
567
+ var productStatusColor = (status) => {
568
+ switch (status) {
569
+ case "draft":
570
+ return "grey";
571
+ case "proposed":
572
+ return "orange";
573
+ case "published":
574
+ return "green";
575
+ case "rejected":
576
+ return "red";
577
+ default:
578
+ return "grey";
579
+ }
580
+ };
581
+ var ProductGeneralSection = ({
582
+ product
583
+ }) => {
584
+ const { t } = useTranslation2();
585
+ const prompt = usePrompt2();
586
+ const navigate = useNavigate();
587
+ const { mutateAsync } = useDeleteProduct(product.id);
588
+ const handleDelete = async () => {
589
+ const res = await prompt({
590
+ title: t("general.areYouSure"),
591
+ description: t("products.deleteWarning", {
592
+ title: product.title
593
+ }),
594
+ confirmText: t("actions.delete"),
595
+ cancelText: t("actions.cancel")
596
+ });
597
+ if (!res) {
598
+ return;
599
+ }
600
+ await mutateAsync(void 0, {
601
+ onSuccess: () => {
602
+ navigate("..");
603
+ }
604
+ });
605
+ };
606
+ return /* @__PURE__ */ jsxs2(Container2, { className: "divide-y p-0", children: [
607
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between px-6 py-4", children: [
608
+ /* @__PURE__ */ jsx2(Heading2, { children: product.title }),
609
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-4", children: [
610
+ /* @__PURE__ */ jsx2(StatusBadge, { color: productStatusColor(product.status), children: t(`products.productStatus.${product.status}`) }),
611
+ /* @__PURE__ */ jsx2(
612
+ ActionMenu,
613
+ {
614
+ groups: [
615
+ {
616
+ actions: [
617
+ {
618
+ label: t("actions.edit"),
619
+ to: "edit",
620
+ icon: /* @__PURE__ */ jsx2(PencilSquare, {})
621
+ }
622
+ ]
623
+ },
624
+ {
625
+ actions: [
626
+ {
627
+ label: t("actions.delete"),
628
+ onClick: handleDelete,
629
+ icon: /* @__PURE__ */ jsx2(Trash, {})
630
+ }
631
+ ]
632
+ }
633
+ ]
634
+ }
635
+ )
636
+ ] })
637
+ ] }),
638
+ /* @__PURE__ */ jsx2(
639
+ SectionRow,
640
+ {
641
+ title: t("fields.description"),
642
+ value: product.description || "-"
643
+ }
644
+ ),
645
+ /* @__PURE__ */ jsx2(
646
+ SectionRow,
647
+ {
648
+ title: t("fields.subtitle"),
649
+ value: product.subtitle || "-"
650
+ }
651
+ ),
652
+ /* @__PURE__ */ jsx2(SectionRow, { title: t("fields.handle"), value: `/${product.handle}` }),
653
+ /* @__PURE__ */ jsx2(
654
+ SectionRow,
655
+ {
656
+ title: t("fields.discountable"),
657
+ value: product.discountable ? t("general.true") : t("general.false")
658
+ }
659
+ )
660
+ ] });
661
+ };
662
+
663
+ // src/pages/products/[id]/_components/product-media-section/product-media-section.tsx
664
+ import { useState } from "react";
665
+ import { PencilSquare as PencilSquare2, ThumbnailBadge } from "@medusajs/icons";
666
+ import {
667
+ Button as Button2,
668
+ Checkbox,
669
+ clx,
670
+ CommandBar,
671
+ Container as Container3,
672
+ Heading as Heading3,
673
+ Text as Text2,
674
+ Tooltip,
675
+ usePrompt as usePrompt3
676
+ } from "@medusajs/ui";
677
+ import { useTranslation as useTranslation3 } from "react-i18next";
678
+ import { Link } from "react-router-dom";
679
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
680
+ var ProductMediaSection = ({
681
+ product
682
+ }) => {
683
+ const { t } = useTranslation3();
684
+ const prompt = usePrompt3();
685
+ const [selection, setSelection] = useState({});
686
+ const media = getMedia(product);
687
+ const handleCheckedChange = (id) => {
688
+ setSelection((prev) => {
689
+ if (prev[id]) {
690
+ const { [id]: _, ...rest } = prev;
691
+ return rest;
692
+ } else {
693
+ return { ...prev, [id]: true };
694
+ }
695
+ });
696
+ };
697
+ const { mutateAsync } = useUpdateProduct(product.id);
698
+ const handleDelete = async () => {
699
+ const ids = Object.keys(selection);
700
+ const includingThumbnail = ids.some((id) => media.find((m) => m.id === id)?.isThumbnail);
701
+ const res = await prompt({
702
+ title: t("general.areYouSure"),
703
+ description: includingThumbnail ? t("products.media.deleteWarningWithThumbnail", {
704
+ count: ids.length
705
+ }) : t("products.media.deleteWarning", {
706
+ count: ids.length
707
+ }),
708
+ confirmText: t("actions.delete"),
709
+ cancelText: t("actions.cancel")
710
+ });
711
+ if (!res) {
712
+ return;
713
+ }
714
+ const mediaToKeep = product.images?.filter((i) => !ids.includes(i.id)).map((i) => ({ url: i.url }));
715
+ await mutateAsync(
716
+ {
717
+ images: mediaToKeep,
718
+ thumbnail: includingThumbnail ? "" : void 0
719
+ },
720
+ {
721
+ onSuccess: () => {
722
+ setSelection({});
723
+ }
724
+ }
725
+ );
726
+ };
727
+ return /* @__PURE__ */ jsxs3(Container3, { className: "divide-y p-0", children: [
728
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between px-6 py-4", children: [
729
+ /* @__PURE__ */ jsx3(Heading3, { level: "h2", children: t("products.media.label") }),
730
+ /* @__PURE__ */ jsx3(
731
+ ActionMenu,
732
+ {
733
+ groups: [
734
+ {
735
+ actions: [
736
+ {
737
+ label: t("actions.edit"),
738
+ to: "media?view=edit",
739
+ icon: /* @__PURE__ */ jsx3(PencilSquare2, {})
740
+ }
741
+ ]
742
+ }
743
+ ]
744
+ }
745
+ )
746
+ ] }),
747
+ media.length > 0 ? /* @__PURE__ */ jsx3("div", { className: "grid grid-cols-[repeat(auto-fill,minmax(96px,1fr))] gap-4 px-6 py-4", children: media.map((i, index) => {
748
+ const isSelected = selection[i.id];
749
+ return /* @__PURE__ */ jsxs3(
750
+ "div",
751
+ {
752
+ className: "group relative aspect-square size-full cursor-pointer overflow-hidden rounded-[8px] shadow-elevation-card-rest transition-fg hover:shadow-elevation-card-hover",
753
+ children: [
754
+ /* @__PURE__ */ jsx3(
755
+ "div",
756
+ {
757
+ className: clx(
758
+ "invisible absolute right-2 top-2 opacity-0 transition-fg group-hover:visible group-hover:opacity-100",
759
+ {
760
+ "visible opacity-100": isSelected
761
+ }
762
+ ),
763
+ children: /* @__PURE__ */ jsx3(
764
+ Checkbox,
765
+ {
766
+ checked: selection[i.id] || false,
767
+ onCheckedChange: () => handleCheckedChange(i.id)
768
+ }
769
+ )
770
+ }
771
+ ),
772
+ i.isThumbnail && /* @__PURE__ */ jsx3("div", { className: "absolute left-2 top-2", children: /* @__PURE__ */ jsx3(Tooltip, { content: t("fields.thumbnail"), children: /* @__PURE__ */ jsx3(ThumbnailBadge, {}) }) }),
773
+ /* @__PURE__ */ jsx3(
774
+ Link,
775
+ {
776
+ to: `media`,
777
+ state: { curr: index },
778
+ children: /* @__PURE__ */ jsx3(
779
+ "img",
780
+ {
781
+ src: i.url,
782
+ alt: product.title,
783
+ className: "size-full object-cover"
784
+ }
785
+ )
786
+ }
787
+ )
788
+ ]
789
+ },
790
+ i.id
791
+ );
792
+ }) }) : /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-center gap-y-4 pb-8 pt-6", children: [
793
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-center", children: [
794
+ /* @__PURE__ */ jsx3(
795
+ Text2,
796
+ {
797
+ size: "small",
798
+ leading: "compact",
799
+ weight: "plus",
800
+ className: "text-ui-fg-subtle",
801
+ children: t("products.media.emptyState.header")
802
+ }
803
+ ),
804
+ /* @__PURE__ */ jsx3(
805
+ Text2,
806
+ {
807
+ size: "small",
808
+ className: "text-ui-fg-muted",
809
+ children: t("products.media.emptyState.description")
810
+ }
811
+ )
812
+ ] }),
813
+ /* @__PURE__ */ jsx3(
814
+ Button2,
815
+ {
816
+ size: "small",
817
+ variant: "secondary",
818
+ asChild: true,
819
+ children: /* @__PURE__ */ jsx3(Link, { to: "media?view=edit", children: t("products.media.emptyState.action") })
820
+ }
821
+ )
822
+ ] }),
823
+ /* @__PURE__ */ jsx3(CommandBar, { open: !!Object.keys(selection).length, children: /* @__PURE__ */ jsxs3(CommandBar.Bar, { children: [
824
+ /* @__PURE__ */ jsx3(CommandBar.Value, { children: t("general.countSelected", {
825
+ count: Object.keys(selection).length
826
+ }) }),
827
+ /* @__PURE__ */ jsx3(CommandBar.Seperator, {}),
828
+ /* @__PURE__ */ jsx3(
829
+ CommandBar.Command,
830
+ {
831
+ action: handleDelete,
832
+ label: t("actions.delete"),
833
+ shortcut: "d"
834
+ }
835
+ )
836
+ ] }) })
837
+ ] });
838
+ };
839
+ var getMedia = (product) => {
840
+ const { images = [], thumbnail } = product;
841
+ const media = (images || []).map((image) => ({
842
+ id: image.id,
843
+ url: image.url,
844
+ isThumbnail: image.url === thumbnail
845
+ }));
846
+ if (thumbnail && !media.some((mediaItem) => mediaItem.url === thumbnail)) {
847
+ media.unshift({
848
+ id: "img_thumbnail",
849
+ url: thumbnail,
850
+ isThumbnail: true
851
+ });
852
+ }
853
+ return media;
854
+ };
855
+
856
+ // src/pages/products/[id]/_components/product-organization-section/product-organization-section.tsx
857
+ import { PencilSquare as PencilSquare3 } from "@medusajs/icons";
858
+ import { Badge, Container as Container4, Heading as Heading4, Tooltip as Tooltip2 } from "@medusajs/ui";
859
+ import { useTranslation as useTranslation4 } from "react-i18next";
860
+ import { Link as Link2 } from "react-router-dom";
861
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
862
+ var ProductOrganizationSection = ({
863
+ product
864
+ }) => {
865
+ const { t } = useTranslation4();
866
+ return /* @__PURE__ */ jsxs4(
867
+ Container4,
868
+ {
869
+ className: "divide-y p-0",
870
+ "data-testid": "product-organization-section",
871
+ children: [
872
+ /* @__PURE__ */ jsxs4(
873
+ "div",
874
+ {
875
+ className: "flex items-center justify-between px-6 py-4",
876
+ "data-testid": "product-organization-header",
877
+ children: [
878
+ /* @__PURE__ */ jsx4(Heading4, { level: "h2", "data-testid": "product-organization-title", children: t("products.organization.header") }),
879
+ /* @__PURE__ */ jsx4(
880
+ ActionMenu,
881
+ {
882
+ groups: [
883
+ {
884
+ actions: [
885
+ {
886
+ label: t("actions.edit"),
887
+ to: "organization",
888
+ icon: /* @__PURE__ */ jsx4(PencilSquare3, {})
889
+ }
890
+ ]
891
+ }
892
+ ],
893
+ "data-testid": "product-organization-action-menu"
894
+ }
895
+ )
896
+ ]
897
+ }
898
+ ),
899
+ /* @__PURE__ */ jsx4(
900
+ SectionRow,
901
+ {
902
+ title: t("fields.category"),
903
+ value: product.categories?.length ? product.categories.map((pcat) => /* @__PURE__ */ jsx4(
904
+ OrganizationTag,
905
+ {
906
+ label: pcat.name,
907
+ to: `/categories/${pcat.id}`
908
+ },
909
+ pcat.id
910
+ )) : void 0,
911
+ "data-testid": "product-categories-row"
912
+ }
913
+ ),
914
+ /* @__PURE__ */ jsx4(
915
+ SectionRow,
916
+ {
917
+ title: t("fields.collection"),
918
+ value: product.collection ? /* @__PURE__ */ jsx4(
919
+ OrganizationTag,
920
+ {
921
+ label: product.collection.title,
922
+ to: `/collections/${product.collection.id}`
923
+ }
924
+ ) : void 0,
925
+ "data-testid": "product-collection-row"
926
+ }
927
+ ),
928
+ /* @__PURE__ */ jsx4(
929
+ SectionRow,
930
+ {
931
+ title: t("fields.tags"),
932
+ value: product.tags?.length ? product.tags.map((tag) => /* @__PURE__ */ jsx4(
933
+ OrganizationTag,
934
+ {
935
+ label: tag.value,
936
+ to: `/settings/product-tags/${tag.id}`
937
+ },
938
+ tag.id
939
+ )) : void 0,
940
+ "data-testid": "product-tags-row"
941
+ }
942
+ ),
943
+ /* @__PURE__ */ jsx4(
944
+ SectionRow,
945
+ {
946
+ title: t("fields.type"),
947
+ value: product.type ? /* @__PURE__ */ jsx4(
948
+ OrganizationTag,
949
+ {
950
+ label: product.type.value,
951
+ to: `/settings/product-types/${product.type_id}`
952
+ }
953
+ ) : void 0,
954
+ "data-testid": "product-type-row"
955
+ }
956
+ )
957
+ ]
958
+ }
959
+ );
960
+ };
961
+ var OrganizationTag = ({ label, to }) => {
962
+ return /* @__PURE__ */ jsx4(Tooltip2, { content: label, children: /* @__PURE__ */ jsx4(Badge, { size: "2xsmall", className: "block w-fit truncate", asChild: true, children: /* @__PURE__ */ jsx4(
963
+ Link2,
964
+ {
965
+ to,
966
+ "data-testid": `organization-tag-${label.toLowerCase().replace(/\s+/g, "-")}`,
967
+ children: label
968
+ }
969
+ ) }) });
970
+ };
971
+
972
+ // src/pages/products/[id]/_components/product-variant-section/product-variant-section.tsx
973
+ import { useCallback, useMemo as useMemo2 } from "react";
974
+ import { PencilSquare as PencilSquare4, Trash as Trash2 } from "@medusajs/icons";
975
+ import {
976
+ Badge as Badge2,
977
+ Button as Button3,
978
+ Container as Container5,
979
+ createDataTableColumnHelper,
980
+ Heading as Heading5,
981
+ toast as toast2,
982
+ Tooltip as Tooltip3,
983
+ usePrompt as usePrompt4
984
+ } from "@medusajs/ui";
985
+ import { keepPreviousData } from "@tanstack/react-query";
986
+ import { useTranslation as useTranslation5 } from "react-i18next";
987
+ import { Link as Link3, useNavigate as useNavigate2, useSearchParams } from "react-router-dom";
988
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
989
+ var PAGE_SIZE = 10;
990
+ var PREFIX = "pv";
991
+ var ProductVariantSection = ({
992
+ product
993
+ }) => {
994
+ const { t } = useTranslation5();
995
+ const { q, order, offset, created_at, updated_at } = useQueryParams(
996
+ ["q", "order", "offset", "created_at", "updated_at"],
997
+ PREFIX
998
+ );
999
+ const columns = useColumns(product);
1000
+ const filters = useFilters();
1001
+ const { variants, count, isPending, isError, error } = useProductVariants(
1002
+ product.id,
1003
+ {
1004
+ q,
1005
+ order: order ? order : "variant_rank",
1006
+ offset: offset ? parseInt(offset) : void 0,
1007
+ limit: PAGE_SIZE,
1008
+ created_at: created_at ? JSON.parse(created_at) : void 0,
1009
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0,
1010
+ fields: "title,sku,created_at,updated_at,*options,*options.option"
1011
+ },
1012
+ {
1013
+ placeholderData: keepPreviousData
1014
+ }
1015
+ );
1016
+ if (isError) {
1017
+ throw error;
1018
+ }
1019
+ return /* @__PURE__ */ jsxs5(Container5, { className: "divide-y p-0", "data-testid": "product-variant-section", children: [
1020
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between px-6 py-4", children: [
1021
+ /* @__PURE__ */ jsx5(Heading5, { level: "h2", children: t("products.variants.header") }),
1022
+ /* @__PURE__ */ jsx5(
1023
+ Button3,
1024
+ {
1025
+ size: "small",
1026
+ variant: "secondary",
1027
+ asChild: true,
1028
+ "data-testid": "product-variants-create-button",
1029
+ children: /* @__PURE__ */ jsx5(Link3, { to: "variants/create", children: t("actions.create") })
1030
+ }
1031
+ )
1032
+ ] }),
1033
+ /* @__PURE__ */ jsx5("div", { "data-testid": "product-variants-table-container", children: /* @__PURE__ */ jsx5(
1034
+ DataTable,
1035
+ {
1036
+ data: variants,
1037
+ columns,
1038
+ filters,
1039
+ rowCount: count,
1040
+ getRowId: (row) => row.id,
1041
+ rowHref: (row) => `/products/${product.id}/variants/${row.id}`,
1042
+ pageSize: PAGE_SIZE,
1043
+ isLoading: isPending,
1044
+ compact: true,
1045
+ emptyState: {
1046
+ empty: {
1047
+ heading: t("products.variants.empty.heading"),
1048
+ description: t("products.variants.empty.description")
1049
+ },
1050
+ filtered: {
1051
+ heading: t("products.variants.filtered.heading"),
1052
+ description: t("products.variants.filtered.description")
1053
+ }
1054
+ },
1055
+ prefix: PREFIX
1056
+ }
1057
+ ) })
1058
+ ] });
1059
+ };
1060
+ var columnHelper = createDataTableColumnHelper();
1061
+ var useColumns = (product) => {
1062
+ const { t } = useTranslation5();
1063
+ const navigate = useNavigate2();
1064
+ const { mutateAsync } = useDeleteVariantLazy(product.id);
1065
+ const prompt = usePrompt4();
1066
+ const [searchParams] = useSearchParams();
1067
+ const tableSearchParams = useMemo2(() => {
1068
+ const filtered = new URLSearchParams();
1069
+ for (const [key, value] of searchParams.entries()) {
1070
+ if (key.startsWith(`${PREFIX}_`)) {
1071
+ filtered.append(key, value);
1072
+ }
1073
+ }
1074
+ return filtered;
1075
+ }, [searchParams]);
1076
+ const dateColumns = useDataTableDateColumns();
1077
+ const handleDelete = useCallback(
1078
+ async (id, title) => {
1079
+ const res = await prompt({
1080
+ title: t("general.areYouSure"),
1081
+ description: t("products.deleteVariantWarning", {
1082
+ title
1083
+ }),
1084
+ confirmText: t("actions.delete"),
1085
+ cancelText: t("actions.cancel")
1086
+ });
1087
+ if (!res) {
1088
+ return;
1089
+ }
1090
+ await mutateAsync(
1091
+ { variantId: id },
1092
+ {
1093
+ onError: (error) => {
1094
+ toast2.error(error.message);
1095
+ }
1096
+ }
1097
+ );
1098
+ },
1099
+ [mutateAsync, prompt, t]
1100
+ );
1101
+ const attributeColumns = useMemo2(() => {
1102
+ const variantAttributes = product?.attributes?.filter((attr) => attr.is_variant_axis);
1103
+ if (!variantAttributes?.length) {
1104
+ return [];
1105
+ }
1106
+ return variantAttributes.map((attribute) => {
1107
+ return columnHelper.display({
1108
+ id: `attribute-${attribute.id}`,
1109
+ header: attribute.name,
1110
+ cell: ({ row }) => {
1111
+ const variantOpt = row.original.options?.find(
1112
+ (opt) => opt.option?.title === attribute.name
1113
+ );
1114
+ if (!variantOpt?.value) {
1115
+ return /* @__PURE__ */ jsx5("span", { className: "text-ui-fg-muted", children: "-" });
1116
+ }
1117
+ return /* @__PURE__ */ jsx5(
1118
+ "div",
1119
+ {
1120
+ className: "flex flex-wrap items-center gap-1",
1121
+ "data-testid": `product-variant-attribute-${attribute.id}-${row.original.id}`,
1122
+ children: /* @__PURE__ */ jsx5(Tooltip3, { content: variantOpt.value, children: /* @__PURE__ */ jsx5(
1123
+ Badge2,
1124
+ {
1125
+ size: "2xsmall",
1126
+ title: variantOpt.value,
1127
+ className: "inline-flex min-w-[20px] max-w-[140px] items-center justify-center overflow-hidden truncate",
1128
+ "data-testid": `product-variant-attribute-badge-${attribute.id}-${row.original.id}-${variantOpt.value}`,
1129
+ children: variantOpt.value
1130
+ }
1131
+ ) })
1132
+ }
1133
+ );
1134
+ }
1135
+ });
1136
+ });
1137
+ }, [product]);
1138
+ const getActions = useCallback(
1139
+ (_ctx) => {
1140
+ const variant = _ctx.row.original;
1141
+ const mainActions = [
1142
+ {
1143
+ icon: /* @__PURE__ */ jsx5(PencilSquare4, {}),
1144
+ label: t("actions.edit"),
1145
+ onClick: (row) => {
1146
+ navigate(
1147
+ `edit-variant?variant_id=${row.row.original.id}&${tableSearchParams.toString()}`,
1148
+ {
1149
+ state: {
1150
+ restore_params: tableSearchParams.toString()
1151
+ }
1152
+ }
1153
+ );
1154
+ }
1155
+ }
1156
+ ];
1157
+ const secondaryActions = [
1158
+ {
1159
+ icon: /* @__PURE__ */ jsx5(Trash2, {}),
1160
+ label: t("actions.delete"),
1161
+ onClick: () => handleDelete(variant.id, variant.title)
1162
+ }
1163
+ ];
1164
+ return [mainActions, secondaryActions];
1165
+ },
1166
+ [handleDelete, navigate, t, tableSearchParams]
1167
+ );
1168
+ return useMemo2(() => {
1169
+ return [
1170
+ columnHelper.accessor("title", {
1171
+ header: t("fields.title"),
1172
+ enableSorting: true,
1173
+ sortAscLabel: t("filters.sorting.alphabeticallyAsc"),
1174
+ sortDescLabel: t("filters.sorting.alphabeticallyDesc")
1175
+ }),
1176
+ columnHelper.accessor("sku", {
1177
+ header: t("fields.sku"),
1178
+ cell: ({ getValue }) => {
1179
+ const value = getValue();
1180
+ return value ? value : /* @__PURE__ */ jsx5("span", { className: "text-ui-fg-muted", children: "-" });
1181
+ }
1182
+ }),
1183
+ ...attributeColumns,
1184
+ ...dateColumns,
1185
+ columnHelper.action({
1186
+ actions: getActions
1187
+ })
1188
+ ];
1189
+ }, [t, attributeColumns, dateColumns, getActions]);
1190
+ };
1191
+ var useFilters = () => {
1192
+ const dateFilters = useDataTableDateFilters();
1193
+ return useMemo2(() => {
1194
+ return [...dateFilters];
1195
+ }, [dateFilters]);
1196
+ };
1197
+
1198
+ // src/pages/products/[id]/_components/product-attribute-section/product-attribute-section.tsx
1199
+ import {
1200
+ ListBullet,
1201
+ Plus,
1202
+ Trash as Trash3,
1203
+ Swatch,
1204
+ DropCap,
1205
+ InformationCircleSolid,
1206
+ PencilSquare as PencilSquare5
1207
+ } from "@medusajs/icons";
1208
+ import {
1209
+ Badge as Badge3,
1210
+ Container as Container6,
1211
+ Heading as Heading6,
1212
+ Text as Text3,
1213
+ toast as toast3,
1214
+ Tooltip as Tooltip4,
1215
+ usePrompt as usePrompt5
1216
+ } from "@medusajs/ui";
1217
+ import { useTranslation as useTranslation6 } from "react-i18next";
1218
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1219
+ var AttributeActions = ({
1220
+ productId,
1221
+ attribute
1222
+ }) => {
1223
+ const { t } = useTranslation6();
1224
+ const prompt = usePrompt5();
1225
+ const { mutateAsync } = useRemoveProductAttribute(productId, attribute.id);
1226
+ const handleDelete = async () => {
1227
+ const res = await prompt({
1228
+ title: t("general.areYouSure"),
1229
+ description: t("products.deleteAttributeWarning", {
1230
+ title: attribute.name
1231
+ }),
1232
+ confirmText: t("actions.delete"),
1233
+ cancelText: t("actions.cancel")
1234
+ });
1235
+ if (!res) {
1236
+ return;
1237
+ }
1238
+ await mutateAsync(void 0, {
1239
+ onError: (error) => {
1240
+ toast3.error(error.message);
1241
+ }
1242
+ });
1243
+ };
1244
+ return /* @__PURE__ */ jsx6(
1245
+ ActionMenu,
1246
+ {
1247
+ groups: [
1248
+ {
1249
+ actions: [
1250
+ {
1251
+ label: t("actions.edit"),
1252
+ to: `attributes/${attribute.id}/edit`,
1253
+ icon: /* @__PURE__ */ jsx6(PencilSquare5, {})
1254
+ }
1255
+ ]
1256
+ },
1257
+ {
1258
+ actions: [
1259
+ {
1260
+ label: t("actions.delete"),
1261
+ onClick: handleDelete,
1262
+ icon: /* @__PURE__ */ jsx6(Trash3, {}),
1263
+ disabled: attribute.is_required,
1264
+ disabledTooltip: attribute.is_required ? t("products.attributeRequiredDeleteDisabledTooltip") : void 0
1265
+ }
1266
+ ]
1267
+ }
1268
+ ]
1269
+ }
1270
+ );
1271
+ };
1272
+ var AttributeGroup = ({
1273
+ icon,
1274
+ title,
1275
+ description,
1276
+ attributes,
1277
+ productId
1278
+ }) => {
1279
+ const { t } = useTranslation6();
1280
+ if (!attributes.length) {
1281
+ return null;
1282
+ }
1283
+ return /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-y-4 px-3 py-4", children: [
1284
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-3 px-3", children: [
1285
+ /* @__PURE__ */ jsx6("div", { className: "text-ui-fg-muted flex h-8 w-8 items-center justify-center rounded-lg border border-ui-border-base bg-ui-bg-component", children: icon }),
1286
+ /* @__PURE__ */ jsxs6("div", { children: [
1287
+ /* @__PURE__ */ jsx6(Text3, { size: "small", weight: "plus", leading: "compact", children: title }),
1288
+ /* @__PURE__ */ jsx6(Text3, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: description })
1289
+ ] })
1290
+ ] }),
1291
+ /* @__PURE__ */ jsx6("div", { className: "flex flex-col gap-y-0", children: /* @__PURE__ */ jsx6("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: attributes.map((attr, index) => {
1292
+ const values = attr.values?.map((v) => v.name) ?? [];
1293
+ return /* @__PURE__ */ jsx6(
1294
+ "div",
1295
+ {
1296
+ className: index < attributes.length - 1 ? "border-b border-ui-border-base" : "",
1297
+ children: /* @__PURE__ */ jsxs6("div", { className: "grid grid-cols-[1fr_1fr_28px] items-center gap-4 bg-ui-bg-component px-4 py-3", children: [
1298
+ /* @__PURE__ */ jsxs6("div", { className: "text-ui-fg-subtle flex items-center gap-x-2", children: [
1299
+ /* @__PURE__ */ jsx6(Text3, { size: "small", weight: "plus", leading: "compact", children: attr.name }),
1300
+ attr.description && /* @__PURE__ */ jsx6(Tooltip4, { content: attr.description, children: /* @__PURE__ */ jsx6("span", { className: "text-ui-fg-muted flex items-center", children: /* @__PURE__ */ jsx6(InformationCircleSolid, {}) }) }),
1301
+ attr.is_required && /* @__PURE__ */ jsx6(
1302
+ Tooltip4,
1303
+ {
1304
+ content: t("products.attributeRequiredByMarketplace"),
1305
+ children: /* @__PURE__ */ jsx6("span", { className: "text-ui-fg-muted flex items-center", children: /* @__PURE__ */ jsx6(InformationCircleSolid, {}) })
1306
+ }
1307
+ )
1308
+ ] }),
1309
+ /* @__PURE__ */ jsx6("div", { className: "flex flex-wrap gap-1", children: ["single_select", "multi_select"].includes(attr.type) ? values.map((val) => /* @__PURE__ */ jsx6(
1310
+ Badge3,
1311
+ {
1312
+ size: "2xsmall",
1313
+ className: "flex min-w-[20px] items-center justify-center",
1314
+ children: val
1315
+ },
1316
+ val
1317
+ )) : /* @__PURE__ */ jsx6(
1318
+ Text3,
1319
+ {
1320
+ size: "small",
1321
+ leading: "compact",
1322
+ className: "text-ui-fg-subtle",
1323
+ children: values.join(", ") || "-"
1324
+ }
1325
+ ) }),
1326
+ /* @__PURE__ */ jsx6(AttributeActions, { productId, attribute: attr })
1327
+ ] })
1328
+ },
1329
+ attr.id
1330
+ );
1331
+ }) }) })
1332
+ ] });
1333
+ };
1334
+ var ProductAttributeSection = ({
1335
+ product
1336
+ }) => {
1337
+ const { t } = useTranslation6();
1338
+ const allAttributes = product.attributes ?? [];
1339
+ const variantAttributes = allAttributes.filter((a) => a.is_variant_axis);
1340
+ const infoAttributes = allAttributes.filter((a) => !a.is_variant_axis);
1341
+ const isEmpty = !variantAttributes.length && !infoAttributes.length;
1342
+ return /* @__PURE__ */ jsxs6(Container6, { className: "p-0", children: [
1343
+ /* @__PURE__ */ jsxs6(
1344
+ "div",
1345
+ {
1346
+ className: `flex items-center justify-between px-6 py-4${isEmpty ? "" : " border-b border-ui-border-base"}`,
1347
+ children: [
1348
+ /* @__PURE__ */ jsx6(Heading6, { level: "h2", children: t("products.attributes") }),
1349
+ /* @__PURE__ */ jsx6(
1350
+ ActionMenu,
1351
+ {
1352
+ groups: [
1353
+ {
1354
+ actions: [
1355
+ {
1356
+ label: t("products.create.attributes.addExisting"),
1357
+ to: "attributes/add",
1358
+ icon: /* @__PURE__ */ jsx6(ListBullet, {})
1359
+ },
1360
+ {
1361
+ label: t("products.create.attributes.createNew"),
1362
+ to: "attributes/create",
1363
+ icon: /* @__PURE__ */ jsx6(Plus, {})
1364
+ }
1365
+ ]
1366
+ }
1367
+ ]
1368
+ }
1369
+ )
1370
+ ]
1371
+ }
1372
+ ),
1373
+ variantAttributes.length > 0 && /* @__PURE__ */ jsx6(
1374
+ AttributeGroup,
1375
+ {
1376
+ icon: /* @__PURE__ */ jsx6(Swatch, {}),
1377
+ title: t("products.create.tabs.variants"),
1378
+ description: t("products.attributeVariantsDescription"),
1379
+ attributes: variantAttributes,
1380
+ productId: product.id
1381
+ }
1382
+ ),
1383
+ variantAttributes.length > 0 && infoAttributes.length > 0 && /* @__PURE__ */ jsx6("div", { className: "border-t border-dashed border-ui-border-base" }),
1384
+ infoAttributes.length > 0 && /* @__PURE__ */ jsx6(
1385
+ AttributeGroup,
1386
+ {
1387
+ icon: /* @__PURE__ */ jsx6(DropCap, {}),
1388
+ title: t("products.attributeProductInformation"),
1389
+ description: t("products.attributeProductInformationDescription"),
1390
+ attributes: infoAttributes,
1391
+ productId: product.id
1392
+ }
1393
+ )
1394
+ ] });
1395
+ };
1396
+
1397
+ // src/pages/products/[id]/_components/product-shipping-profile-section/product-shipping-profile-section.tsx
1398
+ import { PencilSquare as PencilSquare6, ShoppingBag } from "@medusajs/icons";
1399
+ import { Container as Container7, Heading as Heading7 } from "@medusajs/ui";
1400
+ import { useTranslation as useTranslation7 } from "react-i18next";
1401
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1402
+ var ProductShippingProfileSection = ({
1403
+ product
1404
+ }) => {
1405
+ const { t } = useTranslation7();
1406
+ const shippingProfile = product.shipping_profile;
1407
+ return /* @__PURE__ */ jsxs7(Container7, { className: "p-0", children: [
1408
+ /* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between px-6 py-4", children: [
1409
+ /* @__PURE__ */ jsx7(Heading7, { level: "h2", children: t("products.shippingProfile.header") }),
1410
+ /* @__PURE__ */ jsx7(
1411
+ ActionMenu,
1412
+ {
1413
+ groups: [
1414
+ {
1415
+ actions: [
1416
+ {
1417
+ label: t("actions.edit"),
1418
+ to: "shipping-profile",
1419
+ icon: /* @__PURE__ */ jsx7(PencilSquare6, {})
1420
+ }
1421
+ ]
1422
+ }
1423
+ ]
1424
+ }
1425
+ )
1426
+ ] }),
1427
+ shippingProfile && /* @__PURE__ */ jsx7(
1428
+ SidebarLink,
1429
+ {
1430
+ to: `/settings/locations/shipping-profiles/${shippingProfile.id}`,
1431
+ labelKey: shippingProfile.name,
1432
+ descriptionKey: shippingProfile.type,
1433
+ icon: /* @__PURE__ */ jsx7(ShoppingBag, {})
1434
+ }
1435
+ )
1436
+ ] });
1437
+ };
1438
+
1439
+ // src/pages/products/[id]/_components/product-sales-channel-section/product-sales-channel-section.tsx
1440
+ import { Channels, PencilSquare as PencilSquare7 } from "@medusajs/icons";
1441
+ import { Container as Container8, Heading as Heading8, Text as Text4, Tooltip as Tooltip5 } from "@medusajs/ui";
1442
+ import { Trans, useTranslation as useTranslation8 } from "react-i18next";
1443
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1444
+ var ProductSalesChannelSection = ({
1445
+ product
1446
+ }) => {
1447
+ const { count } = useSalesChannels();
1448
+ const { t } = useTranslation8();
1449
+ const availableInSalesChannels = product.sales_channels?.map((sc) => ({
1450
+ id: sc.id,
1451
+ name: sc.name
1452
+ })) ?? [];
1453
+ const firstChannels = availableInSalesChannels.slice(0, 3);
1454
+ const restChannels = availableInSalesChannels.slice(3);
1455
+ return /* @__PURE__ */ jsxs8(Container8, { className: "flex flex-col gap-y-4 px-6 py-4", children: [
1456
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
1457
+ /* @__PURE__ */ jsx8(Heading8, { level: "h2", children: t("fields.sales_channels") }),
1458
+ /* @__PURE__ */ jsx8(
1459
+ ActionMenu,
1460
+ {
1461
+ groups: [
1462
+ {
1463
+ actions: [
1464
+ {
1465
+ label: t("actions.edit"),
1466
+ to: "sales-channels",
1467
+ icon: /* @__PURE__ */ jsx8(PencilSquare7, {})
1468
+ }
1469
+ ]
1470
+ }
1471
+ ]
1472
+ }
1473
+ )
1474
+ ] }),
1475
+ /* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-[28px_1fr] items-center gap-x-3", children: [
1476
+ /* @__PURE__ */ jsx8("div", { className: "bg-ui-bg-base shadow-borders-base flex size-7 items-center justify-center rounded-md", children: /* @__PURE__ */ jsx8("div", { className: "bg-ui-bg-component flex size-6 items-center justify-center rounded-[4px]", children: /* @__PURE__ */ jsx8(Channels, { className: "text-ui-fg-subtle" }) }) }),
1477
+ availableInSalesChannels.length > 0 ? /* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-x-1", children: [
1478
+ /* @__PURE__ */ jsx8(Text4, { size: "small", leading: "compact", children: firstChannels.map((sc) => sc.name).join(", ") }),
1479
+ restChannels.length > 0 && /* @__PURE__ */ jsx8(
1480
+ Tooltip5,
1481
+ {
1482
+ content: /* @__PURE__ */ jsx8("ul", { children: restChannels.map((sc) => /* @__PURE__ */ jsx8("li", { children: sc.name }, sc.id)) }),
1483
+ children: /* @__PURE__ */ jsx8(
1484
+ Text4,
1485
+ {
1486
+ size: "small",
1487
+ leading: "compact",
1488
+ className: "text-ui-fg-subtle",
1489
+ children: `+${restChannels.length}`
1490
+ }
1491
+ )
1492
+ }
1493
+ )
1494
+ ] }) : /* @__PURE__ */ jsx8(Text4, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: t("products.noSalesChannels") })
1495
+ ] }),
1496
+ /* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(Text4, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: /* @__PURE__ */ jsx8(
1497
+ Trans,
1498
+ {
1499
+ i18nKey: "sales_channels.availableIn",
1500
+ values: {
1501
+ x: availableInSalesChannels.length,
1502
+ y: count ?? 0
1503
+ },
1504
+ components: [
1505
+ /* @__PURE__ */ jsx8(
1506
+ "span",
1507
+ {
1508
+ className: "text-ui-fg-base txt-compact-medium-plus"
1509
+ },
1510
+ "x"
1511
+ ),
1512
+ /* @__PURE__ */ jsx8(
1513
+ "span",
1514
+ {
1515
+ className: "text-ui-fg-base txt-compact-medium-plus"
1516
+ },
1517
+ "y"
1518
+ )
1519
+ ]
1520
+ }
1521
+ ) }) })
1522
+ ] });
1523
+ };
1524
+
1525
+ // src/pages/products/[id]/product-detail-page.tsx
1526
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
1527
+ var Root = ({ children }) => {
1528
+ const initialData = useLoaderData();
1529
+ const { id } = useParams();
1530
+ const { product, isLoading, isError, error } = useProduct(
1531
+ id,
1532
+ PRODUCT_DETAIL_QUERY,
1533
+ {
1534
+ initialData
1535
+ }
1536
+ );
1537
+ if (isLoading || !product) {
1538
+ return /* @__PURE__ */ jsx9(TwoColumnPageSkeleton, { mainSections: 4, sidebarSections: 3 });
1539
+ }
1540
+ if (isError) {
1541
+ throw error;
1542
+ }
1543
+ return Children.count(children) > 0 ? /* @__PURE__ */ jsx9(TwoColumnPage, { data: product, "data-testid": "product-detail-page", children }) : /* @__PURE__ */ jsxs9(TwoColumnPage, { data: product, "data-testid": "product-detail-page", children: [
1544
+ /* @__PURE__ */ jsxs9(TwoColumnPage.Main, { "data-testid": "product-detail-main", children: [
1545
+ /* @__PURE__ */ jsx9(ProductActiveEditSection, { product }),
1546
+ /* @__PURE__ */ jsx9(ProductGeneralSection, { product }),
1547
+ /* @__PURE__ */ jsx9(ProductMediaSection, { product }),
1548
+ /* @__PURE__ */ jsx9(ProductVariantSection, { product })
1549
+ ] }),
1550
+ /* @__PURE__ */ jsxs9(TwoColumnPage.Sidebar, { "data-testid": "product-detail-sidebar", children: [
1551
+ /* @__PURE__ */ jsx9(ProductOrganizationSection, { product }),
1552
+ /* @__PURE__ */ jsx9(ProductAttributeSection, { product })
1553
+ ] })
1554
+ ] });
1555
+ };
1556
+ var ProductDetailPage = Object.assign(Root, {
1557
+ Main: TwoColumnPage.Main,
1558
+ Sidebar: TwoColumnPage.Sidebar,
1559
+ MainActiveEditSection: ProductActiveEditSection,
1560
+ MainGeneralSection: ProductGeneralSection,
1561
+ MainMediaSection: ProductMediaSection,
1562
+ MainVariantSection: ProductVariantSection,
1563
+ MainAttributeSection: ProductAttributeSection,
1564
+ SidebarShippingProfileSection: ProductShippingProfileSection,
1565
+ SidebarOrganizationSection: ProductOrganizationSection,
1566
+ SidebarSalesChannelSection: ProductSalesChannelSection
1567
+ });
1568
+ export {
1569
+ ProductDetailPage,
1570
+ loader
1571
+ };