@mercurjs/admin 2.1.2 → 2.2.0-canary.1
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.
- package/dist/[id]-YI7UXOO2.js +499 -0
- package/dist/{add-campaign-promotions-6Z2STQT4.js → add-campaign-promotions-OLNTDP26.js} +14 -16
- package/dist/{adjust-inventory-NVBPZYOF.js → adjust-inventory-CVWSBMHU.js} +13 -12
- package/dist/{api-key-management-create-THDCXGWK.js → api-key-management-create-7RWOCVAO.js} +3 -3
- package/dist/{api-key-management-detail-IRYR6J2I.js → api-key-management-detail-ZIIDMHFI.js} +24 -23
- package/dist/{api-key-management-edit-LTVNXP6T.js → api-key-management-edit-ACH6TJAX.js} +3 -3
- package/dist/{api-key-management-list-4WCDP4B3.js → api-key-management-list-JHBBXGHH.js} +11 -13
- package/dist/{api-key-management-sales-channels-NVFG2ESH.js → api-key-management-sales-channels-XEBTUB5V.js} +15 -15
- package/dist/attribute-create-BYO7BDF5.js +562 -0
- package/dist/attribute-create-possible-value-EXVHC272.js +476 -0
- package/dist/{attribute-detail-R26GDX7Q.js → attribute-detail-36XP35P6.js} +74 -64
- package/dist/attribute-edit-WMJWHT7Z.js +183 -0
- package/dist/attribute-edit-possible-value-KTUZ7YLW.js +164 -0
- package/dist/{attribute-edit-ranking-CEBR5LJ7.js → attribute-edit-ranking-7AAAYEC7.js} +66 -61
- package/dist/{attribute-list-XR7OSL2H.js → attribute-list-OHU2QMUG.js} +24 -26
- package/dist/{campaign-create-AZTR5UZP.js → campaign-create-VFFIIRE4.js} +4 -4
- package/dist/{campaign-detail-TCPO6DTI.js → campaign-detail-AZKBPDLC.js} +27 -28
- package/dist/{campaign-list-DCLVAFEM.js → campaign-list-NQGNOFVZ.js} +10 -12
- package/dist/{categories-metadata-YVUNHMQT.js → categories-metadata-YZUP43OH.js} +17 -16
- package/dist/{category-create-DG3Z5RYE.js → category-create-2MRYTSYM.js} +4 -4
- package/dist/{category-detail-K2UNFPRV.js → category-detail-KTFD3VVR.js} +29 -28
- package/dist/{category-edit-IXU6E3YT.js → category-edit-QLOS2LBA.js} +5 -5
- package/dist/{category-list-2MG37UXJ.js → category-list-U7ZQBSZN.js} +11 -13
- package/dist/{category-organize-CCX2INRS.js → category-organize-TIKTYJFZ.js} +2 -2
- package/dist/{category-products-LKT7564A.js → category-products-7P5DSQN4.js} +30 -29
- package/dist/{chunk-6YGOXPB5.js → chunk-2LQ5SCPB.js} +5 -5
- package/dist/{chunk-ZZO3INVE.js → chunk-2MDGYHWN.js} +128 -25
- package/dist/{chunk-X3YEY2PY.js → chunk-2S6VXFBZ.js} +8 -8
- package/dist/{chunk-5CK6XEFV.js → chunk-2YYXP6XI.js} +183 -111
- package/dist/{chunk-GAD5DQOY.js → chunk-3EDQIZV6.js} +2 -2
- package/dist/{chunk-4IZ2RD3L.js → chunk-3IVTUFBM.js} +8 -8
- package/dist/{chunk-7YHAFHGI.js → chunk-3JSAS7QP.js} +92 -165
- package/dist/{chunk-DVKO4VRC.js → chunk-3P4VTL4S.js} +12 -12
- package/dist/{chunk-GJPGL7RP.js → chunk-3VTAK3S6.js} +108 -28
- package/dist/{chunk-C3WE6EFO.js → chunk-4YWKKCTT.js} +1 -2
- package/dist/chunk-533GMKEG.js +125 -0
- package/dist/chunk-57BHSFNA.js +101 -0
- package/dist/{chunk-AEFDAU3Y.js → chunk-5KGMGL4N.js} +4 -24
- package/dist/{chunk-VGM5UQRA.js → chunk-637OFDFC.js} +809 -306
- package/dist/{chunk-NRJ7F7JW.js → chunk-6AZKWCVL.js} +14 -14
- package/dist/{chunk-JCSPXBS3.js → chunk-6FIU2V6Y.js} +1 -1
- package/dist/chunk-77T2UI6L.js +1671 -0
- package/dist/{chunk-B6SYYKJI.js → chunk-A4UQKKGC.js} +13 -13
- package/dist/{chunk-B6FG7A6W.js → chunk-A772RAKB.js} +1 -1
- package/dist/{chunk-35Q6JF3S.js → chunk-A7JOHU6Q.js} +4 -4
- package/dist/{chunk-N57BOIPU.js → chunk-AB2LHP3M.js} +1 -1
- package/dist/chunk-ABFL4ACD.js +207 -0
- package/dist/{chunk-HY3CV5V6.js → chunk-AKTAFKIU.js} +4 -4
- package/dist/{chunk-N23OD7WS.js → chunk-ALATTLBM.js} +7 -7
- package/dist/{chunk-PBQ5M44A.js → chunk-AXTQMIIK.js} +13 -30
- package/dist/{chunk-TAKEQAZZ.js → chunk-B3EEDC47.js} +2 -2
- package/dist/{chunk-EWMEXGFZ.js → chunk-BCVUMATY.js} +18 -18
- package/dist/{chunk-34I4QIBD.js → chunk-BE6JLTMI.js} +1 -1
- package/dist/{chunk-V7EPLR3E.js → chunk-BFT3CN5L.js} +10 -10
- package/dist/{chunk-O5YFLNSQ.js → chunk-BGGUVHDG.js} +27 -27
- package/dist/{chunk-HGULM6DF.js → chunk-BGQ7H2KL.js} +10 -10
- package/dist/{chunk-3DOCALSU.js → chunk-BHOZKBYY.js} +395 -11
- package/dist/{chunk-KHHMQM2L.js → chunk-BLYJZMNE.js} +5 -5
- package/dist/chunk-CBG4E3M3.js +165 -0
- package/dist/{chunk-5ZBQICCP.js → chunk-CBGXKU7Z.js} +18 -18
- package/dist/{chunk-LFATSJPO.js → chunk-CKACZXMP.js} +9 -9
- package/dist/{chunk-GXRLLA5H.js → chunk-CKD5563X.js} +4 -4
- package/dist/{chunk-E3DLJSYD.js → chunk-COP7NFSJ.js} +1 -1
- package/dist/{chunk-ABUQBBEM.js → chunk-CVFVEDMV.js} +4 -4
- package/dist/chunk-CYGIJOA5.js +79 -0
- package/dist/{chunk-CXO3C3L2.js → chunk-D5T7QOVY.js} +11 -11
- package/dist/{chunk-ARMGWHYU.js → chunk-DOSKHIRH.js} +16 -16
- package/dist/{chunk-UEEYZGM3.js → chunk-DRJAKRTI.js} +46 -17
- package/dist/{chunk-NEN6KWAJ.js → chunk-ED7XNGZD.js} +12 -12
- package/dist/{chunk-W576GZBG.js → chunk-EJTB2SLE.js} +9 -9
- package/dist/{chunk-32OKBVER.js → chunk-ELM74U2R.js} +5 -5
- package/dist/chunk-EREXPX6I.js +348 -0
- package/dist/{chunk-MNYDJXTM.js → chunk-FB7DDNCA.js} +5 -5
- package/dist/{chunk-GZBVMHXS.js → chunk-FFNSWUDC.js} +10 -10
- package/dist/{chunk-YKDEE7ZL.js → chunk-FTAR3BDS.js} +1 -1
- package/dist/{chunk-2OYCT5NO.js → chunk-G4PROEJI.js} +5 -5
- package/dist/{chunk-OQMBWJPH.js → chunk-GKW445WA.js} +1 -1
- package/dist/{chunk-LNAXUDW2.js → chunk-GLPS6QFG.js} +64 -62
- package/dist/{chunk-3IN6MMKV.js → chunk-GNLPUGYK.js} +2 -2
- package/dist/{chunk-3IBSB2U6.js → chunk-H23AKDB2.js} +14 -14
- package/dist/{chunk-Z2QQZOG3.js → chunk-H5PYBIOZ.js} +1 -1
- package/dist/{chunk-63OSYRLS.js → chunk-HR7TFO2X.js} +4 -4
- package/dist/{chunk-XB3HXEZB.js → chunk-HWBUIBJD.js} +77 -72
- package/dist/{chunk-4Q7LZQVY.js → chunk-IAWZQKUH.js} +10 -10
- package/dist/{chunk-2U5BRCQO.js → chunk-IEPNHH7Z.js} +1 -1
- package/dist/chunk-IIFQ7KYL.js +171 -0
- package/dist/{chunk-HNUA6XIW.js → chunk-IRTI3AS3.js} +14 -14
- package/dist/chunk-J65IXAGI.js +292 -0
- package/dist/{chunk-VIGX66F7.js → chunk-JQBSPUH2.js} +1 -1
- package/dist/{chunk-4ZN3D4YS.js → chunk-K4TGNN4P.js} +9 -9
- package/dist/{chunk-R46PKJUT.js → chunk-KXIA66EJ.js} +13 -13
- package/dist/{chunk-CIH5DSU7.js → chunk-LCGLQNOI.js} +11 -11
- package/dist/{chunk-RE3AYHPM.js → chunk-LLOKYZMI.js} +4 -4
- package/dist/chunk-LT3REHJG.js +2355 -0
- package/dist/{chunk-VVWB3GIK.js → chunk-LYZDVZWA.js} +3 -12
- package/dist/{chunk-AZAGUAN4.js → chunk-MN3AEVR7.js} +15 -15
- package/dist/{chunk-J24X54DB.js → chunk-MVNO35S5.js} +7 -7
- package/dist/{chunk-PIZ7FN3L.js → chunk-N2LH7A4X.js} +9 -9
- package/dist/{chunk-SPIVEW2Y.js → chunk-NQBSSM5V.js} +8 -8
- package/dist/{chunk-HKDFWQ6Q.js → chunk-NQEXDLYH.js} +460 -2
- package/dist/{chunk-HO7Z6MC3.js → chunk-NZ2LHIKD.js} +33 -33
- package/dist/{chunk-DBNPVU3L.js → chunk-OSEIN4Y2.js} +1 -1
- package/dist/{chunk-XBHUWCBD.js → chunk-P25PIADJ.js} +1 -1
- package/dist/{chunk-GPKTJXGG.js → chunk-PCLSODMO.js} +32 -32
- package/dist/{chunk-WRRMBJBQ.js → chunk-PXTJJQKJ.js} +1 -1
- package/dist/chunk-PYDRHQTY.js +24 -0
- package/dist/{chunk-ORI7UXS6.js → chunk-Q6I2IKJB.js} +6 -6
- package/dist/{chunk-X4DGVTMC.js → chunk-QIU6DJY6.js} +5 -5
- package/dist/{chunk-F67RRVMJ.js → chunk-RKH3A4O3.js} +13 -13
- package/dist/chunk-RQ4NMLSS.js +8 -0
- package/dist/{chunk-7QWLLYOY.js → chunk-RQPDD3RI.js} +1 -1
- package/dist/{chunk-DL2ZIXBO.js → chunk-S5BJ5CMF.js} +1 -1
- package/dist/chunk-SG76L7C7.js +61 -0
- package/dist/{chunk-3ZSYFPHB.js → chunk-SRDK3XX7.js} +20 -20
- package/dist/{chunk-SJQG3RCN.js → chunk-TGFZ4UBK.js} +19 -19
- package/dist/{chunk-WIQ2HBJG.js → chunk-TITPJHIL.js} +13 -13
- package/dist/{chunk-SOJ4TLWP.js → chunk-TP7L6M7V.js} +5 -5
- package/dist/{chunk-OG4WH7IW.js → chunk-U7XILJH6.js} +35 -32
- package/dist/{chunk-7MTFPHXR.js → chunk-UPNMDPFX.js} +6 -6
- package/dist/{chunk-7XXM72CF.js → chunk-UR6HGBFE.js} +62 -89
- package/dist/{chunk-5OS2MBRB.js → chunk-UXQAHUGZ.js} +8 -8
- package/dist/chunk-V5XHY5LP.js +39 -0
- package/dist/{chunk-NHAOR25V.js → chunk-W7NN2EFL.js} +20 -20
- package/dist/{chunk-YEUUI6JF.js → chunk-WDH5C2NS.js} +1 -1
- package/dist/{chunk-BEU674HI.js → chunk-WKCYMDTV.js} +5 -5
- package/dist/{chunk-M73MP4NC.js → chunk-WNYDGJ3E.js} +19 -19
- package/dist/{chunk-6MJ5HPIP.js → chunk-WS63IRBI.js} +3 -3
- package/dist/chunk-WV4SQ57G.js +141 -0
- package/dist/{chunk-Y3FXVIJO.js → chunk-WVKVPGJW.js} +4 -4
- package/dist/{chunk-GDHF6CT5.js → chunk-X45JKZYW.js} +11 -11
- package/dist/{chunk-GKJLFLGN.js → chunk-XJ3WC4G7.js} +4 -4
- package/dist/{chunk-4LQX5FRH.js → chunk-XODRTI2W.js} +7 -7
- package/dist/{chunk-U7WZYWGA.js → chunk-XZZTC7E5.js} +1 -1
- package/dist/{chunk-7A5WEMNW.js → chunk-Y3NVKGGI.js} +11 -11
- package/dist/{chunk-33XUAKRP.js → chunk-YGAX72XV.js} +3 -1
- package/dist/{chunk-FSPZYOY6.js → chunk-YLKG7W4P.js} +4 -4
- package/dist/{chunk-SESTTUVM.js → chunk-YN3FGNJM.js} +53 -1
- package/dist/{chunk-3T5S5RDO.js → chunk-ZHOI4QMK.js} +4 -4
- package/dist/{chunk-CEG375CR.js → chunk-ZSFJVRRS.js} +4 -4
- package/dist/chunk-ZZ3XFIEM.js +84 -0
- package/dist/{collection-add-products-IRYJ6U6P.js → collection-add-products-XL2TAKQD.js} +30 -29
- package/dist/{collection-create-3BTRORHU.js → collection-create-HUNYHKUJ.js} +2 -2
- package/dist/{collection-detail-263PM4DL.js → collection-detail-2DSZVOI7.js} +28 -27
- package/dist/{collection-edit-L5GPFBBX.js → collection-edit-OQGYTQDO.js} +2 -2
- package/dist/{collection-list-IVPTNBSI.js → collection-list-NGCW7OTG.js} +35 -36
- package/dist/{collection-metadata-KHGPTV5C.js → collection-metadata-47N7TUOH.js} +17 -16
- package/dist/{commission-rate-create-3N6BHEGT.js → commission-rate-create-BQY3UGKV.js} +53 -53
- package/dist/{commission-rate-detail-MY3F2RHR.js → commission-rate-detail-LAZZLZVX.js} +18 -17
- package/dist/{commission-rate-edit-WZDPXLLZ.js → commission-rate-edit-DAFXNYYN.js} +53 -53
- package/dist/{commission-rate-list-JPBOTOTA.js → commission-rate-list-Y5XLEO67.js} +8 -10
- package/dist/{constants-CAwtRicB.d.ts → constants-26tEckuq.d.ts} +3 -3
- package/dist/{customer-detail-2QBJPF7S.js → customer-detail-D5SSLNFT.js} +27 -28
- package/dist/{customer-group-add-customers-JCLAH45C.js → customer-group-add-customers-VJUBEN7M.js} +13 -15
- package/dist/{customer-group-detail-BDKFWKTI.js → customer-group-detail-KRT7E2JA.js} +24 -25
- package/dist/{customer-group-list-3NEEJXQH.js → customer-group-list-KKDIESQ6.js} +24 -25
- package/dist/{customer-group-metadata-YJXZFSFG.js → customer-group-metadata-J6JY7DZ3.js} +17 -16
- package/dist/{customer-list-ZIFNZXO4.js → customer-list-MB6WZFMA.js} +11 -13
- package/dist/{customer-metadata-SG6M7X3Q.js → customer-metadata-AH2LBK4T.js} +17 -16
- package/dist/{customers-add-customer-group-OQIFQZBL.js → customers-add-customer-group-AHGAPEIS.js} +27 -28
- package/dist/{edit-inventory-item-TDG2ZTPM.js → edit-inventory-item-ADNLKLCN.js} +13 -12
- package/dist/{edit-inventory-item-attributes-T56PJTCT.js → edit-inventory-item-attributes-XVR2WLDU.js} +13 -12
- package/dist/{edit-reservation-T6SKOG2F.js → edit-reservation-HQQL42QX.js} +7 -7
- package/dist/{edit-rules-4AHZQGCX.js → edit-rules-YMKM5JPI.js} +17 -15
- package/dist/index.d.ts +2 -2
- package/dist/index.js +824 -598
- package/dist/{inventory-create-P26OGAHD.js → inventory-create-IVESXFSV.js} +19 -18
- package/dist/{inventory-detail-7W7UUWNT.js → inventory-detail-TINIAFVB.js} +26 -27
- package/dist/{inventory-list-PA4B4RWY.js → inventory-list-YLIAKQXI.js} +10 -12
- package/dist/{inventory-metadata-LUGA3KNV.js → inventory-metadata-6INRH2JC.js} +17 -16
- package/dist/{inventory-stock-UZSYXXPX.js → inventory-stock-6YGTATID.js} +21 -20
- package/dist/loader-6KDBTRVR.js +26 -0
- package/dist/{location-detail-RUC2ZP3K.js → location-detail-EK2S7WOK.js} +22 -21
- package/dist/{location-fulfillment-providers-WDET6TJP.js → location-fulfillment-providers-KUUNC2KP.js} +36 -36
- package/dist/{location-list-R7EECG5Z.js → location-list-IV323QW2.js} +19 -19
- package/dist/{location-sales-channels-IS6E3I4S.js → location-sales-channels-EYUXMTW7.js} +12 -12
- package/dist/{location-service-zone-create-HAQVVTKP.js → location-service-zone-create-ZS3UWJAA.js} +8 -11
- package/dist/{location-service-zone-manage-areas-5LCENMAM.js → location-service-zone-manage-areas-S7QZTIFT.js} +8 -11
- package/dist/{location-service-zone-shipping-option-create-FV5Y2PNB.js → location-service-zone-shipping-option-create-36JZFRGY.js} +23 -21
- package/dist/{location-service-zone-shipping-option-edit-PLEDWIY3.js → location-service-zone-shipping-option-edit-3PGSNKYT.js} +8 -7
- package/dist/{location-service-zone-shipping-option-pricing-6QHLZ6IN.js → location-service-zone-shipping-option-pricing-JLGCOZGS.js} +8 -8
- package/dist/{login-EWHQY6G3.js → login-6L3RMREO.js} +13 -12
- package/dist/{manage-locations-TU5HCIKG.js → manage-locations-CFTM6DNH.js} +1 -1
- package/dist/{marketplace-add-currencies-PB73MHM6.js → marketplace-add-currencies-6ANNBGZM.js} +8 -10
- package/dist/{marketplace-detail-3KFGJWQ7.js → marketplace-detail-BAU2MEJT.js} +22 -23
- package/dist/{marketplace-edit-U5B6WA56.js → marketplace-edit-6Q3G2OY5.js} +5 -4
- package/dist/{marketplace-metadata-VYCPYFJD.js → marketplace-metadata-KRCGKOCA.js} +17 -16
- package/dist/offers-IFKM6EQT.js +440 -0
- package/dist/{order-allocate-items-2B6T5JCK.js → order-allocate-items-DJ2V4B7A.js} +11 -11
- package/dist/{order-create-claim-R2SX6YUS.js → order-create-claim-RMDDCUZ6.js} +27 -61
- package/dist/{order-create-edit-G35PDCQ2.js → order-create-edit-PQ54JFZZ.js} +24 -58
- package/dist/{order-create-exchange-7KKMJHXE.js → order-create-exchange-T6DBVS75.js} +41 -48
- package/dist/{order-create-fulfillment-2FTTWTFE.js → order-create-fulfillment-SMSUJSBN.js} +22 -20
- package/dist/{order-create-refund-KWYYLAED.js → order-create-refund-OW3MIXBY.js} +17 -16
- package/dist/{order-create-return-BQFRANNG.js → order-create-return-YCX6C3VP.js} +25 -27
- package/dist/{order-create-shipment-7XP6PDTD.js → order-create-shipment-5ZAWH5CZ.js} +14 -13
- package/dist/{order-detail-BITJD73H.js → order-detail-2OAEGBQG.js} +29 -30
- package/dist/{order-edit-billing-address-FLEI4VDB.js → order-edit-billing-address-VGZBQHF5.js} +15 -14
- package/dist/{order-edit-email-AZIA6X5Q.js → order-edit-email-OOCXVRET.js} +14 -13
- package/dist/{order-edit-shipping-address-GJMUSOPK.js → order-edit-shipping-address-B4F3E5RE.js} +14 -13
- package/dist/{order-list-D2SJOMZ2.js → order-list-DQTMCEFD.js} +25 -27
- package/dist/{order-metadata-RXIJOP4V.js → order-metadata-AN6MPHHT.js} +18 -17
- package/dist/{order-receive-return-JV3X7YHG.js → order-receive-return-DZ4IUOHY.js} +20 -19
- package/dist/{order-request-transfer-6IZVCHGV.js → order-request-transfer-A2NJSQ4H.js} +16 -14
- package/dist/pages/index.d.ts +702 -566
- package/dist/pages/index.js +192 -184
- package/dist/{payout-detail-JWS2Q4TY.js → payout-detail-TWO6HN4E.js} +3 -3
- package/dist/{payout-list-PW6BFT4O.js → payout-list-7WJZFNW5.js} +9 -11
- package/dist/{price-list-configuration-N5D5OFXX.js → price-list-configuration-XAHXLCXR.js} +13 -15
- package/dist/{price-list-create-NQFC2JIJ.js → price-list-create-37SCDSPN.js} +35 -34
- package/dist/{price-list-detail-HRVLVBPS.js → price-list-detail-4Q2HBLAM.js} +30 -29
- package/dist/{price-list-edit-BVVLQ5WV.js → price-list-edit-ZVLD4M5T.js} +5 -5
- package/dist/{price-list-list-K4IJFZYH.js → price-list-list-ER4TOZTY.js} +13 -15
- package/dist/{price-list-prices-add-WXEGEWRA.js → price-list-prices-add-UASPZXKT.js} +31 -30
- package/dist/{price-list-prices-edit-KJEKS6TL.js → price-list-prices-edit-WHCIGSB2.js} +22 -21
- package/dist/product-add-existing-attributes-7HEJUR6J.js +420 -0
- package/dist/{product-attributes-ASPKDH7H.js → product-attributes-MHRXZK5S.js} +4 -4
- package/dist/product-brand-create-B3ZJGHUQ.js +171 -0
- package/dist/product-brand-detail-6MPQ3UFN.js +100 -0
- package/dist/product-brand-edit-3TQDHZNN.js +179 -0
- package/dist/product-brand-list-ZBPBSRQN.js +30 -0
- package/dist/product-brand-metadata-EAMW6PQJ.js +87 -0
- package/dist/product-bulk-edit-J6ZP7GGM.js +287 -0
- package/dist/{product-create-BDQ66ECX.js → product-create-KHJWRSUB.js} +34 -34
- package/dist/product-create-attribute-ZT3VZDNZ.js +196 -0
- package/dist/{product-create-option-B7SV42LO.js → product-create-option-NIAP75EE.js} +6 -24
- package/dist/{product-create-variant-7YAG2YRZ.js → product-create-variant-LCE47YFO.js} +25 -21
- package/dist/{product-detail-DCHR4B4T.js → product-detail-GLISGO65.js} +25 -27
- package/dist/{product-edit-IASCMBET.js → product-edit-EKAZRIJ6.js} +15 -8
- package/dist/product-edit-option-OZUZGMIM.js +166 -0
- package/dist/{product-list-X72QPKOK.js → product-list-2CTGPDDT.js} +31 -30
- package/dist/{product-media-VNSFLCSH.js → product-media-KREKRDOC.js} +15 -8
- package/dist/{product-metadata-GJ7C2UJG.js → product-metadata-O3BAEUYB.js} +20 -19
- package/dist/{product-organization-PN22LYKQ.js → product-organization-SBQY44IF.js} +61 -18
- package/dist/{product-prices-HI4SOTMP.js → product-prices-R5JOHVGS.js} +8 -8
- package/dist/{product-sales-channels-J2ZNRKZT.js → product-sales-channels-TFOGXCMI.js} +15 -15
- package/dist/{product-shipping-profile-G7UPGWYK.js → product-shipping-profile-E4HJ4EYW.js} +6 -5
- package/dist/{product-stock-666D3AMJ.js → product-stock-EIP2XJUR.js} +28 -27
- package/dist/{product-tag-create-PHJICTE4.js → product-tag-create-7JBM6I3V.js} +13 -12
- package/dist/{product-tag-detail-B7JEBNMJ.js → product-tag-detail-MTFAPSG2.js} +51 -51
- package/dist/{product-tag-edit-G4UNGXPT.js → product-tag-edit-O2ADFDD6.js} +13 -12
- package/dist/{product-tag-list-MAUUWH25.js → product-tag-list-EOULJIYQ.js} +51 -51
- package/dist/{product-tag-metadata-I4V6CR6Z.js → product-tag-metadata-SBOUTUXY.js} +17 -16
- package/dist/{product-type-detail-7GHH4ACU.js → product-type-detail-H4CZN27J.js} +28 -27
- package/dist/{product-type-list-LTYTTF4F.js → product-type-list-TM26QMHR.js} +12 -14
- package/dist/{product-type-metadata-KGVRMMTQ.js → product-type-metadata-KN5OXR6J.js} +17 -16
- package/dist/{product-variant-detail-PHGVJWUV.js → product-variant-detail-H2YRFDAU.js} +27 -37
- package/dist/product-variant-edit-6W7LKCEE.js +867 -0
- package/dist/{product-variant-manage-inventory-items-WENX2QCZ.js → product-variant-manage-inventory-items-Q5MJG3EJ.js} +6 -10
- package/dist/{product-variant-metadata-HV72UBCP.js → product-variant-metadata-QESZ7VS2.js} +17 -16
- package/dist/{profile-detail-UQTGEFYF.js → profile-detail-ZRL5SERS.js} +4 -4
- package/dist/{promotion-add-campaign-M4OT6URB.js → promotion-add-campaign-O3RTMS3W.js} +6 -5
- package/dist/{promotion-create-GM37OXEW.js → promotion-create-TGC6BVWF.js} +23 -21
- package/dist/{promotion-detail-PDBRQII7.js → promotion-detail-VYIXZMMD.js} +21 -20
- package/dist/{promotion-list-XW4PNLJF.js → promotion-list-C3SKV5BJ.js} +13 -15
- package/dist/{refund-reason-create-M2CYTCEM.js → refund-reason-create-2KEQFOID.js} +13 -12
- package/dist/{refund-reason-edit-M4XBV633.js → refund-reason-edit-E7CB7SM3.js} +13 -12
- package/dist/{refund-reason-list-2S2MDKBQ.js → refund-reason-list-TAHJK4OX.js} +37 -35
- package/dist/{region-add-countries-T4XZ2CU3.js → region-add-countries-COXN4LP3.js} +7 -9
- package/dist/{region-create-MQXTWBKC.js → region-create-P66Q65XY.js} +14 -15
- package/dist/{region-detail-6OFP76OY.js → region-detail-P2HHBYFV.js} +11 -13
- package/dist/{region-edit-QNJ2HT76.js → region-edit-XFE54SAO.js} +8 -7
- package/dist/{region-list-EYTDREE2.js → region-list-2XXKCDDX.js} +11 -13
- package/dist/{region-metadata-4JWOEGTZ.js → region-metadata-723RQGHS.js} +17 -16
- package/dist/{reservation-create-26QAWABA.js → reservation-create-Y3HG4AZA.js} +4 -4
- package/dist/{reservation-detail-G26K6HZV.js → reservation-detail-HQMADZ56.js} +19 -18
- package/dist/{reservation-list-CHHR6CEV.js → reservation-list-YKC3JJ6K.js} +11 -13
- package/dist/{reservation-metadata-JFLJ27A3.js → reservation-metadata-UG4YTEMY.js} +18 -17
- package/dist/{reset-password-S6IBWG47.js → reset-password-2VNU52CE.js} +1 -1
- package/dist/{return-reason-list-MCGW2JV3.js → return-reason-list-IHFO2LJK.js} +27 -28
- package/dist/{sales-channel-add-products-FH7B7UYR.js → sales-channel-add-products-YZTQ2SDS.js} +31 -30
- package/dist/{sales-channel-create-NSZEHGZE.js → sales-channel-create-BSNCLZWR.js} +2 -2
- package/dist/{sales-channel-detail-KCS472HN.js → sales-channel-detail-67G7K3IE.js} +28 -27
- package/dist/{sales-channel-edit-W6Z2ERBJ.js → sales-channel-edit-FUDXMZYV.js} +2 -2
- package/dist/{sales-channel-list-6HBRUZ2Z.js → sales-channel-list-GYLGH4U7.js} +21 -20
- package/dist/{sales-channel-metadata-NDSKXOGH.js → sales-channel-metadata-H6RSHKVP.js} +17 -16
- package/dist/{shipping-option-type-create-MEL24PGH.js → shipping-option-type-create-QAOW7753.js} +13 -12
- package/dist/{shipping-option-type-detail-IS7CNAYI.js → shipping-option-type-detail-QGWVDTDU.js} +19 -18
- package/dist/{shipping-option-type-edit-IVBHURXR.js → shipping-option-type-edit-WXYBDRNY.js} +13 -12
- package/dist/{shipping-option-type-list-BTPCLBSD.js → shipping-option-type-list-YSWP6DSC.js} +24 -25
- package/dist/{shipping-profile-detail-L3IHPGLL.js → shipping-profile-detail-YAKZHWZI.js} +5 -5
- package/dist/{shipping-profile-metadata-UZPX2PHJ.js → shipping-profile-metadata-UE53IA3J.js} +19 -18
- package/dist/{shipping-profiles-list-2JKVMEZG.js → shipping-profiles-list-JF2SQIQ7.js} +9 -11
- package/dist/{store-bulk-edit-A4ZWZ7HJ.js → store-bulk-edit-UYNQ2CPG.js} +7 -7
- package/dist/{store-create-OQVFVIK4.js → store-create-WNFRHXWR.js} +13 -12
- package/dist/{store-details-BOGWBWE7.js → store-details-R2GQU7HE.js} +44 -44
- package/dist/{store-edit-77WKNZUH.js → store-edit-UW3QOFFX.js} +11 -11
- package/dist/{store-list-2G34KVD5.js → store-list-5CV7VJLO.js} +36 -37
- package/dist/{store-member-invite-4GDKCSTT.js → store-member-invite-M4NVBUXM.js} +3 -3
- package/dist/{tax-region-create-5DDZ23QQ.js → tax-region-create-3KVECMFN.js} +16 -14
- package/dist/{tax-region-detail-VNBNS7FS.js → tax-region-detail-AOT4X4DZ.js} +26 -26
- package/dist/{tax-region-edit-OARZRBVK.js → tax-region-edit-5T7VHKIA.js} +15 -13
- package/dist/{tax-region-list-WCHVLVVC.js → tax-region-list-FIBHEFVD.js} +9 -9
- package/dist/{tax-region-metadata-XJRFOG7I.js → tax-region-metadata-RSZCJGJT.js} +17 -16
- package/dist/{tax-region-province-detail-MXYZMUX7.js → tax-region-province-detail-XEMIX5SQ.js} +24 -24
- package/dist/{tax-region-tax-override-create-VIOPM26G.js → tax-region-tax-override-create-KVVY4AF2.js} +54 -54
- package/dist/{tax-region-tax-override-edit-5FW6YCCW.js → tax-region-tax-override-edit-TVX7SMJD.js} +54 -54
- package/dist/{user-detail-LGIMHLY4.js → user-detail-W7DGVXDZ.js} +6 -6
- package/dist/{user-invite-ZZSWFXFM.js → user-invite-HLZJ7FST.js} +14 -16
- package/dist/{user-list-5QJJS7EA.js → user-list-TR7RSGUO.js} +9 -11
- package/dist/{user-metadata-376YJMY3.js → user-metadata-3AFZX3DM.js} +17 -16
- package/package.json +3 -3
- package/dist/attribute-create-EAOQ6KT6.js +0 -1010
- package/dist/attribute-create-possible-value-BIU2L7AN.js +0 -437
- package/dist/attribute-edit-DRHFOHMK.js +0 -282
- package/dist/attribute-edit-possible-value-G2ON2AE3.js +0 -264
- package/dist/chunk-35NDMIYZ.js +0 -8
- package/dist/chunk-4GPAS5GW.js +0 -36
- package/dist/chunk-4ZTZTIIM.js +0 -69
- package/dist/chunk-7O5NDICV.js +0 -120
- package/dist/chunk-IGTRIAUC.js +0 -84
- package/dist/chunk-KYPPQGGE.js +0 -467
- package/dist/chunk-LBXPX3XC.js +0 -1260
- package/dist/chunk-LO7XX5M7.js +0 -6
- package/dist/chunk-MXGDKEU5.js +0 -248
- package/dist/chunk-QOQSXNEF.js +0 -37
- package/dist/chunk-RSBZREKG.js +0 -144
- package/dist/chunk-WCEMRNW4.js +0 -6
- package/dist/chunk-Z5I2Z6L3.js +0 -160
- package/dist/chunk-ZMC7BKLT.js +0 -56
- package/dist/chunk-ZXYKF4A2.js +0 -2146
- package/dist/product-edit-option-KVTIY5NM.js +0 -156
- package/dist/product-export-E7RBOIO6.js +0 -137
- package/dist/product-import-KOSPPCSW.js +0 -267
- package/dist/product-variant-edit-L77HDGTA.js +0 -547
- package/dist/{chunk-XCANTVXS.js → chunk-CPXK5RSJ.js} +6 -6
- package/dist/{chunk-Y6NK6GBB.js → chunk-GP4J42UD.js} +5 -5
- package/dist/{chunk-L56WFGUN.js → chunk-IMR3MZDP.js} +3 -3
- package/dist/{chunk-OB4NOV4M.js → chunk-LYZT5REU.js} +3 -3
- package/dist/{chunk-ZBJ56XDB.js → chunk-Q2ULPJJ6.js} +3 -3
- package/dist/{chunk-MWX5JCOM.js → chunk-V6OGMYAI.js} +3 -3
- package/dist/{chunk-KCYUY2AI.js → chunk-WQFFCK3R.js} +6 -6
- package/dist/{chunk-ZW34ZAIP.js → chunk-WYA62MUL.js} +8 -8
- package/dist/{chunk-56AUQBQX.js → chunk-YYMACYP6.js} +5 -5
- package/dist/{customer-edit-X4HQOUAE.js → customer-edit-JZ4PQTIN.js} +3 -3
- package/dist/{profile-edit-Y5UUUKVH.js → profile-edit-HQTWYWZ7.js} +6 -6
- package/dist/{promotion-edit-details-E2XKWY7L.js → promotion-edit-details-TKRC5HES.js} +6 -6
|
@@ -0,0 +1,2355 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SortableList
|
|
3
|
+
} from "./chunk-IIFQ7KYL.js";
|
|
4
|
+
import {
|
|
5
|
+
HandleInput
|
|
6
|
+
} from "./chunk-HJ56YXBU.js";
|
|
7
|
+
import {
|
|
8
|
+
UploadMediaFormItem
|
|
9
|
+
} from "./chunk-26UTIAAZ.js";
|
|
10
|
+
import {
|
|
11
|
+
PRODUCT_CREATE_FORM_DEFAULTS,
|
|
12
|
+
ProductCreateSchema,
|
|
13
|
+
decorateVariantsWithDefaultValues,
|
|
14
|
+
generateVariantsFromAttributes,
|
|
15
|
+
normalizeProductFormValues
|
|
16
|
+
} from "./chunk-EREXPX6I.js";
|
|
17
|
+
import {
|
|
18
|
+
useAttributeTableFilters
|
|
19
|
+
} from "./chunk-RT6L7JXU.js";
|
|
20
|
+
import {
|
|
21
|
+
useAttributeTableQuery
|
|
22
|
+
} from "./chunk-4YWKKCTT.js";
|
|
23
|
+
import {
|
|
24
|
+
SingleCategoryCombobox
|
|
25
|
+
} from "./chunk-BHOZKBYY.js";
|
|
26
|
+
import {
|
|
27
|
+
useComboboxData
|
|
28
|
+
} from "./chunk-5KGMGL4N.js";
|
|
29
|
+
import {
|
|
30
|
+
Combobox
|
|
31
|
+
} from "./chunk-AW77UWCZ.js";
|
|
32
|
+
import {
|
|
33
|
+
TabbedForm,
|
|
34
|
+
defineTabMeta,
|
|
35
|
+
useTabbedForm
|
|
36
|
+
} from "./chunk-4LXBQTFN.js";
|
|
37
|
+
import {
|
|
38
|
+
SwitchBox
|
|
39
|
+
} from "./chunk-2EME4AWX.js";
|
|
40
|
+
import {
|
|
41
|
+
ChipInput
|
|
42
|
+
} from "./chunk-YGRTRAWX.js";
|
|
43
|
+
import {
|
|
44
|
+
DataGrid,
|
|
45
|
+
createDataGridHelper,
|
|
46
|
+
createDataGridPriceColumns
|
|
47
|
+
} from "./chunk-V6OGMYAI.js";
|
|
48
|
+
import {
|
|
49
|
+
RouteFocusModal,
|
|
50
|
+
StackedFocusModal,
|
|
51
|
+
useRouteModal,
|
|
52
|
+
useStackedModal
|
|
53
|
+
} from "./chunk-FWJLS7XD.js";
|
|
54
|
+
import {
|
|
55
|
+
Form
|
|
56
|
+
} from "./chunk-3QSRE5LS.js";
|
|
57
|
+
import {
|
|
58
|
+
DataTable
|
|
59
|
+
} from "./chunk-LYZT5REU.js";
|
|
60
|
+
import {
|
|
61
|
+
require_dist
|
|
62
|
+
} from "./chunk-2MDGYHWN.js";
|
|
63
|
+
import {
|
|
64
|
+
useProductAttributes
|
|
65
|
+
} from "./chunk-533GMKEG.js";
|
|
66
|
+
import {
|
|
67
|
+
useRegions
|
|
68
|
+
} from "./chunk-ESPLVOFC.js";
|
|
69
|
+
import {
|
|
70
|
+
useStore
|
|
71
|
+
} from "./chunk-FXWKGNRV.js";
|
|
72
|
+
import {
|
|
73
|
+
usePricePreferences
|
|
74
|
+
} from "./chunk-VDKOJ5WD.js";
|
|
75
|
+
import {
|
|
76
|
+
ActionMenu
|
|
77
|
+
} from "./chunk-BDGZ4EQO.js";
|
|
78
|
+
import {
|
|
79
|
+
useSalesChannel
|
|
80
|
+
} from "./chunk-S5BJ5CMF.js";
|
|
81
|
+
import {
|
|
82
|
+
useCreateProduct
|
|
83
|
+
} from "./chunk-2YYXP6XI.js";
|
|
84
|
+
import {
|
|
85
|
+
sdk
|
|
86
|
+
} from "./chunk-ZBWL72TB.js";
|
|
87
|
+
import {
|
|
88
|
+
__toESM
|
|
89
|
+
} from "./chunk-NBMM2TZK.js";
|
|
90
|
+
|
|
91
|
+
// src/pages/products/product-create/product-create.tsx
|
|
92
|
+
import { Children as Children2 } from "react";
|
|
93
|
+
import { useTranslation as useTranslation11 } from "react-i18next";
|
|
94
|
+
|
|
95
|
+
// src/pages/products/product-create/components/product-create-form/product-create-form.tsx
|
|
96
|
+
import { Button as Button4, toast } from "@medusajs/ui";
|
|
97
|
+
import { useCallback, useEffect as useEffect3, useMemo as useMemo4, Children } from "react";
|
|
98
|
+
import { useForm, useWatch as useWatch4 } from "react-hook-form";
|
|
99
|
+
import { useTranslation as useTranslation10 } from "react-i18next";
|
|
100
|
+
|
|
101
|
+
// src/pages/products/product-create/components/product-create-attributes-form/product-create-attributes-form.tsx
|
|
102
|
+
var import_types = __toESM(require_dist(), 1);
|
|
103
|
+
import { XMarkMini } from "@medusajs/icons";
|
|
104
|
+
import {
|
|
105
|
+
Button as Button2,
|
|
106
|
+
Heading,
|
|
107
|
+
Hint,
|
|
108
|
+
IconButton,
|
|
109
|
+
InlineTip,
|
|
110
|
+
Input,
|
|
111
|
+
Label,
|
|
112
|
+
Select,
|
|
113
|
+
Switch,
|
|
114
|
+
Text,
|
|
115
|
+
Textarea
|
|
116
|
+
} from "@medusajs/ui";
|
|
117
|
+
import { useEffect as useEffect2 } from "react";
|
|
118
|
+
import {
|
|
119
|
+
Controller,
|
|
120
|
+
useFieldArray
|
|
121
|
+
} from "react-hook-form";
|
|
122
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
123
|
+
|
|
124
|
+
// src/pages/products/product-create/components/product-create-attributes-form/product-create-add-attributes-modal.tsx
|
|
125
|
+
import {
|
|
126
|
+
Badge,
|
|
127
|
+
Button,
|
|
128
|
+
createDataTableColumnHelper
|
|
129
|
+
} from "@medusajs/ui";
|
|
130
|
+
import { useEffect, useMemo, useState } from "react";
|
|
131
|
+
import { useTranslation } from "react-i18next";
|
|
132
|
+
import { keepPreviousData } from "@tanstack/react-query";
|
|
133
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
134
|
+
var ADD_ATTRIBUTES_MODAL_ID = "add-attributes";
|
|
135
|
+
var PAGE_SIZE = 20;
|
|
136
|
+
var MAX_VISIBLE_VALUES = 2;
|
|
137
|
+
var ATTRIBUTE_TYPE_LABELS = {
|
|
138
|
+
single_select: "attributes.type.select",
|
|
139
|
+
multi_select: "attributes.type.multivalue",
|
|
140
|
+
unit: "attributes.type.unit",
|
|
141
|
+
toggle: "attributes.type.toggle",
|
|
142
|
+
text: "attributes.type.text_area"
|
|
143
|
+
};
|
|
144
|
+
var ProductCreateAddAttributesModal = () => {
|
|
145
|
+
const form = useTabbedForm();
|
|
146
|
+
const { t } = useTranslation();
|
|
147
|
+
const { getValues, setValue } = form;
|
|
148
|
+
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
149
|
+
const [rowSelection, setRowSelection] = useState(
|
|
150
|
+
{}
|
|
151
|
+
);
|
|
152
|
+
const [state, setState] = useState([]);
|
|
153
|
+
const categoryId = form.watch("category_id");
|
|
154
|
+
const { searchParams } = useAttributeTableQuery({
|
|
155
|
+
pageSize: PAGE_SIZE,
|
|
156
|
+
prefix: ADD_ATTRIBUTES_MODAL_ID
|
|
157
|
+
});
|
|
158
|
+
const attributesQuery = useMemo(
|
|
159
|
+
() => ({ ...searchParams, category_id: categoryId || void 0 }),
|
|
160
|
+
[searchParams, categoryId]
|
|
161
|
+
);
|
|
162
|
+
const { product_attributes, count, isLoading, isError, error } = useProductAttributes(attributesQuery, {
|
|
163
|
+
placeholderData: keepPreviousData
|
|
164
|
+
});
|
|
165
|
+
const open = getIsOpen(ADD_ATTRIBUTES_MODAL_ID);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (!open) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const attributes = getValues("attributes") ?? [];
|
|
171
|
+
const existing = attributes.filter((a) => a.attribute_id);
|
|
172
|
+
const selection = {};
|
|
173
|
+
const stateEntries = [];
|
|
174
|
+
for (const a of existing) {
|
|
175
|
+
if (a.attribute_id) {
|
|
176
|
+
selection[a.attribute_id] = true;
|
|
177
|
+
const apiAttr = product_attributes?.find((pa) => pa.id === a.attribute_id);
|
|
178
|
+
stateEntries.push({
|
|
179
|
+
id: a.attribute_id,
|
|
180
|
+
name: a.title,
|
|
181
|
+
values: Array.isArray(a.values) ? a.values : a.values ? [a.values] : [],
|
|
182
|
+
is_variant_axis: a.use_for_variants,
|
|
183
|
+
type: a.type ?? apiAttr?.type ?? "",
|
|
184
|
+
available_values: a.available_values ?? apiAttr?.values?.map((v) => ({ id: v.id, name: v.name })) ?? []
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (product_attributes) {
|
|
189
|
+
for (const attr of product_attributes) {
|
|
190
|
+
if (attr.is_required && !selection[attr.id]) {
|
|
191
|
+
selection[attr.id] = true;
|
|
192
|
+
stateEntries.push({
|
|
193
|
+
id: attr.id,
|
|
194
|
+
name: attr.name,
|
|
195
|
+
values: [],
|
|
196
|
+
is_variant_axis: attr.is_variant_axis,
|
|
197
|
+
type: attr.type,
|
|
198
|
+
available_values: attr.values?.map((v) => ({ id: v.id, name: v.name })) ?? []
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
setRowSelection(selection);
|
|
204
|
+
setState(stateEntries);
|
|
205
|
+
}, [open, getValues, product_attributes]);
|
|
206
|
+
const onRowSelectionChange = (next) => {
|
|
207
|
+
if (product_attributes) {
|
|
208
|
+
for (const attr of product_attributes) {
|
|
209
|
+
if (attr.is_required) {
|
|
210
|
+
next[attr.id] = true;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const ids = Object.keys(next);
|
|
215
|
+
const addedIdsSet = new Set(
|
|
216
|
+
ids.filter((id) => next[id] && !rowSelection[id])
|
|
217
|
+
);
|
|
218
|
+
let addedAttributes = [];
|
|
219
|
+
if (addedIdsSet.size > 0) {
|
|
220
|
+
addedAttributes = product_attributes?.filter((attr) => addedIdsSet.has(attr.id)).map((attr) => ({
|
|
221
|
+
id: attr.id,
|
|
222
|
+
name: attr.name,
|
|
223
|
+
values: [],
|
|
224
|
+
is_variant_axis: attr.is_variant_axis,
|
|
225
|
+
type: attr.type,
|
|
226
|
+
available_values: attr.values?.map((v) => ({ id: v.id, name: v.name })) ?? []
|
|
227
|
+
})) ?? [];
|
|
228
|
+
}
|
|
229
|
+
setState((prev) => {
|
|
230
|
+
const filteredPrev = prev.filter((a) => next[a.id]);
|
|
231
|
+
return Array.from(/* @__PURE__ */ new Set([...filteredPrev, ...addedAttributes]));
|
|
232
|
+
});
|
|
233
|
+
setRowSelection(next);
|
|
234
|
+
};
|
|
235
|
+
const handleAdd = () => {
|
|
236
|
+
const currentAttributes = getValues("attributes") ?? [];
|
|
237
|
+
const customAttributes = currentAttributes.filter((a) => a.is_custom);
|
|
238
|
+
const requiredIds = new Set(
|
|
239
|
+
product_attributes?.filter((a) => a.is_required).map((a) => a.id) ?? []
|
|
240
|
+
);
|
|
241
|
+
const selectedAttributes = state.map((a) => ({
|
|
242
|
+
attribute_id: a.id,
|
|
243
|
+
title: a.name,
|
|
244
|
+
values: a.values,
|
|
245
|
+
is_custom: false,
|
|
246
|
+
is_required: requiredIds.has(a.id),
|
|
247
|
+
use_for_variants: a.is_variant_axis,
|
|
248
|
+
type: a.type,
|
|
249
|
+
available_values: a.available_values
|
|
250
|
+
}));
|
|
251
|
+
setValue("attributes", [...selectedAttributes, ...customAttributes], {
|
|
252
|
+
shouldDirty: true,
|
|
253
|
+
shouldTouch: true
|
|
254
|
+
});
|
|
255
|
+
setIsOpen(ADD_ATTRIBUTES_MODAL_ID, false);
|
|
256
|
+
};
|
|
257
|
+
const filters = useAttributeTableFilters();
|
|
258
|
+
const columns = useColumns();
|
|
259
|
+
if (isError) {
|
|
260
|
+
throw error;
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ jsxs(StackedFocusModal.Content, { className: "flex flex-col overflow-hidden", children: [
|
|
263
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
|
|
264
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
265
|
+
DataTable,
|
|
266
|
+
{
|
|
267
|
+
data: product_attributes,
|
|
268
|
+
columns,
|
|
269
|
+
filters,
|
|
270
|
+
rowCount: count,
|
|
271
|
+
pageSize: PAGE_SIZE,
|
|
272
|
+
getRowId: (row) => row.id,
|
|
273
|
+
rowSelection: {
|
|
274
|
+
state: rowSelection,
|
|
275
|
+
onRowSelectionChange,
|
|
276
|
+
enableRowSelection: (row) => !row.original.is_required
|
|
277
|
+
},
|
|
278
|
+
isLoading,
|
|
279
|
+
layout: "fill",
|
|
280
|
+
prefix: ADD_ATTRIBUTES_MODAL_ID
|
|
281
|
+
}
|
|
282
|
+
) }),
|
|
283
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
284
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: t("actions.cancel") }) }),
|
|
285
|
+
/* @__PURE__ */ jsx(Button, { size: "small", onClick: handleAdd, type: "button", children: t("actions.save") })
|
|
286
|
+
] }) })
|
|
287
|
+
] });
|
|
288
|
+
};
|
|
289
|
+
var columnHelper = createDataTableColumnHelper();
|
|
290
|
+
var useColumns = () => {
|
|
291
|
+
const { t } = useTranslation();
|
|
292
|
+
return useMemo(
|
|
293
|
+
() => [
|
|
294
|
+
columnHelper.select(),
|
|
295
|
+
columnHelper.accessor("name", {
|
|
296
|
+
header: t("attributes.fields.name"),
|
|
297
|
+
enableSorting: false
|
|
298
|
+
}),
|
|
299
|
+
columnHelper.accessor("handle", {
|
|
300
|
+
header: t("attributes.fields.handle"),
|
|
301
|
+
cell: (info) => {
|
|
302
|
+
const handle = info.getValue();
|
|
303
|
+
return handle ? `/${handle}` : "-";
|
|
304
|
+
},
|
|
305
|
+
enableSorting: false
|
|
306
|
+
}),
|
|
307
|
+
columnHelper.accessor("is_required", {
|
|
308
|
+
header: t("attributes.fields.required"),
|
|
309
|
+
cell: (info) => info.getValue() ? t("filters.radio.yes") : t("filters.radio.no"),
|
|
310
|
+
enableSorting: false
|
|
311
|
+
}),
|
|
312
|
+
columnHelper.accessor("type", {
|
|
313
|
+
header: t("attributes.fields.type"),
|
|
314
|
+
cell: (info) => {
|
|
315
|
+
const type = info.getValue();
|
|
316
|
+
const labelKey = ATTRIBUTE_TYPE_LABELS[type];
|
|
317
|
+
return labelKey ? t(labelKey) : type;
|
|
318
|
+
},
|
|
319
|
+
enableSorting: false
|
|
320
|
+
}),
|
|
321
|
+
columnHelper.accessor("is_variant_axis", {
|
|
322
|
+
header: t("attributes.fields.variantAxis"),
|
|
323
|
+
cell: (info) => info.getValue() ? t("filters.radio.yes") : t("filters.radio.no"),
|
|
324
|
+
enableSorting: false
|
|
325
|
+
}),
|
|
326
|
+
columnHelper.display({
|
|
327
|
+
id: "values",
|
|
328
|
+
header: t("attributes.fields.values"),
|
|
329
|
+
cell: ({ row }) => {
|
|
330
|
+
const values = row.original.values ?? [];
|
|
331
|
+
if (!values.length) {
|
|
332
|
+
return /* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "-" });
|
|
333
|
+
}
|
|
334
|
+
const visible = values.slice(0, MAX_VISIBLE_VALUES);
|
|
335
|
+
const remaining = values.length - MAX_VISIBLE_VALUES;
|
|
336
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
337
|
+
visible.map((v) => /* @__PURE__ */ jsx(Badge, { size: "2xsmall", color: "grey", children: v.name }, v.id)),
|
|
338
|
+
remaining > 0 && /* @__PURE__ */ jsxs(Badge, { size: "2xsmall", color: "grey", children: [
|
|
339
|
+
"+",
|
|
340
|
+
remaining
|
|
341
|
+
] })
|
|
342
|
+
] });
|
|
343
|
+
}
|
|
344
|
+
})
|
|
345
|
+
],
|
|
346
|
+
[t]
|
|
347
|
+
);
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// src/pages/products/product-create/components/product-create-attributes-form/product-create-attributes-form.tsx
|
|
351
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
352
|
+
var Root = () => {
|
|
353
|
+
const { t } = useTranslation2();
|
|
354
|
+
const form = useTabbedForm();
|
|
355
|
+
const { setIsOpen } = useStackedModal();
|
|
356
|
+
const { fields, append, remove } = useFieldArray({
|
|
357
|
+
control: form.control,
|
|
358
|
+
name: "attributes"
|
|
359
|
+
});
|
|
360
|
+
const handleCreateNew = () => {
|
|
361
|
+
append({
|
|
362
|
+
attribute_id: void 0,
|
|
363
|
+
title: "",
|
|
364
|
+
values: [],
|
|
365
|
+
is_custom: true,
|
|
366
|
+
use_for_variants: false
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
const handleAddExisting = () => {
|
|
370
|
+
setIsOpen(ADD_ATTRIBUTES_MODAL_ID, true);
|
|
371
|
+
};
|
|
372
|
+
return /* @__PURE__ */ jsxs2(
|
|
373
|
+
"div",
|
|
374
|
+
{
|
|
375
|
+
className: "flex flex-col items-center p-16",
|
|
376
|
+
"data-testid": "product-create-attributes-form",
|
|
377
|
+
children: [
|
|
378
|
+
/* @__PURE__ */ jsx2(StackedFocusModal, { id: ADD_ATTRIBUTES_MODAL_ID, children: /* @__PURE__ */ jsx2(ProductCreateAddAttributesModal, {}) }),
|
|
379
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
|
|
380
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
381
|
+
/* @__PURE__ */ jsx2(Heading, { level: "h2", children: t("products.create.attributes.header") }),
|
|
382
|
+
/* @__PURE__ */ jsx2(
|
|
383
|
+
Text,
|
|
384
|
+
{
|
|
385
|
+
size: "small",
|
|
386
|
+
className: "text-ui-fg-subtle mt-1 whitespace-pre-line",
|
|
387
|
+
children: t("products.create.attributes.description")
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
] }),
|
|
391
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
|
|
392
|
+
/* @__PURE__ */ jsx2(
|
|
393
|
+
Button2,
|
|
394
|
+
{
|
|
395
|
+
type: "button",
|
|
396
|
+
variant: "secondary",
|
|
397
|
+
size: "small",
|
|
398
|
+
onClick: handleAddExisting,
|
|
399
|
+
"data-testid": "product-create-attributes-add-existing",
|
|
400
|
+
children: t("products.create.attributes.addExisting")
|
|
401
|
+
}
|
|
402
|
+
),
|
|
403
|
+
/* @__PURE__ */ jsx2(
|
|
404
|
+
Button2,
|
|
405
|
+
{
|
|
406
|
+
type: "button",
|
|
407
|
+
variant: "secondary",
|
|
408
|
+
size: "small",
|
|
409
|
+
onClick: handleCreateNew,
|
|
410
|
+
"data-testid": "product-create-attributes-create-new",
|
|
411
|
+
children: t("products.create.attributes.createNew")
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
] }),
|
|
415
|
+
fields.some((f) => !f.is_custom && !!f.attribute_id) && /* @__PURE__ */ jsx2(SelectedAttributes, { fields, remove }),
|
|
416
|
+
fields.some((f) => f.is_custom) && /* @__PURE__ */ jsx2(
|
|
417
|
+
"ul",
|
|
418
|
+
{
|
|
419
|
+
className: "flex flex-col gap-y-4",
|
|
420
|
+
"data-testid": "product-create-attributes-list",
|
|
421
|
+
children: fields.map((field, index) => {
|
|
422
|
+
if (!field.is_custom) return null;
|
|
423
|
+
const useForVariants = form.watch(
|
|
424
|
+
`attributes.${index}.use_for_variants`
|
|
425
|
+
);
|
|
426
|
+
return /* @__PURE__ */ jsxs2(
|
|
427
|
+
"li",
|
|
428
|
+
{
|
|
429
|
+
className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-start gap-1.5 rounded-xl p-1.5",
|
|
430
|
+
"data-testid": `product-create-attribute-row-${index}`,
|
|
431
|
+
children: [
|
|
432
|
+
/* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
|
|
433
|
+
/* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
|
|
434
|
+
Label,
|
|
435
|
+
{
|
|
436
|
+
size: "xsmall",
|
|
437
|
+
weight: "plus",
|
|
438
|
+
className: "text-ui-fg-subtle",
|
|
439
|
+
htmlFor: `attributes.${index}.title`,
|
|
440
|
+
children: t("fields.title")
|
|
441
|
+
}
|
|
442
|
+
) }),
|
|
443
|
+
/* @__PURE__ */ jsx2(
|
|
444
|
+
Input,
|
|
445
|
+
{
|
|
446
|
+
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
447
|
+
...form.register(
|
|
448
|
+
`attributes.${index}.title`
|
|
449
|
+
),
|
|
450
|
+
placeholder: t(
|
|
451
|
+
"products.create.attributes.titlePlaceholder"
|
|
452
|
+
),
|
|
453
|
+
"data-testid": `product-create-attribute-title-${index}`
|
|
454
|
+
}
|
|
455
|
+
),
|
|
456
|
+
/* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
|
|
457
|
+
Label,
|
|
458
|
+
{
|
|
459
|
+
size: "xsmall",
|
|
460
|
+
weight: "plus",
|
|
461
|
+
className: "text-ui-fg-subtle",
|
|
462
|
+
htmlFor: `attributes.${index}.values`,
|
|
463
|
+
children: t("fields.values")
|
|
464
|
+
}
|
|
465
|
+
) }),
|
|
466
|
+
/* @__PURE__ */ jsx2(
|
|
467
|
+
Controller,
|
|
468
|
+
{
|
|
469
|
+
control: form.control,
|
|
470
|
+
name: `attributes.${index}.values`,
|
|
471
|
+
render: ({ field: { onChange, value, ...field2 } }) => useForVariants ? /* @__PURE__ */ jsx2(
|
|
472
|
+
ChipInput,
|
|
473
|
+
{
|
|
474
|
+
...field2,
|
|
475
|
+
variant: "contrast",
|
|
476
|
+
value: Array.isArray(value) ? value : [],
|
|
477
|
+
onChange,
|
|
478
|
+
placeholder: t(
|
|
479
|
+
"products.create.attributes.valuePlaceholder"
|
|
480
|
+
),
|
|
481
|
+
"data-testid": `product-create-attribute-values-${index}`
|
|
482
|
+
}
|
|
483
|
+
) : /* @__PURE__ */ jsx2(
|
|
484
|
+
Textarea,
|
|
485
|
+
{
|
|
486
|
+
...field2,
|
|
487
|
+
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
488
|
+
value: Array.isArray(value) ? value[0] ?? "" : value ?? "",
|
|
489
|
+
onChange: (e) => onChange(e.target.value),
|
|
490
|
+
placeholder: t(
|
|
491
|
+
"products.create.attributes.valuePlaceholder"
|
|
492
|
+
),
|
|
493
|
+
"data-testid": `product-create-attribute-values-${index}`
|
|
494
|
+
}
|
|
495
|
+
)
|
|
496
|
+
}
|
|
497
|
+
),
|
|
498
|
+
/* @__PURE__ */ jsx2("div", {}),
|
|
499
|
+
/* @__PURE__ */ jsx2(
|
|
500
|
+
Form.Field,
|
|
501
|
+
{
|
|
502
|
+
control: form.control,
|
|
503
|
+
name: `attributes.${index}.use_for_variants`,
|
|
504
|
+
render: ({
|
|
505
|
+
field: { value, onChange, ref }
|
|
506
|
+
}) => /* @__PURE__ */ jsx2(Form.Item, { children: /* @__PURE__ */ jsxs2(
|
|
507
|
+
"div",
|
|
508
|
+
{
|
|
509
|
+
className: "flex items-start gap-x-3 py-1.5",
|
|
510
|
+
"data-testid": `product-create-attribute-use-for-variants-${index}`,
|
|
511
|
+
children: [
|
|
512
|
+
/* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(
|
|
513
|
+
Switch,
|
|
514
|
+
{
|
|
515
|
+
ref,
|
|
516
|
+
className: "shrink-0 rtl:rotate-180",
|
|
517
|
+
checked: value,
|
|
518
|
+
onCheckedChange: onChange
|
|
519
|
+
}
|
|
520
|
+
) }),
|
|
521
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
|
|
522
|
+
/* @__PURE__ */ jsx2(Label, { size: "xsmall", weight: "plus", children: t(
|
|
523
|
+
"products.create.attributes.useForVariants"
|
|
524
|
+
) }),
|
|
525
|
+
/* @__PURE__ */ jsx2(Hint, { className: "!txt-small", children: t(
|
|
526
|
+
"products.create.attributes.useForVariantsDescription"
|
|
527
|
+
) })
|
|
528
|
+
] })
|
|
529
|
+
]
|
|
530
|
+
}
|
|
531
|
+
) })
|
|
532
|
+
}
|
|
533
|
+
)
|
|
534
|
+
] }),
|
|
535
|
+
/* @__PURE__ */ jsx2(
|
|
536
|
+
IconButton,
|
|
537
|
+
{
|
|
538
|
+
type: "button",
|
|
539
|
+
size: "small",
|
|
540
|
+
variant: "transparent",
|
|
541
|
+
className: "text-ui-fg-muted",
|
|
542
|
+
onClick: () => remove(index),
|
|
543
|
+
"data-testid": `product-create-attribute-remove-${index}`,
|
|
544
|
+
children: /* @__PURE__ */ jsx2(XMarkMini, {})
|
|
545
|
+
}
|
|
546
|
+
)
|
|
547
|
+
]
|
|
548
|
+
},
|
|
549
|
+
field.id
|
|
550
|
+
);
|
|
551
|
+
})
|
|
552
|
+
}
|
|
553
|
+
),
|
|
554
|
+
/* @__PURE__ */ jsx2(RequiredAttributes, {})
|
|
555
|
+
] })
|
|
556
|
+
]
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
};
|
|
560
|
+
var SelectedAttributes = ({
|
|
561
|
+
fields,
|
|
562
|
+
remove
|
|
563
|
+
}) => {
|
|
564
|
+
const { t } = useTranslation2();
|
|
565
|
+
const form = useTabbedForm();
|
|
566
|
+
const entries = fields.map((field, index) => ({ field, index })).filter(({ field }) => !field.is_custom && !field.is_required && !!field.attribute_id);
|
|
567
|
+
if (!entries.length) return null;
|
|
568
|
+
return /* @__PURE__ */ jsx2(
|
|
569
|
+
"ul",
|
|
570
|
+
{
|
|
571
|
+
className: "flex flex-col gap-y-4",
|
|
572
|
+
"data-testid": "product-create-selected-attributes-list",
|
|
573
|
+
children: entries.map(({ field, index }) => {
|
|
574
|
+
const attrType = field.type;
|
|
575
|
+
const availableValues = field.available_values ?? [];
|
|
576
|
+
return /* @__PURE__ */ jsxs2(
|
|
577
|
+
"li",
|
|
578
|
+
{
|
|
579
|
+
className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-start gap-1.5 rounded-xl p-1.5",
|
|
580
|
+
"data-testid": `product-create-selected-attribute-row-${index}`,
|
|
581
|
+
children: [
|
|
582
|
+
/* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
|
|
583
|
+
/* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
|
|
584
|
+
Label,
|
|
585
|
+
{
|
|
586
|
+
size: "xsmall",
|
|
587
|
+
weight: "plus",
|
|
588
|
+
className: "text-ui-fg-subtle",
|
|
589
|
+
children: t("fields.title")
|
|
590
|
+
}
|
|
591
|
+
) }),
|
|
592
|
+
/* @__PURE__ */ jsx2(
|
|
593
|
+
Input,
|
|
594
|
+
{
|
|
595
|
+
value: field.title,
|
|
596
|
+
disabled: true,
|
|
597
|
+
className: "bg-ui-bg-field-component",
|
|
598
|
+
"data-testid": `product-create-selected-attribute-title-${index}`
|
|
599
|
+
}
|
|
600
|
+
),
|
|
601
|
+
/* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
|
|
602
|
+
Label,
|
|
603
|
+
{
|
|
604
|
+
size: "xsmall",
|
|
605
|
+
weight: "plus",
|
|
606
|
+
className: "text-ui-fg-subtle",
|
|
607
|
+
children: t("fields.values")
|
|
608
|
+
}
|
|
609
|
+
) }),
|
|
610
|
+
attrType === import_types.AttributeType.MULTI_SELECT ? /* @__PURE__ */ jsx2(
|
|
611
|
+
Controller,
|
|
612
|
+
{
|
|
613
|
+
control: form.control,
|
|
614
|
+
name: `attributes.${index}.values`,
|
|
615
|
+
render: ({ field: { onChange, value, ref, ...rest } }) => /* @__PURE__ */ jsx2(
|
|
616
|
+
Combobox,
|
|
617
|
+
{
|
|
618
|
+
...rest,
|
|
619
|
+
ref,
|
|
620
|
+
value: Array.isArray(value) ? value : [],
|
|
621
|
+
onChange: (val) => onChange(val ?? []),
|
|
622
|
+
options: availableValues.map((v) => ({
|
|
623
|
+
value: v.name,
|
|
624
|
+
label: v.name
|
|
625
|
+
})),
|
|
626
|
+
placeholder: t(
|
|
627
|
+
"products.create.attributes.selectValues"
|
|
628
|
+
)
|
|
629
|
+
}
|
|
630
|
+
)
|
|
631
|
+
}
|
|
632
|
+
) : attrType === import_types.AttributeType.SINGLE_SELECT ? /* @__PURE__ */ jsx2(
|
|
633
|
+
Controller,
|
|
634
|
+
{
|
|
635
|
+
control: form.control,
|
|
636
|
+
name: `attributes.${index}.values`,
|
|
637
|
+
render: ({ field: { onChange, value, ref, ...rest } }) => /* @__PURE__ */ jsxs2(
|
|
638
|
+
Select,
|
|
639
|
+
{
|
|
640
|
+
...rest,
|
|
641
|
+
value: typeof value === "string" ? value : value?.[0] ?? "",
|
|
642
|
+
onValueChange: onChange,
|
|
643
|
+
children: [
|
|
644
|
+
/* @__PURE__ */ jsx2(Select.Trigger, { ref, children: /* @__PURE__ */ jsx2(
|
|
645
|
+
Select.Value,
|
|
646
|
+
{
|
|
647
|
+
placeholder: t(
|
|
648
|
+
"products.create.attributes.selectValues"
|
|
649
|
+
)
|
|
650
|
+
}
|
|
651
|
+
) }),
|
|
652
|
+
/* @__PURE__ */ jsx2(Select.Content, { children: availableValues.map((v) => /* @__PURE__ */ jsx2(Select.Item, { value: v.name, children: v.name }, v.id)) })
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
)
|
|
656
|
+
}
|
|
657
|
+
) : attrType === import_types.AttributeType.TEXT ? /* @__PURE__ */ jsx2(
|
|
658
|
+
Controller,
|
|
659
|
+
{
|
|
660
|
+
control: form.control,
|
|
661
|
+
name: `attributes.${index}.values`,
|
|
662
|
+
render: ({ field: { onChange, value, ...rest } }) => /* @__PURE__ */ jsx2(
|
|
663
|
+
Textarea,
|
|
664
|
+
{
|
|
665
|
+
...rest,
|
|
666
|
+
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
667
|
+
value: typeof value === "string" ? value : value?.[0] ?? "",
|
|
668
|
+
onChange: (e) => onChange(e.target.value),
|
|
669
|
+
placeholder: t(
|
|
670
|
+
"products.create.attributes.valuePlaceholder"
|
|
671
|
+
)
|
|
672
|
+
}
|
|
673
|
+
)
|
|
674
|
+
}
|
|
675
|
+
) : attrType === import_types.AttributeType.TOGGLE ? /* @__PURE__ */ jsx2(
|
|
676
|
+
Controller,
|
|
677
|
+
{
|
|
678
|
+
control: form.control,
|
|
679
|
+
name: `attributes.${index}.values`,
|
|
680
|
+
render: ({ field: { onChange, value, ...rest } }) => /* @__PURE__ */ jsxs2(
|
|
681
|
+
Select,
|
|
682
|
+
{
|
|
683
|
+
...rest,
|
|
684
|
+
value: typeof value === "string" ? value : value?.[0] ?? "",
|
|
685
|
+
onValueChange: onChange,
|
|
686
|
+
children: [
|
|
687
|
+
/* @__PURE__ */ jsx2(Select.Trigger, { children: /* @__PURE__ */ jsx2(
|
|
688
|
+
Select.Value,
|
|
689
|
+
{
|
|
690
|
+
placeholder: t(
|
|
691
|
+
"products.create.attributes.selectValues"
|
|
692
|
+
)
|
|
693
|
+
}
|
|
694
|
+
) }),
|
|
695
|
+
/* @__PURE__ */ jsxs2(Select.Content, { children: [
|
|
696
|
+
/* @__PURE__ */ jsx2(Select.Item, { value: "true", children: t("filters.radio.yes") }),
|
|
697
|
+
/* @__PURE__ */ jsx2(Select.Item, { value: "false", children: t("filters.radio.no") })
|
|
698
|
+
] })
|
|
699
|
+
]
|
|
700
|
+
}
|
|
701
|
+
)
|
|
702
|
+
}
|
|
703
|
+
) : /* @__PURE__ */ jsx2(
|
|
704
|
+
Controller,
|
|
705
|
+
{
|
|
706
|
+
control: form.control,
|
|
707
|
+
name: `attributes.${index}.values`,
|
|
708
|
+
render: ({ field: { onChange, value, ...rest } }) => /* @__PURE__ */ jsx2(
|
|
709
|
+
Input,
|
|
710
|
+
{
|
|
711
|
+
...rest,
|
|
712
|
+
value: typeof value === "string" ? value : value?.[0] ?? "",
|
|
713
|
+
onChange: (e) => onChange(e.target.value),
|
|
714
|
+
placeholder: t(
|
|
715
|
+
"products.create.attributes.valuePlaceholder"
|
|
716
|
+
)
|
|
717
|
+
}
|
|
718
|
+
)
|
|
719
|
+
}
|
|
720
|
+
),
|
|
721
|
+
field.use_for_variants && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
722
|
+
/* @__PURE__ */ jsx2("div", {}),
|
|
723
|
+
/* @__PURE__ */ jsx2(VariantAxisTip, {})
|
|
724
|
+
] })
|
|
725
|
+
] }),
|
|
726
|
+
/* @__PURE__ */ jsx2(
|
|
727
|
+
IconButton,
|
|
728
|
+
{
|
|
729
|
+
type: "button",
|
|
730
|
+
size: "small",
|
|
731
|
+
variant: "transparent",
|
|
732
|
+
className: "text-ui-fg-muted",
|
|
733
|
+
onClick: () => remove(index),
|
|
734
|
+
"data-testid": `product-create-selected-attribute-remove-${index}`,
|
|
735
|
+
children: /* @__PURE__ */ jsx2(XMarkMini, {})
|
|
736
|
+
}
|
|
737
|
+
)
|
|
738
|
+
]
|
|
739
|
+
},
|
|
740
|
+
field.id
|
|
741
|
+
);
|
|
742
|
+
})
|
|
743
|
+
}
|
|
744
|
+
);
|
|
745
|
+
};
|
|
746
|
+
var RequiredAttributes = () => {
|
|
747
|
+
const { t } = useTranslation2();
|
|
748
|
+
const form = useTabbedForm();
|
|
749
|
+
const categoryId = form.watch("category_id");
|
|
750
|
+
const { product_attributes } = useProductAttributes(
|
|
751
|
+
{
|
|
752
|
+
category_id: categoryId,
|
|
753
|
+
is_required: true
|
|
754
|
+
},
|
|
755
|
+
{ enabled: !!categoryId }
|
|
756
|
+
);
|
|
757
|
+
const attributes = form.watch("attributes") || [];
|
|
758
|
+
useEffect2(() => {
|
|
759
|
+
if (!product_attributes) return;
|
|
760
|
+
const currentAttributes = form.getValues("attributes") || [];
|
|
761
|
+
const requiredIds = new Set(product_attributes.map((a) => a.id));
|
|
762
|
+
const otherAttributes = currentAttributes.filter(
|
|
763
|
+
(a) => a.is_custom || !requiredIds.has(a.attribute_id ?? "")
|
|
764
|
+
);
|
|
765
|
+
const requiredAttributes = product_attributes.map((attr) => {
|
|
766
|
+
const existing = currentAttributes.find(
|
|
767
|
+
(a) => a.attribute_id === attr.id
|
|
768
|
+
);
|
|
769
|
+
if (existing) return existing;
|
|
770
|
+
return {
|
|
771
|
+
attribute_id: attr.id,
|
|
772
|
+
title: attr.name,
|
|
773
|
+
values: attr.type === import_types.AttributeType.MULTI_SELECT ? [] : "",
|
|
774
|
+
is_custom: false,
|
|
775
|
+
is_required: true,
|
|
776
|
+
use_for_variants: attr.is_variant_axis
|
|
777
|
+
};
|
|
778
|
+
});
|
|
779
|
+
form.setValue("attributes", [...otherAttributes, ...requiredAttributes]);
|
|
780
|
+
}, [product_attributes]);
|
|
781
|
+
if (!categoryId || !product_attributes?.length) return null;
|
|
782
|
+
const requiredEntries = attributes.map((attr, index) => ({ attr, index })).filter(({ attr }) => !attr.is_custom);
|
|
783
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
784
|
+
/* @__PURE__ */ jsx2("div", { className: "border-ui-border-base border-t border-dashed" }),
|
|
785
|
+
/* @__PURE__ */ jsxs2(
|
|
786
|
+
"div",
|
|
787
|
+
{
|
|
788
|
+
className: "flex flex-col gap-y-6",
|
|
789
|
+
"data-testid": "product-create-attributes-required",
|
|
790
|
+
children: [
|
|
791
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
792
|
+
/* @__PURE__ */ jsx2(Text, { size: "small", weight: "plus", leading: "compact", children: t("products.create.attributes.requiredAttributes") }),
|
|
793
|
+
/* @__PURE__ */ jsx2(Text, { size: "small", className: "text-ui-fg-subtle", children: t("products.create.attributes.requiredAttributesHint") })
|
|
794
|
+
] }),
|
|
795
|
+
requiredEntries.map(({ attr, index }) => {
|
|
796
|
+
const apiAttr = product_attributes.find(
|
|
797
|
+
(a) => a.id === attr.attribute_id
|
|
798
|
+
);
|
|
799
|
+
if (!apiAttr) return null;
|
|
800
|
+
return /* @__PURE__ */ jsx2(
|
|
801
|
+
RequiredAttributeField,
|
|
802
|
+
{
|
|
803
|
+
attribute: apiAttr,
|
|
804
|
+
index
|
|
805
|
+
},
|
|
806
|
+
apiAttr.id
|
|
807
|
+
);
|
|
808
|
+
})
|
|
809
|
+
]
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
] });
|
|
813
|
+
};
|
|
814
|
+
var RequiredAttributeField = ({
|
|
815
|
+
attribute,
|
|
816
|
+
index
|
|
817
|
+
}) => {
|
|
818
|
+
const { t } = useTranslation2();
|
|
819
|
+
const form = useTabbedForm();
|
|
820
|
+
return /* @__PURE__ */ jsx2(
|
|
821
|
+
Form.Field,
|
|
822
|
+
{
|
|
823
|
+
control: form.control,
|
|
824
|
+
name: `attributes.${index}.values`,
|
|
825
|
+
render: ({ field: { onChange, value, ref, ...field } }) => /* @__PURE__ */ jsxs2(Form.Item, { children: [
|
|
826
|
+
/* @__PURE__ */ jsx2(Form.Label, { children: attribute.name }),
|
|
827
|
+
/* @__PURE__ */ jsx2(Form.Control, { children: attribute.type === import_types.AttributeType.SINGLE_SELECT ? /* @__PURE__ */ jsxs2(
|
|
828
|
+
Select,
|
|
829
|
+
{
|
|
830
|
+
...field,
|
|
831
|
+
value: typeof value === "string" ? value : value?.[0] ?? "",
|
|
832
|
+
onValueChange: onChange,
|
|
833
|
+
children: [
|
|
834
|
+
/* @__PURE__ */ jsx2(Select.Trigger, { ref, children: /* @__PURE__ */ jsx2(
|
|
835
|
+
Select.Value,
|
|
836
|
+
{
|
|
837
|
+
placeholder: t(
|
|
838
|
+
"products.create.attributes.valuePlaceholder"
|
|
839
|
+
)
|
|
840
|
+
}
|
|
841
|
+
) }),
|
|
842
|
+
/* @__PURE__ */ jsx2(Select.Content, { children: attribute.values?.map((v) => /* @__PURE__ */ jsx2(Select.Item, { value: v.name, children: v.name }, v.id)) })
|
|
843
|
+
]
|
|
844
|
+
}
|
|
845
|
+
) : attribute.type === import_types.AttributeType.MULTI_SELECT ? /* @__PURE__ */ jsx2(
|
|
846
|
+
Combobox,
|
|
847
|
+
{
|
|
848
|
+
...field,
|
|
849
|
+
ref,
|
|
850
|
+
value: Array.isArray(value) ? value : [],
|
|
851
|
+
onChange: (val) => onChange(val ?? []),
|
|
852
|
+
options: attribute.values?.map((v) => ({
|
|
853
|
+
value: v.name,
|
|
854
|
+
label: v.name
|
|
855
|
+
})) ?? [],
|
|
856
|
+
placeholder: t(
|
|
857
|
+
"products.create.attributes.selectValues"
|
|
858
|
+
)
|
|
859
|
+
}
|
|
860
|
+
) : attribute.type === import_types.AttributeType.TEXT ? /* @__PURE__ */ jsx2(
|
|
861
|
+
Input,
|
|
862
|
+
{
|
|
863
|
+
...field,
|
|
864
|
+
ref,
|
|
865
|
+
value: typeof value === "string" ? value : value?.[0] ?? "",
|
|
866
|
+
onChange: (e) => onChange(e.target.value),
|
|
867
|
+
placeholder: t(
|
|
868
|
+
"products.create.attributes.valuePlaceholder"
|
|
869
|
+
)
|
|
870
|
+
}
|
|
871
|
+
) : attribute.type === import_types.AttributeType.TOGGLE ? /* @__PURE__ */ jsx2(
|
|
872
|
+
Switch,
|
|
873
|
+
{
|
|
874
|
+
...field,
|
|
875
|
+
className: "rtl:rotate-180",
|
|
876
|
+
checked: value === "true" || value === true,
|
|
877
|
+
onCheckedChange: (checked) => onChange(String(checked))
|
|
878
|
+
}
|
|
879
|
+
) : /* @__PURE__ */ jsx2(
|
|
880
|
+
Input,
|
|
881
|
+
{
|
|
882
|
+
...field,
|
|
883
|
+
ref,
|
|
884
|
+
value: typeof value === "string" ? value : value?.[0] ?? "",
|
|
885
|
+
onChange: (e) => onChange(e.target.value),
|
|
886
|
+
placeholder: t(
|
|
887
|
+
"products.create.attributes.valuePlaceholder"
|
|
888
|
+
)
|
|
889
|
+
}
|
|
890
|
+
) }),
|
|
891
|
+
/* @__PURE__ */ jsx2(Form.ErrorMessage, {}),
|
|
892
|
+
attribute.is_variant_axis && /* @__PURE__ */ jsx2(VariantAxisTip, {})
|
|
893
|
+
] })
|
|
894
|
+
}
|
|
895
|
+
);
|
|
896
|
+
};
|
|
897
|
+
var VariantAxisTip = () => {
|
|
898
|
+
const { t } = useTranslation2();
|
|
899
|
+
return /* @__PURE__ */ jsx2(InlineTip, { label: t("products.create.attributes.tip"), children: t("products.create.attributes.variantAxisTip") });
|
|
900
|
+
};
|
|
901
|
+
Root._tabMeta = defineTabMeta({
|
|
902
|
+
id: "attributes",
|
|
903
|
+
labelKey: "products.create.tabs.attributes",
|
|
904
|
+
validationFields: ["attributes"]
|
|
905
|
+
});
|
|
906
|
+
var ProductCreateAttributesForm = Root;
|
|
907
|
+
|
|
908
|
+
// src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx
|
|
909
|
+
import { Heading as Heading3 } from "@medusajs/ui";
|
|
910
|
+
import { useTranslation as useTranslation6 } from "react-i18next";
|
|
911
|
+
|
|
912
|
+
// src/pages/products/product-create/components/product-create-details-form/components/product-create-details-general-section/product-create-general-section.tsx
|
|
913
|
+
import { Input as Input2, Textarea as Textarea2 } from "@medusajs/ui";
|
|
914
|
+
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
915
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
916
|
+
var ProductCreateGeneralSection = () => {
|
|
917
|
+
const form = useTabbedForm();
|
|
918
|
+
const { t } = useTranslation3();
|
|
919
|
+
return /* @__PURE__ */ jsxs3("div", { id: "general", className: "flex flex-col gap-y-6", "data-testid": "product-create-general-section", children: [
|
|
920
|
+
/* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-y-2", "data-testid": "product-create-general-section-fields", children: /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-3", "data-testid": "product-create-general-section-title-fields", children: [
|
|
921
|
+
/* @__PURE__ */ jsx3(
|
|
922
|
+
Form.Field,
|
|
923
|
+
{
|
|
924
|
+
control: form.control,
|
|
925
|
+
name: "title",
|
|
926
|
+
render: ({ field }) => {
|
|
927
|
+
return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-title-item", children: [
|
|
928
|
+
/* @__PURE__ */ jsx3(Form.Label, { "data-testid": "product-create-general-section-title-label", children: t("products.fields.title.label") }),
|
|
929
|
+
/* @__PURE__ */ jsx3(Form.Control, { "data-testid": "product-create-general-section-title-control", children: /* @__PURE__ */ jsx3(Input2, { ...field, placeholder: t("products.fields.title.placeholder"), "data-testid": "product-create-general-section-title-input" }) })
|
|
930
|
+
] });
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
),
|
|
934
|
+
/* @__PURE__ */ jsx3(
|
|
935
|
+
Form.Field,
|
|
936
|
+
{
|
|
937
|
+
control: form.control,
|
|
938
|
+
name: "subtitle",
|
|
939
|
+
render: ({ field }) => {
|
|
940
|
+
return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-subtitle-item", children: [
|
|
941
|
+
/* @__PURE__ */ jsx3(Form.Label, { optional: true, "data-testid": "product-create-general-section-subtitle-label", children: t("products.fields.subtitle.label") }),
|
|
942
|
+
/* @__PURE__ */ jsx3(Form.Control, { "data-testid": "product-create-general-section-subtitle-control", children: /* @__PURE__ */ jsx3(Input2, { ...field, placeholder: t("products.fields.subtitle.placeholder"), "data-testid": "product-create-general-section-subtitle-input" }) })
|
|
943
|
+
] });
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
),
|
|
947
|
+
/* @__PURE__ */ jsx3(
|
|
948
|
+
Form.Field,
|
|
949
|
+
{
|
|
950
|
+
control: form.control,
|
|
951
|
+
name: "handle",
|
|
952
|
+
render: ({ field }) => {
|
|
953
|
+
return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-handle-item", children: [
|
|
954
|
+
/* @__PURE__ */ jsx3(
|
|
955
|
+
Form.Label,
|
|
956
|
+
{
|
|
957
|
+
tooltip: t("products.fields.handle.tooltip"),
|
|
958
|
+
optional: true,
|
|
959
|
+
"data-testid": "product-create-general-section-handle-label",
|
|
960
|
+
children: t("fields.handle")
|
|
961
|
+
}
|
|
962
|
+
),
|
|
963
|
+
/* @__PURE__ */ jsx3(Form.Control, { "data-testid": "product-create-general-section-handle-control", children: /* @__PURE__ */ jsx3(HandleInput, { ...field, placeholder: t("products.fields.handle.placeholder"), "data-testid": "product-create-general-section-handle-input" }) })
|
|
964
|
+
] });
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
)
|
|
968
|
+
] }) }),
|
|
969
|
+
/* @__PURE__ */ jsx3(
|
|
970
|
+
Form.Field,
|
|
971
|
+
{
|
|
972
|
+
control: form.control,
|
|
973
|
+
name: "description",
|
|
974
|
+
render: ({ field }) => {
|
|
975
|
+
return /* @__PURE__ */ jsxs3(Form.Item, { "data-testid": "product-create-general-section-description-item", children: [
|
|
976
|
+
/* @__PURE__ */ jsx3(Form.Label, { optional: true, "data-testid": "product-create-general-section-description-label", children: t("products.fields.description.label") }),
|
|
977
|
+
/* @__PURE__ */ jsx3(Form.Control, { "data-testid": "product-create-general-section-description-control", children: /* @__PURE__ */ jsx3(Textarea2, { ...field, placeholder: t("products.fields.description.placeholder"), "data-testid": "product-create-general-section-description-input" }) })
|
|
978
|
+
] });
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
)
|
|
982
|
+
] });
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
// src/pages/products/product-create/components/product-create-details-form/components/product-create-details-media-section/product-create-details-media-section.tsx
|
|
986
|
+
import {
|
|
987
|
+
defaultDropAnimationSideEffects,
|
|
988
|
+
DndContext,
|
|
989
|
+
DragOverlay,
|
|
990
|
+
KeyboardSensor,
|
|
991
|
+
PointerSensor,
|
|
992
|
+
useSensor,
|
|
993
|
+
useSensors
|
|
994
|
+
} from "@dnd-kit/core";
|
|
995
|
+
import {
|
|
996
|
+
arrayMove,
|
|
997
|
+
SortableContext,
|
|
998
|
+
sortableKeyboardCoordinates,
|
|
999
|
+
useSortable
|
|
1000
|
+
} from "@dnd-kit/sortable";
|
|
1001
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
1002
|
+
import {
|
|
1003
|
+
DotsSix,
|
|
1004
|
+
StackPerspective,
|
|
1005
|
+
ThumbnailBadge,
|
|
1006
|
+
Trash,
|
|
1007
|
+
XMark
|
|
1008
|
+
} from "@medusajs/icons";
|
|
1009
|
+
import { IconButton as IconButton2, Text as Text2 } from "@medusajs/ui";
|
|
1010
|
+
import { useState as useState2 } from "react";
|
|
1011
|
+
import { useFieldArray as useFieldArray2 } from "react-hook-form";
|
|
1012
|
+
import { useTranslation as useTranslation4 } from "react-i18next";
|
|
1013
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1014
|
+
var dropAnimationConfig = {
|
|
1015
|
+
sideEffects: defaultDropAnimationSideEffects({
|
|
1016
|
+
styles: {
|
|
1017
|
+
active: {
|
|
1018
|
+
opacity: "0.4"
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
})
|
|
1022
|
+
};
|
|
1023
|
+
var ProductCreateMediaSection = () => {
|
|
1024
|
+
const form = useTabbedForm();
|
|
1025
|
+
const { fields, append, remove } = useFieldArray2({
|
|
1026
|
+
name: "media",
|
|
1027
|
+
control: form.control,
|
|
1028
|
+
keyName: "field_id"
|
|
1029
|
+
});
|
|
1030
|
+
const [activeId, setActiveId] = useState2(null);
|
|
1031
|
+
const sensors = useSensors(
|
|
1032
|
+
useSensor(PointerSensor),
|
|
1033
|
+
useSensor(KeyboardSensor, {
|
|
1034
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
1035
|
+
})
|
|
1036
|
+
);
|
|
1037
|
+
const handleDragStart = (event) => {
|
|
1038
|
+
setActiveId(event.active.id);
|
|
1039
|
+
};
|
|
1040
|
+
const handleDragEnd = (event) => {
|
|
1041
|
+
setActiveId(null);
|
|
1042
|
+
const { active, over } = event;
|
|
1043
|
+
if (active.id !== over?.id) {
|
|
1044
|
+
const oldIndex = fields.findIndex((item) => item.field_id === active.id);
|
|
1045
|
+
const newIndex = fields.findIndex((item) => item.field_id === over?.id);
|
|
1046
|
+
form.setValue("media", arrayMove(fields, oldIndex, newIndex), {
|
|
1047
|
+
shouldDirty: true,
|
|
1048
|
+
shouldTouch: true
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
const handleDragCancel = () => {
|
|
1053
|
+
setActiveId(null);
|
|
1054
|
+
};
|
|
1055
|
+
const getOnDelete = (index) => {
|
|
1056
|
+
return () => {
|
|
1057
|
+
remove(index);
|
|
1058
|
+
};
|
|
1059
|
+
};
|
|
1060
|
+
const getMakeThumbnail = (index) => {
|
|
1061
|
+
return () => {
|
|
1062
|
+
const newFields = fields.map((field, i) => {
|
|
1063
|
+
return {
|
|
1064
|
+
...field,
|
|
1065
|
+
isThumbnail: i === index
|
|
1066
|
+
};
|
|
1067
|
+
});
|
|
1068
|
+
form.setValue("media", newFields, {
|
|
1069
|
+
shouldDirty: true,
|
|
1070
|
+
shouldTouch: true
|
|
1071
|
+
});
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1074
|
+
const getItemHandlers = (index) => {
|
|
1075
|
+
return {
|
|
1076
|
+
onDelete: getOnDelete(index),
|
|
1077
|
+
onMakeThumbnail: getMakeThumbnail(index)
|
|
1078
|
+
};
|
|
1079
|
+
};
|
|
1080
|
+
return /* @__PURE__ */ jsxs4("div", { id: "media", className: "flex flex-col gap-y-2", "data-testid": "product-create-media-section", children: [
|
|
1081
|
+
/* @__PURE__ */ jsx4(UploadMediaFormItem, { form, append, showHint: false, "data-testid": "product-create-media-section-upload" }),
|
|
1082
|
+
/* @__PURE__ */ jsxs4(
|
|
1083
|
+
DndContext,
|
|
1084
|
+
{
|
|
1085
|
+
sensors,
|
|
1086
|
+
onDragEnd: handleDragEnd,
|
|
1087
|
+
onDragStart: handleDragStart,
|
|
1088
|
+
onDragCancel: handleDragCancel,
|
|
1089
|
+
children: [
|
|
1090
|
+
/* @__PURE__ */ jsx4(DragOverlay, { dropAnimation: dropAnimationConfig, children: activeId ? /* @__PURE__ */ jsx4(
|
|
1091
|
+
MediaGridItemOverlay,
|
|
1092
|
+
{
|
|
1093
|
+
field: fields.find((m) => m.field_id === activeId)
|
|
1094
|
+
}
|
|
1095
|
+
) : null }),
|
|
1096
|
+
/* @__PURE__ */ jsx4("ul", { className: "flex flex-col gap-y-2", "data-testid": "product-create-media-section-list", children: /* @__PURE__ */ jsx4(SortableContext, { items: fields.map((field) => field.field_id), children: fields.map((field, index) => {
|
|
1097
|
+
const { onDelete, onMakeThumbnail } = getItemHandlers(index);
|
|
1098
|
+
return /* @__PURE__ */ jsx4(
|
|
1099
|
+
MediaItem,
|
|
1100
|
+
{
|
|
1101
|
+
field,
|
|
1102
|
+
onDelete,
|
|
1103
|
+
onMakeThumbnail
|
|
1104
|
+
},
|
|
1105
|
+
field.field_id
|
|
1106
|
+
);
|
|
1107
|
+
}) }) })
|
|
1108
|
+
]
|
|
1109
|
+
}
|
|
1110
|
+
)
|
|
1111
|
+
] });
|
|
1112
|
+
};
|
|
1113
|
+
var MediaItem = ({ field, onDelete, onMakeThumbnail }) => {
|
|
1114
|
+
const { t } = useTranslation4();
|
|
1115
|
+
const {
|
|
1116
|
+
attributes,
|
|
1117
|
+
listeners,
|
|
1118
|
+
setNodeRef,
|
|
1119
|
+
setActivatorNodeRef,
|
|
1120
|
+
transform,
|
|
1121
|
+
transition,
|
|
1122
|
+
isDragging
|
|
1123
|
+
} = useSortable({ id: field.field_id });
|
|
1124
|
+
const style = {
|
|
1125
|
+
opacity: isDragging ? 0.4 : void 0,
|
|
1126
|
+
transform: CSS.Translate.toString(transform),
|
|
1127
|
+
transition
|
|
1128
|
+
};
|
|
1129
|
+
if (!field.file) {
|
|
1130
|
+
return null;
|
|
1131
|
+
}
|
|
1132
|
+
return /* @__PURE__ */ jsxs4(
|
|
1133
|
+
"li",
|
|
1134
|
+
{
|
|
1135
|
+
className: "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
1136
|
+
ref: setNodeRef,
|
|
1137
|
+
style,
|
|
1138
|
+
"data-testid": `product-create-media-section-item-${field.field_id}`,
|
|
1139
|
+
children: [
|
|
1140
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-2", children: [
|
|
1141
|
+
/* @__PURE__ */ jsx4(
|
|
1142
|
+
IconButton2,
|
|
1143
|
+
{
|
|
1144
|
+
variant: "transparent",
|
|
1145
|
+
type: "button",
|
|
1146
|
+
size: "small",
|
|
1147
|
+
...attributes,
|
|
1148
|
+
...listeners,
|
|
1149
|
+
ref: setActivatorNodeRef,
|
|
1150
|
+
className: "cursor-grab touch-none active:cursor-grabbing",
|
|
1151
|
+
children: /* @__PURE__ */ jsx4(DotsSix, { className: "text-ui-fg-muted" })
|
|
1152
|
+
}
|
|
1153
|
+
),
|
|
1154
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-3", children: [
|
|
1155
|
+
/* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx4(ThumbnailPreview, { url: field.url }) }),
|
|
1156
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
|
|
1157
|
+
/* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: field.file.name }),
|
|
1158
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
|
|
1159
|
+
field.isThumbnail && /* @__PURE__ */ jsx4(ThumbnailBadge, {}),
|
|
1160
|
+
/* @__PURE__ */ jsx4(
|
|
1161
|
+
Text2,
|
|
1162
|
+
{
|
|
1163
|
+
size: "xsmall",
|
|
1164
|
+
leading: "compact",
|
|
1165
|
+
className: "text-ui-fg-subtle",
|
|
1166
|
+
children: formatFileSize(field.file.size)
|
|
1167
|
+
}
|
|
1168
|
+
)
|
|
1169
|
+
] })
|
|
1170
|
+
] })
|
|
1171
|
+
] })
|
|
1172
|
+
] }),
|
|
1173
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
|
|
1174
|
+
/* @__PURE__ */ jsx4(
|
|
1175
|
+
ActionMenu,
|
|
1176
|
+
{
|
|
1177
|
+
groups: [
|
|
1178
|
+
{
|
|
1179
|
+
actions: [
|
|
1180
|
+
{
|
|
1181
|
+
label: t("products.media.makeThumbnail"),
|
|
1182
|
+
icon: /* @__PURE__ */ jsx4(StackPerspective, {}),
|
|
1183
|
+
onClick: onMakeThumbnail
|
|
1184
|
+
}
|
|
1185
|
+
]
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
actions: [
|
|
1189
|
+
{
|
|
1190
|
+
icon: /* @__PURE__ */ jsx4(Trash, {}),
|
|
1191
|
+
label: t("actions.delete"),
|
|
1192
|
+
onClick: onDelete
|
|
1193
|
+
}
|
|
1194
|
+
]
|
|
1195
|
+
}
|
|
1196
|
+
],
|
|
1197
|
+
"data-testid": `product-create-media-section-item-menu-${field.field_id}`
|
|
1198
|
+
}
|
|
1199
|
+
),
|
|
1200
|
+
/* @__PURE__ */ jsx4(
|
|
1201
|
+
IconButton2,
|
|
1202
|
+
{
|
|
1203
|
+
type: "button",
|
|
1204
|
+
size: "small",
|
|
1205
|
+
variant: "transparent",
|
|
1206
|
+
onClick: onDelete,
|
|
1207
|
+
"data-testid": `product-create-media-section-item-delete-${field.field_id}`,
|
|
1208
|
+
children: /* @__PURE__ */ jsx4(XMark, {})
|
|
1209
|
+
}
|
|
1210
|
+
)
|
|
1211
|
+
] })
|
|
1212
|
+
]
|
|
1213
|
+
}
|
|
1214
|
+
);
|
|
1215
|
+
};
|
|
1216
|
+
var MediaGridItemOverlay = ({ field }) => {
|
|
1217
|
+
return /* @__PURE__ */ jsxs4("li", { className: "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2", children: [
|
|
1218
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-2", children: [
|
|
1219
|
+
/* @__PURE__ */ jsx4(
|
|
1220
|
+
IconButton2,
|
|
1221
|
+
{
|
|
1222
|
+
variant: "transparent",
|
|
1223
|
+
size: "small",
|
|
1224
|
+
className: "cursor-grab touch-none active:cursor-grabbing",
|
|
1225
|
+
children: /* @__PURE__ */ jsx4(DotsSix, { className: "text-ui-fg-muted" })
|
|
1226
|
+
}
|
|
1227
|
+
),
|
|
1228
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-3", children: [
|
|
1229
|
+
/* @__PURE__ */ jsx4("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx4(ThumbnailPreview, { url: field.url }) }),
|
|
1230
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
|
|
1231
|
+
/* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: field.file?.name }),
|
|
1232
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
|
|
1233
|
+
field.isThumbnail && /* @__PURE__ */ jsx4(ThumbnailBadge, {}),
|
|
1234
|
+
/* @__PURE__ */ jsx4(
|
|
1235
|
+
Text2,
|
|
1236
|
+
{
|
|
1237
|
+
size: "xsmall",
|
|
1238
|
+
leading: "compact",
|
|
1239
|
+
className: "text-ui-fg-subtle",
|
|
1240
|
+
children: formatFileSize(field.file?.size ?? 0)
|
|
1241
|
+
}
|
|
1242
|
+
)
|
|
1243
|
+
] })
|
|
1244
|
+
] })
|
|
1245
|
+
] })
|
|
1246
|
+
] }),
|
|
1247
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
|
|
1248
|
+
/* @__PURE__ */ jsx4(ActionMenu, { groups: [] }),
|
|
1249
|
+
/* @__PURE__ */ jsx4(
|
|
1250
|
+
IconButton2,
|
|
1251
|
+
{
|
|
1252
|
+
type: "button",
|
|
1253
|
+
size: "small",
|
|
1254
|
+
variant: "transparent",
|
|
1255
|
+
onClick: () => {
|
|
1256
|
+
},
|
|
1257
|
+
children: /* @__PURE__ */ jsx4(XMark, {})
|
|
1258
|
+
}
|
|
1259
|
+
)
|
|
1260
|
+
] })
|
|
1261
|
+
] });
|
|
1262
|
+
};
|
|
1263
|
+
var ThumbnailPreview = ({ url }) => {
|
|
1264
|
+
if (!url) {
|
|
1265
|
+
return null;
|
|
1266
|
+
}
|
|
1267
|
+
return /* @__PURE__ */ jsx4("img", { src: url, alt: "", className: "size-full object-cover object-center" });
|
|
1268
|
+
};
|
|
1269
|
+
function formatFileSize(bytes, decimalPlaces = 2) {
|
|
1270
|
+
if (bytes === 0) {
|
|
1271
|
+
return "0 Bytes";
|
|
1272
|
+
}
|
|
1273
|
+
const k = 1024;
|
|
1274
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
1275
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1276
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPlaces)) + " " + sizes[i];
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// src/pages/products/product-create/components/product-create-details-form/components/product-create-details-variant-section/product-create-details-variant-section.tsx
|
|
1280
|
+
import {
|
|
1281
|
+
Alert,
|
|
1282
|
+
Checkbox,
|
|
1283
|
+
clx,
|
|
1284
|
+
Heading as Heading2,
|
|
1285
|
+
Hint as Hint2,
|
|
1286
|
+
InlineTip as InlineTip2,
|
|
1287
|
+
Label as Label2,
|
|
1288
|
+
Text as Text3
|
|
1289
|
+
} from "@medusajs/ui";
|
|
1290
|
+
import { useFieldArray as useFieldArray3, useWatch } from "react-hook-form";
|
|
1291
|
+
import { useTranslation as useTranslation5 } from "react-i18next";
|
|
1292
|
+
import { useMemo as useMemo2 } from "react";
|
|
1293
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1294
|
+
var ProductCreateVariantsSection = () => {
|
|
1295
|
+
const form = useTabbedForm();
|
|
1296
|
+
const { t } = useTranslation5();
|
|
1297
|
+
const variants = useFieldArray3({
|
|
1298
|
+
control: form.control,
|
|
1299
|
+
name: "variants"
|
|
1300
|
+
});
|
|
1301
|
+
const watchedAttributes = useWatch({
|
|
1302
|
+
control: form.control,
|
|
1303
|
+
name: "attributes",
|
|
1304
|
+
defaultValue: []
|
|
1305
|
+
});
|
|
1306
|
+
const watchedVariants = useWatch({
|
|
1307
|
+
control: form.control,
|
|
1308
|
+
name: "variants",
|
|
1309
|
+
defaultValue: []
|
|
1310
|
+
});
|
|
1311
|
+
const variantAxes = useMemo2(() => {
|
|
1312
|
+
return (watchedAttributes ?? []).filter((attr) => attr.use_for_variants).map((attr) => ({
|
|
1313
|
+
title: attr.title,
|
|
1314
|
+
values: Array.isArray(attr.values) ? attr.values : attr.values ? [attr.values] : []
|
|
1315
|
+
})).filter((axis) => axis.title && axis.values.length > 0);
|
|
1316
|
+
}, [watchedAttributes]);
|
|
1317
|
+
const hasVariantAxes = variantAxes.length > 0;
|
|
1318
|
+
const showInvalidVariantsMessage = form.formState.errors.variants?.root?.message === "invalid_length";
|
|
1319
|
+
const handleRankChange = (items) => {
|
|
1320
|
+
const update = items.map((item, index) => {
|
|
1321
|
+
const variant = watchedVariants.find((v) => v.title === item.title);
|
|
1322
|
+
return {
|
|
1323
|
+
id: item.id,
|
|
1324
|
+
...variant || item,
|
|
1325
|
+
variant_rank: index
|
|
1326
|
+
};
|
|
1327
|
+
});
|
|
1328
|
+
variants.replace(update);
|
|
1329
|
+
};
|
|
1330
|
+
const getCheckboxState = (variants2) => {
|
|
1331
|
+
if (variants2.every((variant) => variant.should_create)) {
|
|
1332
|
+
return true;
|
|
1333
|
+
}
|
|
1334
|
+
if (variants2.some((variant) => variant.should_create)) {
|
|
1335
|
+
return "indeterminate";
|
|
1336
|
+
}
|
|
1337
|
+
return false;
|
|
1338
|
+
};
|
|
1339
|
+
const onCheckboxChange = (value) => {
|
|
1340
|
+
switch (value) {
|
|
1341
|
+
case true: {
|
|
1342
|
+
const update = watchedVariants.map((variant) => ({
|
|
1343
|
+
...variant,
|
|
1344
|
+
should_create: true
|
|
1345
|
+
}));
|
|
1346
|
+
form.setValue("variants", update);
|
|
1347
|
+
break;
|
|
1348
|
+
}
|
|
1349
|
+
case false: {
|
|
1350
|
+
const update = watchedVariants.map((variant) => ({
|
|
1351
|
+
...variant,
|
|
1352
|
+
should_create: false
|
|
1353
|
+
}));
|
|
1354
|
+
form.setValue("variants", decorateVariantsWithDefaultValues(update));
|
|
1355
|
+
break;
|
|
1356
|
+
}
|
|
1357
|
+
case "indeterminate":
|
|
1358
|
+
break;
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
if (!hasVariantAxes) {
|
|
1362
|
+
return null;
|
|
1363
|
+
}
|
|
1364
|
+
return /* @__PURE__ */ jsxs5(
|
|
1365
|
+
"div",
|
|
1366
|
+
{
|
|
1367
|
+
id: "variants",
|
|
1368
|
+
className: "flex flex-col gap-y-8",
|
|
1369
|
+
"data-testid": "product-create-variants-section",
|
|
1370
|
+
children: [
|
|
1371
|
+
/* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx5(Heading2, { level: "h2", children: t("products.create.variants.header") }) }),
|
|
1372
|
+
/* @__PURE__ */ jsx5("div", { className: "grid grid-cols-1 gap-x-4 gap-y-8", children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-y-6", children: [
|
|
1373
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col", children: [
|
|
1374
|
+
/* @__PURE__ */ jsx5(Label2, { weight: "plus", children: t("products.create.variants.productVariants.label") }),
|
|
1375
|
+
/* @__PURE__ */ jsx5(Hint2, { children: t("products.create.variants.productVariants.hint") })
|
|
1376
|
+
] }),
|
|
1377
|
+
showInvalidVariantsMessage && /* @__PURE__ */ jsx5(Alert, { dismissible: true, variant: "error", children: t("products.create.errors.variants") }),
|
|
1378
|
+
variants.fields.length > 0 ? /* @__PURE__ */ jsxs5("div", { className: "overflow-hidden rounded-xl border", children: [
|
|
1379
|
+
/* @__PURE__ */ jsxs5(
|
|
1380
|
+
"div",
|
|
1381
|
+
{
|
|
1382
|
+
className: "bg-ui-bg-component text-ui-fg-subtle grid items-center gap-3 border-b px-6 py-2.5",
|
|
1383
|
+
style: {
|
|
1384
|
+
gridTemplateColumns: `20px 28px repeat(${variantAxes.length}, 1fr)`
|
|
1385
|
+
},
|
|
1386
|
+
children: [
|
|
1387
|
+
/* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(
|
|
1388
|
+
Checkbox,
|
|
1389
|
+
{
|
|
1390
|
+
className: "relative",
|
|
1391
|
+
checked: getCheckboxState(watchedVariants),
|
|
1392
|
+
onCheckedChange: onCheckboxChange
|
|
1393
|
+
}
|
|
1394
|
+
) }),
|
|
1395
|
+
/* @__PURE__ */ jsx5("div", {}),
|
|
1396
|
+
variantAxes.map((axis, index) => /* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", weight: "plus", children: axis.title }) }, index))
|
|
1397
|
+
]
|
|
1398
|
+
}
|
|
1399
|
+
),
|
|
1400
|
+
/* @__PURE__ */ jsx5(
|
|
1401
|
+
SortableList,
|
|
1402
|
+
{
|
|
1403
|
+
items: variants.fields,
|
|
1404
|
+
onChange: handleRankChange,
|
|
1405
|
+
renderItem: (item, index) => {
|
|
1406
|
+
return /* @__PURE__ */ jsx5(
|
|
1407
|
+
SortableList.Item,
|
|
1408
|
+
{
|
|
1409
|
+
id: item.id,
|
|
1410
|
+
className: clx("bg-ui-bg-base border-b", {
|
|
1411
|
+
"border-b-0": index === variants.fields.length - 1
|
|
1412
|
+
}),
|
|
1413
|
+
children: /* @__PURE__ */ jsxs5(
|
|
1414
|
+
"div",
|
|
1415
|
+
{
|
|
1416
|
+
className: "text-ui-fg-subtle grid w-full items-center gap-3 px-6 py-2.5",
|
|
1417
|
+
style: {
|
|
1418
|
+
gridTemplateColumns: `20px 28px repeat(${variantAxes.length}, 1fr)`
|
|
1419
|
+
},
|
|
1420
|
+
children: [
|
|
1421
|
+
/* @__PURE__ */ jsx5(
|
|
1422
|
+
Form.Field,
|
|
1423
|
+
{
|
|
1424
|
+
control: form.control,
|
|
1425
|
+
name: `variants.${index}.should_create`,
|
|
1426
|
+
render: ({
|
|
1427
|
+
field: { value, onChange, ...field }
|
|
1428
|
+
}) => /* @__PURE__ */ jsx5(Form.Item, { children: /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(
|
|
1429
|
+
Checkbox,
|
|
1430
|
+
{
|
|
1431
|
+
className: "relative",
|
|
1432
|
+
...field,
|
|
1433
|
+
checked: value,
|
|
1434
|
+
onCheckedChange: onChange
|
|
1435
|
+
}
|
|
1436
|
+
) }) })
|
|
1437
|
+
}
|
|
1438
|
+
),
|
|
1439
|
+
/* @__PURE__ */ jsx5(SortableList.DragHandle, {}),
|
|
1440
|
+
variantAxes.map((axis, i) => /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", children: item.attribute_values?.[axis.title] ?? "-" }, i))
|
|
1441
|
+
]
|
|
1442
|
+
}
|
|
1443
|
+
)
|
|
1444
|
+
}
|
|
1445
|
+
);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
)
|
|
1449
|
+
] }) : /* @__PURE__ */ jsx5(Alert, { children: t("products.create.variants.productVariants.alert") }),
|
|
1450
|
+
variants.fields.length > 0 && /* @__PURE__ */ jsx5(InlineTip2, { label: t("general.tip"), children: t("products.create.variants.productVariants.tip") })
|
|
1451
|
+
] }) })
|
|
1452
|
+
]
|
|
1453
|
+
}
|
|
1454
|
+
);
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1457
|
+
// src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx
|
|
1458
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1459
|
+
var Root2 = () => {
|
|
1460
|
+
return /* @__PURE__ */ jsx6(
|
|
1461
|
+
"div",
|
|
1462
|
+
{
|
|
1463
|
+
className: "flex flex-col items-center p-16",
|
|
1464
|
+
"data-testid": "product-create-details-form",
|
|
1465
|
+
children: /* @__PURE__ */ jsxs6(
|
|
1466
|
+
"div",
|
|
1467
|
+
{
|
|
1468
|
+
className: "flex w-full max-w-[720px] flex-col gap-y-8",
|
|
1469
|
+
"data-testid": "product-create-details-form-content",
|
|
1470
|
+
children: [
|
|
1471
|
+
/* @__PURE__ */ jsx6(Header, {}),
|
|
1472
|
+
/* @__PURE__ */ jsxs6(
|
|
1473
|
+
"div",
|
|
1474
|
+
{
|
|
1475
|
+
className: "flex flex-col gap-y-6",
|
|
1476
|
+
"data-testid": "product-create-details-form-sections",
|
|
1477
|
+
children: [
|
|
1478
|
+
/* @__PURE__ */ jsx6(ProductCreateGeneralSection, {}),
|
|
1479
|
+
/* @__PURE__ */ jsx6(ProductCreateMediaSection, {})
|
|
1480
|
+
]
|
|
1481
|
+
}
|
|
1482
|
+
),
|
|
1483
|
+
/* @__PURE__ */ jsx6(ProductCreateVariantsSection, {})
|
|
1484
|
+
]
|
|
1485
|
+
}
|
|
1486
|
+
)
|
|
1487
|
+
}
|
|
1488
|
+
);
|
|
1489
|
+
};
|
|
1490
|
+
Root2._tabMeta = defineTabMeta({
|
|
1491
|
+
id: "details",
|
|
1492
|
+
labelKey: "products.create.tabs.details",
|
|
1493
|
+
validationFields: ["title", "handle", "description", "media"]
|
|
1494
|
+
});
|
|
1495
|
+
var ProductCreateDetailsForm = Root2;
|
|
1496
|
+
var Header = () => {
|
|
1497
|
+
const { t } = useTranslation6();
|
|
1498
|
+
return /* @__PURE__ */ jsx6(
|
|
1499
|
+
"div",
|
|
1500
|
+
{
|
|
1501
|
+
className: "flex flex-col",
|
|
1502
|
+
"data-testid": "product-create-details-form-header",
|
|
1503
|
+
children: /* @__PURE__ */ jsx6(Heading3, { "data-testid": "product-create-details-form-heading", children: t("products.create.header") })
|
|
1504
|
+
}
|
|
1505
|
+
);
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1508
|
+
// src/pages/products/product-create/components/product-create-inventory-kit-form/components/product-create-inventory-kit-section/product-create-inventory-kit-section.tsx
|
|
1509
|
+
import { Button as Button3, Heading as Heading4, IconButton as IconButton3, Input as Input3, Label as Label3 } from "@medusajs/ui";
|
|
1510
|
+
import { useFieldArray as useFieldArray4, useWatch as useWatch2 } from "react-hook-form";
|
|
1511
|
+
import { XMarkMini as XMarkMini2 } from "@medusajs/icons";
|
|
1512
|
+
import { useTranslation as useTranslation7 } from "react-i18next";
|
|
1513
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1514
|
+
function InventoryItemRow({
|
|
1515
|
+
variantIndex,
|
|
1516
|
+
inventoryIndex,
|
|
1517
|
+
inventoryItem,
|
|
1518
|
+
isItemOptionDisabled,
|
|
1519
|
+
onRemove
|
|
1520
|
+
}) {
|
|
1521
|
+
const form = useTabbedForm();
|
|
1522
|
+
const { t } = useTranslation7();
|
|
1523
|
+
const selectedInventoryItemId = useWatch2({
|
|
1524
|
+
control: form.control,
|
|
1525
|
+
name: `variants.${variantIndex}.inventory.${inventoryIndex}.inventory_item_id`
|
|
1526
|
+
});
|
|
1527
|
+
const items = useComboboxData({
|
|
1528
|
+
queryKey: ["inventory_items"],
|
|
1529
|
+
defaultValueKey: "id",
|
|
1530
|
+
selectedValue: selectedInventoryItemId,
|
|
1531
|
+
queryFn: (params) => sdk.admin.inventoryItems.query(params),
|
|
1532
|
+
getOptions: (data) => data.inventory_items.map((item) => ({
|
|
1533
|
+
label: `${item.title} ${item.sku ? `(${item.sku})` : ""}`,
|
|
1534
|
+
value: item.id
|
|
1535
|
+
}))
|
|
1536
|
+
});
|
|
1537
|
+
return /* @__PURE__ */ jsxs7(
|
|
1538
|
+
"li",
|
|
1539
|
+
{
|
|
1540
|
+
className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-center gap-1.5 rounded-xl p-1.5",
|
|
1541
|
+
children: [
|
|
1542
|
+
/* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
|
|
1543
|
+
/* @__PURE__ */ jsx7("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx7(
|
|
1544
|
+
Label3,
|
|
1545
|
+
{
|
|
1546
|
+
size: "xsmall",
|
|
1547
|
+
weight: "plus",
|
|
1548
|
+
className: "text-ui-fg-subtle",
|
|
1549
|
+
htmlFor: `variants.${variantIndex}.inventory.${inventoryIndex}.inventory_item_id`,
|
|
1550
|
+
children: t("fields.item")
|
|
1551
|
+
}
|
|
1552
|
+
) }),
|
|
1553
|
+
/* @__PURE__ */ jsx7(
|
|
1554
|
+
Form.Field,
|
|
1555
|
+
{
|
|
1556
|
+
control: form.control,
|
|
1557
|
+
name: `variants.${variantIndex}.inventory.${inventoryIndex}.inventory_item_id`,
|
|
1558
|
+
render: ({ field }) => {
|
|
1559
|
+
return /* @__PURE__ */ jsx7(Form.Item, { children: /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(
|
|
1560
|
+
Combobox,
|
|
1561
|
+
{
|
|
1562
|
+
...field,
|
|
1563
|
+
options: items.options.map((o) => ({
|
|
1564
|
+
...o,
|
|
1565
|
+
disabled: isItemOptionDisabled(o, inventoryIndex)
|
|
1566
|
+
})),
|
|
1567
|
+
searchValue: items.searchValue,
|
|
1568
|
+
onBlur: () => items.onSearchValueChange(""),
|
|
1569
|
+
onSearchValueChange: items.onSearchValueChange,
|
|
1570
|
+
fetchNextPage: items.fetchNextPage,
|
|
1571
|
+
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
1572
|
+
placeholder: t("products.create.inventory.itemPlaceholder")
|
|
1573
|
+
}
|
|
1574
|
+
) }) });
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
),
|
|
1578
|
+
/* @__PURE__ */ jsx7("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx7(
|
|
1579
|
+
Label3,
|
|
1580
|
+
{
|
|
1581
|
+
size: "xsmall",
|
|
1582
|
+
weight: "plus",
|
|
1583
|
+
className: "text-ui-fg-subtle",
|
|
1584
|
+
htmlFor: `variants.${variantIndex}.inventory.${inventoryIndex}.required_quantity`,
|
|
1585
|
+
children: t("fields.quantity")
|
|
1586
|
+
}
|
|
1587
|
+
) }),
|
|
1588
|
+
/* @__PURE__ */ jsx7(
|
|
1589
|
+
Form.Field,
|
|
1590
|
+
{
|
|
1591
|
+
control: form.control,
|
|
1592
|
+
name: `variants.${variantIndex}.inventory.${inventoryIndex}.required_quantity`,
|
|
1593
|
+
render: ({ field: { onChange, value, ...field } }) => {
|
|
1594
|
+
return /* @__PURE__ */ jsxs7(Form.Item, { children: [
|
|
1595
|
+
/* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(
|
|
1596
|
+
Input3,
|
|
1597
|
+
{
|
|
1598
|
+
type: "number",
|
|
1599
|
+
className: "bg-ui-bg-field-component",
|
|
1600
|
+
min: 0,
|
|
1601
|
+
value,
|
|
1602
|
+
onChange: (e) => {
|
|
1603
|
+
const value2 = e.target.value;
|
|
1604
|
+
if (value2 === "") {
|
|
1605
|
+
onChange(null);
|
|
1606
|
+
} else {
|
|
1607
|
+
onChange(Number(value2));
|
|
1608
|
+
}
|
|
1609
|
+
},
|
|
1610
|
+
...field,
|
|
1611
|
+
placeholder: t(
|
|
1612
|
+
"products.create.inventory.quantityPlaceholder"
|
|
1613
|
+
)
|
|
1614
|
+
}
|
|
1615
|
+
) }),
|
|
1616
|
+
/* @__PURE__ */ jsx7(Form.ErrorMessage, {})
|
|
1617
|
+
] });
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
)
|
|
1621
|
+
] }),
|
|
1622
|
+
/* @__PURE__ */ jsx7(
|
|
1623
|
+
IconButton3,
|
|
1624
|
+
{
|
|
1625
|
+
type: "button",
|
|
1626
|
+
size: "small",
|
|
1627
|
+
variant: "transparent",
|
|
1628
|
+
className: "text-ui-fg-muted",
|
|
1629
|
+
onClick: onRemove,
|
|
1630
|
+
children: /* @__PURE__ */ jsx7(XMarkMini2, {})
|
|
1631
|
+
}
|
|
1632
|
+
)
|
|
1633
|
+
]
|
|
1634
|
+
},
|
|
1635
|
+
inventoryItem.id
|
|
1636
|
+
);
|
|
1637
|
+
}
|
|
1638
|
+
function VariantSection({ variant, index }) {
|
|
1639
|
+
const form = useTabbedForm();
|
|
1640
|
+
const { t } = useTranslation7();
|
|
1641
|
+
const inventory = useFieldArray4({
|
|
1642
|
+
control: form.control,
|
|
1643
|
+
name: `variants.${index}.inventory`
|
|
1644
|
+
});
|
|
1645
|
+
const inventoryFormData = useWatch2({
|
|
1646
|
+
control: form.control,
|
|
1647
|
+
name: `variants.${index}.inventory`
|
|
1648
|
+
});
|
|
1649
|
+
const isItemOptionDisabled = (option, inventoryIndex) => {
|
|
1650
|
+
return !!inventoryFormData?.some(
|
|
1651
|
+
(i, index2) => index2 != inventoryIndex && i.inventory_item_id === option.value
|
|
1652
|
+
);
|
|
1653
|
+
};
|
|
1654
|
+
return /* @__PURE__ */ jsxs7("div", { className: "grid gap-y-4", children: [
|
|
1655
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-start justify-between gap-x-4", children: [
|
|
1656
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-col", children: [
|
|
1657
|
+
/* @__PURE__ */ jsx7(Form.Label, { children: variant.title }),
|
|
1658
|
+
/* @__PURE__ */ jsx7(Form.Hint, { children: t("products.create.inventory.label") })
|
|
1659
|
+
] }),
|
|
1660
|
+
/* @__PURE__ */ jsx7(
|
|
1661
|
+
Button3,
|
|
1662
|
+
{
|
|
1663
|
+
size: "small",
|
|
1664
|
+
variant: "secondary",
|
|
1665
|
+
type: "button",
|
|
1666
|
+
onClick: () => {
|
|
1667
|
+
inventory.append({
|
|
1668
|
+
inventory_item_id: "",
|
|
1669
|
+
required_quantity: ""
|
|
1670
|
+
});
|
|
1671
|
+
},
|
|
1672
|
+
children: t("actions.add")
|
|
1673
|
+
}
|
|
1674
|
+
)
|
|
1675
|
+
] }),
|
|
1676
|
+
inventory.fields.map((inventoryItem, inventoryIndex) => /* @__PURE__ */ jsx7(
|
|
1677
|
+
InventoryItemRow,
|
|
1678
|
+
{
|
|
1679
|
+
variantIndex: index,
|
|
1680
|
+
inventoryIndex,
|
|
1681
|
+
inventoryItem,
|
|
1682
|
+
isItemOptionDisabled,
|
|
1683
|
+
onRemove: () => inventory.remove(inventoryIndex)
|
|
1684
|
+
},
|
|
1685
|
+
inventoryItem.id
|
|
1686
|
+
))
|
|
1687
|
+
] });
|
|
1688
|
+
}
|
|
1689
|
+
var ProductCreateInventoryKitSection = () => {
|
|
1690
|
+
const form = useTabbedForm();
|
|
1691
|
+
const { t } = useTranslation7();
|
|
1692
|
+
const variants = useFieldArray4({
|
|
1693
|
+
control: form.control,
|
|
1694
|
+
name: "variants"
|
|
1695
|
+
});
|
|
1696
|
+
return /* @__PURE__ */ jsxs7("div", { id: "organize", className: "flex flex-col gap-y-8", children: [
|
|
1697
|
+
/* @__PURE__ */ jsx7(Heading4, { children: t("products.create.inventory.heading") }),
|
|
1698
|
+
variants.fields.filter((v) => v.inventory_kit).map((variant, variantIndex) => /* @__PURE__ */ jsx7(
|
|
1699
|
+
VariantSection,
|
|
1700
|
+
{
|
|
1701
|
+
variant,
|
|
1702
|
+
index: variantIndex
|
|
1703
|
+
},
|
|
1704
|
+
variant.id
|
|
1705
|
+
))
|
|
1706
|
+
] });
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
// src/pages/products/product-create/components/product-create-inventory-kit-form/product-create-inventory-kit-form.tsx
|
|
1710
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1711
|
+
var Root3 = () => {
|
|
1712
|
+
return /* @__PURE__ */ jsx8("div", { className: "flex flex-col items-center p-16", "data-testid": "product-create-inventory-kit-form", children: /* @__PURE__ */ jsx8("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", "data-testid": "product-create-inventory-kit-form-content", children: /* @__PURE__ */ jsx8(ProductCreateInventoryKitSection, {}) }) });
|
|
1713
|
+
};
|
|
1714
|
+
Root3._tabMeta = defineTabMeta({
|
|
1715
|
+
id: "inventory",
|
|
1716
|
+
labelKey: "products.create.tabs.inventory",
|
|
1717
|
+
validationFields: ["variants"]
|
|
1718
|
+
});
|
|
1719
|
+
var ProductCreateInventoryKitForm = Root3;
|
|
1720
|
+
|
|
1721
|
+
// src/pages/products/product-create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx
|
|
1722
|
+
import { Heading as Heading5 } from "@medusajs/ui";
|
|
1723
|
+
import { useTranslation as useTranslation8 } from "react-i18next";
|
|
1724
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1725
|
+
var ProductCreateOrganizationSection = () => {
|
|
1726
|
+
const form = useTabbedForm();
|
|
1727
|
+
const { t } = useTranslation8();
|
|
1728
|
+
const collections = useComboboxData({
|
|
1729
|
+
queryKey: ["product_collections"],
|
|
1730
|
+
queryFn: (params) => sdk.admin.collections.query(params),
|
|
1731
|
+
getOptions: (data) => data.collections.map((collection) => ({
|
|
1732
|
+
label: collection.title,
|
|
1733
|
+
value: collection.id
|
|
1734
|
+
}))
|
|
1735
|
+
});
|
|
1736
|
+
const types = useComboboxData({
|
|
1737
|
+
queryKey: ["product_types"],
|
|
1738
|
+
queryFn: (params) => sdk.admin.productTypes.query(params),
|
|
1739
|
+
getOptions: (data) => data.product_types.map((type) => ({
|
|
1740
|
+
label: type.value,
|
|
1741
|
+
value: type.id
|
|
1742
|
+
}))
|
|
1743
|
+
});
|
|
1744
|
+
const tags = useComboboxData({
|
|
1745
|
+
queryKey: ["product_tags"],
|
|
1746
|
+
queryFn: (params) => sdk.admin.productTags.query(params),
|
|
1747
|
+
getOptions: (data) => data.product_tags.map((tag) => ({
|
|
1748
|
+
label: tag.value,
|
|
1749
|
+
value: tag.id
|
|
1750
|
+
}))
|
|
1751
|
+
});
|
|
1752
|
+
const sellers = useComboboxData({
|
|
1753
|
+
queryKey: ["sellers"],
|
|
1754
|
+
queryFn: (params) => sdk.admin.sellers.query(params),
|
|
1755
|
+
getOptions: (data) => data.sellers.map((seller) => ({
|
|
1756
|
+
label: seller.name,
|
|
1757
|
+
value: seller.id
|
|
1758
|
+
}))
|
|
1759
|
+
});
|
|
1760
|
+
return /* @__PURE__ */ jsxs8("div", { id: "organize", className: "flex flex-col gap-y-8", "data-testid": "product-create-organize-section", children: [
|
|
1761
|
+
/* @__PURE__ */ jsx9(Heading5, { "data-testid": "product-create-organize-section-heading", children: t("products.organization.header") }),
|
|
1762
|
+
/* @__PURE__ */ jsx9(
|
|
1763
|
+
SwitchBox,
|
|
1764
|
+
{
|
|
1765
|
+
control: form.control,
|
|
1766
|
+
name: "discountable",
|
|
1767
|
+
label: t("products.fields.discountable.label"),
|
|
1768
|
+
description: t("products.fields.discountable.hint"),
|
|
1769
|
+
optional: true,
|
|
1770
|
+
"data-testid": "product-create-organize-section-discountable-switch"
|
|
1771
|
+
}
|
|
1772
|
+
),
|
|
1773
|
+
/* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-category-collection", children: [
|
|
1774
|
+
/* @__PURE__ */ jsx9(
|
|
1775
|
+
Form.Field,
|
|
1776
|
+
{
|
|
1777
|
+
control: form.control,
|
|
1778
|
+
name: "category_id",
|
|
1779
|
+
render: ({ field }) => {
|
|
1780
|
+
return /* @__PURE__ */ jsxs8(Form.Item, { "data-testid": "product-create-organize-section-category-item", children: [
|
|
1781
|
+
/* @__PURE__ */ jsx9(Form.Label, { "data-testid": "product-create-organize-section-category-label", children: t("fields.category") }),
|
|
1782
|
+
/* @__PURE__ */ jsx9(Form.Control, { "data-testid": "product-create-organize-section-category-control", children: /* @__PURE__ */ jsx9(
|
|
1783
|
+
SingleCategoryCombobox,
|
|
1784
|
+
{
|
|
1785
|
+
...field,
|
|
1786
|
+
"data-testid": "product-create-organize-section-category-input"
|
|
1787
|
+
}
|
|
1788
|
+
) }),
|
|
1789
|
+
/* @__PURE__ */ jsx9(Form.ErrorMessage, {})
|
|
1790
|
+
] });
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
),
|
|
1794
|
+
/* @__PURE__ */ jsx9(
|
|
1795
|
+
Form.Field,
|
|
1796
|
+
{
|
|
1797
|
+
control: form.control,
|
|
1798
|
+
name: "collection_id",
|
|
1799
|
+
render: ({ field }) => {
|
|
1800
|
+
return /* @__PURE__ */ jsxs8(Form.Item, { "data-testid": "product-create-organize-section-collection-item", children: [
|
|
1801
|
+
/* @__PURE__ */ jsx9(Form.Label, { optional: true, "data-testid": "product-create-organize-section-collection-label", children: t("products.fields.collection.label") }),
|
|
1802
|
+
/* @__PURE__ */ jsx9(Form.Control, { "data-testid": "product-create-organize-section-collection-control", children: /* @__PURE__ */ jsx9(
|
|
1803
|
+
Combobox,
|
|
1804
|
+
{
|
|
1805
|
+
...field,
|
|
1806
|
+
options: collections.options,
|
|
1807
|
+
searchValue: collections.searchValue,
|
|
1808
|
+
onSearchValueChange: collections.onSearchValueChange,
|
|
1809
|
+
fetchNextPage: collections.fetchNextPage,
|
|
1810
|
+
"data-testid": "product-create-organize-section-collection-input"
|
|
1811
|
+
}
|
|
1812
|
+
) }),
|
|
1813
|
+
/* @__PURE__ */ jsx9(Form.ErrorMessage, {})
|
|
1814
|
+
] });
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
)
|
|
1818
|
+
] }),
|
|
1819
|
+
/* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-type-tags", children: [
|
|
1820
|
+
/* @__PURE__ */ jsx9(
|
|
1821
|
+
Form.Field,
|
|
1822
|
+
{
|
|
1823
|
+
control: form.control,
|
|
1824
|
+
name: "type_id",
|
|
1825
|
+
render: ({ field }) => {
|
|
1826
|
+
return /* @__PURE__ */ jsxs8(Form.Item, { "data-testid": "product-create-organize-section-type-item", children: [
|
|
1827
|
+
/* @__PURE__ */ jsx9(Form.Label, { optional: true, "data-testid": "product-create-organize-section-type-label", children: t("products.fields.type.label") }),
|
|
1828
|
+
/* @__PURE__ */ jsx9(Form.Control, { "data-testid": "product-create-organize-section-type-control", children: /* @__PURE__ */ jsx9(
|
|
1829
|
+
Combobox,
|
|
1830
|
+
{
|
|
1831
|
+
...field,
|
|
1832
|
+
options: types.options,
|
|
1833
|
+
searchValue: types.searchValue,
|
|
1834
|
+
onSearchValueChange: types.onSearchValueChange,
|
|
1835
|
+
fetchNextPage: types.fetchNextPage,
|
|
1836
|
+
"data-testid": "product-create-organize-section-type-input"
|
|
1837
|
+
}
|
|
1838
|
+
) }),
|
|
1839
|
+
/* @__PURE__ */ jsx9(Form.ErrorMessage, {})
|
|
1840
|
+
] });
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
),
|
|
1844
|
+
/* @__PURE__ */ jsx9(
|
|
1845
|
+
Form.Field,
|
|
1846
|
+
{
|
|
1847
|
+
control: form.control,
|
|
1848
|
+
name: "tags",
|
|
1849
|
+
render: ({ field }) => {
|
|
1850
|
+
return /* @__PURE__ */ jsxs8(Form.Item, { "data-testid": "product-create-organize-section-tags-item", children: [
|
|
1851
|
+
/* @__PURE__ */ jsx9(Form.Label, { optional: true, "data-testid": "product-create-organize-section-tags-label", children: t("products.fields.tags.label") }),
|
|
1852
|
+
/* @__PURE__ */ jsx9(Form.Control, { "data-testid": "product-create-organize-section-tags-control", children: /* @__PURE__ */ jsx9(
|
|
1853
|
+
Combobox,
|
|
1854
|
+
{
|
|
1855
|
+
...field,
|
|
1856
|
+
options: tags.options,
|
|
1857
|
+
searchValue: tags.searchValue,
|
|
1858
|
+
onSearchValueChange: tags.onSearchValueChange,
|
|
1859
|
+
fetchNextPage: tags.fetchNextPage,
|
|
1860
|
+
"data-testid": "product-create-organize-section-tags-input"
|
|
1861
|
+
}
|
|
1862
|
+
) }),
|
|
1863
|
+
/* @__PURE__ */ jsx9(Form.ErrorMessage, {})
|
|
1864
|
+
] });
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
)
|
|
1868
|
+
] }),
|
|
1869
|
+
/* @__PURE__ */ jsx9("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-stores", children: /* @__PURE__ */ jsx9(
|
|
1870
|
+
Form.Field,
|
|
1871
|
+
{
|
|
1872
|
+
control: form.control,
|
|
1873
|
+
name: "seller_ids",
|
|
1874
|
+
render: ({ field }) => {
|
|
1875
|
+
return /* @__PURE__ */ jsxs8(Form.Item, { "data-testid": "product-create-organize-section-stores-item", children: [
|
|
1876
|
+
/* @__PURE__ */ jsx9(Form.Label, { optional: true, "data-testid": "product-create-organize-section-stores-label", children: t("products.fields.stores.label") }),
|
|
1877
|
+
/* @__PURE__ */ jsx9(Form.Control, { "data-testid": "product-create-organize-section-stores-control", children: /* @__PURE__ */ jsx9(
|
|
1878
|
+
Combobox,
|
|
1879
|
+
{
|
|
1880
|
+
...field,
|
|
1881
|
+
value: field.value ?? [],
|
|
1882
|
+
options: sellers.options,
|
|
1883
|
+
searchValue: sellers.searchValue,
|
|
1884
|
+
onSearchValueChange: sellers.onSearchValueChange,
|
|
1885
|
+
fetchNextPage: sellers.fetchNextPage,
|
|
1886
|
+
"data-testid": "product-create-organize-section-stores-input"
|
|
1887
|
+
}
|
|
1888
|
+
) }),
|
|
1889
|
+
/* @__PURE__ */ jsx9(Form.ErrorMessage, {})
|
|
1890
|
+
] });
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
) })
|
|
1894
|
+
] });
|
|
1895
|
+
};
|
|
1896
|
+
|
|
1897
|
+
// src/pages/products/product-create/components/product-create-organize-form/product-create-organize-form.tsx
|
|
1898
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1899
|
+
var Root4 = () => {
|
|
1900
|
+
return /* @__PURE__ */ jsx10(
|
|
1901
|
+
"div",
|
|
1902
|
+
{
|
|
1903
|
+
className: "flex flex-col items-center p-16",
|
|
1904
|
+
"data-testid": "product-create-organize-form",
|
|
1905
|
+
children: /* @__PURE__ */ jsx10(
|
|
1906
|
+
"div",
|
|
1907
|
+
{
|
|
1908
|
+
className: "flex w-full max-w-[720px] flex-col gap-y-8",
|
|
1909
|
+
"data-testid": "product-create-organize-form-content",
|
|
1910
|
+
children: /* @__PURE__ */ jsx10(ProductCreateOrganizationSection, {})
|
|
1911
|
+
}
|
|
1912
|
+
)
|
|
1913
|
+
}
|
|
1914
|
+
);
|
|
1915
|
+
};
|
|
1916
|
+
Root4._tabMeta = defineTabMeta({
|
|
1917
|
+
id: "organize",
|
|
1918
|
+
labelKey: "products.create.tabs.organize",
|
|
1919
|
+
validationFields: [
|
|
1920
|
+
"type_id",
|
|
1921
|
+
"collection_id",
|
|
1922
|
+
"category_id",
|
|
1923
|
+
"seller_ids",
|
|
1924
|
+
"tags",
|
|
1925
|
+
"origin_country",
|
|
1926
|
+
"material",
|
|
1927
|
+
"width",
|
|
1928
|
+
"length",
|
|
1929
|
+
"height",
|
|
1930
|
+
"weight",
|
|
1931
|
+
"mid_code",
|
|
1932
|
+
"hs_code"
|
|
1933
|
+
]
|
|
1934
|
+
});
|
|
1935
|
+
var ProductCreateOrganizeForm = Root4;
|
|
1936
|
+
|
|
1937
|
+
// src/pages/products/product-create/components/product-create-variants-form/product-create-variants-form.tsx
|
|
1938
|
+
import { useMemo as useMemo3 } from "react";
|
|
1939
|
+
import { useWatch as useWatch3 } from "react-hook-form";
|
|
1940
|
+
import { useTranslation as useTranslation9 } from "react-i18next";
|
|
1941
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1942
|
+
var Root5 = () => {
|
|
1943
|
+
const form = useTabbedForm();
|
|
1944
|
+
const { setCloseOnEscape } = useRouteModal();
|
|
1945
|
+
const { store } = useStore({
|
|
1946
|
+
fields: "+default_sales_channel"
|
|
1947
|
+
});
|
|
1948
|
+
const { regions } = useRegions({ limit: 9999 });
|
|
1949
|
+
const { price_preferences: pricePreferences } = usePricePreferences({
|
|
1950
|
+
limit: 9999
|
|
1951
|
+
});
|
|
1952
|
+
const currencyCodes = useMemo3(
|
|
1953
|
+
() => store?.supported_currencies?.map((c) => c.currency_code) || [],
|
|
1954
|
+
[store]
|
|
1955
|
+
);
|
|
1956
|
+
const variants = useWatch3({
|
|
1957
|
+
control: form.control,
|
|
1958
|
+
name: "variants",
|
|
1959
|
+
defaultValue: []
|
|
1960
|
+
});
|
|
1961
|
+
const watchedAttributes = useWatch3({
|
|
1962
|
+
control: form.control,
|
|
1963
|
+
name: "attributes",
|
|
1964
|
+
defaultValue: []
|
|
1965
|
+
});
|
|
1966
|
+
const variantAxes = useMemo3(() => {
|
|
1967
|
+
return (watchedAttributes ?? []).filter((attr) => attr.use_for_variants && attr.title).map((attr) => ({
|
|
1968
|
+
title: attr.title
|
|
1969
|
+
}));
|
|
1970
|
+
}, [watchedAttributes]);
|
|
1971
|
+
const columns = useColumns2({
|
|
1972
|
+
variantAxes,
|
|
1973
|
+
currencies: currencyCodes,
|
|
1974
|
+
regions: regions ?? [],
|
|
1975
|
+
pricePreferences: pricePreferences ?? []
|
|
1976
|
+
});
|
|
1977
|
+
const variantData = useMemo3(() => {
|
|
1978
|
+
const ret = [];
|
|
1979
|
+
variants.forEach((v, i) => {
|
|
1980
|
+
if (v.should_create) {
|
|
1981
|
+
ret.push({ ...v, originalIndex: i });
|
|
1982
|
+
}
|
|
1983
|
+
});
|
|
1984
|
+
return ret;
|
|
1985
|
+
}, [variants]);
|
|
1986
|
+
return /* @__PURE__ */ jsx11(
|
|
1987
|
+
"div",
|
|
1988
|
+
{
|
|
1989
|
+
className: "flex size-full flex-col divide-y overflow-hidden",
|
|
1990
|
+
"data-testid": "product-create-variants-form",
|
|
1991
|
+
children: /* @__PURE__ */ jsx11("div", { "data-testid": "product-create-variants-form-datagrid", children: /* @__PURE__ */ jsx11(
|
|
1992
|
+
DataGrid,
|
|
1993
|
+
{
|
|
1994
|
+
columns,
|
|
1995
|
+
data: variantData,
|
|
1996
|
+
state: form,
|
|
1997
|
+
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
1998
|
+
}
|
|
1999
|
+
) })
|
|
2000
|
+
}
|
|
2001
|
+
);
|
|
2002
|
+
};
|
|
2003
|
+
Root5._tabMeta = defineTabMeta({
|
|
2004
|
+
id: "variants",
|
|
2005
|
+
labelKey: "products.create.tabs.variants",
|
|
2006
|
+
validationFields: ["variants"]
|
|
2007
|
+
});
|
|
2008
|
+
var ProductCreateVariantsForm = Root5;
|
|
2009
|
+
var columnHelper2 = createDataGridHelper();
|
|
2010
|
+
var useColumns2 = ({
|
|
2011
|
+
variantAxes,
|
|
2012
|
+
currencies = [],
|
|
2013
|
+
regions = [],
|
|
2014
|
+
pricePreferences = []
|
|
2015
|
+
}) => {
|
|
2016
|
+
const { t } = useTranslation9();
|
|
2017
|
+
return useMemo3(
|
|
2018
|
+
() => [
|
|
2019
|
+
columnHelper2.column({
|
|
2020
|
+
id: "attributes",
|
|
2021
|
+
header: () => /* @__PURE__ */ jsx11("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx11("span", { className: "truncate", children: variantAxes.map((a) => a.title).join(" / ") }) }),
|
|
2022
|
+
cell: (context) => {
|
|
2023
|
+
return /* @__PURE__ */ jsx11(DataGrid.ReadonlyCell, { context, children: variantAxes.map((a) => context.row.original.attribute_values?.[a.title]).join(" / ") });
|
|
2024
|
+
},
|
|
2025
|
+
disableHiding: true
|
|
2026
|
+
}),
|
|
2027
|
+
columnHelper2.column({
|
|
2028
|
+
id: "title",
|
|
2029
|
+
name: t("fields.title"),
|
|
2030
|
+
header: t("fields.title"),
|
|
2031
|
+
field: (context) => `variants.${context.row.original.originalIndex}.title`,
|
|
2032
|
+
type: "text",
|
|
2033
|
+
cell: (context) => {
|
|
2034
|
+
return /* @__PURE__ */ jsx11(DataGrid.TextCell, { context });
|
|
2035
|
+
}
|
|
2036
|
+
}),
|
|
2037
|
+
columnHelper2.column({
|
|
2038
|
+
id: "sku",
|
|
2039
|
+
name: t("fields.sku"),
|
|
2040
|
+
header: t("fields.sku"),
|
|
2041
|
+
field: (context) => `variants.${context.row.original.originalIndex}.sku`,
|
|
2042
|
+
type: "text",
|
|
2043
|
+
cell: (context) => {
|
|
2044
|
+
return /* @__PURE__ */ jsx11(DataGrid.TextCell, { context });
|
|
2045
|
+
}
|
|
2046
|
+
}),
|
|
2047
|
+
columnHelper2.column({
|
|
2048
|
+
id: "manage_inventory",
|
|
2049
|
+
name: t("fields.managedInventory"),
|
|
2050
|
+
header: t("fields.managedInventory"),
|
|
2051
|
+
field: (context) => `variants.${context.row.original.originalIndex}.manage_inventory`,
|
|
2052
|
+
type: "boolean",
|
|
2053
|
+
cell: (context) => {
|
|
2054
|
+
return /* @__PURE__ */ jsx11(DataGrid.BooleanCell, { context });
|
|
2055
|
+
}
|
|
2056
|
+
}),
|
|
2057
|
+
columnHelper2.column({
|
|
2058
|
+
id: "allow_backorder",
|
|
2059
|
+
name: t("fields.allowBackorder"),
|
|
2060
|
+
header: t("fields.allowBackorder"),
|
|
2061
|
+
field: (context) => `variants.${context.row.original.originalIndex}.allow_backorder`,
|
|
2062
|
+
type: "boolean",
|
|
2063
|
+
cell: (context) => {
|
|
2064
|
+
return /* @__PURE__ */ jsx11(DataGrid.BooleanCell, { context });
|
|
2065
|
+
}
|
|
2066
|
+
}),
|
|
2067
|
+
columnHelper2.column({
|
|
2068
|
+
id: "inventory_kit",
|
|
2069
|
+
name: t("fields.inventoryKit"),
|
|
2070
|
+
header: t("fields.inventoryKit"),
|
|
2071
|
+
field: (context) => `variants.${context.row.original.originalIndex}.inventory_kit`,
|
|
2072
|
+
type: "boolean",
|
|
2073
|
+
cell: (context) => {
|
|
2074
|
+
return /* @__PURE__ */ jsx11(
|
|
2075
|
+
DataGrid.BooleanCell,
|
|
2076
|
+
{
|
|
2077
|
+
context,
|
|
2078
|
+
disabled: !context.row.original.manage_inventory
|
|
2079
|
+
}
|
|
2080
|
+
);
|
|
2081
|
+
}
|
|
2082
|
+
}),
|
|
2083
|
+
...createDataGridPriceColumns({
|
|
2084
|
+
currencies,
|
|
2085
|
+
regions,
|
|
2086
|
+
pricePreferences,
|
|
2087
|
+
getFieldName: (context, value) => {
|
|
2088
|
+
if (context.column.id?.startsWith("currency_prices")) {
|
|
2089
|
+
return `variants.${context.row.original.originalIndex}.prices.${value}`;
|
|
2090
|
+
}
|
|
2091
|
+
return `variants.${context.row.original.originalIndex}.prices.${value}`;
|
|
2092
|
+
},
|
|
2093
|
+
t
|
|
2094
|
+
})
|
|
2095
|
+
],
|
|
2096
|
+
[currencies, regions, variantAxes, pricePreferences, t]
|
|
2097
|
+
);
|
|
2098
|
+
};
|
|
2099
|
+
|
|
2100
|
+
// src/pages/products/product-create/components/product-create-form/product-create-form.tsx
|
|
2101
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
2102
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2103
|
+
var SAVE_DRAFT_BUTTON = "save-draft-button";
|
|
2104
|
+
var ProductCreateForm = ({
|
|
2105
|
+
children,
|
|
2106
|
+
schema,
|
|
2107
|
+
defaultValues: extraDefaults
|
|
2108
|
+
}) => {
|
|
2109
|
+
const { t } = useTranslation10();
|
|
2110
|
+
const { handleSuccess } = useRouteModal();
|
|
2111
|
+
const form = useForm({
|
|
2112
|
+
defaultValues: {
|
|
2113
|
+
...PRODUCT_CREATE_FORM_DEFAULTS,
|
|
2114
|
+
...extraDefaults
|
|
2115
|
+
},
|
|
2116
|
+
resolver: zodResolver(schema ?? ProductCreateSchema)
|
|
2117
|
+
});
|
|
2118
|
+
const { mutateAsync, isPending } = useCreateProduct();
|
|
2119
|
+
const {
|
|
2120
|
+
regions,
|
|
2121
|
+
isPending: isRegionsPending,
|
|
2122
|
+
isError: isRegionsError,
|
|
2123
|
+
error: regionsError
|
|
2124
|
+
} = useRegions({ limit: 9999 });
|
|
2125
|
+
if (isRegionsError) {
|
|
2126
|
+
throw regionsError;
|
|
2127
|
+
}
|
|
2128
|
+
const regionsCurrencyMap = useMemo4(() => {
|
|
2129
|
+
if (!regions?.length) {
|
|
2130
|
+
return {};
|
|
2131
|
+
}
|
|
2132
|
+
return regions.reduce(
|
|
2133
|
+
(acc, reg) => {
|
|
2134
|
+
acc[reg.id] = reg.currency_code;
|
|
2135
|
+
return acc;
|
|
2136
|
+
},
|
|
2137
|
+
{}
|
|
2138
|
+
);
|
|
2139
|
+
}, [regions]);
|
|
2140
|
+
const watchedVariants = useWatch4({
|
|
2141
|
+
control: form.control,
|
|
2142
|
+
name: "variants"
|
|
2143
|
+
});
|
|
2144
|
+
const watchedAttributes = useWatch4({
|
|
2145
|
+
control: form.control,
|
|
2146
|
+
name: "attributes"
|
|
2147
|
+
});
|
|
2148
|
+
useEffect3(() => {
|
|
2149
|
+
const currentVariants = form.getValues("variants") ?? [];
|
|
2150
|
+
const newVariants = generateVariantsFromAttributes(
|
|
2151
|
+
watchedAttributes ?? [],
|
|
2152
|
+
currentVariants
|
|
2153
|
+
);
|
|
2154
|
+
if (JSON.stringify(newVariants.map((v) => v.attribute_values)) !== JSON.stringify(currentVariants.map((v) => v.attribute_values))) {
|
|
2155
|
+
form.setValue("variants", newVariants);
|
|
2156
|
+
}
|
|
2157
|
+
}, [watchedAttributes]);
|
|
2158
|
+
const handleSubmit = form.handleSubmit(async (values, e) => {
|
|
2159
|
+
if (isRegionsPending) {
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
let isDraftSubmission = false;
|
|
2163
|
+
if (e?.nativeEvent instanceof SubmitEvent) {
|
|
2164
|
+
const submitter = e?.nativeEvent?.submitter;
|
|
2165
|
+
isDraftSubmission = submitter.dataset.name === SAVE_DRAFT_BUTTON;
|
|
2166
|
+
}
|
|
2167
|
+
const media = values.media || [];
|
|
2168
|
+
const payload = { ...values, media: void 0 };
|
|
2169
|
+
let uploadedMedia = [];
|
|
2170
|
+
try {
|
|
2171
|
+
if (media.length) {
|
|
2172
|
+
const thumbnailReq = media.find((m) => m.isThumbnail);
|
|
2173
|
+
const otherMediaReq = media.filter((m) => !m.isThumbnail);
|
|
2174
|
+
const fileReqs = [];
|
|
2175
|
+
if (thumbnailReq) {
|
|
2176
|
+
fileReqs.push(
|
|
2177
|
+
sdk.admin.uploads.mutate({ files: [thumbnailReq.file] }).then((r) => r.files.map((f) => ({ ...f, isThumbnail: true })))
|
|
2178
|
+
);
|
|
2179
|
+
}
|
|
2180
|
+
if (otherMediaReq?.length) {
|
|
2181
|
+
fileReqs.push(
|
|
2182
|
+
sdk.admin.uploads.mutate({
|
|
2183
|
+
files: otherMediaReq.map((m) => m.file)
|
|
2184
|
+
}).then((r) => r.files.map((f) => ({ ...f, isThumbnail: false })))
|
|
2185
|
+
);
|
|
2186
|
+
}
|
|
2187
|
+
uploadedMedia = (await Promise.all(fileReqs)).flat();
|
|
2188
|
+
}
|
|
2189
|
+
} catch (error) {
|
|
2190
|
+
if (error instanceof Error) {
|
|
2191
|
+
toast.error(error.message);
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
await mutateAsync(
|
|
2195
|
+
normalizeProductFormValues({
|
|
2196
|
+
...payload,
|
|
2197
|
+
media: uploadedMedia,
|
|
2198
|
+
status: isDraftSubmission ? "draft" : "published",
|
|
2199
|
+
regionsCurrencyMap
|
|
2200
|
+
}),
|
|
2201
|
+
{
|
|
2202
|
+
onSuccess: (data) => {
|
|
2203
|
+
toast.success(
|
|
2204
|
+
t("products.create.successToast", {
|
|
2205
|
+
title: data.product.title
|
|
2206
|
+
})
|
|
2207
|
+
);
|
|
2208
|
+
handleSuccess(`../${data.product.id}`);
|
|
2209
|
+
},
|
|
2210
|
+
onError: (error) => {
|
|
2211
|
+
toast.error(error.message);
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
);
|
|
2215
|
+
});
|
|
2216
|
+
const transformTabs = useCallback(
|
|
2217
|
+
(tabs) => {
|
|
2218
|
+
const showInventoryTab = watchedVariants?.some((v) => v.manage_inventory && v.inventory_kit) ?? false;
|
|
2219
|
+
return tabs.map((tab) => {
|
|
2220
|
+
if (tab.id === "inventory") {
|
|
2221
|
+
return {
|
|
2222
|
+
...tab,
|
|
2223
|
+
isVisible: () => showInventoryTab
|
|
2224
|
+
};
|
|
2225
|
+
}
|
|
2226
|
+
return tab;
|
|
2227
|
+
});
|
|
2228
|
+
},
|
|
2229
|
+
[watchedVariants]
|
|
2230
|
+
);
|
|
2231
|
+
const defaultTabs = useMemo4(
|
|
2232
|
+
() => [
|
|
2233
|
+
/* @__PURE__ */ jsx12(ProductCreateDetailsForm, {}, "details"),
|
|
2234
|
+
/* @__PURE__ */ jsx12(ProductCreateOrganizeForm, {}, "organize"),
|
|
2235
|
+
/* @__PURE__ */ jsx12(ProductCreateAttributesForm, {}, "attributes"),
|
|
2236
|
+
/* @__PURE__ */ jsx12(ProductCreateVariantsForm, {}, "variants"),
|
|
2237
|
+
/* @__PURE__ */ jsx12(ProductCreateInventoryKitForm, {}, "inventory")
|
|
2238
|
+
],
|
|
2239
|
+
[]
|
|
2240
|
+
);
|
|
2241
|
+
const hasCustomChildren = Children.count(children) > 0;
|
|
2242
|
+
return /* @__PURE__ */ jsx12(
|
|
2243
|
+
TabbedForm,
|
|
2244
|
+
{
|
|
2245
|
+
form,
|
|
2246
|
+
onSubmit: handleSubmit,
|
|
2247
|
+
isLoading: isPending || isRegionsPending,
|
|
2248
|
+
transformTabs,
|
|
2249
|
+
footer: ({ isLastTab, onNext, isLoading }) => /* @__PURE__ */ jsxs9(
|
|
2250
|
+
"div",
|
|
2251
|
+
{
|
|
2252
|
+
className: "flex items-center justify-end gap-x-2",
|
|
2253
|
+
"data-testid": "product-create-form-footer-actions",
|
|
2254
|
+
children: [
|
|
2255
|
+
/* @__PURE__ */ jsx12(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx12(
|
|
2256
|
+
Button4,
|
|
2257
|
+
{
|
|
2258
|
+
variant: "secondary",
|
|
2259
|
+
size: "small",
|
|
2260
|
+
"data-testid": "product-create-form-cancel-button",
|
|
2261
|
+
children: t("actions.cancel")
|
|
2262
|
+
}
|
|
2263
|
+
) }),
|
|
2264
|
+
/* @__PURE__ */ jsx12(
|
|
2265
|
+
Button4,
|
|
2266
|
+
{
|
|
2267
|
+
"data-name": SAVE_DRAFT_BUTTON,
|
|
2268
|
+
size: "small",
|
|
2269
|
+
type: "submit",
|
|
2270
|
+
isLoading,
|
|
2271
|
+
className: "whitespace-nowrap",
|
|
2272
|
+
"data-testid": "product-create-form-save-draft-button",
|
|
2273
|
+
children: t("actions.saveAsDraft")
|
|
2274
|
+
}
|
|
2275
|
+
),
|
|
2276
|
+
isLastTab ? /* @__PURE__ */ jsx12(
|
|
2277
|
+
Button4,
|
|
2278
|
+
{
|
|
2279
|
+
"data-name": "publish-button",
|
|
2280
|
+
type: "submit",
|
|
2281
|
+
variant: "primary",
|
|
2282
|
+
size: "small",
|
|
2283
|
+
isLoading,
|
|
2284
|
+
"data-testid": "product-create-form-publish-button",
|
|
2285
|
+
children: t("actions.publish")
|
|
2286
|
+
},
|
|
2287
|
+
"submit-button"
|
|
2288
|
+
) : /* @__PURE__ */ jsx12(
|
|
2289
|
+
Button4,
|
|
2290
|
+
{
|
|
2291
|
+
type: "button",
|
|
2292
|
+
variant: "primary",
|
|
2293
|
+
size: "small",
|
|
2294
|
+
onClick: () => onNext(),
|
|
2295
|
+
"data-testid": "product-create-form-continue-button",
|
|
2296
|
+
children: t("actions.continue")
|
|
2297
|
+
},
|
|
2298
|
+
"next-button"
|
|
2299
|
+
)
|
|
2300
|
+
]
|
|
2301
|
+
}
|
|
2302
|
+
),
|
|
2303
|
+
children: hasCustomChildren ? children : defaultTabs
|
|
2304
|
+
}
|
|
2305
|
+
);
|
|
2306
|
+
};
|
|
2307
|
+
|
|
2308
|
+
// src/pages/products/product-create/product-create.tsx
|
|
2309
|
+
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2310
|
+
var Root6 = ({ children }) => {
|
|
2311
|
+
const { t } = useTranslation11();
|
|
2312
|
+
const {
|
|
2313
|
+
store,
|
|
2314
|
+
isPending: isStorePending,
|
|
2315
|
+
isError: isStoreError,
|
|
2316
|
+
error: storeError
|
|
2317
|
+
} = useStore({
|
|
2318
|
+
fields: "+default_sales_channel"
|
|
2319
|
+
});
|
|
2320
|
+
const {
|
|
2321
|
+
sales_channel,
|
|
2322
|
+
isPending: isSalesChannelPending,
|
|
2323
|
+
isError: isSalesChannelError,
|
|
2324
|
+
error: salesChannelError
|
|
2325
|
+
} = useSalesChannel(store?.default_sales_channel_id, {
|
|
2326
|
+
enabled: !!store?.default_sales_channel_id
|
|
2327
|
+
});
|
|
2328
|
+
const ready = !!store && !isStorePending && !!sales_channel && !isSalesChannelPending;
|
|
2329
|
+
if (isStoreError) {
|
|
2330
|
+
throw storeError;
|
|
2331
|
+
}
|
|
2332
|
+
if (isSalesChannelError) {
|
|
2333
|
+
throw salesChannelError;
|
|
2334
|
+
}
|
|
2335
|
+
return /* @__PURE__ */ jsxs10(RouteFocusModal, { children: [
|
|
2336
|
+
/* @__PURE__ */ jsx13(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx13("span", { className: "sr-only", children: t("products.create.title") }) }),
|
|
2337
|
+
/* @__PURE__ */ jsx13(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx13("span", { className: "sr-only", children: t("products.create.description") }) }),
|
|
2338
|
+
ready && (Children2.count(children) > 0 ? children : /* @__PURE__ */ jsx13(ProductCreateForm, {}))
|
|
2339
|
+
] });
|
|
2340
|
+
};
|
|
2341
|
+
var ProductCreate = Root6;
|
|
2342
|
+
var ProductCreatePage = Object.assign(Root6, {
|
|
2343
|
+
Form: ProductCreateForm,
|
|
2344
|
+
DetailsTab: ProductCreateDetailsForm,
|
|
2345
|
+
OrganizeTab: ProductCreateOrganizeForm,
|
|
2346
|
+
AttributesTab: ProductCreateAttributesForm,
|
|
2347
|
+
VariantsTab: ProductCreateVariantsForm,
|
|
2348
|
+
InventoryTab: ProductCreateInventoryKitForm,
|
|
2349
|
+
Tab: TabbedForm.Tab
|
|
2350
|
+
});
|
|
2351
|
+
|
|
2352
|
+
export {
|
|
2353
|
+
ProductCreate,
|
|
2354
|
+
ProductCreatePage
|
|
2355
|
+
};
|