@mercurjs/vendor 2.0.0 → 2.0.2
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]-S6EPH4OO.js → [id]-6WYSWXWC.js} +30 -28
- package/dist/{[id]-SJXBJLAT.js → [id]-CLZ7BUYL.js} +9 -8
- package/dist/{[id]-47FGVJYM.js → [id]-DCCF7277.js} +35 -33
- package/dist/{[id]-ARXBXGNZ.js → [id]-EJAHMOOE.js} +33 -31
- package/dist/{[id]-HD76VJ2P.js → [id]-ENTJSLN2.js} +16 -15
- package/dist/{[id]-XY3A3EMF.js → [id]-LZPT5Y55.js} +32 -31
- package/dist/{[id]-Z4P7XA4G.js → [id]-OGHRZ2VY.js} +232 -103
- package/dist/{[id]-FLIHBDAS.js → [id]-PHS2WYFX.js} +33 -31
- package/dist/{[id]-JF6CCBRE.js → [id]-T64V4G6T.js} +19 -18
- package/dist/{[id]-IWPWKLOH.js → [id]-TLZZ53G7.js} +13 -12
- package/dist/{[id]-6HM66I3E.js → [id]-UAOAQVEM.js} +48 -45
- package/dist/{[id]-Q6HILUAG.js → [id]-VKG2WEIR.js} +39 -37
- package/dist/{[id]-VTFOP3BF.js → [id]-WRA56ZMU.js} +5 -5
- package/dist/{[id]-MIV4U5UW.js → [id]-XRGNT7CY.js} +7 -7
- package/dist/{[location_id]-AWDD2VHW.js → [location_id]-7ZUB2TTU.js} +14 -14
- package/dist/{[province_id]-36QJ2FKC.js → [province_id]-XGA44S7P.js} +30 -29
- package/dist/add-7ZTE42IE.js +158 -0
- package/dist/{add-YUANWTIL.js → add-AKC7LTK3.js} +49 -46
- package/dist/{add-customer-groups-7SLONTS2.js → add-customer-groups-BRC3DKQ2.js} +29 -27
- package/dist/{add-products-ISR3DRPQ.js → add-products-ZSULNZVI.js} +31 -29
- package/dist/{add-promotions-FZRDYHYX.js → add-promotions-TNFVT5ST.js} +12 -11
- package/dist/{add-to-campaign-V6D7JKRS.js → add-to-campaign-HL6NGRR4.js} +6 -6
- package/dist/address-3DSJESKM.js +249 -0
- package/dist/{adjust-inventory-P7AB7VIB.js → adjust-inventory-H4EUP7J3.js} +4 -4
- package/dist/{allocate-items-QAS5PZLR.js → allocate-items-6OAKG25R.js} +8 -8
- package/dist/{areas-Y7VDWH7G.js → areas-JO6L3M7Y.js} +11 -10
- package/dist/{attributes-UEM2VJKV.js → attributes-WRZYJEYN.js} +5 -4
- package/dist/{breadcrumb-6NAAOPIY.js → breadcrumb-3Z7KZG62.js} +4 -4
- package/dist/{breadcrumb-5OTOCYNL.js → breadcrumb-5BXDYVRO.js} +4 -4
- package/dist/{breadcrumb-3QTVWXZB.js → breadcrumb-BS7Y5OKF.js} +5 -5
- package/dist/{breadcrumb-CIGKLKKS.js → breadcrumb-D3UDTWGE.js} +3 -3
- package/dist/breadcrumb-D6QNYOAO.js +45 -0
- package/dist/{breadcrumb-OVMEC5OZ.js → breadcrumb-F3BN5753.js} +3 -3
- package/dist/{breadcrumb-MOQ7GI3Z.js → breadcrumb-KQSFIXQ4.js} +3 -3
- package/dist/{breadcrumb-NCBGPQML.js → breadcrumb-M5Z5WA6I.js} +4 -4
- package/dist/{breadcrumb-EOYLR3IQ.js → breadcrumb-OIGGCB3L.js} +3 -3
- package/dist/{breadcrumb-LENACUAA.js → breadcrumb-UAUX7XCV.js} +3 -3
- package/dist/breadcrumb-UH7FAYU2.js +46 -0
- package/dist/{breadcrumb-ASB2YCNV.js → breadcrumb-Y5UW3I4C.js} +3 -3
- package/dist/{breadcrumb-WP34OXGQ.js → breadcrumb-YBBYFQYG.js} +3 -3
- package/dist/breadcrumb-ZMVHXCOX.js +32 -0
- package/dist/bulk-edit-C6WJKURW.js +244 -0
- package/dist/{campaigns-PMVKUFEA.js → campaigns-SF2YDBID.js} +9 -8
- package/dist/{categories-JARCKR7M.js → categories-WRDJAJ2Q.js} +9 -8
- package/dist/{chunk-HUZG6A3X.js → chunk-2POPPFAP.js} +3 -3
- package/dist/{chunk-S5GQ2SES.js → chunk-2SLAVXFY.js} +5 -5
- package/dist/{chunk-JVBLYMY2.js → chunk-32RYSB2V.js} +2 -2
- package/dist/{chunk-VHMGJUYN.js → chunk-3B34B2M2.js} +1 -1
- package/dist/{chunk-BI2WWFPS.js → chunk-3BZBEC3Y.js} +1 -1
- package/dist/{chunk-LMHJRE4A.js → chunk-3DXMZA7M.js} +2 -2
- package/dist/{chunk-Z2WPXJ6J.js → chunk-4DYUQ3G5.js} +2 -2
- package/dist/{chunk-HBQC3YQZ.js → chunk-573EQEW2.js} +1 -1
- package/dist/{chunk-FBZHM2QZ.js → chunk-5BONGICL.js} +5 -5
- package/dist/{chunk-ZZ7VKT2S.js → chunk-5IWBNPZX.js} +766 -204
- package/dist/{chunk-KHHY7EEM.js → chunk-6WY5X4PE.js} +5 -5
- package/dist/{chunk-CUO22GTM.js → chunk-7TIZP4YG.js} +1 -1
- package/dist/{chunk-52I65K53.js → chunk-7XC7ZRG7.js} +17 -129
- package/dist/{chunk-AONKZGWL.js → chunk-ASEVHHCT.js} +3 -3
- package/dist/{chunk-TG3TCIL6.js → chunk-AW4WN2EK.js} +6 -6
- package/dist/{chunk-DDEIH66R.js → chunk-B5326BWT.js} +4 -4
- package/dist/{chunk-O6PRBSFL.js → chunk-BI2AYXZQ.js} +50 -35
- package/dist/{chunk-HUNGNEPY.js → chunk-BOZJOOGW.js} +1 -1
- package/dist/{chunk-AIFLEWO2.js → chunk-BWGPN6XV.js} +1 -1
- package/dist/{chunk-5XOCUDS2.js → chunk-CUMY2VZ5.js} +1 -1
- package/dist/chunk-DLNNTQRY.js +217 -0
- package/dist/{chunk-B2RVONU7.js → chunk-DRAZNW7J.js} +4 -4
- package/dist/{chunk-CVVYQI5F.js → chunk-EBZ5VZEO.js} +1 -1
- package/dist/{chunk-ZPGWTLF2.js → chunk-EFIF2GCZ.js} +4 -4
- package/dist/{chunk-DHADGZJ5.js → chunk-F4OJN2F2.js} +40 -5
- package/dist/{chunk-PYQJ5N25.js → chunk-FEUCCLKR.js} +6 -6
- package/dist/{chunk-JKSPDM7I.js → chunk-FNG7ZA7N.js} +1 -1
- package/dist/{chunk-UXKKD4AD.js → chunk-FQTYHU6G.js} +5 -5
- package/dist/chunk-FX4V5JCF.js +37 -0
- package/dist/{chunk-ZFFA36DB.js → chunk-GCSQEJMD.js} +2 -2
- package/dist/{chunk-NANYVBFI.js → chunk-GJM5XI3E.js} +1 -1
- package/dist/{chunk-W6ZVQJYB.js → chunk-GYV6SKY7.js} +1 -1
- package/dist/chunk-I5K5USJM.js +330 -0
- package/dist/{chunk-J2XP7VRG.js → chunk-IBTTL6EJ.js} +4 -4
- package/dist/{chunk-3LPVUPZZ.js → chunk-IDYGSAHT.js} +1 -1
- package/dist/{chunk-DC2K6CFQ.js → chunk-IQWK723D.js} +1 -1
- package/dist/{chunk-PWZKFTJS.js → chunk-ITQW6CK2.js} +5 -5
- package/dist/{chunk-NWFWI4IE.js → chunk-JKKRKFCS.js} +55 -62
- package/dist/chunk-JQV7CXEC.js +37 -0
- package/dist/{chunk-RH2NI4BC.js → chunk-JRT2U4UI.js} +448 -101
- package/dist/{chunk-4FCZDRAE.js → chunk-JTCUWZ7D.js} +5 -5
- package/dist/chunk-LA6XSPQG.js +3723 -0
- package/dist/{chunk-JXP5YZ77.js → chunk-LHKHQAAY.js} +1 -1
- package/dist/{chunk-TTFCO5HU.js → chunk-LKA7QM6R.js} +7 -7
- package/dist/{chunk-FGCKXH45.js → chunk-LPOAVK6Y.js} +1 -0
- package/dist/{chunk-VGJTARSA.js → chunk-LRARA622.js} +2 -2
- package/dist/chunk-LRD242C7.js +40 -0
- package/dist/{chunk-PADOWAXM.js → chunk-LWJF63JW.js} +1 -1
- package/dist/{chunk-DYUTYBAQ.js → chunk-M6N4ISXL.js} +1 -1
- package/dist/{chunk-2F3H6ORE.js → chunk-MWQQVKRU.js} +1 -1
- package/dist/{chunk-JK5CK6SW.js → chunk-N2WKLVUX.js} +20 -3
- package/dist/{chunk-R65A4P4H.js → chunk-N335VHD3.js} +1 -1
- package/dist/chunk-NBMM2TZK.js +33 -0
- package/dist/{chunk-SI4ALL7W.js → chunk-NBPMNUKZ.js} +1 -1
- package/dist/{chunk-GDMNHL7E.js → chunk-NCABGI3E.js} +6 -6
- package/dist/chunk-NYRRRCJS.js +339 -0
- package/dist/{chunk-QJ7QW3SZ.js → chunk-O7E4KQAK.js} +6 -6
- package/dist/{chunk-NKB6WTBH.js → chunk-OWPZ3CIR.js} +5 -5
- package/dist/{chunk-RE7YXVFG.js → chunk-PCMNEUMV.js} +3 -3
- package/dist/{chunk-CFETU5BI.js → chunk-QHQWEERJ.js} +1 -36
- package/dist/{chunk-WHTS4G5K.js → chunk-QXUKJDZB.js} +1 -1
- package/dist/{chunk-Y224F4UU.js → chunk-RIN4CBRB.js} +0 -1
- package/dist/{chunk-LWVBKUUL.js → chunk-RL7SFZOF.js} +2 -2
- package/dist/{chunk-UYJ65N46.js → chunk-RLETOWCM.js} +5 -5
- package/dist/{chunk-DVPTD7LZ.js → chunk-RMBCBXWD.js} +1 -1
- package/dist/{chunk-A2BNIZ7D.js → chunk-RTAWYMQP.js} +1 -1
- package/dist/{chunk-VJTYMQVA.js → chunk-RUE5BPC2.js} +2 -2
- package/dist/{chunk-EOOK6473.js → chunk-RV5UTYBG.js} +15 -13
- package/dist/chunk-S2Q7PO7I.js +177 -0
- package/dist/{chunk-Y4VBOHAP.js → chunk-S7EKBD2C.js} +3 -3
- package/dist/{chunk-CELHWX5P.js → chunk-SDSEW72R.js} +5 -5
- package/dist/{chunk-4TBDDMFP.js → chunk-SGT6QYWH.js} +1 -1
- package/dist/chunk-STBCWNZQ.js +57 -0
- package/dist/{chunk-LZ7QV42C.js → chunk-SYNUA6LQ.js} +1 -1
- package/dist/{chunk-CTWSWZ4R.js → chunk-T7LEJIIM.js} +4 -4
- package/dist/{chunk-7EM7WET3.js → chunk-TZTKHOEK.js} +4 -4
- package/dist/chunk-UL4O5M4S.js +45 -0
- package/dist/{chunk-AW77UWCZ.js → chunk-VBRTC2VU.js} +13 -4
- package/dist/{chunk-VDWGP2U6.js → chunk-VV6IKGCN.js} +1 -1
- package/dist/{chunk-JKXAL7WR.js → chunk-VXMOPVRH.js} +2 -2
- package/dist/{chunk-RIILGKYR.js → chunk-VXWN37PT.js} +1 -1
- package/dist/{chunk-CDIZEXFJ.js → chunk-WQX4ASK4.js} +6 -4
- package/dist/{chunk-SOZMJA7V.js → chunk-X22KTLZ7.js} +1 -1
- package/dist/{chunk-SDA5NDMT.js → chunk-XZG2HZYW.js} +2 -2
- package/dist/{chunk-SECZTXSU.js → chunk-YQYRAD5C.js} +1 -1
- package/dist/{chunk-WPFTRRWV.js → chunk-ZEVYT6IX.js} +202 -6
- package/dist/chunk-ZWTCVOHQ.js +14 -0
- package/dist/{chunk-NX26QE2O.js → chunk-ZYOXKUKZ.js} +1 -1
- package/dist/chunk-ZZO3INVE.js +9631 -0
- package/dist/collections-2M4RFH4P.js +66 -0
- package/dist/{configuration-RNWBTRAH.js → configuration-O5GDANA7.js} +5 -5
- package/dist/{configuration-KWAL2QZ5.js → configuration-RHPIO2QT.js} +3 -3
- package/dist/{create-BEVGWF6U.js → create-2TUWGQ2D.js} +33 -32
- package/dist/{create-YPCVTXAK.js → create-33TRLASX.js} +4 -4
- package/dist/{create-BBFTIFI2.js → create-3WUTLUJO.js} +36 -33
- package/dist/create-6IRE6AMF.js +78 -0
- package/dist/{create-F5K53QPH.js → create-D4F457BD.js} +38 -36
- package/dist/{create-7UEEO5TM.js → create-D6EW3EWC.js} +3 -3
- package/dist/{create-EJM5C2XP.js → create-FFKQAZ5D.js} +6 -6
- package/dist/{create-ZU362U3B.js → create-GHM7OTCR.js} +3 -3
- package/dist/{create-VUKGQU4L.js → create-IFMEEHN4.js} +34 -32
- package/dist/{create-IE6MYOIY.js → create-IOUKWPE4.js} +11 -10
- package/dist/{create-XGF6DB5F.js → create-KGOMJUXR.js} +5 -4
- package/dist/{create-TFDUNJSI.js → create-KGYL7FBM.js} +3 -3
- package/dist/{create-UCU73IXX.js → create-OF2OZ7EI.js} +25 -23
- package/dist/{create-MKBBF2V3.js → create-Q6ITSYJM.js} +3 -3
- package/dist/{create-VEWS4QDP.js → create-QK2SSLZK.js} +48 -45
- package/dist/{create-NPSYO6PE.js → create-YITFTHMA.js} +37 -35
- package/dist/{customers-4QWR5UOL.js → customers-OXAD52MC.js} +10 -9
- package/dist/{edit-J3LD76JS.js → edit-4HZHLYI3.js} +6 -6
- package/dist/{edit-47I7VVNB.js → edit-5CJZRHAA.js} +3 -3
- package/dist/{edit-BYXHU3IG.js → edit-7GVP6SRA.js} +3 -3
- package/dist/{edit-J6WCPHDS.js → edit-7HTH2UJF.js} +5 -5
- package/dist/{edit-XU33IVZH.js → edit-ATXE6CM5.js} +3 -3
- package/dist/{edit-ZMINDMGM.js → edit-B5B3XKDM.js} +3 -3
- package/dist/{edit-DG3MY3ZH.js → edit-FC64DWB2.js} +5 -5
- package/dist/{edit-LOKLQGM2.js → edit-FNDDSSMT.js} +3 -3
- package/dist/{edit-S7B7VPM4.js → edit-J5SC7GHQ.js} +29 -28
- package/dist/{edit-7LQATDUD.js → edit-LRRJTHV2.js} +4 -4
- package/dist/{edit-BQLSTFTQ.js → edit-MYSWY6W4.js} +5 -5
- package/dist/edit-ONSN756P.js +237 -0
- package/dist/{edit-JZVEAKJU.js → edit-PIE7Y73J.js} +49 -46
- package/dist/{edit-CZVL3IVY.js → edit-QRJIWTU2.js} +30 -29
- package/dist/{edit-JAKXFAVP.js → edit-SGEECDCR.js} +25 -24
- package/dist/{edit-5BUGSOTL.js → edit-UAXMJAEI.js} +5 -4
- package/dist/edit-UQAQVEUI.js +353 -0
- package/dist/edit-Z7EZRPUP.js +362 -0
- package/dist/{edit-NHU3LJIH.js → edit-ZEIL7EQW.js} +23 -22
- package/dist/{edit-budget-Z5USV462.js → edit-budget-J27CSEZH.js} +3 -3
- package/dist/{edit-inventory-item-YFW2AFRD.js → edit-inventory-item-US77M2FF.js} +3 -3
- package/dist/{edit-inventory-item-attributes-IYAMJDTB.js → edit-inventory-item-attributes-QYNDTUHT.js} +5 -4
- package/dist/edit-stocks-and-prices-543AYFDJ.js +409 -0
- package/dist/{fulfillment-V3D4XU3R.js → fulfillment-5LNFBSBS.js} +26 -25
- package/dist/{fulfillment-providers-YYN3GVV7.js → fulfillment-providers-U7Z7QMOQ.js} +33 -31
- package/dist/{home-PP7YYCSB.js → home-I3OILW5Z.js} +2 -2
- package/dist/index.css +5127 -3
- package/dist/index.js +453 -215
- package/dist/{inventory-AIRQ2KNS.js → inventory-W6S2NIBI.js} +8 -7
- package/dist/invite-P6HTOEIV.js +301 -0
- package/dist/invite-SI2KIPWI.js +370 -0
- package/dist/{locations-SQKM7JWN.js → locations-7SQJ3O2F.js} +4 -4
- package/dist/login-QDS5UXKV.js +36 -0
- package/dist/{manage-locations-4PQS4QY7.js → manage-locations-R4T72DTA.js} +4 -4
- package/dist/{media-UR73M6X2.js → media-RDXCLPKQ.js} +7 -6
- package/dist/{metadata-REBVXJJF.js → metadata-7JKDCVYY.js} +26 -25
- package/dist/{metadata-DIJTVDF7.js → metadata-AWUKZ25V.js} +6 -6
- package/dist/{metadata-ZKG2TRYU.js → metadata-UKBRUFH2.js} +23 -22
- package/dist/{metadata-UBZXDIFG.js → metadata-W5XIPFVU.js} +26 -25
- package/dist/{metadata-OOM44E2U.js → metadata-X4UIPNL6.js} +26 -25
- package/dist/{metadata-OGVHZEKS.js → metadata-ZV5RYLKR.js} +23 -22
- package/dist/{no-match-BO2NNLCM.js → no-match-JLVLPCRH.js} +1 -1
- package/dist/onboarding-DLIBZRKE.js +873 -0
- package/dist/orders-IAL3JNPU.js +61 -0
- package/dist/organization-QCSXE52A.js +303 -0
- package/dist/{organize-5AIJPYS2.js → organize-5W5KNBM2.js} +5 -5
- package/dist/{organize-YXJVI74L.js → organize-U2LVYSOD.js} +5 -5
- package/dist/pages/index.d.ts +222 -49
- package/dist/pages/index.js +96 -93
- package/dist/payment-details-ATUYMVJX.js +234 -0
- package/dist/{payouts-3BY73LZ3.js → payouts-ZLX3KFQT.js} +9 -8
- package/dist/{price-lists-G256JJN7.js → price-lists-JX22K5EO.js} +10 -9
- package/dist/{prices-EW7KBY6R.js → prices-6NY4DELP.js} +14 -13
- package/dist/{pricing-SQNF3KGG.js → pricing-RBESFX5P.js} +33 -31
- package/dist/{product-tags-FR32HXFW.js → product-tags-W4BL6RWV.js} +43 -40
- package/dist/{product-types-WJPLJI7H.js → product-types-MBLFYJOA.js} +10 -9
- package/dist/{product-variant-detail-G5MBDTFL.js → product-variant-detail-KU5OCL7E.js} +270 -56
- package/dist/{product-variant-edit-PW7W5J5E.js → product-variant-edit-5FMMMH2W.js} +8 -7
- package/dist/{products-C4BF2X7D.js → products-3VVYJUH7.js} +31 -29
- package/dist/products-YYLVCOOY.js +93 -0
- package/dist/professional-details-6Y5K6GBL.js +167 -0
- package/dist/profile-Y4AATQES.js +171 -0
- package/dist/{promotions-INYBMACT.js → promotions-NBJTFP6N.js} +10 -9
- package/dist/register-ZLE6MNPF.js +223 -0
- package/dist/{reset-password-CPTU3KHW.js → reset-password-PLCDLFL4.js} +4 -4
- package/dist/{chunk-5NF4OTVV.js → return-reasons-64WZ5Z3Z.js} +46 -5
- package/dist/{sales-channels-6I3U4W4Z.js → sales-channels-UIDLFCX6.js} +10 -9
- package/dist/{sales-channels-SOACADV2.js → sales-channels-UWPEFKAO.js} +12 -11
- package/dist/{settings-MAXHH7EC.js → settings-5MNWE5CR.js} +53 -56
- package/dist/{shipping-profile-7FTHSPY2.js → shipping-profile-JJBIVZPM.js} +4 -4
- package/dist/shipping-profiles-O7XB2DTE.js +45 -0
- package/dist/{stock-LOO5SU5Q.js → stock-2CGEFBXO.js} +30 -30
- package/dist/{stock-4G4PELBV.js → stock-VJAAYYW5.js} +30 -31
- package/dist/store-ZBSMNWFT.js +568 -0
- package/dist/store-closure-43FK32AQ.js +172 -0
- package/dist/store-select-Q2HE572R.js +166 -0
- package/dist/{tax-regions-45JVTUP3.js → tax-regions-FPMGLITT.js} +8 -8
- package/dist/team-ZLZJJWIY.js +269 -0
- package/package.json +9 -6
- package/dist/additional-attributes-XUFDADGP.js +0 -219
- package/dist/breadcrumb-3RAESPC7.js +0 -31
- package/dist/breadcrumb-54IEJEAX.js +0 -45
- package/dist/breadcrumb-CFDJOGTA.js +0 -44
- package/dist/chunk-6EYGH3TB.js +0 -26
- package/dist/chunk-FPJLYWOU.js +0 -190
- package/dist/chunk-GTUR4HSV.js +0 -53
- package/dist/chunk-LODQAVDC.js +0 -179
- package/dist/chunk-NYK5PQIF.js +0 -2078
- package/dist/chunk-PKBMQBKP.js +0 -7
- package/dist/chunk-RNC4NFVK.js +0 -170
- package/dist/collections-2222I5MO.js +0 -63
- package/dist/create-R3SFYWAH.js +0 -69
- package/dist/edit-HBNCGMQO.js +0 -413
- package/dist/login-RDIRFQ7U.js +0 -35
- package/dist/orders-Q347PBOH.js +0 -59
- package/dist/organization-TDDI3HOH.js +0 -233
- package/dist/products-4WTWZIVH.js +0 -85
- package/dist/register-6WOPLDJK.js +0 -366
- package/dist/return-reasons-4V2KVSRI.js +0 -52
- package/dist/seller-44DTDU26.js +0 -36
- package/dist/shipping-profiles-3PYQLYFE.js +0 -43
- /package/dist/{chunk-XG4PTPRM.js → chunk-NXDFDEKP.js} +0 -0
- /package/dist/{chunk-S3PQKKNV.js → chunk-V74Y5NIV.js} +0 -0
package/dist/chunk-NYK5PQIF.js
DELETED
|
@@ -1,2078 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChipInput
|
|
3
|
-
} from "./chunk-NCYTM57J.js";
|
|
4
|
-
import {
|
|
5
|
-
DataGrid,
|
|
6
|
-
createDataGridHelper,
|
|
7
|
-
createDataGridPriceColumns
|
|
8
|
-
} from "./chunk-ZZ7VKT2S.js";
|
|
9
|
-
import {
|
|
10
|
-
SwitchBox
|
|
11
|
-
} from "./chunk-YVCBMOJG.js";
|
|
12
|
-
import {
|
|
13
|
-
useSalesChannelTableColumns,
|
|
14
|
-
useSalesChannelTableEmptyState,
|
|
15
|
-
useSalesChannelTableFilters,
|
|
16
|
-
useSalesChannelTableQuery
|
|
17
|
-
} from "./chunk-SDA5NDMT.js";
|
|
18
|
-
import {
|
|
19
|
-
CategoryCombobox
|
|
20
|
-
} from "./chunk-7EM7WET3.js";
|
|
21
|
-
import {
|
|
22
|
-
UploadMediaFormItem
|
|
23
|
-
} from "./chunk-BI2WWFPS.js";
|
|
24
|
-
import {
|
|
25
|
-
PRODUCT_CREATE_FORM_DEFAULTS,
|
|
26
|
-
ProductCreateSchema,
|
|
27
|
-
decorateVariantsWithDefaultValues
|
|
28
|
-
} from "./chunk-52I65K53.js";
|
|
29
|
-
import {
|
|
30
|
-
CountrySelect
|
|
31
|
-
} from "./chunk-S3PQKKNV.js";
|
|
32
|
-
import {
|
|
33
|
-
useComboboxData
|
|
34
|
-
} from "./chunk-OVPAOBZB.js";
|
|
35
|
-
import {
|
|
36
|
-
Combobox
|
|
37
|
-
} from "./chunk-AW77UWCZ.js";
|
|
38
|
-
import {
|
|
39
|
-
TabbedForm,
|
|
40
|
-
useTabbedForm
|
|
41
|
-
} from "./chunk-FGCKXH45.js";
|
|
42
|
-
import {
|
|
43
|
-
RouteFocusModal,
|
|
44
|
-
StackedFocusModal,
|
|
45
|
-
useRouteModal,
|
|
46
|
-
useStackedModal
|
|
47
|
-
} from "./chunk-3CK6OINO.js";
|
|
48
|
-
import {
|
|
49
|
-
Form
|
|
50
|
-
} from "./chunk-3QSRE5LS.js";
|
|
51
|
-
import {
|
|
52
|
-
DataTable
|
|
53
|
-
} from "./chunk-5XOCUDS2.js";
|
|
54
|
-
import {
|
|
55
|
-
ActionMenu
|
|
56
|
-
} from "./chunk-BDGZ4EQO.js";
|
|
57
|
-
import {
|
|
58
|
-
useRegions
|
|
59
|
-
} from "./chunk-6EYGH3TB.js";
|
|
60
|
-
import {
|
|
61
|
-
usePricePreferences,
|
|
62
|
-
useStore
|
|
63
|
-
} from "./chunk-GTUR4HSV.js";
|
|
64
|
-
import {
|
|
65
|
-
useSalesChannels
|
|
66
|
-
} from "./chunk-VHMGJUYN.js";
|
|
67
|
-
import {
|
|
68
|
-
useCreateProduct
|
|
69
|
-
} from "./chunk-WPFTRRWV.js";
|
|
70
|
-
import {
|
|
71
|
-
fetchQuery,
|
|
72
|
-
sdk,
|
|
73
|
-
uploadFilesQuery
|
|
74
|
-
} from "./chunk-Y224F4UU.js";
|
|
75
|
-
|
|
76
|
-
// src/pages/products/create/product-create-page.tsx
|
|
77
|
-
import { Children as Children6 } from "react";
|
|
78
|
-
import { useTranslation as useTranslation11 } from "react-i18next";
|
|
79
|
-
|
|
80
|
-
// src/pages/products/create/product-create-form/product-create-form.tsx
|
|
81
|
-
import { Button as Button4, toast } from "@medusajs/ui";
|
|
82
|
-
import { Children as Children5, useCallback, useMemo as useMemo4 } from "react";
|
|
83
|
-
import { useForm, useWatch as useWatch4 } from "react-hook-form";
|
|
84
|
-
import { useTranslation as useTranslation10 } from "react-i18next";
|
|
85
|
-
|
|
86
|
-
// src/pages/products/create/product-create-details-form/product-create-details-form.tsx
|
|
87
|
-
import { Divider, Heading as Heading2 } from "@medusajs/ui";
|
|
88
|
-
import { Children } from "react";
|
|
89
|
-
import { useTranslation as useTranslation4 } from "react-i18next";
|
|
90
|
-
|
|
91
|
-
// src/pages/products/create/product-create-details-form/components/product-create-details-general-section/product-create-general-section.tsx
|
|
92
|
-
import { Input as Input2, Textarea } from "@medusajs/ui";
|
|
93
|
-
import { useTranslation } from "react-i18next";
|
|
94
|
-
|
|
95
|
-
// src/components/inputs/handle-input/handle-input.tsx
|
|
96
|
-
import { Input, Text } from "@medusajs/ui";
|
|
97
|
-
import { forwardRef } from "react";
|
|
98
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
99
|
-
var HandleInput = forwardRef(
|
|
100
|
-
(props, ref) => {
|
|
101
|
-
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
102
|
-
/* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsx(
|
|
103
|
-
Text,
|
|
104
|
-
{
|
|
105
|
-
className: "text-ui-fg-muted",
|
|
106
|
-
size: "small",
|
|
107
|
-
leading: "compact",
|
|
108
|
-
weight: "plus",
|
|
109
|
-
children: "/"
|
|
110
|
-
}
|
|
111
|
-
) }),
|
|
112
|
-
/* @__PURE__ */ jsx(Input, { ref, ...props, className: "pl-10" })
|
|
113
|
-
] });
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
HandleInput.displayName = "HandleInput";
|
|
117
|
-
|
|
118
|
-
// src/pages/products/create/product-create-details-form/components/product-create-details-general-section/product-create-general-section.tsx
|
|
119
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
120
|
-
var ProductCreateGeneralSection = () => {
|
|
121
|
-
const { t } = useTranslation();
|
|
122
|
-
const form = useTabbedForm();
|
|
123
|
-
return /* @__PURE__ */ jsxs2("div", { id: "general", className: "flex flex-col gap-y-6", children: [
|
|
124
|
-
/* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-y-2", children: /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-3", children: [
|
|
125
|
-
/* @__PURE__ */ jsx2(
|
|
126
|
-
Form.Field,
|
|
127
|
-
{
|
|
128
|
-
control: form.control,
|
|
129
|
-
name: "title",
|
|
130
|
-
render: ({ field }) => {
|
|
131
|
-
return /* @__PURE__ */ jsxs2(Form.Item, { children: [
|
|
132
|
-
/* @__PURE__ */ jsx2(Form.Label, { children: t("products.fields.title.label") }),
|
|
133
|
-
/* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(Input2, { ...field, placeholder: "Winter jacket" }) })
|
|
134
|
-
] });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
),
|
|
138
|
-
/* @__PURE__ */ jsx2(
|
|
139
|
-
Form.Field,
|
|
140
|
-
{
|
|
141
|
-
control: form.control,
|
|
142
|
-
name: "subtitle",
|
|
143
|
-
render: ({ field }) => {
|
|
144
|
-
return /* @__PURE__ */ jsxs2(Form.Item, { children: [
|
|
145
|
-
/* @__PURE__ */ jsx2(Form.Label, { optional: true, children: t("products.fields.subtitle.label") }),
|
|
146
|
-
/* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(Input2, { ...field, placeholder: "Warm and cosy" }) })
|
|
147
|
-
] });
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
),
|
|
151
|
-
/* @__PURE__ */ jsx2(
|
|
152
|
-
Form.Field,
|
|
153
|
-
{
|
|
154
|
-
control: form.control,
|
|
155
|
-
name: "handle",
|
|
156
|
-
render: ({ field }) => {
|
|
157
|
-
return /* @__PURE__ */ jsxs2(Form.Item, { children: [
|
|
158
|
-
/* @__PURE__ */ jsx2(
|
|
159
|
-
Form.Label,
|
|
160
|
-
{
|
|
161
|
-
tooltip: t("products.fields.handle.tooltip"),
|
|
162
|
-
optional: true,
|
|
163
|
-
children: t("fields.handle")
|
|
164
|
-
}
|
|
165
|
-
),
|
|
166
|
-
/* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(HandleInput, { ...field, placeholder: "winter-jacket" }) })
|
|
167
|
-
] });
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
)
|
|
171
|
-
] }) }),
|
|
172
|
-
/* @__PURE__ */ jsx2(
|
|
173
|
-
Form.Field,
|
|
174
|
-
{
|
|
175
|
-
control: form.control,
|
|
176
|
-
name: "description",
|
|
177
|
-
render: ({ field }) => {
|
|
178
|
-
return /* @__PURE__ */ jsxs2(Form.Item, { children: [
|
|
179
|
-
/* @__PURE__ */ jsx2(Form.Label, { optional: true, children: t("products.fields.description.label") }),
|
|
180
|
-
/* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(Textarea, { ...field, placeholder: "A warm and cozy jacket" }) })
|
|
181
|
-
] });
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
)
|
|
185
|
-
] });
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// src/pages/products/create/product-create-details-form/components/product-create-details-media-section/product-create-details-media-section.tsx
|
|
189
|
-
import {
|
|
190
|
-
defaultDropAnimationSideEffects,
|
|
191
|
-
DndContext,
|
|
192
|
-
DragOverlay,
|
|
193
|
-
KeyboardSensor,
|
|
194
|
-
PointerSensor,
|
|
195
|
-
useSensor,
|
|
196
|
-
useSensors
|
|
197
|
-
} from "@dnd-kit/core";
|
|
198
|
-
import {
|
|
199
|
-
arrayMove,
|
|
200
|
-
SortableContext,
|
|
201
|
-
sortableKeyboardCoordinates,
|
|
202
|
-
useSortable
|
|
203
|
-
} from "@dnd-kit/sortable";
|
|
204
|
-
import { CSS } from "@dnd-kit/utilities";
|
|
205
|
-
import {
|
|
206
|
-
DotsSix,
|
|
207
|
-
StackPerspective,
|
|
208
|
-
ThumbnailBadge,
|
|
209
|
-
Trash,
|
|
210
|
-
XMark
|
|
211
|
-
} from "@medusajs/icons";
|
|
212
|
-
import { IconButton, Text as Text2 } from "@medusajs/ui";
|
|
213
|
-
import { useState } from "react";
|
|
214
|
-
import { useFieldArray } from "react-hook-form";
|
|
215
|
-
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
216
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
217
|
-
var dropAnimationConfig = {
|
|
218
|
-
sideEffects: defaultDropAnimationSideEffects({
|
|
219
|
-
styles: {
|
|
220
|
-
active: {
|
|
221
|
-
opacity: "0.4"
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
})
|
|
225
|
-
};
|
|
226
|
-
var ProductCreateMediaSection = () => {
|
|
227
|
-
const form = useTabbedForm();
|
|
228
|
-
const { fields, append, remove } = useFieldArray({
|
|
229
|
-
name: "media",
|
|
230
|
-
control: form.control,
|
|
231
|
-
keyName: "field_id"
|
|
232
|
-
});
|
|
233
|
-
const [activeId, setActiveId] = useState(null);
|
|
234
|
-
const sensors = useSensors(
|
|
235
|
-
useSensor(PointerSensor),
|
|
236
|
-
useSensor(KeyboardSensor, {
|
|
237
|
-
coordinateGetter: sortableKeyboardCoordinates
|
|
238
|
-
})
|
|
239
|
-
);
|
|
240
|
-
const handleDragStart = (event) => {
|
|
241
|
-
setActiveId(event.active.id);
|
|
242
|
-
};
|
|
243
|
-
const handleDragEnd = (event) => {
|
|
244
|
-
setActiveId(null);
|
|
245
|
-
const { active, over } = event;
|
|
246
|
-
if (active.id !== over?.id) {
|
|
247
|
-
const oldIndex = fields.findIndex((item) => item.field_id === active.id);
|
|
248
|
-
const newIndex = fields.findIndex((item) => item.field_id === over?.id);
|
|
249
|
-
form.setValue("media", arrayMove(fields, oldIndex, newIndex), {
|
|
250
|
-
shouldDirty: true,
|
|
251
|
-
shouldTouch: true
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
const handleDragCancel = () => {
|
|
256
|
-
setActiveId(null);
|
|
257
|
-
};
|
|
258
|
-
const getOnDelete = (index) => {
|
|
259
|
-
return () => {
|
|
260
|
-
remove(index);
|
|
261
|
-
};
|
|
262
|
-
};
|
|
263
|
-
const getMakeThumbnail = (index) => {
|
|
264
|
-
return () => {
|
|
265
|
-
const newFields = fields.map((field, i) => {
|
|
266
|
-
return {
|
|
267
|
-
...field,
|
|
268
|
-
isThumbnail: i === index
|
|
269
|
-
};
|
|
270
|
-
});
|
|
271
|
-
form.setValue("media", newFields, {
|
|
272
|
-
shouldDirty: true,
|
|
273
|
-
shouldTouch: true
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
};
|
|
277
|
-
const getItemHandlers = (index) => {
|
|
278
|
-
return {
|
|
279
|
-
onDelete: getOnDelete(index),
|
|
280
|
-
onMakeThumbnail: getMakeThumbnail(index)
|
|
281
|
-
};
|
|
282
|
-
};
|
|
283
|
-
return /* @__PURE__ */ jsxs3("div", { id: "media", className: "flex flex-col gap-y-2", children: [
|
|
284
|
-
/* @__PURE__ */ jsx3(UploadMediaFormItem, { form, append, showHint: false }),
|
|
285
|
-
/* @__PURE__ */ jsxs3(
|
|
286
|
-
DndContext,
|
|
287
|
-
{
|
|
288
|
-
sensors,
|
|
289
|
-
onDragEnd: handleDragEnd,
|
|
290
|
-
onDragStart: handleDragStart,
|
|
291
|
-
onDragCancel: handleDragCancel,
|
|
292
|
-
children: [
|
|
293
|
-
/* @__PURE__ */ jsx3(DragOverlay, { dropAnimation: dropAnimationConfig, children: activeId ? /* @__PURE__ */ jsx3(
|
|
294
|
-
MediaGridItemOverlay,
|
|
295
|
-
{
|
|
296
|
-
field: fields.find((m) => m.field_id === activeId)
|
|
297
|
-
}
|
|
298
|
-
) : null }),
|
|
299
|
-
/* @__PURE__ */ jsx3("ul", { className: "flex flex-col gap-y-2", children: /* @__PURE__ */ jsx3(SortableContext, { items: fields.map((field) => field.field_id), children: fields.map((field, index) => {
|
|
300
|
-
const { onDelete, onMakeThumbnail } = getItemHandlers(index);
|
|
301
|
-
return /* @__PURE__ */ jsx3(
|
|
302
|
-
MediaItem,
|
|
303
|
-
{
|
|
304
|
-
field,
|
|
305
|
-
onDelete,
|
|
306
|
-
onMakeThumbnail
|
|
307
|
-
},
|
|
308
|
-
field.field_id
|
|
309
|
-
);
|
|
310
|
-
}) }) })
|
|
311
|
-
]
|
|
312
|
-
}
|
|
313
|
-
)
|
|
314
|
-
] });
|
|
315
|
-
};
|
|
316
|
-
var MediaItem = ({ field, onDelete, onMakeThumbnail }) => {
|
|
317
|
-
const { t } = useTranslation2();
|
|
318
|
-
const {
|
|
319
|
-
attributes,
|
|
320
|
-
listeners,
|
|
321
|
-
setNodeRef,
|
|
322
|
-
setActivatorNodeRef,
|
|
323
|
-
transform,
|
|
324
|
-
transition,
|
|
325
|
-
isDragging
|
|
326
|
-
} = useSortable({ id: field.field_id });
|
|
327
|
-
const style = {
|
|
328
|
-
opacity: isDragging ? 0.4 : void 0,
|
|
329
|
-
transform: CSS.Translate.toString(transform),
|
|
330
|
-
transition
|
|
331
|
-
};
|
|
332
|
-
if (!field.file) {
|
|
333
|
-
return null;
|
|
334
|
-
}
|
|
335
|
-
return /* @__PURE__ */ jsxs3(
|
|
336
|
-
"li",
|
|
337
|
-
{
|
|
338
|
-
className: "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
339
|
-
ref: setNodeRef,
|
|
340
|
-
style,
|
|
341
|
-
children: [
|
|
342
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-2", children: [
|
|
343
|
-
/* @__PURE__ */ jsx3(
|
|
344
|
-
IconButton,
|
|
345
|
-
{
|
|
346
|
-
variant: "transparent",
|
|
347
|
-
type: "button",
|
|
348
|
-
size: "small",
|
|
349
|
-
...attributes,
|
|
350
|
-
...listeners,
|
|
351
|
-
ref: setActivatorNodeRef,
|
|
352
|
-
className: "cursor-grab touch-none active:cursor-grabbing",
|
|
353
|
-
children: /* @__PURE__ */ jsx3(DotsSix, { className: "text-ui-fg-muted" })
|
|
354
|
-
}
|
|
355
|
-
),
|
|
356
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-3", children: [
|
|
357
|
-
/* @__PURE__ */ jsx3("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx3(ThumbnailPreview, { url: field.url }) }),
|
|
358
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col", children: [
|
|
359
|
-
/* @__PURE__ */ jsx3(Text2, { size: "small", leading: "compact", children: field.file.name }),
|
|
360
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-1", children: [
|
|
361
|
-
field.isThumbnail && /* @__PURE__ */ jsx3(ThumbnailBadge, {}),
|
|
362
|
-
/* @__PURE__ */ jsx3(
|
|
363
|
-
Text2,
|
|
364
|
-
{
|
|
365
|
-
size: "xsmall",
|
|
366
|
-
leading: "compact",
|
|
367
|
-
className: "text-ui-fg-subtle",
|
|
368
|
-
children: formatFileSize(field.file.size)
|
|
369
|
-
}
|
|
370
|
-
)
|
|
371
|
-
] })
|
|
372
|
-
] })
|
|
373
|
-
] })
|
|
374
|
-
] }),
|
|
375
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-1", children: [
|
|
376
|
-
/* @__PURE__ */ jsx3(
|
|
377
|
-
ActionMenu,
|
|
378
|
-
{
|
|
379
|
-
groups: [
|
|
380
|
-
{
|
|
381
|
-
actions: [
|
|
382
|
-
{
|
|
383
|
-
label: t("products.media.makeThumbnail"),
|
|
384
|
-
icon: /* @__PURE__ */ jsx3(StackPerspective, {}),
|
|
385
|
-
onClick: onMakeThumbnail
|
|
386
|
-
}
|
|
387
|
-
]
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
actions: [
|
|
391
|
-
{
|
|
392
|
-
icon: /* @__PURE__ */ jsx3(Trash, {}),
|
|
393
|
-
label: t("actions.delete"),
|
|
394
|
-
onClick: onDelete
|
|
395
|
-
}
|
|
396
|
-
]
|
|
397
|
-
}
|
|
398
|
-
]
|
|
399
|
-
}
|
|
400
|
-
),
|
|
401
|
-
/* @__PURE__ */ jsx3(
|
|
402
|
-
IconButton,
|
|
403
|
-
{
|
|
404
|
-
type: "button",
|
|
405
|
-
size: "small",
|
|
406
|
-
variant: "transparent",
|
|
407
|
-
onClick: onDelete,
|
|
408
|
-
children: /* @__PURE__ */ jsx3(XMark, {})
|
|
409
|
-
}
|
|
410
|
-
)
|
|
411
|
-
] })
|
|
412
|
-
]
|
|
413
|
-
}
|
|
414
|
-
);
|
|
415
|
-
};
|
|
416
|
-
var MediaGridItemOverlay = ({ field }) => {
|
|
417
|
-
return /* @__PURE__ */ jsxs3("li", { className: "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2", children: [
|
|
418
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-2", children: [
|
|
419
|
-
/* @__PURE__ */ jsx3(
|
|
420
|
-
IconButton,
|
|
421
|
-
{
|
|
422
|
-
variant: "transparent",
|
|
423
|
-
size: "small",
|
|
424
|
-
className: "cursor-grab touch-none active:cursor-grabbing",
|
|
425
|
-
children: /* @__PURE__ */ jsx3(DotsSix, { className: "text-ui-fg-muted" })
|
|
426
|
-
}
|
|
427
|
-
),
|
|
428
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-3", children: [
|
|
429
|
-
/* @__PURE__ */ jsx3("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx3(ThumbnailPreview, { url: field.url }) }),
|
|
430
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex flex-col", children: [
|
|
431
|
-
/* @__PURE__ */ jsx3(Text2, { size: "small", leading: "compact", children: field.file?.name }),
|
|
432
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-1", children: [
|
|
433
|
-
field.isThumbnail && /* @__PURE__ */ jsx3(ThumbnailBadge, {}),
|
|
434
|
-
/* @__PURE__ */ jsx3(
|
|
435
|
-
Text2,
|
|
436
|
-
{
|
|
437
|
-
size: "xsmall",
|
|
438
|
-
leading: "compact",
|
|
439
|
-
className: "text-ui-fg-subtle",
|
|
440
|
-
children: formatFileSize(field.file?.size ?? 0)
|
|
441
|
-
}
|
|
442
|
-
)
|
|
443
|
-
] })
|
|
444
|
-
] })
|
|
445
|
-
] })
|
|
446
|
-
] }),
|
|
447
|
-
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-x-1", children: [
|
|
448
|
-
/* @__PURE__ */ jsx3(ActionMenu, { groups: [] }),
|
|
449
|
-
/* @__PURE__ */ jsx3(
|
|
450
|
-
IconButton,
|
|
451
|
-
{
|
|
452
|
-
type: "button",
|
|
453
|
-
size: "small",
|
|
454
|
-
variant: "transparent",
|
|
455
|
-
onClick: () => {
|
|
456
|
-
},
|
|
457
|
-
children: /* @__PURE__ */ jsx3(XMark, {})
|
|
458
|
-
}
|
|
459
|
-
)
|
|
460
|
-
] })
|
|
461
|
-
] });
|
|
462
|
-
};
|
|
463
|
-
var ThumbnailPreview = ({ url }) => {
|
|
464
|
-
if (!url) {
|
|
465
|
-
return null;
|
|
466
|
-
}
|
|
467
|
-
return /* @__PURE__ */ jsx3("img", { src: url, alt: "", className: "size-full object-cover object-center" });
|
|
468
|
-
};
|
|
469
|
-
function formatFileSize(bytes, decimalPlaces = 2) {
|
|
470
|
-
if (bytes === 0) {
|
|
471
|
-
return "0 Bytes";
|
|
472
|
-
}
|
|
473
|
-
const k = 1024;
|
|
474
|
-
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
475
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
476
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPlaces)) + " " + sizes[i];
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// src/pages/products/create/product-create-details-form/components/product-create-details-variant-section/product-create-details-variant-section.tsx
|
|
480
|
-
import { XMarkMini } from "@medusajs/icons";
|
|
481
|
-
import {
|
|
482
|
-
Alert,
|
|
483
|
-
Button,
|
|
484
|
-
Checkbox,
|
|
485
|
-
Heading,
|
|
486
|
-
Hint,
|
|
487
|
-
IconButton as IconButton3,
|
|
488
|
-
InlineTip,
|
|
489
|
-
Input as Input3,
|
|
490
|
-
Label,
|
|
491
|
-
Text as Text3,
|
|
492
|
-
clx as clx2
|
|
493
|
-
} from "@medusajs/ui";
|
|
494
|
-
import {
|
|
495
|
-
Controller,
|
|
496
|
-
useFieldArray as useFieldArray2,
|
|
497
|
-
useWatch
|
|
498
|
-
} from "react-hook-form";
|
|
499
|
-
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
500
|
-
|
|
501
|
-
// src/components/common/sortable-list/sortable-list.tsx
|
|
502
|
-
import {
|
|
503
|
-
DndContext as DndContext2,
|
|
504
|
-
DragOverlay as DragOverlay2,
|
|
505
|
-
KeyboardSensor as KeyboardSensor2,
|
|
506
|
-
PointerSensor as PointerSensor2,
|
|
507
|
-
defaultDropAnimationSideEffects as defaultDropAnimationSideEffects2,
|
|
508
|
-
useSensor as useSensor2,
|
|
509
|
-
useSensors as useSensors2
|
|
510
|
-
} from "@dnd-kit/core";
|
|
511
|
-
import {
|
|
512
|
-
SortableContext as SortableContext2,
|
|
513
|
-
arrayMove as arrayMove2,
|
|
514
|
-
sortableKeyboardCoordinates as sortableKeyboardCoordinates2,
|
|
515
|
-
useSortable as useSortable2
|
|
516
|
-
} from "@dnd-kit/sortable";
|
|
517
|
-
import { CSS as CSS2 } from "@dnd-kit/utilities";
|
|
518
|
-
import { DotsSix as DotsSix2 } from "@medusajs/icons";
|
|
519
|
-
import { IconButton as IconButton2, clx } from "@medusajs/ui";
|
|
520
|
-
import {
|
|
521
|
-
Fragment,
|
|
522
|
-
createContext,
|
|
523
|
-
useContext,
|
|
524
|
-
useMemo,
|
|
525
|
-
useState as useState2
|
|
526
|
-
} from "react";
|
|
527
|
-
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
528
|
-
var List = ({
|
|
529
|
-
items,
|
|
530
|
-
onChange,
|
|
531
|
-
renderItem
|
|
532
|
-
}) => {
|
|
533
|
-
const [active, setActive] = useState2(null);
|
|
534
|
-
const [activeItem, activeIndex] = useMemo(() => {
|
|
535
|
-
if (active === null) {
|
|
536
|
-
return [null, null];
|
|
537
|
-
}
|
|
538
|
-
const index = items.findIndex(({ id }) => id === active.id);
|
|
539
|
-
return [items[index], index];
|
|
540
|
-
}, [active, items]);
|
|
541
|
-
const sensors = useSensors2(
|
|
542
|
-
useSensor2(PointerSensor2),
|
|
543
|
-
useSensor2(KeyboardSensor2, {
|
|
544
|
-
coordinateGetter: sortableKeyboardCoordinates2
|
|
545
|
-
})
|
|
546
|
-
);
|
|
547
|
-
const handleDragStart = ({ active: active2 }) => {
|
|
548
|
-
setActive(active2);
|
|
549
|
-
};
|
|
550
|
-
const handleDragEnd = ({ active: active2, over }) => {
|
|
551
|
-
if (over && active2.id !== over.id) {
|
|
552
|
-
const activeIndex2 = items.findIndex(({ id }) => id === active2.id);
|
|
553
|
-
const overIndex = items.findIndex(({ id }) => id === over.id);
|
|
554
|
-
onChange(arrayMove2(items, activeIndex2, overIndex));
|
|
555
|
-
}
|
|
556
|
-
setActive(null);
|
|
557
|
-
};
|
|
558
|
-
const handleDragCancel = () => {
|
|
559
|
-
setActive(null);
|
|
560
|
-
};
|
|
561
|
-
return /* @__PURE__ */ jsxs4(
|
|
562
|
-
DndContext2,
|
|
563
|
-
{
|
|
564
|
-
sensors,
|
|
565
|
-
onDragStart: handleDragStart,
|
|
566
|
-
onDragEnd: handleDragEnd,
|
|
567
|
-
onDragCancel: handleDragCancel,
|
|
568
|
-
children: [
|
|
569
|
-
/* @__PURE__ */ jsx4(Overlay, { children: activeItem && activeIndex !== null ? renderItem(activeItem, activeIndex) : null }),
|
|
570
|
-
/* @__PURE__ */ jsx4(SortableContext2, { items, children: /* @__PURE__ */ jsx4(
|
|
571
|
-
"ul",
|
|
572
|
-
{
|
|
573
|
-
role: "application",
|
|
574
|
-
className: "flex list-inside list-none list-image-none flex-col p-0",
|
|
575
|
-
children: items.map((item, index) => /* @__PURE__ */ jsx4(Fragment, { children: renderItem(item, index) }, item.id))
|
|
576
|
-
}
|
|
577
|
-
) })
|
|
578
|
-
]
|
|
579
|
-
}
|
|
580
|
-
);
|
|
581
|
-
};
|
|
582
|
-
var dropAnimationConfig2 = {
|
|
583
|
-
sideEffects: defaultDropAnimationSideEffects2({
|
|
584
|
-
styles: {
|
|
585
|
-
active: {
|
|
586
|
-
opacity: "0.4"
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
})
|
|
590
|
-
};
|
|
591
|
-
var Overlay = ({ children }) => {
|
|
592
|
-
return /* @__PURE__ */ jsx4(
|
|
593
|
-
DragOverlay2,
|
|
594
|
-
{
|
|
595
|
-
className: "shadow-elevation-card-hover overflow-hidden rounded-md [&>li]:border-b-0",
|
|
596
|
-
dropAnimation: dropAnimationConfig2,
|
|
597
|
-
children
|
|
598
|
-
}
|
|
599
|
-
);
|
|
600
|
-
};
|
|
601
|
-
var SortableItemContext = createContext(null);
|
|
602
|
-
var useSortableItemContext = () => {
|
|
603
|
-
const context = useContext(SortableItemContext);
|
|
604
|
-
if (!context) {
|
|
605
|
-
throw new Error(
|
|
606
|
-
"useSortableItemContext must be used within a SortableItemContext"
|
|
607
|
-
);
|
|
608
|
-
}
|
|
609
|
-
return context;
|
|
610
|
-
};
|
|
611
|
-
var Item = ({
|
|
612
|
-
id,
|
|
613
|
-
className,
|
|
614
|
-
children
|
|
615
|
-
}) => {
|
|
616
|
-
const {
|
|
617
|
-
attributes,
|
|
618
|
-
isDragging,
|
|
619
|
-
listeners,
|
|
620
|
-
setNodeRef,
|
|
621
|
-
setActivatorNodeRef,
|
|
622
|
-
transform,
|
|
623
|
-
transition
|
|
624
|
-
} = useSortable2({ id });
|
|
625
|
-
const context = useMemo(
|
|
626
|
-
() => ({
|
|
627
|
-
attributes,
|
|
628
|
-
listeners,
|
|
629
|
-
ref: setActivatorNodeRef,
|
|
630
|
-
isDragging
|
|
631
|
-
}),
|
|
632
|
-
[attributes, listeners, setActivatorNodeRef, isDragging]
|
|
633
|
-
);
|
|
634
|
-
const style = {
|
|
635
|
-
opacity: isDragging ? 0.4 : void 0,
|
|
636
|
-
transform: CSS2.Translate.toString(transform),
|
|
637
|
-
transition
|
|
638
|
-
};
|
|
639
|
-
return /* @__PURE__ */ jsx4(SortableItemContext.Provider, { value: context, children: /* @__PURE__ */ jsx4(
|
|
640
|
-
"li",
|
|
641
|
-
{
|
|
642
|
-
className: clx("transition-fg flex flex-1 list-none", className),
|
|
643
|
-
ref: setNodeRef,
|
|
644
|
-
style,
|
|
645
|
-
children
|
|
646
|
-
}
|
|
647
|
-
) });
|
|
648
|
-
};
|
|
649
|
-
var DragHandle = () => {
|
|
650
|
-
const { attributes, listeners, ref } = useSortableItemContext();
|
|
651
|
-
return /* @__PURE__ */ jsx4(
|
|
652
|
-
IconButton2,
|
|
653
|
-
{
|
|
654
|
-
variant: "transparent",
|
|
655
|
-
size: "small",
|
|
656
|
-
...attributes,
|
|
657
|
-
...listeners,
|
|
658
|
-
ref,
|
|
659
|
-
className: "cursor-grab touch-none active:cursor-grabbing",
|
|
660
|
-
children: /* @__PURE__ */ jsx4(DotsSix2, { className: "text-ui-fg-muted" })
|
|
661
|
-
}
|
|
662
|
-
);
|
|
663
|
-
};
|
|
664
|
-
var SortableList = Object.assign(List, {
|
|
665
|
-
Item,
|
|
666
|
-
DragHandle
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
// src/pages/products/create/product-create-details-form/components/product-create-details-variant-section/product-create-details-variant-section.tsx
|
|
670
|
-
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
671
|
-
var getPermutations = (data) => {
|
|
672
|
-
if (data.length === 0) {
|
|
673
|
-
return [];
|
|
674
|
-
}
|
|
675
|
-
if (data.length === 1) {
|
|
676
|
-
return data[0].values.map((value) => ({ [data[0].title]: value }));
|
|
677
|
-
}
|
|
678
|
-
const toProcess = data[0];
|
|
679
|
-
const rest = data.slice(1);
|
|
680
|
-
return toProcess.values.flatMap((value) => {
|
|
681
|
-
return getPermutations(rest).map((permutation) => {
|
|
682
|
-
return {
|
|
683
|
-
[toProcess.title]: value,
|
|
684
|
-
...permutation
|
|
685
|
-
};
|
|
686
|
-
});
|
|
687
|
-
});
|
|
688
|
-
};
|
|
689
|
-
var getVariantName = (options) => {
|
|
690
|
-
return Object.values(options).join(" / ");
|
|
691
|
-
};
|
|
692
|
-
var ProductCreateVariantsSection = () => {
|
|
693
|
-
const { t } = useTranslation3();
|
|
694
|
-
const form = useTabbedForm();
|
|
695
|
-
const options = useFieldArray2({
|
|
696
|
-
control: form.control,
|
|
697
|
-
name: "options"
|
|
698
|
-
});
|
|
699
|
-
const variants = useFieldArray2({
|
|
700
|
-
control: form.control,
|
|
701
|
-
name: "variants"
|
|
702
|
-
});
|
|
703
|
-
const watchedAreVariantsEnabled = useWatch({
|
|
704
|
-
control: form.control,
|
|
705
|
-
name: "enable_variants",
|
|
706
|
-
defaultValue: false
|
|
707
|
-
});
|
|
708
|
-
const watchedOptions = useWatch({
|
|
709
|
-
control: form.control,
|
|
710
|
-
name: "options",
|
|
711
|
-
defaultValue: []
|
|
712
|
-
});
|
|
713
|
-
const watchedVariants = useWatch({
|
|
714
|
-
control: form.control,
|
|
715
|
-
name: "variants",
|
|
716
|
-
defaultValue: []
|
|
717
|
-
});
|
|
718
|
-
const showInvalidOptionsMessage = !!form.formState.errors.options?.length;
|
|
719
|
-
const showInvalidVariantsMessage = form.formState.errors.variants?.root?.message === "invalid_length";
|
|
720
|
-
const handleOptionValueUpdate = (index, value) => {
|
|
721
|
-
const { isTouched: hasUserSelectedVariants } = form.getFieldState("variants");
|
|
722
|
-
const newOptions = [...watchedOptions];
|
|
723
|
-
newOptions[index].values = value;
|
|
724
|
-
const permutations = getPermutations(newOptions);
|
|
725
|
-
const oldVariants = [...watchedVariants];
|
|
726
|
-
const findMatchingPermutation = (options2) => {
|
|
727
|
-
return permutations.find(
|
|
728
|
-
(permutation) => Object.keys(options2).every((key) => options2[key] === permutation[key])
|
|
729
|
-
);
|
|
730
|
-
};
|
|
731
|
-
const newVariants = oldVariants.reduce(
|
|
732
|
-
(variants2, variant) => {
|
|
733
|
-
const match = findMatchingPermutation(variant.options);
|
|
734
|
-
if (match) {
|
|
735
|
-
variants2.push({
|
|
736
|
-
...variant,
|
|
737
|
-
title: getVariantName(match),
|
|
738
|
-
options: match
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
return variants2;
|
|
742
|
-
},
|
|
743
|
-
[]
|
|
744
|
-
);
|
|
745
|
-
const usedPermutations = new Set(
|
|
746
|
-
newVariants.map((variant) => variant.options)
|
|
747
|
-
);
|
|
748
|
-
const unusedPermutations = permutations.filter(
|
|
749
|
-
(permutation) => !usedPermutations.has(permutation)
|
|
750
|
-
);
|
|
751
|
-
unusedPermutations.forEach((permutation) => {
|
|
752
|
-
newVariants.push({
|
|
753
|
-
title: getVariantName(permutation),
|
|
754
|
-
options: permutation,
|
|
755
|
-
should_create: hasUserSelectedVariants ? false : true,
|
|
756
|
-
variant_rank: newVariants.length,
|
|
757
|
-
inventory: [{ inventory_item_id: "", required_quantity: "" }]
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
form.setValue("variants", newVariants);
|
|
761
|
-
};
|
|
762
|
-
const handleRemoveOption = (index) => {
|
|
763
|
-
if (index === 0) {
|
|
764
|
-
return;
|
|
765
|
-
}
|
|
766
|
-
options.remove(index);
|
|
767
|
-
const newOptions = [...watchedOptions];
|
|
768
|
-
newOptions.splice(index, 1);
|
|
769
|
-
const permutations = getPermutations(newOptions);
|
|
770
|
-
const oldVariants = [...watchedVariants];
|
|
771
|
-
const findMatchingPermutation = (options2) => {
|
|
772
|
-
return permutations.find(
|
|
773
|
-
(permutation) => Object.keys(options2).every((key) => options2[key] === permutation[key])
|
|
774
|
-
);
|
|
775
|
-
};
|
|
776
|
-
const newVariants = oldVariants.reduce(
|
|
777
|
-
(variants2, variant) => {
|
|
778
|
-
const match = findMatchingPermutation(variant.options);
|
|
779
|
-
if (match) {
|
|
780
|
-
variants2.push({
|
|
781
|
-
...variant,
|
|
782
|
-
title: getVariantName(match),
|
|
783
|
-
options: match
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
return variants2;
|
|
787
|
-
},
|
|
788
|
-
[]
|
|
789
|
-
);
|
|
790
|
-
const usedPermutations = new Set(
|
|
791
|
-
newVariants.map((variant) => variant.options)
|
|
792
|
-
);
|
|
793
|
-
const unusedPermutations = permutations.filter(
|
|
794
|
-
(permutation) => !usedPermutations.has(permutation)
|
|
795
|
-
);
|
|
796
|
-
unusedPermutations.forEach((permutation) => {
|
|
797
|
-
newVariants.push({
|
|
798
|
-
title: getVariantName(permutation),
|
|
799
|
-
options: permutation,
|
|
800
|
-
should_create: false,
|
|
801
|
-
variant_rank: newVariants.length
|
|
802
|
-
});
|
|
803
|
-
});
|
|
804
|
-
form.setValue("variants", newVariants);
|
|
805
|
-
};
|
|
806
|
-
const handleRankChange = (items) => {
|
|
807
|
-
const update = items.map((item, index) => {
|
|
808
|
-
const variant = watchedVariants.find((v) => v.title === item.title);
|
|
809
|
-
return {
|
|
810
|
-
id: item.id,
|
|
811
|
-
...variant || item,
|
|
812
|
-
variant_rank: index
|
|
813
|
-
};
|
|
814
|
-
});
|
|
815
|
-
variants.replace(update);
|
|
816
|
-
};
|
|
817
|
-
const getCheckboxState = (variants2) => {
|
|
818
|
-
if (variants2.every((variant) => variant.should_create)) {
|
|
819
|
-
return true;
|
|
820
|
-
}
|
|
821
|
-
if (variants2.some((variant) => variant.should_create)) {
|
|
822
|
-
return "indeterminate";
|
|
823
|
-
}
|
|
824
|
-
return false;
|
|
825
|
-
};
|
|
826
|
-
const onCheckboxChange = (value) => {
|
|
827
|
-
switch (value) {
|
|
828
|
-
case true: {
|
|
829
|
-
const update = watchedVariants.map((variant) => {
|
|
830
|
-
return {
|
|
831
|
-
...variant,
|
|
832
|
-
should_create: true
|
|
833
|
-
};
|
|
834
|
-
});
|
|
835
|
-
form.setValue("variants", update);
|
|
836
|
-
break;
|
|
837
|
-
}
|
|
838
|
-
case false: {
|
|
839
|
-
const update = watchedVariants.map((variant) => {
|
|
840
|
-
return {
|
|
841
|
-
...variant,
|
|
842
|
-
should_create: false
|
|
843
|
-
};
|
|
844
|
-
});
|
|
845
|
-
form.setValue("variants", decorateVariantsWithDefaultValues(update));
|
|
846
|
-
break;
|
|
847
|
-
}
|
|
848
|
-
case "indeterminate":
|
|
849
|
-
break;
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
const createDefaultOptionAndVariant = () => {
|
|
853
|
-
form.setValue("options", [
|
|
854
|
-
{
|
|
855
|
-
title: "Default option",
|
|
856
|
-
values: ["Default option value"]
|
|
857
|
-
}
|
|
858
|
-
]);
|
|
859
|
-
form.setValue(
|
|
860
|
-
"variants",
|
|
861
|
-
decorateVariantsWithDefaultValues([
|
|
862
|
-
{
|
|
863
|
-
title: "Default variant",
|
|
864
|
-
should_create: true,
|
|
865
|
-
variant_rank: 0,
|
|
866
|
-
options: {
|
|
867
|
-
"Default option": "Default option value"
|
|
868
|
-
},
|
|
869
|
-
inventory: [{ inventory_item_id: "", required_quantity: "" }],
|
|
870
|
-
is_default: true
|
|
871
|
-
}
|
|
872
|
-
])
|
|
873
|
-
);
|
|
874
|
-
};
|
|
875
|
-
return /* @__PURE__ */ jsxs5("div", { id: "variants", className: "flex flex-col gap-y-8", children: [
|
|
876
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-y-6", children: [
|
|
877
|
-
/* @__PURE__ */ jsx5(Heading, { level: "h2", children: t("products.create.variants.header") }),
|
|
878
|
-
/* @__PURE__ */ jsx5(
|
|
879
|
-
SwitchBox,
|
|
880
|
-
{
|
|
881
|
-
control: form.control,
|
|
882
|
-
name: "enable_variants",
|
|
883
|
-
label: t("products.create.variants.subHeadingTitle"),
|
|
884
|
-
description: t("products.create.variants.subHeadingDescription"),
|
|
885
|
-
onCheckedChange: (checked) => {
|
|
886
|
-
if (checked) {
|
|
887
|
-
form.setValue("options", [
|
|
888
|
-
{
|
|
889
|
-
title: "",
|
|
890
|
-
values: []
|
|
891
|
-
}
|
|
892
|
-
]);
|
|
893
|
-
form.setValue("variants", []);
|
|
894
|
-
} else {
|
|
895
|
-
createDefaultOptionAndVariant();
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
)
|
|
900
|
-
] }),
|
|
901
|
-
watchedAreVariantsEnabled && /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
902
|
-
/* @__PURE__ */ jsx5("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx5(
|
|
903
|
-
Form.Field,
|
|
904
|
-
{
|
|
905
|
-
control: form.control,
|
|
906
|
-
name: "options",
|
|
907
|
-
render: () => {
|
|
908
|
-
return /* @__PURE__ */ jsx5(Form.Item, { children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-y-6", children: [
|
|
909
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex items-start justify-between gap-x-4", children: [
|
|
910
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col", children: [
|
|
911
|
-
/* @__PURE__ */ jsx5(Form.Label, { children: t("products.create.variants.productOptions.label") }),
|
|
912
|
-
/* @__PURE__ */ jsx5(Form.Hint, { children: t("products.create.variants.productOptions.hint") })
|
|
913
|
-
] }),
|
|
914
|
-
/* @__PURE__ */ jsx5(
|
|
915
|
-
Button,
|
|
916
|
-
{
|
|
917
|
-
size: "small",
|
|
918
|
-
variant: "secondary",
|
|
919
|
-
type: "button",
|
|
920
|
-
onClick: () => {
|
|
921
|
-
options.append({
|
|
922
|
-
title: "",
|
|
923
|
-
values: []
|
|
924
|
-
});
|
|
925
|
-
},
|
|
926
|
-
children: t("actions.add")
|
|
927
|
-
}
|
|
928
|
-
)
|
|
929
|
-
] }),
|
|
930
|
-
showInvalidOptionsMessage && /* @__PURE__ */ jsx5(Alert, { dismissible: true, variant: "error", children: t("products.create.errors.options") }),
|
|
931
|
-
/* @__PURE__ */ jsx5("ul", { className: "flex flex-col gap-y-4", children: options.fields.map((option, index) => {
|
|
932
|
-
return /* @__PURE__ */ jsxs5(
|
|
933
|
-
"li",
|
|
934
|
-
{
|
|
935
|
-
className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-center gap-1.5 rounded-xl p-1.5",
|
|
936
|
-
children: [
|
|
937
|
-
/* @__PURE__ */ jsxs5("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
|
|
938
|
-
/* @__PURE__ */ jsx5("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx5(
|
|
939
|
-
Label,
|
|
940
|
-
{
|
|
941
|
-
size: "xsmall",
|
|
942
|
-
weight: "plus",
|
|
943
|
-
className: "text-ui-fg-subtle",
|
|
944
|
-
htmlFor: `options.${index}.title`,
|
|
945
|
-
children: t("fields.title")
|
|
946
|
-
}
|
|
947
|
-
) }),
|
|
948
|
-
/* @__PURE__ */ jsx5(
|
|
949
|
-
Input3,
|
|
950
|
-
{
|
|
951
|
-
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
952
|
-
...form.register(
|
|
953
|
-
`options.${index}.title`
|
|
954
|
-
),
|
|
955
|
-
placeholder: t(
|
|
956
|
-
"products.fields.options.optionTitlePlaceholder"
|
|
957
|
-
)
|
|
958
|
-
}
|
|
959
|
-
),
|
|
960
|
-
/* @__PURE__ */ jsx5("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx5(
|
|
961
|
-
Label,
|
|
962
|
-
{
|
|
963
|
-
size: "xsmall",
|
|
964
|
-
weight: "plus",
|
|
965
|
-
className: "text-ui-fg-subtle",
|
|
966
|
-
htmlFor: `options.${index}.values`,
|
|
967
|
-
children: t("fields.values")
|
|
968
|
-
}
|
|
969
|
-
) }),
|
|
970
|
-
/* @__PURE__ */ jsx5(
|
|
971
|
-
Controller,
|
|
972
|
-
{
|
|
973
|
-
control: form.control,
|
|
974
|
-
name: `options.${index}.values`,
|
|
975
|
-
render: ({
|
|
976
|
-
field: { onChange, ...field }
|
|
977
|
-
}) => {
|
|
978
|
-
const handleValueChange = (value) => {
|
|
979
|
-
handleOptionValueUpdate(index, value);
|
|
980
|
-
onChange(value);
|
|
981
|
-
};
|
|
982
|
-
return /* @__PURE__ */ jsx5(
|
|
983
|
-
ChipInput,
|
|
984
|
-
{
|
|
985
|
-
...field,
|
|
986
|
-
variant: "contrast",
|
|
987
|
-
onChange: handleValueChange,
|
|
988
|
-
placeholder: t(
|
|
989
|
-
"products.fields.options.variantionsPlaceholder"
|
|
990
|
-
)
|
|
991
|
-
}
|
|
992
|
-
);
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
)
|
|
996
|
-
] }),
|
|
997
|
-
/* @__PURE__ */ jsx5(
|
|
998
|
-
IconButton3,
|
|
999
|
-
{
|
|
1000
|
-
type: "button",
|
|
1001
|
-
size: "small",
|
|
1002
|
-
variant: "transparent",
|
|
1003
|
-
className: "text-ui-fg-muted",
|
|
1004
|
-
disabled: index === 0,
|
|
1005
|
-
onClick: () => handleRemoveOption(index),
|
|
1006
|
-
children: /* @__PURE__ */ jsx5(XMarkMini, {})
|
|
1007
|
-
}
|
|
1008
|
-
)
|
|
1009
|
-
]
|
|
1010
|
-
},
|
|
1011
|
-
option.id
|
|
1012
|
-
);
|
|
1013
|
-
}) })
|
|
1014
|
-
] }) });
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
) }),
|
|
1018
|
-
/* @__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: [
|
|
1019
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col", children: [
|
|
1020
|
-
/* @__PURE__ */ jsx5(Label, { weight: "plus", children: t("products.create.variants.productVariants.label") }),
|
|
1021
|
-
/* @__PURE__ */ jsx5(Hint, { children: t("products.create.variants.productVariants.hint") })
|
|
1022
|
-
] }),
|
|
1023
|
-
!showInvalidOptionsMessage && showInvalidVariantsMessage && /* @__PURE__ */ jsx5(Alert, { dismissible: true, variant: "error", children: t("products.create.errors.variants") }),
|
|
1024
|
-
variants.fields.length > 0 ? /* @__PURE__ */ jsxs5("div", { className: "overflow-hidden rounded-xl border", children: [
|
|
1025
|
-
/* @__PURE__ */ jsxs5(
|
|
1026
|
-
"div",
|
|
1027
|
-
{
|
|
1028
|
-
className: "bg-ui-bg-component text-ui-fg-subtle grid items-center gap-3 border-b px-6 py-2.5",
|
|
1029
|
-
style: {
|
|
1030
|
-
gridTemplateColumns: `20px 28px repeat(${watchedOptions.length}, 1fr)`
|
|
1031
|
-
},
|
|
1032
|
-
children: [
|
|
1033
|
-
/* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(
|
|
1034
|
-
Checkbox,
|
|
1035
|
-
{
|
|
1036
|
-
className: "relative",
|
|
1037
|
-
checked: getCheckboxState(watchedVariants),
|
|
1038
|
-
onCheckedChange: onCheckboxChange
|
|
1039
|
-
}
|
|
1040
|
-
) }),
|
|
1041
|
-
/* @__PURE__ */ jsx5("div", {}),
|
|
1042
|
-
watchedOptions.map((option, index) => /* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", weight: "plus", children: option.title }) }, index))
|
|
1043
|
-
]
|
|
1044
|
-
}
|
|
1045
|
-
),
|
|
1046
|
-
/* @__PURE__ */ jsx5(
|
|
1047
|
-
SortableList,
|
|
1048
|
-
{
|
|
1049
|
-
items: variants.fields,
|
|
1050
|
-
onChange: handleRankChange,
|
|
1051
|
-
renderItem: (item, index) => {
|
|
1052
|
-
return /* @__PURE__ */ jsx5(
|
|
1053
|
-
SortableList.Item,
|
|
1054
|
-
{
|
|
1055
|
-
id: item.id,
|
|
1056
|
-
className: clx2("bg-ui-bg-base border-b", {
|
|
1057
|
-
"border-b-0": index === variants.fields.length - 1
|
|
1058
|
-
}),
|
|
1059
|
-
children: /* @__PURE__ */ jsxs5(
|
|
1060
|
-
"div",
|
|
1061
|
-
{
|
|
1062
|
-
className: "text-ui-fg-subtle grid w-full items-center gap-3 px-6 py-2.5",
|
|
1063
|
-
style: {
|
|
1064
|
-
gridTemplateColumns: `20px 28px repeat(${watchedOptions.length}, 1fr)`
|
|
1065
|
-
},
|
|
1066
|
-
children: [
|
|
1067
|
-
/* @__PURE__ */ jsx5(
|
|
1068
|
-
Form.Field,
|
|
1069
|
-
{
|
|
1070
|
-
control: form.control,
|
|
1071
|
-
name: `variants.${index}.should_create`,
|
|
1072
|
-
render: ({
|
|
1073
|
-
field: { value, onChange, ...field }
|
|
1074
|
-
}) => {
|
|
1075
|
-
return /* @__PURE__ */ jsx5(Form.Item, { children: /* @__PURE__ */ jsx5(Form.Control, { children: /* @__PURE__ */ jsx5(
|
|
1076
|
-
Checkbox,
|
|
1077
|
-
{
|
|
1078
|
-
className: "relative",
|
|
1079
|
-
...field,
|
|
1080
|
-
checked: value,
|
|
1081
|
-
onCheckedChange: onChange
|
|
1082
|
-
}
|
|
1083
|
-
) }) });
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
),
|
|
1087
|
-
/* @__PURE__ */ jsx5(SortableList.DragHandle, {}),
|
|
1088
|
-
Object.values(item.options).map((value, index2) => /* @__PURE__ */ jsx5(Text3, { size: "small", leading: "compact", children: value }, index2))
|
|
1089
|
-
]
|
|
1090
|
-
}
|
|
1091
|
-
)
|
|
1092
|
-
}
|
|
1093
|
-
);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
)
|
|
1097
|
-
] }) : /* @__PURE__ */ jsx5(Alert, { children: t("products.create.variants.productVariants.alert") }),
|
|
1098
|
-
variants.fields.length > 0 && /* @__PURE__ */ jsx5(InlineTip, { label: t("general.tip"), children: t("products.create.variants.productVariants.tip") })
|
|
1099
|
-
] }) })
|
|
1100
|
-
] })
|
|
1101
|
-
] });
|
|
1102
|
-
};
|
|
1103
|
-
|
|
1104
|
-
// src/pages/products/create/product-create-details-form/product-create-details-form.tsx
|
|
1105
|
-
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1106
|
-
var Root = ({ children }) => {
|
|
1107
|
-
if (Children.count(children) > 0) {
|
|
1108
|
-
return /* @__PURE__ */ jsx6("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsxs6("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
|
|
1109
|
-
/* @__PURE__ */ jsx6(Header, {}),
|
|
1110
|
-
children
|
|
1111
|
-
] }) });
|
|
1112
|
-
}
|
|
1113
|
-
return /* @__PURE__ */ jsx6("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsxs6("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
|
|
1114
|
-
/* @__PURE__ */ jsx6(Header, {}),
|
|
1115
|
-
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-y-6", children: [
|
|
1116
|
-
/* @__PURE__ */ jsx6(ProductCreateGeneralSection, {}),
|
|
1117
|
-
/* @__PURE__ */ jsx6(ProductCreateMediaSection, {})
|
|
1118
|
-
] }),
|
|
1119
|
-
/* @__PURE__ */ jsx6(Divider, {}),
|
|
1120
|
-
/* @__PURE__ */ jsx6(ProductCreateVariantsSection, {})
|
|
1121
|
-
] }) });
|
|
1122
|
-
};
|
|
1123
|
-
Root._tabMeta = {
|
|
1124
|
-
id: "details",
|
|
1125
|
-
labelKey: "products.create.tabs.details",
|
|
1126
|
-
validationFields: ["title", "media", "options", "variants", "enable_variants"]
|
|
1127
|
-
};
|
|
1128
|
-
var Header = () => {
|
|
1129
|
-
const { t } = useTranslation4();
|
|
1130
|
-
return /* @__PURE__ */ jsx6("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx6(Heading2, { children: t("products.create.header") }) });
|
|
1131
|
-
};
|
|
1132
|
-
var ProductCreateDetailsForm = Object.assign(Root, {
|
|
1133
|
-
_tabMeta: Root._tabMeta,
|
|
1134
|
-
GeneralSection: ProductCreateGeneralSection,
|
|
1135
|
-
MediaSection: ProductCreateMediaSection,
|
|
1136
|
-
VariantsSection: ProductCreateVariantsSection
|
|
1137
|
-
});
|
|
1138
|
-
|
|
1139
|
-
// src/pages/products/create/product-create-inventory-kit-form/product-create-inventory-kit-form.tsx
|
|
1140
|
-
import { Children as Children2 } from "react";
|
|
1141
|
-
|
|
1142
|
-
// src/pages/products/create/product-create-inventory-kit-form/components/product-create-inventory-kit-section/product-create-inventory-kit-section.tsx
|
|
1143
|
-
import { Button as Button2, Heading as Heading3, IconButton as IconButton4, Input as Input4, Label as Label2 } from "@medusajs/ui";
|
|
1144
|
-
import { useFieldArray as useFieldArray3, useWatch as useWatch2 } from "react-hook-form";
|
|
1145
|
-
import { XMarkMini as XMarkMini2 } from "@medusajs/icons";
|
|
1146
|
-
import { useTranslation as useTranslation5 } from "react-i18next";
|
|
1147
|
-
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1148
|
-
function VariantSection({ variant, index }) {
|
|
1149
|
-
const { t } = useTranslation5();
|
|
1150
|
-
const form = useTabbedForm();
|
|
1151
|
-
const inventory = useFieldArray3({
|
|
1152
|
-
control: form.control,
|
|
1153
|
-
name: `variants.${index}.inventory`
|
|
1154
|
-
});
|
|
1155
|
-
const inventoryFormData = useWatch2({
|
|
1156
|
-
control: form.control,
|
|
1157
|
-
name: `variants.${index}.inventory`
|
|
1158
|
-
});
|
|
1159
|
-
const items = useComboboxData({
|
|
1160
|
-
queryKey: ["inventory_items"],
|
|
1161
|
-
queryFn: (params) => fetchQuery(`/vendor/inventory-items`, {
|
|
1162
|
-
method: "GET",
|
|
1163
|
-
query: params
|
|
1164
|
-
}),
|
|
1165
|
-
getOptions: (data) => data.inventory_items.map((item) => ({
|
|
1166
|
-
label: item.title || item.sku || item.id,
|
|
1167
|
-
value: item.id
|
|
1168
|
-
}))
|
|
1169
|
-
});
|
|
1170
|
-
const isItemOptionDisabled = (option, inventoryIndex) => {
|
|
1171
|
-
return inventoryFormData?.some(
|
|
1172
|
-
(i, index2) => index2 != inventoryIndex && i.inventory_item_id === option.value
|
|
1173
|
-
);
|
|
1174
|
-
};
|
|
1175
|
-
return /* @__PURE__ */ jsxs7("div", { className: "grid gap-y-4", children: [
|
|
1176
|
-
/* @__PURE__ */ jsxs7("div", { className: "flex items-start justify-between gap-x-4", children: [
|
|
1177
|
-
/* @__PURE__ */ jsxs7("div", { className: "flex flex-col", children: [
|
|
1178
|
-
/* @__PURE__ */ jsx7(Form.Label, { children: variant.title }),
|
|
1179
|
-
/* @__PURE__ */ jsx7(Form.Hint, { children: t("products.create.inventory.label") })
|
|
1180
|
-
] }),
|
|
1181
|
-
/* @__PURE__ */ jsx7(
|
|
1182
|
-
Button2,
|
|
1183
|
-
{
|
|
1184
|
-
size: "small",
|
|
1185
|
-
variant: "secondary",
|
|
1186
|
-
type: "button",
|
|
1187
|
-
onClick: () => {
|
|
1188
|
-
inventory.append({
|
|
1189
|
-
inventory_item_id: "",
|
|
1190
|
-
required_quantity: ""
|
|
1191
|
-
});
|
|
1192
|
-
},
|
|
1193
|
-
children: t("actions.add")
|
|
1194
|
-
}
|
|
1195
|
-
)
|
|
1196
|
-
] }),
|
|
1197
|
-
inventory.fields.map((inventoryItem, inventoryIndex) => /* @__PURE__ */ jsxs7(
|
|
1198
|
-
"li",
|
|
1199
|
-
{
|
|
1200
|
-
className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-center gap-1.5 rounded-xl p-1.5",
|
|
1201
|
-
children: [
|
|
1202
|
-
/* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
|
|
1203
|
-
/* @__PURE__ */ jsx7("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx7(
|
|
1204
|
-
Label2,
|
|
1205
|
-
{
|
|
1206
|
-
size: "xsmall",
|
|
1207
|
-
weight: "plus",
|
|
1208
|
-
className: "text-ui-fg-subtle",
|
|
1209
|
-
htmlFor: `variants.${index}.inventory.${inventoryIndex}.inventory_item_id`,
|
|
1210
|
-
children: t("fields.item")
|
|
1211
|
-
}
|
|
1212
|
-
) }),
|
|
1213
|
-
/* @__PURE__ */ jsx7(
|
|
1214
|
-
Form.Field,
|
|
1215
|
-
{
|
|
1216
|
-
control: form.control,
|
|
1217
|
-
name: `variants.${index}.inventory.${inventoryIndex}.inventory_item_id`,
|
|
1218
|
-
render: ({ field }) => {
|
|
1219
|
-
return /* @__PURE__ */ jsx7(Form.Item, { children: /* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(
|
|
1220
|
-
Combobox,
|
|
1221
|
-
{
|
|
1222
|
-
...field,
|
|
1223
|
-
options: items.options.map((o) => ({
|
|
1224
|
-
...o,
|
|
1225
|
-
disabled: isItemOptionDisabled(o, inventoryIndex)
|
|
1226
|
-
})),
|
|
1227
|
-
searchValue: items.searchValue,
|
|
1228
|
-
onSearchValueChange: items.onSearchValueChange,
|
|
1229
|
-
fetchNextPage: items.fetchNextPage,
|
|
1230
|
-
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
1231
|
-
placeholder: t(
|
|
1232
|
-
"products.create.inventory.itemPlaceholder"
|
|
1233
|
-
)
|
|
1234
|
-
}
|
|
1235
|
-
) }) });
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
),
|
|
1239
|
-
/* @__PURE__ */ jsx7("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx7(
|
|
1240
|
-
Label2,
|
|
1241
|
-
{
|
|
1242
|
-
size: "xsmall",
|
|
1243
|
-
weight: "plus",
|
|
1244
|
-
className: "text-ui-fg-subtle",
|
|
1245
|
-
htmlFor: `variants.${index}.inventory.${inventoryIndex}.required_quantity`,
|
|
1246
|
-
children: t("fields.quantity")
|
|
1247
|
-
}
|
|
1248
|
-
) }),
|
|
1249
|
-
/* @__PURE__ */ jsx7(
|
|
1250
|
-
Form.Field,
|
|
1251
|
-
{
|
|
1252
|
-
control: form.control,
|
|
1253
|
-
name: `variants.${index}.inventory.${inventoryIndex}.required_quantity`,
|
|
1254
|
-
render: ({ field: { onChange, value, ...field } }) => {
|
|
1255
|
-
return /* @__PURE__ */ jsxs7(Form.Item, { children: [
|
|
1256
|
-
/* @__PURE__ */ jsx7(Form.Control, { children: /* @__PURE__ */ jsx7(
|
|
1257
|
-
Input4,
|
|
1258
|
-
{
|
|
1259
|
-
type: "number",
|
|
1260
|
-
className: "bg-ui-bg-field-component",
|
|
1261
|
-
min: 0,
|
|
1262
|
-
value,
|
|
1263
|
-
onChange: (e) => {
|
|
1264
|
-
const value2 = e.target.value;
|
|
1265
|
-
if (value2 === "") {
|
|
1266
|
-
onChange(null);
|
|
1267
|
-
} else {
|
|
1268
|
-
onChange(Number(value2));
|
|
1269
|
-
}
|
|
1270
|
-
},
|
|
1271
|
-
...field,
|
|
1272
|
-
placeholder: t(
|
|
1273
|
-
"products.create.inventory.quantityPlaceholder"
|
|
1274
|
-
)
|
|
1275
|
-
}
|
|
1276
|
-
) }),
|
|
1277
|
-
/* @__PURE__ */ jsx7(Form.ErrorMessage, {})
|
|
1278
|
-
] });
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
)
|
|
1282
|
-
] }),
|
|
1283
|
-
/* @__PURE__ */ jsx7(
|
|
1284
|
-
IconButton4,
|
|
1285
|
-
{
|
|
1286
|
-
type: "button",
|
|
1287
|
-
size: "small",
|
|
1288
|
-
variant: "transparent",
|
|
1289
|
-
className: "text-ui-fg-muted",
|
|
1290
|
-
onClick: () => inventory.remove(inventoryIndex),
|
|
1291
|
-
children: /* @__PURE__ */ jsx7(XMarkMini2, {})
|
|
1292
|
-
}
|
|
1293
|
-
)
|
|
1294
|
-
]
|
|
1295
|
-
},
|
|
1296
|
-
inventoryItem.id
|
|
1297
|
-
))
|
|
1298
|
-
] });
|
|
1299
|
-
}
|
|
1300
|
-
var ProductCreateInventoryKitSection = () => {
|
|
1301
|
-
const { t } = useTranslation5();
|
|
1302
|
-
const form = useTabbedForm();
|
|
1303
|
-
const variants = useFieldArray3({
|
|
1304
|
-
control: form.control,
|
|
1305
|
-
name: "variants"
|
|
1306
|
-
});
|
|
1307
|
-
return /* @__PURE__ */ jsxs7("div", { id: "organize", className: "flex flex-col gap-y-8", children: [
|
|
1308
|
-
/* @__PURE__ */ jsx7(Heading3, { children: t("products.create.inventory.heading") }),
|
|
1309
|
-
variants.fields.filter((v) => v.inventory_kit).map((variant, variantIndex) => /* @__PURE__ */ jsx7(
|
|
1310
|
-
VariantSection,
|
|
1311
|
-
{
|
|
1312
|
-
variant,
|
|
1313
|
-
index: variantIndex
|
|
1314
|
-
},
|
|
1315
|
-
variant.id
|
|
1316
|
-
))
|
|
1317
|
-
] });
|
|
1318
|
-
};
|
|
1319
|
-
|
|
1320
|
-
// src/pages/products/create/product-create-inventory-kit-form/product-create-inventory-kit-form.tsx
|
|
1321
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1322
|
-
var Root2 = ({ children }) => {
|
|
1323
|
-
if (Children2.count(children) > 0) {
|
|
1324
|
-
return /* @__PURE__ */ jsx8("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsx8("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children }) });
|
|
1325
|
-
}
|
|
1326
|
-
return /* @__PURE__ */ jsx8("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsx8("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: /* @__PURE__ */ jsx8(ProductCreateInventoryKitSection, {}) }) });
|
|
1327
|
-
};
|
|
1328
|
-
Root2._tabMeta = {
|
|
1329
|
-
id: "inventory",
|
|
1330
|
-
labelKey: "products.create.tabs.inventory",
|
|
1331
|
-
isVisible: (form) => form.getValues("variants").some((v) => v.manage_inventory && v.inventory_kit)
|
|
1332
|
-
};
|
|
1333
|
-
var ProductCreateInventoryKitForm = Object.assign(Root2, {
|
|
1334
|
-
_tabMeta: Root2._tabMeta,
|
|
1335
|
-
InventoryKitSection: ProductCreateInventoryKitSection
|
|
1336
|
-
});
|
|
1337
|
-
|
|
1338
|
-
// src/pages/products/create/product-create-organize-form/product-create-organize-form.tsx
|
|
1339
|
-
import { Children as Children3 } from "react";
|
|
1340
|
-
|
|
1341
|
-
// src/pages/products/create/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx
|
|
1342
|
-
import { Heading as Heading4 } from "@medusajs/ui";
|
|
1343
|
-
import { useTranslation as useTranslation6 } from "react-i18next";
|
|
1344
|
-
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1345
|
-
var ProductCreateOrganizationSection = () => {
|
|
1346
|
-
const { t } = useTranslation6();
|
|
1347
|
-
const form = useTabbedForm();
|
|
1348
|
-
const collections = useComboboxData({
|
|
1349
|
-
queryKey: ["product_collections"],
|
|
1350
|
-
queryFn: (params) => sdk.vendor.collections.query({ offset: 0, limit: 100, ...params }),
|
|
1351
|
-
getOptions: (data) => data.collections.map((collection) => ({
|
|
1352
|
-
label: collection.title,
|
|
1353
|
-
value: collection.id
|
|
1354
|
-
}))
|
|
1355
|
-
});
|
|
1356
|
-
const types = useComboboxData({
|
|
1357
|
-
queryKey: ["product_types", "creating"],
|
|
1358
|
-
queryFn: (params) => fetchQuery("/vendor/product-types", {
|
|
1359
|
-
method: "GET",
|
|
1360
|
-
query: params
|
|
1361
|
-
}),
|
|
1362
|
-
getOptions: (data) => data.product_types.map((type) => ({
|
|
1363
|
-
label: type.value,
|
|
1364
|
-
value: type.id
|
|
1365
|
-
}))
|
|
1366
|
-
});
|
|
1367
|
-
const tags = useComboboxData({
|
|
1368
|
-
queryKey: ["product_tags", "creating"],
|
|
1369
|
-
queryFn: (params) => fetchQuery("/vendor/product-tags", {
|
|
1370
|
-
method: "GET",
|
|
1371
|
-
query: params
|
|
1372
|
-
}),
|
|
1373
|
-
getOptions: (data) => data.product_tags.map((tag) => ({
|
|
1374
|
-
label: tag.value,
|
|
1375
|
-
value: tag.id
|
|
1376
|
-
}))
|
|
1377
|
-
});
|
|
1378
|
-
return /* @__PURE__ */ jsxs8("div", { id: "organize", className: "flex flex-col gap-y-8", children: [
|
|
1379
|
-
/* @__PURE__ */ jsx9(Heading4, { children: t("products.organization.header") }),
|
|
1380
|
-
/* @__PURE__ */ jsx9(
|
|
1381
|
-
SwitchBox,
|
|
1382
|
-
{
|
|
1383
|
-
control: form.control,
|
|
1384
|
-
name: "discountable",
|
|
1385
|
-
label: t("products.fields.discountable.label"),
|
|
1386
|
-
description: t("products.fields.discountable.hint"),
|
|
1387
|
-
optional: true
|
|
1388
|
-
}
|
|
1389
|
-
),
|
|
1390
|
-
/* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
1391
|
-
/* @__PURE__ */ jsx9(
|
|
1392
|
-
Form.Field,
|
|
1393
|
-
{
|
|
1394
|
-
control: form.control,
|
|
1395
|
-
name: "type_id",
|
|
1396
|
-
render: ({ field }) => {
|
|
1397
|
-
return /* @__PURE__ */ jsxs8(Form.Item, { children: [
|
|
1398
|
-
/* @__PURE__ */ jsx9(Form.Label, { optional: true, children: t("products.fields.type.label") }),
|
|
1399
|
-
/* @__PURE__ */ jsx9(Form.Control, { children: /* @__PURE__ */ jsx9(
|
|
1400
|
-
Combobox,
|
|
1401
|
-
{
|
|
1402
|
-
...field,
|
|
1403
|
-
options: types.options,
|
|
1404
|
-
searchValue: types.searchValue,
|
|
1405
|
-
onSearchValueChange: types.onSearchValueChange,
|
|
1406
|
-
fetchNextPage: types.fetchNextPage,
|
|
1407
|
-
allowClear: true
|
|
1408
|
-
}
|
|
1409
|
-
) }),
|
|
1410
|
-
/* @__PURE__ */ jsx9(Form.ErrorMessage, {})
|
|
1411
|
-
] });
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
),
|
|
1415
|
-
/* @__PURE__ */ jsx9(
|
|
1416
|
-
Form.Field,
|
|
1417
|
-
{
|
|
1418
|
-
control: form.control,
|
|
1419
|
-
name: "collection_id",
|
|
1420
|
-
render: ({ field }) => {
|
|
1421
|
-
return /* @__PURE__ */ jsxs8(Form.Item, { children: [
|
|
1422
|
-
/* @__PURE__ */ jsx9(Form.Label, { optional: true, children: t("products.fields.collection.label") }),
|
|
1423
|
-
/* @__PURE__ */ jsx9(Form.Control, { children: /* @__PURE__ */ jsx9(
|
|
1424
|
-
Combobox,
|
|
1425
|
-
{
|
|
1426
|
-
...field,
|
|
1427
|
-
options: collections.options,
|
|
1428
|
-
searchValue: collections.searchValue,
|
|
1429
|
-
onSearchValueChange: collections.onSearchValueChange,
|
|
1430
|
-
fetchNextPage: collections.fetchNextPage,
|
|
1431
|
-
allowClear: true
|
|
1432
|
-
}
|
|
1433
|
-
) }),
|
|
1434
|
-
/* @__PURE__ */ jsx9(Form.ErrorMessage, {})
|
|
1435
|
-
] });
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
)
|
|
1439
|
-
] }),
|
|
1440
|
-
/* @__PURE__ */ jsxs8("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
1441
|
-
/* @__PURE__ */ jsx9(
|
|
1442
|
-
Form.Field,
|
|
1443
|
-
{
|
|
1444
|
-
control: form.control,
|
|
1445
|
-
name: "categories",
|
|
1446
|
-
render: ({ field }) => {
|
|
1447
|
-
return /* @__PURE__ */ jsxs8(Form.Item, { children: [
|
|
1448
|
-
/* @__PURE__ */ jsx9(Form.Label, { optional: true, children: t("products.fields.categories.label") }),
|
|
1449
|
-
/* @__PURE__ */ jsx9(Form.Control, { children: /* @__PURE__ */ jsx9(CategoryCombobox, { ...field }) }),
|
|
1450
|
-
/* @__PURE__ */ jsx9(Form.ErrorMessage, {})
|
|
1451
|
-
] });
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
),
|
|
1455
|
-
/* @__PURE__ */ jsx9(
|
|
1456
|
-
Form.Field,
|
|
1457
|
-
{
|
|
1458
|
-
control: form.control,
|
|
1459
|
-
name: "tags",
|
|
1460
|
-
render: ({ field }) => {
|
|
1461
|
-
return /* @__PURE__ */ jsxs8(Form.Item, { children: [
|
|
1462
|
-
/* @__PURE__ */ jsx9(Form.Label, { optional: true, children: t("products.fields.tags.label") }),
|
|
1463
|
-
/* @__PURE__ */ jsx9(Form.Control, { children: /* @__PURE__ */ jsx9(
|
|
1464
|
-
Combobox,
|
|
1465
|
-
{
|
|
1466
|
-
...field,
|
|
1467
|
-
options: tags.options,
|
|
1468
|
-
searchValue: tags.searchValue,
|
|
1469
|
-
onSearchValueChange: tags.onSearchValueChange,
|
|
1470
|
-
fetchNextPage: tags.fetchNextPage
|
|
1471
|
-
}
|
|
1472
|
-
) }),
|
|
1473
|
-
/* @__PURE__ */ jsx9(Form.ErrorMessage, {})
|
|
1474
|
-
] });
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
)
|
|
1478
|
-
] })
|
|
1479
|
-
] });
|
|
1480
|
-
};
|
|
1481
|
-
|
|
1482
|
-
// src/pages/products/create/product-create-organize-form/components/product-create-organize-attribute-section/product-create-details-attribute-section.tsx
|
|
1483
|
-
import { Heading as Heading5, Input as Input5 } from "@medusajs/ui";
|
|
1484
|
-
import { useTranslation as useTranslation7 } from "react-i18next";
|
|
1485
|
-
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1486
|
-
var ProductCreateAttributeSection = () => {
|
|
1487
|
-
const { t } = useTranslation7();
|
|
1488
|
-
const form = useTabbedForm();
|
|
1489
|
-
return /* @__PURE__ */ jsxs9("div", { id: "attributes", className: "flex flex-col gap-y-8", children: [
|
|
1490
|
-
/* @__PURE__ */ jsx10(Heading5, { level: "h2", children: t("products.attributes") }),
|
|
1491
|
-
/* @__PURE__ */ jsxs9("div", { className: "grid grid-cols-2 gap-x-4 gap-y-8", children: [
|
|
1492
|
-
/* @__PURE__ */ jsx10(
|
|
1493
|
-
Form.Field,
|
|
1494
|
-
{
|
|
1495
|
-
control: form.control,
|
|
1496
|
-
name: "origin_country",
|
|
1497
|
-
render: ({ field }) => {
|
|
1498
|
-
return /* @__PURE__ */ jsxs9(Form.Item, { children: [
|
|
1499
|
-
/* @__PURE__ */ jsx10(Form.Label, { optional: true, children: t("products.fields.countryOrigin.label") }),
|
|
1500
|
-
/* @__PURE__ */ jsx10(Form.Control, { children: /* @__PURE__ */ jsx10(CountrySelect, { ...field }) })
|
|
1501
|
-
] });
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
),
|
|
1505
|
-
/* @__PURE__ */ jsx10(
|
|
1506
|
-
Form.Field,
|
|
1507
|
-
{
|
|
1508
|
-
control: form.control,
|
|
1509
|
-
name: "material",
|
|
1510
|
-
render: ({ field }) => {
|
|
1511
|
-
return /* @__PURE__ */ jsxs9(Form.Item, { children: [
|
|
1512
|
-
/* @__PURE__ */ jsx10(Form.Label, { optional: true, children: t("products.fields.material.label") }),
|
|
1513
|
-
/* @__PURE__ */ jsx10(Form.Control, { children: /* @__PURE__ */ jsx10(Input5, { ...field }) })
|
|
1514
|
-
] });
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
)
|
|
1518
|
-
] }),
|
|
1519
|
-
/* @__PURE__ */ jsxs9("div", { className: "grid grid-cols-2 gap-x-4 gap-y-8", children: [
|
|
1520
|
-
/* @__PURE__ */ jsx10(
|
|
1521
|
-
Form.Field,
|
|
1522
|
-
{
|
|
1523
|
-
control: form.control,
|
|
1524
|
-
name: "width",
|
|
1525
|
-
render: ({ field }) => {
|
|
1526
|
-
return /* @__PURE__ */ jsxs9(Form.Item, { children: [
|
|
1527
|
-
/* @__PURE__ */ jsx10(Form.Label, { optional: true, children: t("products.fields.width.label") }),
|
|
1528
|
-
/* @__PURE__ */ jsx10(Form.Control, { children: /* @__PURE__ */ jsx10(Input5, { ...field, type: "number", min: 0 }) })
|
|
1529
|
-
] });
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
),
|
|
1533
|
-
/* @__PURE__ */ jsx10(
|
|
1534
|
-
Form.Field,
|
|
1535
|
-
{
|
|
1536
|
-
control: form.control,
|
|
1537
|
-
name: "length",
|
|
1538
|
-
render: ({ field }) => {
|
|
1539
|
-
return /* @__PURE__ */ jsxs9(Form.Item, { children: [
|
|
1540
|
-
/* @__PURE__ */ jsx10(Form.Label, { optional: true, children: t("products.fields.length.label") }),
|
|
1541
|
-
/* @__PURE__ */ jsx10(Form.Control, { children: /* @__PURE__ */ jsx10(Input5, { ...field, type: "number", min: 0 }) })
|
|
1542
|
-
] });
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
),
|
|
1546
|
-
/* @__PURE__ */ jsx10(
|
|
1547
|
-
Form.Field,
|
|
1548
|
-
{
|
|
1549
|
-
control: form.control,
|
|
1550
|
-
name: "height",
|
|
1551
|
-
render: ({ field }) => {
|
|
1552
|
-
return /* @__PURE__ */ jsxs9(Form.Item, { children: [
|
|
1553
|
-
/* @__PURE__ */ jsx10(Form.Label, { optional: true, children: t("products.fields.height.label") }),
|
|
1554
|
-
/* @__PURE__ */ jsx10(Form.Control, { children: /* @__PURE__ */ jsx10(Input5, { ...field, type: "number", min: 0 }) })
|
|
1555
|
-
] });
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
),
|
|
1559
|
-
/* @__PURE__ */ jsx10(
|
|
1560
|
-
Form.Field,
|
|
1561
|
-
{
|
|
1562
|
-
control: form.control,
|
|
1563
|
-
name: "weight",
|
|
1564
|
-
render: ({ field }) => {
|
|
1565
|
-
return /* @__PURE__ */ jsxs9(Form.Item, { children: [
|
|
1566
|
-
/* @__PURE__ */ jsx10(Form.Label, { optional: true, children: t("products.fields.weight.label") }),
|
|
1567
|
-
/* @__PURE__ */ jsx10(Form.Control, { children: /* @__PURE__ */ jsx10(Input5, { ...field, type: "number", min: 0 }) })
|
|
1568
|
-
] });
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
),
|
|
1572
|
-
/* @__PURE__ */ jsx10(
|
|
1573
|
-
Form.Field,
|
|
1574
|
-
{
|
|
1575
|
-
control: form.control,
|
|
1576
|
-
name: "mid_code",
|
|
1577
|
-
render: ({ field }) => {
|
|
1578
|
-
return /* @__PURE__ */ jsxs9(Form.Item, { children: [
|
|
1579
|
-
/* @__PURE__ */ jsx10(Form.Label, { optional: true, children: t("products.fields.mid_code.label") }),
|
|
1580
|
-
/* @__PURE__ */ jsx10(Form.Control, { children: /* @__PURE__ */ jsx10(Input5, { ...field }) })
|
|
1581
|
-
] });
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
),
|
|
1585
|
-
/* @__PURE__ */ jsx10(
|
|
1586
|
-
Form.Field,
|
|
1587
|
-
{
|
|
1588
|
-
control: form.control,
|
|
1589
|
-
name: "hs_code",
|
|
1590
|
-
render: ({ field }) => {
|
|
1591
|
-
return /* @__PURE__ */ jsxs9(Form.Item, { children: [
|
|
1592
|
-
/* @__PURE__ */ jsx10(Form.Label, { optional: true, children: t("products.fields.hs_code.label") }),
|
|
1593
|
-
/* @__PURE__ */ jsx10(Form.Control, { children: /* @__PURE__ */ jsx10(Input5, { ...field }) })
|
|
1594
|
-
] });
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
)
|
|
1598
|
-
] })
|
|
1599
|
-
] });
|
|
1600
|
-
};
|
|
1601
|
-
|
|
1602
|
-
// src/pages/products/create/product-create-organize-form/components/product-create-sales-channel-stacked-modal/product-create-sales-channel-drawer.tsx
|
|
1603
|
-
import {
|
|
1604
|
-
Button as Button3,
|
|
1605
|
-
createDataTableColumnHelper
|
|
1606
|
-
} from "@medusajs/ui";
|
|
1607
|
-
import { useEffect, useMemo as useMemo2, useState as useState3 } from "react";
|
|
1608
|
-
import { useTranslation as useTranslation8 } from "react-i18next";
|
|
1609
|
-
import { keepPreviousData } from "@tanstack/react-query";
|
|
1610
|
-
|
|
1611
|
-
// src/pages/products/create/product-create-organize-form/constants.ts
|
|
1612
|
-
var SC_STACKED_MODAL_ID = "sc";
|
|
1613
|
-
|
|
1614
|
-
// src/pages/products/create/product-create-organize-form/components/product-create-sales-channel-stacked-modal/product-create-sales-channel-drawer.tsx
|
|
1615
|
-
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1616
|
-
var PAGE_SIZE = 50;
|
|
1617
|
-
var ProductCreateSalesChannelStackedModal = () => {
|
|
1618
|
-
const { t } = useTranslation8();
|
|
1619
|
-
const form = useTabbedForm();
|
|
1620
|
-
const { getValues, setValue } = form;
|
|
1621
|
-
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
1622
|
-
const [rowSelection, setRowSelection] = useState3(
|
|
1623
|
-
{}
|
|
1624
|
-
);
|
|
1625
|
-
const [state, setState] = useState3([]);
|
|
1626
|
-
const searchParams = useSalesChannelTableQuery({
|
|
1627
|
-
pageSize: PAGE_SIZE,
|
|
1628
|
-
prefix: SC_STACKED_MODAL_ID
|
|
1629
|
-
});
|
|
1630
|
-
const { sales_channels, count, isLoading, isError, error } = useSalesChannels(
|
|
1631
|
-
searchParams,
|
|
1632
|
-
{
|
|
1633
|
-
placeholderData: keepPreviousData
|
|
1634
|
-
}
|
|
1635
|
-
);
|
|
1636
|
-
const open = getIsOpen(SC_STACKED_MODAL_ID);
|
|
1637
|
-
useEffect(() => {
|
|
1638
|
-
if (!open) {
|
|
1639
|
-
return;
|
|
1640
|
-
}
|
|
1641
|
-
const salesChannels = getValues("sales_channels");
|
|
1642
|
-
if (salesChannels) {
|
|
1643
|
-
setState(
|
|
1644
|
-
salesChannels.map((channel) => ({
|
|
1645
|
-
id: channel.id,
|
|
1646
|
-
name: channel.name
|
|
1647
|
-
}))
|
|
1648
|
-
);
|
|
1649
|
-
setRowSelection(
|
|
1650
|
-
salesChannels.reduce(
|
|
1651
|
-
(acc, channel) => ({
|
|
1652
|
-
...acc,
|
|
1653
|
-
[channel.id]: true
|
|
1654
|
-
}),
|
|
1655
|
-
{}
|
|
1656
|
-
)
|
|
1657
|
-
);
|
|
1658
|
-
}
|
|
1659
|
-
}, [open, getValues]);
|
|
1660
|
-
const onRowSelectionChange = (state2) => {
|
|
1661
|
-
const ids = Object.keys(state2);
|
|
1662
|
-
const addedIdsSet = new Set(
|
|
1663
|
-
ids.filter((id) => state2[id] && !rowSelection[id])
|
|
1664
|
-
);
|
|
1665
|
-
let addedSalesChannels = [];
|
|
1666
|
-
if (addedIdsSet.size > 0) {
|
|
1667
|
-
addedSalesChannels = sales_channels?.filter((channel) => addedIdsSet.has(channel.id)) ?? [];
|
|
1668
|
-
}
|
|
1669
|
-
setState((prev) => {
|
|
1670
|
-
const filteredPrev = prev.filter((channel) => state2[channel.id]);
|
|
1671
|
-
return Array.from(/* @__PURE__ */ new Set([...filteredPrev, ...addedSalesChannels]));
|
|
1672
|
-
});
|
|
1673
|
-
setRowSelection(state2);
|
|
1674
|
-
};
|
|
1675
|
-
const handleAdd = () => {
|
|
1676
|
-
setValue("sales_channels", state, {
|
|
1677
|
-
shouldDirty: true,
|
|
1678
|
-
shouldTouch: true
|
|
1679
|
-
});
|
|
1680
|
-
setIsOpen(SC_STACKED_MODAL_ID, false);
|
|
1681
|
-
};
|
|
1682
|
-
const filters = useSalesChannelTableFilters();
|
|
1683
|
-
const columns = useColumns();
|
|
1684
|
-
const emptyState = useSalesChannelTableEmptyState();
|
|
1685
|
-
if (isError) {
|
|
1686
|
-
throw error;
|
|
1687
|
-
}
|
|
1688
|
-
return /* @__PURE__ */ jsxs10(StackedFocusModal.Content, { className: "flex flex-col overflow-hidden", children: [
|
|
1689
|
-
/* @__PURE__ */ jsx11(StackedFocusModal.Header, {}),
|
|
1690
|
-
/* @__PURE__ */ jsx11(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx11(
|
|
1691
|
-
DataTable,
|
|
1692
|
-
{
|
|
1693
|
-
data: sales_channels,
|
|
1694
|
-
columns,
|
|
1695
|
-
filters,
|
|
1696
|
-
emptyState,
|
|
1697
|
-
rowCount: count,
|
|
1698
|
-
pageSize: PAGE_SIZE,
|
|
1699
|
-
getRowId: (row) => row.id,
|
|
1700
|
-
rowSelection: {
|
|
1701
|
-
state: rowSelection,
|
|
1702
|
-
onRowSelectionChange
|
|
1703
|
-
},
|
|
1704
|
-
isLoading,
|
|
1705
|
-
layout: "fill",
|
|
1706
|
-
prefix: SC_STACKED_MODAL_ID
|
|
1707
|
-
}
|
|
1708
|
-
) }),
|
|
1709
|
-
/* @__PURE__ */ jsx11(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
1710
|
-
/* @__PURE__ */ jsx11(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx11(Button3, { size: "small", variant: "secondary", type: "button", children: t("actions.cancel") }) }),
|
|
1711
|
-
/* @__PURE__ */ jsx11(Button3, { size: "small", onClick: handleAdd, type: "button", children: t("actions.save") })
|
|
1712
|
-
] }) })
|
|
1713
|
-
] });
|
|
1714
|
-
};
|
|
1715
|
-
var columnHelper = createDataTableColumnHelper();
|
|
1716
|
-
var useColumns = () => {
|
|
1717
|
-
const base = useSalesChannelTableColumns();
|
|
1718
|
-
return useMemo2(() => [columnHelper.select(), ...base], [base]);
|
|
1719
|
-
};
|
|
1720
|
-
|
|
1721
|
-
// src/pages/products/create/product-create-organize-form/product-create-organize-form.tsx
|
|
1722
|
-
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1723
|
-
var Root3 = ({ children }) => {
|
|
1724
|
-
if (Children3.count(children) > 0) {
|
|
1725
|
-
return /* @__PURE__ */ jsxs11(StackedFocusModal, { id: SC_STACKED_MODAL_ID, children: [
|
|
1726
|
-
/* @__PURE__ */ jsx12("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsx12("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children }) }),
|
|
1727
|
-
/* @__PURE__ */ jsx12(ProductCreateSalesChannelStackedModal, {})
|
|
1728
|
-
] });
|
|
1729
|
-
}
|
|
1730
|
-
return /* @__PURE__ */ jsxs11(StackedFocusModal, { id: SC_STACKED_MODAL_ID, children: [
|
|
1731
|
-
/* @__PURE__ */ jsx12("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsx12("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: /* @__PURE__ */ jsx12(ProductCreateOrganizationSection, {}) }) }),
|
|
1732
|
-
/* @__PURE__ */ jsx12(ProductCreateSalesChannelStackedModal, {})
|
|
1733
|
-
] });
|
|
1734
|
-
};
|
|
1735
|
-
Root3._tabMeta = {
|
|
1736
|
-
id: "organize",
|
|
1737
|
-
labelKey: "products.create.tabs.organize",
|
|
1738
|
-
validationFields: ["discountable", "categories", "tags", "sales_channels"]
|
|
1739
|
-
};
|
|
1740
|
-
var ProductCreateOrganizeForm = Object.assign(Root3, {
|
|
1741
|
-
_tabMeta: Root3._tabMeta,
|
|
1742
|
-
OrganizationSection: ProductCreateOrganizationSection,
|
|
1743
|
-
AttributeSection: ProductCreateAttributeSection,
|
|
1744
|
-
SalesChannelModal: ProductCreateSalesChannelStackedModal
|
|
1745
|
-
});
|
|
1746
|
-
|
|
1747
|
-
// src/pages/products/create/product-create-variants-form/product-create-variants-form.tsx
|
|
1748
|
-
import { Children as Children4, useMemo as useMemo3 } from "react";
|
|
1749
|
-
import { useWatch as useWatch3 } from "react-hook-form";
|
|
1750
|
-
import { useTranslation as useTranslation9 } from "react-i18next";
|
|
1751
|
-
import { Fragment as Fragment3, jsx as jsx13 } from "react/jsx-runtime";
|
|
1752
|
-
var Root4 = ({ children }) => {
|
|
1753
|
-
const form = useTabbedForm();
|
|
1754
|
-
const { store } = useStore();
|
|
1755
|
-
const { regions } = useRegions({ limit: 9999 });
|
|
1756
|
-
const { price_preferences: pricePreferences } = usePricePreferences({ limit: 9999 });
|
|
1757
|
-
const { setCloseOnEscape } = useRouteModal();
|
|
1758
|
-
const currencyCodes = useMemo3(
|
|
1759
|
-
() => store?.supported_currencies?.map((c) => c.currency_code) || [],
|
|
1760
|
-
[store]
|
|
1761
|
-
);
|
|
1762
|
-
const variants = useWatch3({
|
|
1763
|
-
control: form.control,
|
|
1764
|
-
name: "variants",
|
|
1765
|
-
defaultValue: []
|
|
1766
|
-
});
|
|
1767
|
-
const options = useWatch3({
|
|
1768
|
-
control: form.control,
|
|
1769
|
-
name: "options",
|
|
1770
|
-
defaultValue: []
|
|
1771
|
-
});
|
|
1772
|
-
const columns = useColumns2({
|
|
1773
|
-
options,
|
|
1774
|
-
currencies: currencyCodes,
|
|
1775
|
-
regions,
|
|
1776
|
-
pricePreferences
|
|
1777
|
-
});
|
|
1778
|
-
const variantData = useMemo3(() => {
|
|
1779
|
-
const ret = [];
|
|
1780
|
-
variants.forEach((v, i) => {
|
|
1781
|
-
if (v.should_create) {
|
|
1782
|
-
ret.push({ ...v, originalIndex: i });
|
|
1783
|
-
}
|
|
1784
|
-
});
|
|
1785
|
-
return ret;
|
|
1786
|
-
}, [variants]);
|
|
1787
|
-
if (Children4.count(children) > 0) {
|
|
1788
|
-
return /* @__PURE__ */ jsx13(Fragment3, { children });
|
|
1789
|
-
}
|
|
1790
|
-
return /* @__PURE__ */ jsx13("div", { className: "flex size-full flex-col divide-y overflow-hidden", children: /* @__PURE__ */ jsx13(
|
|
1791
|
-
DataGrid,
|
|
1792
|
-
{
|
|
1793
|
-
columns,
|
|
1794
|
-
data: variantData,
|
|
1795
|
-
state: form,
|
|
1796
|
-
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
1797
|
-
}
|
|
1798
|
-
) });
|
|
1799
|
-
};
|
|
1800
|
-
Root4._tabMeta = {
|
|
1801
|
-
id: "variants",
|
|
1802
|
-
labelKey: "products.create.tabs.variants"
|
|
1803
|
-
};
|
|
1804
|
-
var ProductCreateVariantsForm = Object.assign(Root4, {
|
|
1805
|
-
_tabMeta: Root4._tabMeta
|
|
1806
|
-
});
|
|
1807
|
-
var columnHelper2 = createDataGridHelper();
|
|
1808
|
-
var useColumns2 = ({
|
|
1809
|
-
options,
|
|
1810
|
-
currencies = [],
|
|
1811
|
-
regions = [],
|
|
1812
|
-
pricePreferences = []
|
|
1813
|
-
}) => {
|
|
1814
|
-
const { t } = useTranslation9();
|
|
1815
|
-
return useMemo3(
|
|
1816
|
-
() => [
|
|
1817
|
-
columnHelper2.column({
|
|
1818
|
-
id: "options",
|
|
1819
|
-
header: () => /* @__PURE__ */ jsx13("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx13("span", { className: "truncate", children: options.map((o) => o.title).join(" / ") }) }),
|
|
1820
|
-
cell: (context) => {
|
|
1821
|
-
return /* @__PURE__ */ jsx13(DataGrid.ReadonlyCell, { context, children: options.map((o) => context.row.original.options[o.title]).join(" / ") });
|
|
1822
|
-
},
|
|
1823
|
-
disableHiding: true
|
|
1824
|
-
}),
|
|
1825
|
-
columnHelper2.column({
|
|
1826
|
-
id: "title",
|
|
1827
|
-
name: t("fields.title"),
|
|
1828
|
-
header: t("fields.title"),
|
|
1829
|
-
field: (context) => `variants.${context.row.original.originalIndex}.title`,
|
|
1830
|
-
type: "text",
|
|
1831
|
-
cell: (context) => {
|
|
1832
|
-
return /* @__PURE__ */ jsx13(DataGrid.TextCell, { context });
|
|
1833
|
-
}
|
|
1834
|
-
}),
|
|
1835
|
-
columnHelper2.column({
|
|
1836
|
-
id: "sku",
|
|
1837
|
-
name: t("fields.sku"),
|
|
1838
|
-
header: t("fields.sku"),
|
|
1839
|
-
field: (context) => `variants.${context.row.original.originalIndex}.sku`,
|
|
1840
|
-
type: "text",
|
|
1841
|
-
cell: (context) => {
|
|
1842
|
-
return /* @__PURE__ */ jsx13(DataGrid.TextCell, { context });
|
|
1843
|
-
}
|
|
1844
|
-
}),
|
|
1845
|
-
...createDataGridPriceColumns({
|
|
1846
|
-
currencies,
|
|
1847
|
-
regions,
|
|
1848
|
-
pricePreferences,
|
|
1849
|
-
getFieldName: (context, value) => {
|
|
1850
|
-
return `variants.${context.row.original.originalIndex}.prices.${value}`;
|
|
1851
|
-
},
|
|
1852
|
-
t
|
|
1853
|
-
})
|
|
1854
|
-
],
|
|
1855
|
-
[currencies, regions, options, pricePreferences, t]
|
|
1856
|
-
);
|
|
1857
|
-
};
|
|
1858
|
-
|
|
1859
|
-
// src/pages/products/create/product-create-form/product-create-form.tsx
|
|
1860
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
1861
|
-
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1862
|
-
var SAVE_DRAFT_BUTTON = "save-draft-button";
|
|
1863
|
-
var ProductCreateForm = ({
|
|
1864
|
-
defaultChannel: defaultChannelProp,
|
|
1865
|
-
children,
|
|
1866
|
-
schema,
|
|
1867
|
-
defaultValues: extraDefaults
|
|
1868
|
-
}) => {
|
|
1869
|
-
const { t } = useTranslation10();
|
|
1870
|
-
const { handleSuccess } = useRouteModal();
|
|
1871
|
-
const defaultChannel = defaultChannelProp;
|
|
1872
|
-
const form = useForm({
|
|
1873
|
-
defaultValues: {
|
|
1874
|
-
...PRODUCT_CREATE_FORM_DEFAULTS,
|
|
1875
|
-
...extraDefaults,
|
|
1876
|
-
sales_channels: defaultChannel ? [
|
|
1877
|
-
{
|
|
1878
|
-
id: defaultChannel.id,
|
|
1879
|
-
name: defaultChannel.name
|
|
1880
|
-
}
|
|
1881
|
-
] : []
|
|
1882
|
-
},
|
|
1883
|
-
resolver: zodResolver(schema ?? ProductCreateSchema)
|
|
1884
|
-
});
|
|
1885
|
-
const { mutateAsync, isPending } = useCreateProduct();
|
|
1886
|
-
const defaultTabs = useMemo4(
|
|
1887
|
-
() => [
|
|
1888
|
-
/* @__PURE__ */ jsx14(ProductCreateDetailsForm, {}, "details"),
|
|
1889
|
-
/* @__PURE__ */ jsx14(ProductCreateOrganizeForm, {}, "organize"),
|
|
1890
|
-
/* @__PURE__ */ jsx14(ProductCreateVariantsForm, {}, "variants"),
|
|
1891
|
-
/* @__PURE__ */ jsx14(ProductCreateInventoryKitForm, {}, "inventory")
|
|
1892
|
-
],
|
|
1893
|
-
[]
|
|
1894
|
-
);
|
|
1895
|
-
const hasCustomChildren = Children5.count(children) > 0;
|
|
1896
|
-
const watchedVariants = useWatch4({
|
|
1897
|
-
control: form.control,
|
|
1898
|
-
name: "variants"
|
|
1899
|
-
});
|
|
1900
|
-
const transformTabs = useCallback(
|
|
1901
|
-
(tabs) => tabs.map((tab) => {
|
|
1902
|
-
if (tab.id === "inventory" && tab.isVisible) {
|
|
1903
|
-
return {
|
|
1904
|
-
...tab,
|
|
1905
|
-
isVisible: () => watchedVariants.some(
|
|
1906
|
-
(v) => v.manage_inventory && v.inventory_kit
|
|
1907
|
-
)
|
|
1908
|
-
};
|
|
1909
|
-
}
|
|
1910
|
-
return tab;
|
|
1911
|
-
}),
|
|
1912
|
-
[watchedVariants]
|
|
1913
|
-
);
|
|
1914
|
-
const handleSubmit = form.handleSubmit(async (values, e) => {
|
|
1915
|
-
let isDraftSubmission = false;
|
|
1916
|
-
if (e?.nativeEvent instanceof SubmitEvent) {
|
|
1917
|
-
const submitter = e?.nativeEvent?.submitter;
|
|
1918
|
-
isDraftSubmission = submitter.dataset.name === SAVE_DRAFT_BUTTON;
|
|
1919
|
-
}
|
|
1920
|
-
const media = values.media || [];
|
|
1921
|
-
const payload = { ...values, media: void 0 };
|
|
1922
|
-
let uploadedMedia = [];
|
|
1923
|
-
try {
|
|
1924
|
-
if (media.length) {
|
|
1925
|
-
const thumbnailReq = media.filter((m) => m.isThumbnail);
|
|
1926
|
-
const otherMediaReq = media.filter((m) => !m.isThumbnail);
|
|
1927
|
-
const fileReqs = [];
|
|
1928
|
-
if (thumbnailReq?.length) {
|
|
1929
|
-
fileReqs.push(
|
|
1930
|
-
uploadFilesQuery(thumbnailReq).then(
|
|
1931
|
-
(r) => r.files.map((f) => ({
|
|
1932
|
-
...f,
|
|
1933
|
-
isThumbnail: true
|
|
1934
|
-
}))
|
|
1935
|
-
)
|
|
1936
|
-
);
|
|
1937
|
-
}
|
|
1938
|
-
if (otherMediaReq?.length) {
|
|
1939
|
-
fileReqs.push(
|
|
1940
|
-
uploadFilesQuery(otherMediaReq).then(
|
|
1941
|
-
(r) => r.files.map((f) => ({
|
|
1942
|
-
...f,
|
|
1943
|
-
isThumbnail: false
|
|
1944
|
-
}))
|
|
1945
|
-
)
|
|
1946
|
-
);
|
|
1947
|
-
}
|
|
1948
|
-
uploadedMedia = (await Promise.all(fileReqs)).flat();
|
|
1949
|
-
}
|
|
1950
|
-
} catch (error) {
|
|
1951
|
-
if (error instanceof Error) {
|
|
1952
|
-
toast.error(error.message);
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
await mutateAsync(
|
|
1956
|
-
{
|
|
1957
|
-
...payload,
|
|
1958
|
-
status: isDraftSubmission ? "draft" : "published",
|
|
1959
|
-
images: uploadedMedia,
|
|
1960
|
-
weight: parseInt(payload.weight || "") || void 0,
|
|
1961
|
-
length: parseInt(payload.length || "") || void 0,
|
|
1962
|
-
height: parseInt(payload.height || "") || void 0,
|
|
1963
|
-
width: parseInt(payload.width || "") || void 0,
|
|
1964
|
-
type_id: payload.type_id || void 0,
|
|
1965
|
-
tags: payload.tags?.map((tag) => ({
|
|
1966
|
-
id: tag
|
|
1967
|
-
})) || [],
|
|
1968
|
-
collection_id: payload.collection_id || void 0,
|
|
1969
|
-
shipping_profile_id: void 0,
|
|
1970
|
-
enable_variants: void 0,
|
|
1971
|
-
additional_data: void 0,
|
|
1972
|
-
categories: payload.categories.map((cat) => ({
|
|
1973
|
-
id: cat
|
|
1974
|
-
})),
|
|
1975
|
-
variants: payload.variants.map((variant) => ({
|
|
1976
|
-
...variant,
|
|
1977
|
-
sku: variant.sku === "" ? void 0 : variant.sku,
|
|
1978
|
-
manage_inventory: true,
|
|
1979
|
-
allow_backorder: false,
|
|
1980
|
-
should_create: void 0,
|
|
1981
|
-
is_default: void 0,
|
|
1982
|
-
inventory_kit: void 0,
|
|
1983
|
-
inventory: void 0,
|
|
1984
|
-
prices: Object.keys(variant.prices || {}).map((key) => ({
|
|
1985
|
-
currency_code: key,
|
|
1986
|
-
amount: parseFloat(variant.prices?.[key])
|
|
1987
|
-
}))
|
|
1988
|
-
}))
|
|
1989
|
-
},
|
|
1990
|
-
{
|
|
1991
|
-
onSuccess: (data) => {
|
|
1992
|
-
toast.success(
|
|
1993
|
-
t("products.create.successToast", {
|
|
1994
|
-
title: data.product.title
|
|
1995
|
-
})
|
|
1996
|
-
);
|
|
1997
|
-
handleSuccess(`../${data.product.id}`);
|
|
1998
|
-
},
|
|
1999
|
-
onError: (error) => {
|
|
2000
|
-
toast.error(error.message);
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
);
|
|
2004
|
-
});
|
|
2005
|
-
return /* @__PURE__ */ jsx14(
|
|
2006
|
-
TabbedForm,
|
|
2007
|
-
{
|
|
2008
|
-
form,
|
|
2009
|
-
onSubmit: handleSubmit,
|
|
2010
|
-
isLoading: isPending,
|
|
2011
|
-
transformTabs,
|
|
2012
|
-
footer: ({ isLastTab, onNext, isLoading }) => /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
2013
|
-
/* @__PURE__ */ jsx14(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx14(Button4, { variant: "secondary", size: "small", children: t("actions.cancel") }) }),
|
|
2014
|
-
/* @__PURE__ */ jsx14(
|
|
2015
|
-
Button4,
|
|
2016
|
-
{
|
|
2017
|
-
"data-name": SAVE_DRAFT_BUTTON,
|
|
2018
|
-
size: "small",
|
|
2019
|
-
type: "submit",
|
|
2020
|
-
isLoading,
|
|
2021
|
-
className: "whitespace-nowrap",
|
|
2022
|
-
children: "Draft"
|
|
2023
|
-
}
|
|
2024
|
-
),
|
|
2025
|
-
isLastTab ? /* @__PURE__ */ jsx14(
|
|
2026
|
-
Button4,
|
|
2027
|
-
{
|
|
2028
|
-
"data-name": "publish-button",
|
|
2029
|
-
type: "submit",
|
|
2030
|
-
variant: "primary",
|
|
2031
|
-
size: "small",
|
|
2032
|
-
isLoading,
|
|
2033
|
-
children: "Create Product"
|
|
2034
|
-
},
|
|
2035
|
-
"submit-button"
|
|
2036
|
-
) : /* @__PURE__ */ jsx14(
|
|
2037
|
-
Button4,
|
|
2038
|
-
{
|
|
2039
|
-
type: "button",
|
|
2040
|
-
variant: "primary",
|
|
2041
|
-
size: "small",
|
|
2042
|
-
onClick: () => onNext(),
|
|
2043
|
-
children: t("actions.continue")
|
|
2044
|
-
},
|
|
2045
|
-
"next-button"
|
|
2046
|
-
)
|
|
2047
|
-
] }),
|
|
2048
|
-
children: hasCustomChildren ? children : defaultTabs
|
|
2049
|
-
}
|
|
2050
|
-
);
|
|
2051
|
-
};
|
|
2052
|
-
|
|
2053
|
-
// src/pages/products/create/product-create-page.tsx
|
|
2054
|
-
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2055
|
-
var Root5 = ({ children }) => {
|
|
2056
|
-
const { t } = useTranslation11();
|
|
2057
|
-
const { store, isPending: isStorePending } = useStore();
|
|
2058
|
-
const { sales_channels, isPending: isSalesChannelPending } = useSalesChannels();
|
|
2059
|
-
const ready = !!store && !isStorePending && !!sales_channels && !isSalesChannelPending;
|
|
2060
|
-
const defaultChannel = sales_channels?.[0];
|
|
2061
|
-
return /* @__PURE__ */ jsxs13(RouteFocusModal, { children: [
|
|
2062
|
-
/* @__PURE__ */ jsx15(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx15("span", { className: "sr-only", children: t("products.create.title") }) }),
|
|
2063
|
-
/* @__PURE__ */ jsx15(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx15("span", { className: "sr-only", children: t("products.create.description") }) }),
|
|
2064
|
-
ready && (Children6.count(children) > 0 ? children : /* @__PURE__ */ jsx15(ProductCreateForm, { defaultChannel }))
|
|
2065
|
-
] });
|
|
2066
|
-
};
|
|
2067
|
-
var ProductCreatePage = Object.assign(Root5, {
|
|
2068
|
-
DetailsForm: ProductCreateDetailsForm,
|
|
2069
|
-
OrganizeForm: ProductCreateOrganizeForm,
|
|
2070
|
-
VariantsForm: ProductCreateVariantsForm,
|
|
2071
|
-
InventoryKitForm: ProductCreateInventoryKitForm,
|
|
2072
|
-
Form: ProductCreateForm,
|
|
2073
|
-
Tab: TabbedForm.Tab
|
|
2074
|
-
});
|
|
2075
|
-
|
|
2076
|
-
export {
|
|
2077
|
-
ProductCreatePage
|
|
2078
|
-
};
|