@mercurjs/admin 2.0.0-canary.24
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/add-campaign-promotions-JDC36EOE.js +265 -0
- package/dist/adjust-inventory-2YLC4O4I.js +262 -0
- package/dist/api-key-management-create-KERROZ6Z.js +282 -0
- package/dist/api-key-management-detail-PXY2ZH4V.js +481 -0
- package/dist/api-key-management-edit-7IPPTW37.js +106 -0
- package/dist/api-key-management-list-QQHOCVV4.js +350 -0
- package/dist/api-key-management-sales-channels-AO6SRCAW.js +201 -0
- package/dist/campaign-budget-edit-C5PCVES3.js +147 -0
- package/dist/campaign-configuration-ONC2CL7Q.js +154 -0
- package/dist/campaign-create-J2PN77A6.js +29 -0
- package/dist/campaign-detail-2XJ7PXOQ.js +666 -0
- package/dist/campaign-edit-MU4TVOEC.js +206 -0
- package/dist/campaign-list-BWYHTJL2.js +187 -0
- package/dist/categories-metadata-UC3N6YSC.js +83 -0
- package/dist/category-create-DRJZI3EM.js +427 -0
- package/dist/category-detail-DEGYVUXB.js +544 -0
- package/dist/category-edit-PTYOK7VV.js +220 -0
- package/dist/category-list-T4GPTLOA.js +286 -0
- package/dist/category-organize-MLBY54BT.js +110 -0
- package/dist/category-products-W7U2VZTZ.js +281 -0
- package/dist/chunk-25LYVP3C.js +37 -0
- package/dist/chunk-26OOAKQ6.js +18 -0
- package/dist/chunk-2I3BDP2Z.js +61 -0
- package/dist/chunk-2KCF3ZIB.js +32 -0
- package/dist/chunk-2MKZ4HD4.js +175 -0
- package/dist/chunk-2PZGY332.js +88 -0
- package/dist/chunk-2QKPRGNK.js +107 -0
- package/dist/chunk-2Y3WMGN6.js +39 -0
- package/dist/chunk-2ZFELO2L.js +13 -0
- package/dist/chunk-33XUAKRP.js +6 -0
- package/dist/chunk-362QMJZM.js +77 -0
- package/dist/chunk-3CKTAFTR.js +143 -0
- package/dist/chunk-3EF54XFY.js +64 -0
- package/dist/chunk-3KOTDGC2.js +18 -0
- package/dist/chunk-3LDJURK5.js +296 -0
- package/dist/chunk-3QSRE5LS.js +161 -0
- package/dist/chunk-3XPXUIK3.js +34 -0
- package/dist/chunk-4F5GP7J7.js +45 -0
- package/dist/chunk-4GPAS5GW.js +36 -0
- package/dist/chunk-54EPH67T.js +34 -0
- package/dist/chunk-54RTJBYO.js +153 -0
- package/dist/chunk-54TMLQH3.js +9 -0
- package/dist/chunk-5LZ2G4ZX.js +422 -0
- package/dist/chunk-5S6J5PG5.js +182 -0
- package/dist/chunk-6IJMSVC6.js +16 -0
- package/dist/chunk-6KI3GDYH.js +46 -0
- package/dist/chunk-7AV5EJJ5.js +29 -0
- package/dist/chunk-7RPRNVBS.js +45 -0
- package/dist/chunk-7SVLKK6Q.js +31 -0
- package/dist/chunk-AW77UWCZ.js +363 -0
- package/dist/chunk-AWZFIP25.js +117 -0
- package/dist/chunk-AYVH6Q5O.js +31 -0
- package/dist/chunk-BDGZ4EQO.js +86 -0
- package/dist/chunk-BMNW3AEU.js +373 -0
- package/dist/chunk-BRUOBAPY.js +234 -0
- package/dist/chunk-BYZIWSBB.js +185 -0
- package/dist/chunk-C6SUTRP2.js +13 -0
- package/dist/chunk-CBRSGM3X.js +342 -0
- package/dist/chunk-CI5Z6FGV.js +87 -0
- package/dist/chunk-CMHI2RPL.js +20 -0
- package/dist/chunk-CP5IL4P6.js +98 -0
- package/dist/chunk-D3KDXELJ.js +110 -0
- package/dist/chunk-D6IERBVW.js +43 -0
- package/dist/chunk-DB6ANJBO.js +35 -0
- package/dist/chunk-DLKKSPFE.js +50 -0
- package/dist/chunk-DV73MHTN.js +457 -0
- package/dist/chunk-DXZOR4AG.js +69 -0
- package/dist/chunk-DY3XQPHC.js +31 -0
- package/dist/chunk-EOZUAYQL.js +6 -0
- package/dist/chunk-ERTSYQAI.js +121 -0
- package/dist/chunk-EZIB4NST.js +94 -0
- package/dist/chunk-FGZCSG7T.js +232 -0
- package/dist/chunk-FI474ADU.js +0 -0
- package/dist/chunk-FLCYR7E5.js +467 -0
- package/dist/chunk-FMFVTERD.js +0 -0
- package/dist/chunk-FODCCP6C.js +76 -0
- package/dist/chunk-FQERBIVS.js +0 -0
- package/dist/chunk-FWPGOIFA.js +22 -0
- package/dist/chunk-G5OVX555.js +26 -0
- package/dist/chunk-GUIDZSDY.js +41 -0
- package/dist/chunk-H22XDSXD.js +47 -0
- package/dist/chunk-HC25LNX7.js +45 -0
- package/dist/chunk-HINXQTCW.js +97 -0
- package/dist/chunk-HYUGYB23.js +161 -0
- package/dist/chunk-I43SCBL3.js +106 -0
- package/dist/chunk-IGTRIAUC.js +84 -0
- package/dist/chunk-INNFZYX2.js +183 -0
- package/dist/chunk-IQPN4PZJ.js +749 -0
- package/dist/chunk-IZ5RG5XI.js +72 -0
- package/dist/chunk-JDGE23BZ.js +332 -0
- package/dist/chunk-JHIMVLB2.js +42 -0
- package/dist/chunk-JISYRXUS.js +389 -0
- package/dist/chunk-JJVGCTKT.js +243 -0
- package/dist/chunk-JQV7CXEC.js +37 -0
- package/dist/chunk-JRTZWK77.js +1764 -0
- package/dist/chunk-KAZ5BYTQ.js +132 -0
- package/dist/chunk-KBYZLKI4.js +1093 -0
- package/dist/chunk-KTKL7M34.js +90 -0
- package/dist/chunk-KUWNYCGL.js +4113 -0
- package/dist/chunk-KW56S7WF.js +67 -0
- package/dist/chunk-LAVHRER2.js +17 -0
- package/dist/chunk-LCZXAT4Q.js +58 -0
- package/dist/chunk-LFKTHNWI.js +83 -0
- package/dist/chunk-LGJWR5LX.js +164 -0
- package/dist/chunk-LLWK3OR6.js +169 -0
- package/dist/chunk-LQSLDDPT.js +67 -0
- package/dist/chunk-LR4ACD6E.js +86676 -0
- package/dist/chunk-LTBX54CI.js +11 -0
- package/dist/chunk-LXP7K6HL.js +817 -0
- package/dist/chunk-LXSBG6LK.js +18 -0
- package/dist/chunk-LZALOVO3.js +372 -0
- package/dist/chunk-M6SOYQJ6.js +39 -0
- package/dist/chunk-MAEP2UCK.js +110 -0
- package/dist/chunk-MG4GKUJW.js +31 -0
- package/dist/chunk-MWOKFNRO.js +446 -0
- package/dist/chunk-N2TQXB44.js +1280 -0
- package/dist/chunk-N5IUYCUZ.js +31 -0
- package/dist/chunk-NBMM2TZK.js +33 -0
- package/dist/chunk-NCMUZ6BQ.js +0 -0
- package/dist/chunk-NCYTM57J.js +160 -0
- package/dist/chunk-NIRWGTM3.js +1104 -0
- package/dist/chunk-NS5CHWOH.js +80 -0
- package/dist/chunk-NWQRHWE5.js +9461 -0
- package/dist/chunk-NXDFDEKP.js +0 -0
- package/dist/chunk-NZJGUN67.js +266 -0
- package/dist/chunk-NZN7PFPB.js +169 -0
- package/dist/chunk-O5HZRJPB.js +55 -0
- package/dist/chunk-O5VKW5FL.js +41 -0
- package/dist/chunk-O67KME6D.js +110 -0
- package/dist/chunk-ODBDAABQ.js +88 -0
- package/dist/chunk-OGYWOPHZ.js +96 -0
- package/dist/chunk-ORW4HNX5.js +357 -0
- package/dist/chunk-P3IZB24Y.js +109 -0
- package/dist/chunk-PHOCVOZ5.js +9 -0
- package/dist/chunk-PVZBDWLK.js +41 -0
- package/dist/chunk-PX675AEP.js +129 -0
- package/dist/chunk-PXYDR7WQ.js +48 -0
- package/dist/chunk-QDPLZDMX.js +17 -0
- package/dist/chunk-QG6PLWNH.js +106 -0
- package/dist/chunk-QSGR43JM.js +30 -0
- package/dist/chunk-RK5N3XIX.js +56 -0
- package/dist/chunk-RLMLYJDI.js +38 -0
- package/dist/chunk-RMXYSYK4.js +50 -0
- package/dist/chunk-RPIJY6TT.js +637 -0
- package/dist/chunk-RSBZREKG.js +144 -0
- package/dist/chunk-RXM4B6HR.js +8 -0
- package/dist/chunk-S2WEYEQR.js +14 -0
- package/dist/chunk-S4SVK5DE.js +39 -0
- package/dist/chunk-S6LPCNXQ.js +29 -0
- package/dist/chunk-SMQT3ZNO.js +8 -0
- package/dist/chunk-T435NFHC.js +490 -0
- package/dist/chunk-THHRRYRS.js +16 -0
- package/dist/chunk-TKGWSUEI.js +0 -0
- package/dist/chunk-TLE6YHGH.js +26 -0
- package/dist/chunk-TN4TIT7O.js +116 -0
- package/dist/chunk-TUJIAA5O.js +101 -0
- package/dist/chunk-U2EI2ZLM.js +32 -0
- package/dist/chunk-U2L77ZDR.js +17 -0
- package/dist/chunk-U2UCL2VG.js +369 -0
- package/dist/chunk-U2ZFCAPX.js +34 -0
- package/dist/chunk-U5MJIHLY.js +87 -0
- package/dist/chunk-U62GYN4A.js +227 -0
- package/dist/chunk-UM7ZR3VU.js +14 -0
- package/dist/chunk-UQITHKTH.js +342 -0
- package/dist/chunk-UZJ2NQSN.js +257 -0
- package/dist/chunk-UZWFZMOX.js +40 -0
- package/dist/chunk-V74Y5NIV.js +49 -0
- package/dist/chunk-VBMMWVB5.js +49 -0
- package/dist/chunk-VKOE5J66.js +31 -0
- package/dist/chunk-VOHEQ7B5.js +31 -0
- package/dist/chunk-VVTSF42Z.js +52 -0
- package/dist/chunk-VW56KWO2.js +9 -0
- package/dist/chunk-VWGKHDZ6.js +528 -0
- package/dist/chunk-W6Y3PPU5.js +73 -0
- package/dist/chunk-WCEMRNW4.js +6 -0
- package/dist/chunk-WDZFLCSQ.js +77 -0
- package/dist/chunk-WIYFXWRI.js +30 -0
- package/dist/chunk-WMA3WTCM.js +117 -0
- package/dist/chunk-WWANSDFM.js +175 -0
- package/dist/chunk-XBMLI2YI.js +85 -0
- package/dist/chunk-XBVIP2BA.js +609 -0
- package/dist/chunk-XCMR2HTV.js +102 -0
- package/dist/chunk-XFR5JLNF.js +44 -0
- package/dist/chunk-XL52SYWY.js +23 -0
- package/dist/chunk-XQNVC4Q7.js +212 -0
- package/dist/chunk-XSX255FK.js +12 -0
- package/dist/chunk-Y2M536WR.js +67 -0
- package/dist/chunk-Y456KVIN.js +116 -0
- package/dist/chunk-Y7QKP6QU.js +35 -0
- package/dist/chunk-YBZWO4ZV.js +57 -0
- package/dist/chunk-YGQUBTKR.js +81 -0
- package/dist/chunk-YGSM5PVN.js +170 -0
- package/dist/chunk-YVCBMOJG.js +50 -0
- package/dist/chunk-YWWUOGJA.js +62 -0
- package/dist/chunk-YXFG3M2D.js +792 -0
- package/dist/chunk-ZAUMHCIL.js +42 -0
- package/dist/chunk-ZDJWCSZ4.js +85 -0
- package/dist/chunk-ZQZHFMD7.js +19 -0
- package/dist/chunk-ZYNBKBY3.js +14 -0
- package/dist/collection-add-products-IUDEIUM5.js +284 -0
- package/dist/collection-create-AQ3GUG3G.js +133 -0
- package/dist/collection-detail-SDFALX6M.js +444 -0
- package/dist/collection-edit-AAHL2WFH.js +121 -0
- package/dist/collection-list-JGKC5EVM.js +228 -0
- package/dist/collection-metadata-YQWA2JTU.js +80 -0
- package/dist/customer-create-5VT2TB6S.js +183 -0
- package/dist/customer-create-address-ICEFEFD2.js +299 -0
- package/dist/customer-detail-CDELSJ77.js +695 -0
- package/dist/customer-edit-DZAD53JC.js +192 -0
- package/dist/customer-list-EIQP23FQ.js +152 -0
- package/dist/customer-metadata-ATAORBRN.js +81 -0
- package/dist/customers-add-customer-group-542PUCCT.js +308 -0
- package/dist/edit-inventory-item-P2HVULPA.js +152 -0
- package/dist/edit-inventory-item-attributes-V2HK3WTQ.js +323 -0
- package/dist/edit-reservation-LX2Z6KVD.js +246 -0
- package/dist/edit-rules-Q5UNWAUD.js +316 -0
- package/dist/home-I3OILW5Z.js +16 -0
- package/dist/index.css +6 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +4824 -0
- package/dist/inventory-create-FT7GL4RK.js +616 -0
- package/dist/inventory-detail-LNZ5QC67.js +771 -0
- package/dist/inventory-list-UXY7PU3N.js +432 -0
- package/dist/inventory-metadata-OYETRH5X.js +83 -0
- package/dist/inventory-stock-3MBERL3K.js +288 -0
- package/dist/invite-HJ7BRO6H.js +372 -0
- package/dist/location-create-ZVVQT2KP.js +238 -0
- package/dist/location-detail-A5SHPUQN.js +823 -0
- package/dist/location-edit-QSRHHDQ2.js +253 -0
- package/dist/location-fulfillment-providers-4HMT5L7L.js +289 -0
- package/dist/location-list-TC5FEN5R.js +346 -0
- package/dist/location-sales-channels-STDHWQSC.js +215 -0
- package/dist/location-service-zone-create-63LUYCJI.js +173 -0
- package/dist/location-service-zone-edit-UNXI5BQV.js +134 -0
- package/dist/location-service-zone-manage-areas-UMD6CZDZ.js +154 -0
- package/dist/location-service-zone-shipping-option-create-5L73SAGE.js +807 -0
- package/dist/location-service-zone-shipping-option-edit-2FEWQD6Y.js +362 -0
- package/dist/location-service-zone-shipping-option-pricing-QSB56QZD.js +362 -0
- package/dist/login-V4HZQTCQ.js +254 -0
- package/dist/manage-locations-NVHONEZE.js +249 -0
- package/dist/no-match-JLVLPCRH.js +33 -0
- package/dist/order-allocate-items-F7CXZQGX.js +558 -0
- package/dist/order-create-claim-GDVWGZJA.js +2203 -0
- package/dist/order-create-edit-6YYKYT66.js +936 -0
- package/dist/order-create-exchange-NLDIMGBG.js +2190 -0
- package/dist/order-create-fulfillment-EIYGSKXP.js +621 -0
- package/dist/order-create-refund-BBXEZNWA.js +403 -0
- package/dist/order-create-return-6TA5J3AW.js +1292 -0
- package/dist/order-create-shipment-T4C6UE2K.js +208 -0
- package/dist/order-detail-Y4EG3P5F.js +3846 -0
- package/dist/order-edit-billing-address-NNIFUC5C.js +400 -0
- package/dist/order-edit-email-VXOX62P6.js +171 -0
- package/dist/order-edit-shipping-address-WDKCQRRG.js +397 -0
- package/dist/order-list-XDOAXZXN.js +231 -0
- package/dist/order-metadata-S6N3GDOA.js +82 -0
- package/dist/order-receive-return-5VWUPWZJ.js +549 -0
- package/dist/order-request-transfer-VFSY5IFF.js +571 -0
- package/dist/price-list-configuration-GH67LL2N.js +356 -0
- package/dist/price-list-create-INX5HG7G.js +973 -0
- package/dist/price-list-detail-5LGPE67O.js +540 -0
- package/dist/price-list-edit-HRWPEIZI.js +227 -0
- package/dist/price-list-list-IXZVTXU5.js +228 -0
- package/dist/price-list-prices-add-QHE3TUTV.js +614 -0
- package/dist/price-list-prices-edit-TMVJ7S7J.js +326 -0
- package/dist/product-attributes-P7WFH4I2.js +358 -0
- package/dist/product-create-YC6MCJ2M.js +2305 -0
- package/dist/product-create-option-BNF2KKJM.js +144 -0
- package/dist/product-create-variant-SIJX7AE3.js +837 -0
- package/dist/product-detail-2GJ3PGHW.js +1638 -0
- package/dist/product-edit-YOGTWZ4I.js +397 -0
- package/dist/product-edit-option-4MUSMFS7.js +152 -0
- package/dist/product-export-5L4HNM3W.js +127 -0
- package/dist/product-import-Y54VG4AC.js +261 -0
- package/dist/product-list-EV2TS3Y4.js +313 -0
- package/dist/product-media-ZSMGHCNP.js +879 -0
- package/dist/product-metadata-572YVJH3.js +80 -0
- package/dist/product-organization-LVKRBJOQ.js +312 -0
- package/dist/product-prices-K5YM2TL6.js +266 -0
- package/dist/product-sales-channels-J3OH4NWX.js +157 -0
- package/dist/product-shipping-profile-NOOFEUBZ.js +146 -0
- package/dist/product-stock-J4LTIX64.js +540 -0
- package/dist/product-tag-create-5JJPPELP.js +122 -0
- package/dist/product-tag-detail-CGLCH3BJ.js +281 -0
- package/dist/product-tag-edit-OR7KSC7I.js +134 -0
- package/dist/product-tag-list-DY7GJUJQ.js +259 -0
- package/dist/product-tag-metadata-BFGPRMME.js +80 -0
- package/dist/product-type-create-FPVSGIKL.js +101 -0
- package/dist/product-type-detail-JYW2DAM4.js +242 -0
- package/dist/product-type-edit-FBT4Z4ZJ.js +113 -0
- package/dist/product-type-list-FK237DSQ.js +175 -0
- package/dist/product-type-metadata-SFJR5OQN.js +80 -0
- package/dist/product-variant-detail-6KPB3HL7.js +485 -0
- package/dist/product-variant-edit-QFHGNDW7.js +538 -0
- package/dist/product-variant-manage-inventory-items-ZEX2IW53.js +340 -0
- package/dist/product-variant-metadata-F45CSWU6.js +86 -0
- package/dist/profile-detail-LLXUNQOT.js +89 -0
- package/dist/profile-edit-UDYMDQLT.js +176 -0
- package/dist/promotion-add-campaign-U6X2FNWZ.js +43 -0
- package/dist/promotion-create-QB7E277L.js +1258 -0
- package/dist/promotion-detail-7D6D6PQ7.js +486 -0
- package/dist/promotion-edit-details-HYQJAZDF.js +512 -0
- package/dist/promotion-list-HTJ5GIWG.js +206 -0
- package/dist/refund-reason-create-LZCL6QJI.js +192 -0
- package/dist/refund-reason-edit-QNGFKZMN.js +192 -0
- package/dist/refund-reason-list-ZEKWYQ45.js +233 -0
- package/dist/region-add-countries-CWJ62VPK.js +226 -0
- package/dist/region-create-Z3JQFIKN.js +507 -0
- package/dist/region-detail-46R3HACJ.js +508 -0
- package/dist/region-edit-W5IVVP7Z.js +380 -0
- package/dist/region-list-DCU6NQFA.js +205 -0
- package/dist/region-metadata-VG5DLCOK.js +83 -0
- package/dist/reservation-create-VG5FSV3F.js +309 -0
- package/dist/reservation-detail-36BA3V2F.js +221 -0
- package/dist/reservation-list-R5UBPNI4.js +298 -0
- package/dist/reservation-metadata-KR4HOHTH.js +83 -0
- package/dist/reset-password-VZPICVMM.js +458 -0
- package/dist/return-reason-create-KTKI6NJE.js +165 -0
- package/dist/return-reason-edit-5KU7WKJF.js +168 -0
- package/dist/return-reason-list-HBSKNIMW.js +240 -0
- package/dist/sales-channel-add-products-6TUDLE4D.js +274 -0
- package/dist/sales-channel-create-2BTWSYIK.js +154 -0
- package/dist/sales-channel-detail-IQIQDN3L.js +437 -0
- package/dist/sales-channel-edit-YBNPALFT.js +163 -0
- package/dist/sales-channel-list-5KNN734B.js +193 -0
- package/dist/sales-channel-metadata-SVW6FYSV.js +88 -0
- package/dist/seller-details-HBVN4GGD.js +77 -0
- package/dist/seller-edit-OXDARXYJ.js +387 -0
- package/dist/seller-list-HG2VXA6V.js +192 -0
- package/dist/settings-D43GVDOO.js +19 -0
- package/dist/shipping-option-type-create-7KYU5NNF.js +195 -0
- package/dist/shipping-option-type-detail-4CNTT3MO.js +169 -0
- package/dist/shipping-option-type-edit-AN6IPVI6.js +191 -0
- package/dist/shipping-option-type-list-36ZS2QZO.js +266 -0
- package/dist/shipping-profile-create-3OWHNAOB.js +123 -0
- package/dist/shipping-profile-detail-WW7IVUVV.js +157 -0
- package/dist/shipping-profile-metadata-AD3DSZLR.js +84 -0
- package/dist/shipping-profiles-list-WOGGP7IT.js +241 -0
- package/dist/store-add-currencies-PIGEOZ4G.js +304 -0
- package/dist/store-detail-MFHPXBIN.js +525 -0
- package/dist/store-edit-WBF6EL5N.js +246 -0
- package/dist/store-metadata-LSK7UVSC.js +85 -0
- package/dist/tax-region-create-XTX4YWRA.js +300 -0
- package/dist/tax-region-detail-XUYJHBHI.js +320 -0
- package/dist/tax-region-edit-AC64YA64.js +162 -0
- package/dist/tax-region-list-XRAYDYK3.js +91 -0
- package/dist/tax-region-metadata-YDQX3Y4X.js +83 -0
- package/dist/tax-region-province-create-GDL65SQF.js +315 -0
- package/dist/tax-region-province-detail-QMPIKT7K.js +215 -0
- package/dist/tax-region-tax-override-create-X2QWOHSU.js +679 -0
- package/dist/tax-region-tax-override-edit-VZJ6EPSU.js +788 -0
- package/dist/tax-region-tax-rate-create-VC2WDVJJ.js +193 -0
- package/dist/tax-region-tax-rate-edit-SDW36H6I.js +192 -0
- package/dist/user-detail-IEIX24PZ.js +163 -0
- package/dist/user-edit-CJ7TNY3H.js +115 -0
- package/dist/user-invite-OTBYWV4L.js +389 -0
- package/dist/user-list-BJXFPTJ7.js +341 -0
- package/dist/user-metadata-ZLC6T6XH.js +83 -0
- package/package.json +87 -0
|
@@ -0,0 +1,2305 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChipGroup
|
|
3
|
+
} from "./chunk-IGTRIAUC.js";
|
|
4
|
+
import {
|
|
5
|
+
HandleInput
|
|
6
|
+
} from "./chunk-TLE6YHGH.js";
|
|
7
|
+
import {
|
|
8
|
+
ChipInput
|
|
9
|
+
} from "./chunk-NCYTM57J.js";
|
|
10
|
+
import {
|
|
11
|
+
SwitchBox
|
|
12
|
+
} from "./chunk-YVCBMOJG.js";
|
|
13
|
+
import {
|
|
14
|
+
useSalesChannelTableColumns,
|
|
15
|
+
useSalesChannelTableEmptyState,
|
|
16
|
+
useSalesChannelTableFilters,
|
|
17
|
+
useSalesChannelTableQuery
|
|
18
|
+
} from "./chunk-NZN7PFPB.js";
|
|
19
|
+
import {
|
|
20
|
+
CategoryCombobox
|
|
21
|
+
} from "./chunk-5LZ2G4ZX.js";
|
|
22
|
+
import {
|
|
23
|
+
useComboboxData
|
|
24
|
+
} from "./chunk-O67KME6D.js";
|
|
25
|
+
import {
|
|
26
|
+
Combobox
|
|
27
|
+
} from "./chunk-AW77UWCZ.js";
|
|
28
|
+
import {
|
|
29
|
+
PRODUCT_CREATE_FORM_DEFAULTS,
|
|
30
|
+
ProductCreateSchema,
|
|
31
|
+
UploadMediaFormItem,
|
|
32
|
+
decorateVariantsWithDefaultValues,
|
|
33
|
+
normalizeProductFormValues
|
|
34
|
+
} from "./chunk-JDGE23BZ.js";
|
|
35
|
+
import "./chunk-IZ5RG5XI.js";
|
|
36
|
+
import {
|
|
37
|
+
DataGrid,
|
|
38
|
+
createDataGridHelper,
|
|
39
|
+
createDataGridPriceColumns
|
|
40
|
+
} from "./chunk-KUWNYCGL.js";
|
|
41
|
+
import "./chunk-IQPN4PZJ.js";
|
|
42
|
+
import "./chunk-SMQT3ZNO.js";
|
|
43
|
+
import "./chunk-LR4ACD6E.js";
|
|
44
|
+
import "./chunk-TKGWSUEI.js";
|
|
45
|
+
import {
|
|
46
|
+
KeyboundForm
|
|
47
|
+
} from "./chunk-U2ZFCAPX.js";
|
|
48
|
+
import "./chunk-TN4TIT7O.js";
|
|
49
|
+
import {
|
|
50
|
+
RouteFocusModal,
|
|
51
|
+
StackedFocusModal,
|
|
52
|
+
useRouteModal,
|
|
53
|
+
useStackedModal
|
|
54
|
+
} from "./chunk-MWOKFNRO.js";
|
|
55
|
+
import {
|
|
56
|
+
Form
|
|
57
|
+
} from "./chunk-3QSRE5LS.js";
|
|
58
|
+
import "./chunk-54RTJBYO.js";
|
|
59
|
+
import {
|
|
60
|
+
DataTable
|
|
61
|
+
} from "./chunk-UQITHKTH.js";
|
|
62
|
+
import "./chunk-INNFZYX2.js";
|
|
63
|
+
import {
|
|
64
|
+
ActionMenu
|
|
65
|
+
} from "./chunk-BDGZ4EQO.js";
|
|
66
|
+
import "./chunk-LAVHRER2.js";
|
|
67
|
+
import {
|
|
68
|
+
useDocumentDirection
|
|
69
|
+
} from "./chunk-Y7QKP6QU.js";
|
|
70
|
+
import "./chunk-THHRRYRS.js";
|
|
71
|
+
import "./chunk-UZWFZMOX.js";
|
|
72
|
+
import "./chunk-XQNVC4Q7.js";
|
|
73
|
+
import "./chunk-ORW4HNX5.js";
|
|
74
|
+
import "./chunk-ODBDAABQ.js";
|
|
75
|
+
import "./chunk-YGQUBTKR.js";
|
|
76
|
+
import "./chunk-362QMJZM.js";
|
|
77
|
+
import "./chunk-FODCCP6C.js";
|
|
78
|
+
import "./chunk-AWZFIP25.js";
|
|
79
|
+
import "./chunk-2QKPRGNK.js";
|
|
80
|
+
import "./chunk-XBMLI2YI.js";
|
|
81
|
+
import "./chunk-XL52SYWY.js";
|
|
82
|
+
import "./chunk-NS5CHWOH.js";
|
|
83
|
+
import "./chunk-WDZFLCSQ.js";
|
|
84
|
+
import "./chunk-VVTSF42Z.js";
|
|
85
|
+
import "./chunk-D3KDXELJ.js";
|
|
86
|
+
import "./chunk-2MKZ4HD4.js";
|
|
87
|
+
import "./chunk-OGYWOPHZ.js";
|
|
88
|
+
import "./chunk-U62GYN4A.js";
|
|
89
|
+
import "./chunk-KTKL7M34.js";
|
|
90
|
+
import "./chunk-JJVGCTKT.js";
|
|
91
|
+
import "./chunk-I43SCBL3.js";
|
|
92
|
+
import "./chunk-LLWK3OR6.js";
|
|
93
|
+
import {
|
|
94
|
+
useSalesChannel,
|
|
95
|
+
useSalesChannels
|
|
96
|
+
} from "./chunk-HYUGYB23.js";
|
|
97
|
+
import "./chunk-XCMR2HTV.js";
|
|
98
|
+
import {
|
|
99
|
+
useRegions
|
|
100
|
+
} from "./chunk-CI5Z6FGV.js";
|
|
101
|
+
import {
|
|
102
|
+
useStore
|
|
103
|
+
} from "./chunk-LCZXAT4Q.js";
|
|
104
|
+
import {
|
|
105
|
+
usePricePreferences
|
|
106
|
+
} from "./chunk-S6LPCNXQ.js";
|
|
107
|
+
import {
|
|
108
|
+
useCreateProduct
|
|
109
|
+
} from "./chunk-T435NFHC.js";
|
|
110
|
+
import "./chunk-2KCF3ZIB.js";
|
|
111
|
+
import {
|
|
112
|
+
sdk
|
|
113
|
+
} from "./chunk-ZYNBKBY3.js";
|
|
114
|
+
import "./chunk-NBMM2TZK.js";
|
|
115
|
+
|
|
116
|
+
// src/pages/products/product-create/product-create.tsx
|
|
117
|
+
import { useTranslation as useTranslation10 } from "react-i18next";
|
|
118
|
+
|
|
119
|
+
// src/pages/products/product-create/components/product-create-form/product-create-form.tsx
|
|
120
|
+
import { Button as Button5, ProgressTabs, toast } from "@medusajs/ui";
|
|
121
|
+
import { useEffect as useEffect2, useMemo as useMemo4, useState as useState4 } from "react";
|
|
122
|
+
import { useForm, useWatch as useWatch4 } from "react-hook-form";
|
|
123
|
+
import { useTranslation as useTranslation9 } from "react-i18next";
|
|
124
|
+
|
|
125
|
+
// src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx
|
|
126
|
+
import { Divider, Heading as Heading2 } from "@medusajs/ui";
|
|
127
|
+
import { useTranslation as useTranslation4 } from "react-i18next";
|
|
128
|
+
|
|
129
|
+
// src/pages/products/product-create/components/product-create-details-form/components/product-create-details-general-section/product-create-general-section.tsx
|
|
130
|
+
import { Input, Textarea } from "@medusajs/ui";
|
|
131
|
+
import { useTranslation } from "react-i18next";
|
|
132
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
133
|
+
var ProductCreateGeneralSection = ({
|
|
134
|
+
form
|
|
135
|
+
}) => {
|
|
136
|
+
const { t } = useTranslation();
|
|
137
|
+
return /* @__PURE__ */ jsxs("div", { id: "general", className: "flex flex-col gap-y-6", "data-testid": "product-create-general-section", children: [
|
|
138
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-2", "data-testid": "product-create-general-section-fields", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-3", "data-testid": "product-create-general-section-title-fields", children: [
|
|
139
|
+
/* @__PURE__ */ jsx(
|
|
140
|
+
Form.Field,
|
|
141
|
+
{
|
|
142
|
+
control: form.control,
|
|
143
|
+
name: "title",
|
|
144
|
+
render: ({ field }) => {
|
|
145
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "product-create-general-section-title-item", children: [
|
|
146
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "product-create-general-section-title-label", children: t("products.fields.title.label") }),
|
|
147
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "product-create-general-section-title-control", children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: t("products.fields.title.placeholder"), "data-testid": "product-create-general-section-title-input" }) })
|
|
148
|
+
] });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
Form.Field,
|
|
154
|
+
{
|
|
155
|
+
control: form.control,
|
|
156
|
+
name: "subtitle",
|
|
157
|
+
render: ({ field }) => {
|
|
158
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "product-create-general-section-subtitle-item", children: [
|
|
159
|
+
/* @__PURE__ */ jsx(Form.Label, { optional: true, "data-testid": "product-create-general-section-subtitle-label", children: t("products.fields.subtitle.label") }),
|
|
160
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "product-create-general-section-subtitle-control", children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: t("products.fields.subtitle.placeholder"), "data-testid": "product-create-general-section-subtitle-input" }) })
|
|
161
|
+
] });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
Form.Field,
|
|
167
|
+
{
|
|
168
|
+
control: form.control,
|
|
169
|
+
name: "handle",
|
|
170
|
+
render: ({ field }) => {
|
|
171
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "product-create-general-section-handle-item", children: [
|
|
172
|
+
/* @__PURE__ */ jsx(
|
|
173
|
+
Form.Label,
|
|
174
|
+
{
|
|
175
|
+
tooltip: t("products.fields.handle.tooltip"),
|
|
176
|
+
optional: true,
|
|
177
|
+
"data-testid": "product-create-general-section-handle-label",
|
|
178
|
+
children: t("fields.handle")
|
|
179
|
+
}
|
|
180
|
+
),
|
|
181
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "product-create-general-section-handle-control", children: /* @__PURE__ */ jsx(HandleInput, { ...field, placeholder: t("products.fields.handle.placeholder"), "data-testid": "product-create-general-section-handle-input" }) })
|
|
182
|
+
] });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] }) }),
|
|
187
|
+
/* @__PURE__ */ jsx(
|
|
188
|
+
Form.Field,
|
|
189
|
+
{
|
|
190
|
+
control: form.control,
|
|
191
|
+
name: "description",
|
|
192
|
+
render: ({ field }) => {
|
|
193
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "product-create-general-section-description-item", children: [
|
|
194
|
+
/* @__PURE__ */ jsx(Form.Label, { optional: true, "data-testid": "product-create-general-section-description-label", children: t("products.fields.description.label") }),
|
|
195
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "product-create-general-section-description-control", children: /* @__PURE__ */ jsx(Textarea, { ...field, placeholder: t("products.fields.description.placeholder"), "data-testid": "product-create-general-section-description-input" }) })
|
|
196
|
+
] });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] });
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// src/pages/products/product-create/components/product-create-details-form/components/product-create-details-media-section/product-create-details-media-section.tsx
|
|
204
|
+
import {
|
|
205
|
+
defaultDropAnimationSideEffects,
|
|
206
|
+
DndContext,
|
|
207
|
+
DragOverlay,
|
|
208
|
+
KeyboardSensor,
|
|
209
|
+
PointerSensor,
|
|
210
|
+
useSensor,
|
|
211
|
+
useSensors
|
|
212
|
+
} from "@dnd-kit/core";
|
|
213
|
+
import {
|
|
214
|
+
arrayMove,
|
|
215
|
+
SortableContext,
|
|
216
|
+
sortableKeyboardCoordinates,
|
|
217
|
+
useSortable
|
|
218
|
+
} from "@dnd-kit/sortable";
|
|
219
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
220
|
+
import {
|
|
221
|
+
DotsSix,
|
|
222
|
+
StackPerspective,
|
|
223
|
+
ThumbnailBadge,
|
|
224
|
+
Trash,
|
|
225
|
+
XMark
|
|
226
|
+
} from "@medusajs/icons";
|
|
227
|
+
import { IconButton, Text } from "@medusajs/ui";
|
|
228
|
+
import { useState } from "react";
|
|
229
|
+
import { useFieldArray } from "react-hook-form";
|
|
230
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
231
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
232
|
+
var dropAnimationConfig = {
|
|
233
|
+
sideEffects: defaultDropAnimationSideEffects({
|
|
234
|
+
styles: {
|
|
235
|
+
active: {
|
|
236
|
+
opacity: "0.4"
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
};
|
|
241
|
+
var ProductCreateMediaSection = ({
|
|
242
|
+
form
|
|
243
|
+
}) => {
|
|
244
|
+
const { fields, append, remove } = useFieldArray({
|
|
245
|
+
name: "media",
|
|
246
|
+
control: form.control,
|
|
247
|
+
keyName: "field_id"
|
|
248
|
+
});
|
|
249
|
+
const [activeId, setActiveId] = useState(null);
|
|
250
|
+
const sensors = useSensors(
|
|
251
|
+
useSensor(PointerSensor),
|
|
252
|
+
useSensor(KeyboardSensor, {
|
|
253
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
254
|
+
})
|
|
255
|
+
);
|
|
256
|
+
const handleDragStart = (event) => {
|
|
257
|
+
setActiveId(event.active.id);
|
|
258
|
+
};
|
|
259
|
+
const handleDragEnd = (event) => {
|
|
260
|
+
setActiveId(null);
|
|
261
|
+
const { active, over } = event;
|
|
262
|
+
if (active.id !== over?.id) {
|
|
263
|
+
const oldIndex = fields.findIndex((item) => item.field_id === active.id);
|
|
264
|
+
const newIndex = fields.findIndex((item) => item.field_id === over?.id);
|
|
265
|
+
form.setValue("media", arrayMove(fields, oldIndex, newIndex), {
|
|
266
|
+
shouldDirty: true,
|
|
267
|
+
shouldTouch: true
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const handleDragCancel = () => {
|
|
272
|
+
setActiveId(null);
|
|
273
|
+
};
|
|
274
|
+
const getOnDelete = (index) => {
|
|
275
|
+
return () => {
|
|
276
|
+
remove(index);
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
const getMakeThumbnail = (index) => {
|
|
280
|
+
return () => {
|
|
281
|
+
const newFields = fields.map((field, i) => {
|
|
282
|
+
return {
|
|
283
|
+
...field,
|
|
284
|
+
isThumbnail: i === index
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
form.setValue("media", newFields, {
|
|
288
|
+
shouldDirty: true,
|
|
289
|
+
shouldTouch: true
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
const getItemHandlers = (index) => {
|
|
294
|
+
return {
|
|
295
|
+
onDelete: getOnDelete(index),
|
|
296
|
+
onMakeThumbnail: getMakeThumbnail(index)
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
return /* @__PURE__ */ jsxs2("div", { id: "media", className: "flex flex-col gap-y-2", "data-testid": "product-create-media-section", children: [
|
|
300
|
+
/* @__PURE__ */ jsx2(UploadMediaFormItem, { form, append, showHint: false, "data-testid": "product-create-media-section-upload" }),
|
|
301
|
+
/* @__PURE__ */ jsxs2(
|
|
302
|
+
DndContext,
|
|
303
|
+
{
|
|
304
|
+
sensors,
|
|
305
|
+
onDragEnd: handleDragEnd,
|
|
306
|
+
onDragStart: handleDragStart,
|
|
307
|
+
onDragCancel: handleDragCancel,
|
|
308
|
+
children: [
|
|
309
|
+
/* @__PURE__ */ jsx2(DragOverlay, { dropAnimation: dropAnimationConfig, children: activeId ? /* @__PURE__ */ jsx2(
|
|
310
|
+
MediaGridItemOverlay,
|
|
311
|
+
{
|
|
312
|
+
field: fields.find((m) => m.field_id === activeId)
|
|
313
|
+
}
|
|
314
|
+
) : null }),
|
|
315
|
+
/* @__PURE__ */ jsx2("ul", { className: "flex flex-col gap-y-2", "data-testid": "product-create-media-section-list", children: /* @__PURE__ */ jsx2(SortableContext, { items: fields.map((field) => field.field_id), children: fields.map((field, index) => {
|
|
316
|
+
const { onDelete, onMakeThumbnail } = getItemHandlers(index);
|
|
317
|
+
return /* @__PURE__ */ jsx2(
|
|
318
|
+
MediaItem,
|
|
319
|
+
{
|
|
320
|
+
field,
|
|
321
|
+
onDelete,
|
|
322
|
+
onMakeThumbnail
|
|
323
|
+
},
|
|
324
|
+
field.field_id
|
|
325
|
+
);
|
|
326
|
+
}) }) })
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
)
|
|
330
|
+
] });
|
|
331
|
+
};
|
|
332
|
+
var MediaItem = ({ field, onDelete, onMakeThumbnail }) => {
|
|
333
|
+
const { t } = useTranslation2();
|
|
334
|
+
const {
|
|
335
|
+
attributes,
|
|
336
|
+
listeners,
|
|
337
|
+
setNodeRef,
|
|
338
|
+
setActivatorNodeRef,
|
|
339
|
+
transform,
|
|
340
|
+
transition,
|
|
341
|
+
isDragging
|
|
342
|
+
} = useSortable({ id: field.field_id });
|
|
343
|
+
const style = {
|
|
344
|
+
opacity: isDragging ? 0.4 : void 0,
|
|
345
|
+
transform: CSS.Translate.toString(transform),
|
|
346
|
+
transition
|
|
347
|
+
};
|
|
348
|
+
if (!field.file) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
return /* @__PURE__ */ jsxs2(
|
|
352
|
+
"li",
|
|
353
|
+
{
|
|
354
|
+
className: "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
355
|
+
ref: setNodeRef,
|
|
356
|
+
style,
|
|
357
|
+
"data-testid": `product-create-media-section-item-${field.field_id}`,
|
|
358
|
+
children: [
|
|
359
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
|
|
360
|
+
/* @__PURE__ */ jsx2(
|
|
361
|
+
IconButton,
|
|
362
|
+
{
|
|
363
|
+
variant: "transparent",
|
|
364
|
+
type: "button",
|
|
365
|
+
size: "small",
|
|
366
|
+
...attributes,
|
|
367
|
+
...listeners,
|
|
368
|
+
ref: setActivatorNodeRef,
|
|
369
|
+
className: "cursor-grab touch-none active:cursor-grabbing",
|
|
370
|
+
children: /* @__PURE__ */ jsx2(DotsSix, { className: "text-ui-fg-muted" })
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-3", children: [
|
|
374
|
+
/* @__PURE__ */ jsx2("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx2(ThumbnailPreview, { url: field.url }) }),
|
|
375
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
|
|
376
|
+
/* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: field.file.name }),
|
|
377
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-1", children: [
|
|
378
|
+
field.isThumbnail && /* @__PURE__ */ jsx2(ThumbnailBadge, {}),
|
|
379
|
+
/* @__PURE__ */ jsx2(
|
|
380
|
+
Text,
|
|
381
|
+
{
|
|
382
|
+
size: "xsmall",
|
|
383
|
+
leading: "compact",
|
|
384
|
+
className: "text-ui-fg-subtle",
|
|
385
|
+
children: formatFileSize(field.file.size)
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
] })
|
|
389
|
+
] })
|
|
390
|
+
] })
|
|
391
|
+
] }),
|
|
392
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-1", children: [
|
|
393
|
+
/* @__PURE__ */ jsx2(
|
|
394
|
+
ActionMenu,
|
|
395
|
+
{
|
|
396
|
+
groups: [
|
|
397
|
+
{
|
|
398
|
+
actions: [
|
|
399
|
+
{
|
|
400
|
+
label: t("products.media.makeThumbnail"),
|
|
401
|
+
icon: /* @__PURE__ */ jsx2(StackPerspective, {}),
|
|
402
|
+
onClick: onMakeThumbnail
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
actions: [
|
|
408
|
+
{
|
|
409
|
+
icon: /* @__PURE__ */ jsx2(Trash, {}),
|
|
410
|
+
label: t("actions.delete"),
|
|
411
|
+
onClick: onDelete
|
|
412
|
+
}
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
],
|
|
416
|
+
"data-testid": `product-create-media-section-item-menu-${field.field_id}`
|
|
417
|
+
}
|
|
418
|
+
),
|
|
419
|
+
/* @__PURE__ */ jsx2(
|
|
420
|
+
IconButton,
|
|
421
|
+
{
|
|
422
|
+
type: "button",
|
|
423
|
+
size: "small",
|
|
424
|
+
variant: "transparent",
|
|
425
|
+
onClick: onDelete,
|
|
426
|
+
"data-testid": `product-create-media-section-item-delete-${field.field_id}`,
|
|
427
|
+
children: /* @__PURE__ */ jsx2(XMark, {})
|
|
428
|
+
}
|
|
429
|
+
)
|
|
430
|
+
] })
|
|
431
|
+
]
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
};
|
|
435
|
+
var MediaGridItemOverlay = ({ field }) => {
|
|
436
|
+
return /* @__PURE__ */ jsxs2("li", { className: "bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2", children: [
|
|
437
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
|
|
438
|
+
/* @__PURE__ */ jsx2(
|
|
439
|
+
IconButton,
|
|
440
|
+
{
|
|
441
|
+
variant: "transparent",
|
|
442
|
+
size: "small",
|
|
443
|
+
className: "cursor-grab touch-none active:cursor-grabbing",
|
|
444
|
+
children: /* @__PURE__ */ jsx2(DotsSix, { className: "text-ui-fg-muted" })
|
|
445
|
+
}
|
|
446
|
+
),
|
|
447
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-3", children: [
|
|
448
|
+
/* @__PURE__ */ jsx2("div", { className: "bg-ui-bg-base h-10 w-[30px] overflow-hidden rounded-md", children: /* @__PURE__ */ jsx2(ThumbnailPreview, { url: field.url }) }),
|
|
449
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
|
|
450
|
+
/* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", children: field.file?.name }),
|
|
451
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-1", children: [
|
|
452
|
+
field.isThumbnail && /* @__PURE__ */ jsx2(ThumbnailBadge, {}),
|
|
453
|
+
/* @__PURE__ */ jsx2(
|
|
454
|
+
Text,
|
|
455
|
+
{
|
|
456
|
+
size: "xsmall",
|
|
457
|
+
leading: "compact",
|
|
458
|
+
className: "text-ui-fg-subtle",
|
|
459
|
+
children: formatFileSize(field.file?.size ?? 0)
|
|
460
|
+
}
|
|
461
|
+
)
|
|
462
|
+
] })
|
|
463
|
+
] })
|
|
464
|
+
] })
|
|
465
|
+
] }),
|
|
466
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-1", children: [
|
|
467
|
+
/* @__PURE__ */ jsx2(ActionMenu, { groups: [] }),
|
|
468
|
+
/* @__PURE__ */ jsx2(
|
|
469
|
+
IconButton,
|
|
470
|
+
{
|
|
471
|
+
type: "button",
|
|
472
|
+
size: "small",
|
|
473
|
+
variant: "transparent",
|
|
474
|
+
onClick: () => {
|
|
475
|
+
},
|
|
476
|
+
children: /* @__PURE__ */ jsx2(XMark, {})
|
|
477
|
+
}
|
|
478
|
+
)
|
|
479
|
+
] })
|
|
480
|
+
] });
|
|
481
|
+
};
|
|
482
|
+
var ThumbnailPreview = ({ url }) => {
|
|
483
|
+
if (!url) {
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
return /* @__PURE__ */ jsx2("img", { src: url, alt: "", className: "size-full object-cover object-center" });
|
|
487
|
+
};
|
|
488
|
+
function formatFileSize(bytes, decimalPlaces = 2) {
|
|
489
|
+
if (bytes === 0) {
|
|
490
|
+
return "0 Bytes";
|
|
491
|
+
}
|
|
492
|
+
const k = 1024;
|
|
493
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
494
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
495
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPlaces)) + " " + sizes[i];
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// src/pages/products/product-create/components/product-create-details-form/components/product-create-details-variant-section/product-create-details-variant-section.tsx
|
|
499
|
+
import { XMarkMini } from "@medusajs/icons";
|
|
500
|
+
import {
|
|
501
|
+
Alert,
|
|
502
|
+
Button,
|
|
503
|
+
Checkbox,
|
|
504
|
+
clx as clx2,
|
|
505
|
+
Heading,
|
|
506
|
+
Hint,
|
|
507
|
+
IconButton as IconButton3,
|
|
508
|
+
InlineTip,
|
|
509
|
+
Input as Input2,
|
|
510
|
+
Label,
|
|
511
|
+
Text as Text2
|
|
512
|
+
} from "@medusajs/ui";
|
|
513
|
+
import {
|
|
514
|
+
Controller,
|
|
515
|
+
useFieldArray as useFieldArray2,
|
|
516
|
+
useWatch
|
|
517
|
+
} from "react-hook-form";
|
|
518
|
+
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
519
|
+
|
|
520
|
+
// src/components/common/sortable-list/sortable-list.tsx
|
|
521
|
+
import {
|
|
522
|
+
DndContext as DndContext2,
|
|
523
|
+
DragOverlay as DragOverlay2,
|
|
524
|
+
KeyboardSensor as KeyboardSensor2,
|
|
525
|
+
PointerSensor as PointerSensor2,
|
|
526
|
+
defaultDropAnimationSideEffects as defaultDropAnimationSideEffects2,
|
|
527
|
+
useSensor as useSensor2,
|
|
528
|
+
useSensors as useSensors2
|
|
529
|
+
} from "@dnd-kit/core";
|
|
530
|
+
import {
|
|
531
|
+
SortableContext as SortableContext2,
|
|
532
|
+
arrayMove as arrayMove2,
|
|
533
|
+
sortableKeyboardCoordinates as sortableKeyboardCoordinates2,
|
|
534
|
+
useSortable as useSortable2
|
|
535
|
+
} from "@dnd-kit/sortable";
|
|
536
|
+
import { CSS as CSS2 } from "@dnd-kit/utilities";
|
|
537
|
+
import { DotsSix as DotsSix2 } from "@medusajs/icons";
|
|
538
|
+
import { IconButton as IconButton2, clx } from "@medusajs/ui";
|
|
539
|
+
import {
|
|
540
|
+
Fragment,
|
|
541
|
+
createContext,
|
|
542
|
+
useContext,
|
|
543
|
+
useMemo,
|
|
544
|
+
useState as useState2
|
|
545
|
+
} from "react";
|
|
546
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
547
|
+
var List = ({
|
|
548
|
+
items,
|
|
549
|
+
onChange,
|
|
550
|
+
renderItem
|
|
551
|
+
}) => {
|
|
552
|
+
const [active, setActive] = useState2(null);
|
|
553
|
+
const [activeItem, activeIndex] = useMemo(() => {
|
|
554
|
+
if (active === null) {
|
|
555
|
+
return [null, null];
|
|
556
|
+
}
|
|
557
|
+
const index = items.findIndex(({ id }) => id === active.id);
|
|
558
|
+
return [items[index], index];
|
|
559
|
+
}, [active, items]);
|
|
560
|
+
const sensors = useSensors2(
|
|
561
|
+
useSensor2(PointerSensor2),
|
|
562
|
+
useSensor2(KeyboardSensor2, {
|
|
563
|
+
coordinateGetter: sortableKeyboardCoordinates2
|
|
564
|
+
})
|
|
565
|
+
);
|
|
566
|
+
const handleDragStart = ({ active: active2 }) => {
|
|
567
|
+
setActive(active2);
|
|
568
|
+
};
|
|
569
|
+
const handleDragEnd = ({ active: active2, over }) => {
|
|
570
|
+
if (over && active2.id !== over.id) {
|
|
571
|
+
const activeIndex2 = items.findIndex(({ id }) => id === active2.id);
|
|
572
|
+
const overIndex = items.findIndex(({ id }) => id === over.id);
|
|
573
|
+
onChange(arrayMove2(items, activeIndex2, overIndex));
|
|
574
|
+
}
|
|
575
|
+
setActive(null);
|
|
576
|
+
};
|
|
577
|
+
const handleDragCancel = () => {
|
|
578
|
+
setActive(null);
|
|
579
|
+
};
|
|
580
|
+
return /* @__PURE__ */ jsxs3(
|
|
581
|
+
DndContext2,
|
|
582
|
+
{
|
|
583
|
+
sensors,
|
|
584
|
+
onDragStart: handleDragStart,
|
|
585
|
+
onDragEnd: handleDragEnd,
|
|
586
|
+
onDragCancel: handleDragCancel,
|
|
587
|
+
children: [
|
|
588
|
+
/* @__PURE__ */ jsx3(Overlay, { children: activeItem && activeIndex !== null ? renderItem(activeItem, activeIndex) : null }),
|
|
589
|
+
/* @__PURE__ */ jsx3(SortableContext2, { items, children: /* @__PURE__ */ jsx3(
|
|
590
|
+
"ul",
|
|
591
|
+
{
|
|
592
|
+
role: "application",
|
|
593
|
+
className: "flex list-inside list-none list-image-none flex-col p-0",
|
|
594
|
+
children: items.map((item, index) => /* @__PURE__ */ jsx3(Fragment, { children: renderItem(item, index) }, item.id))
|
|
595
|
+
}
|
|
596
|
+
) })
|
|
597
|
+
]
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
};
|
|
601
|
+
var dropAnimationConfig2 = {
|
|
602
|
+
sideEffects: defaultDropAnimationSideEffects2({
|
|
603
|
+
styles: {
|
|
604
|
+
active: {
|
|
605
|
+
opacity: "0.4"
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
})
|
|
609
|
+
};
|
|
610
|
+
var Overlay = ({ children }) => {
|
|
611
|
+
return /* @__PURE__ */ jsx3(
|
|
612
|
+
DragOverlay2,
|
|
613
|
+
{
|
|
614
|
+
className: "shadow-elevation-card-hover overflow-hidden rounded-md [&>li]:border-b-0",
|
|
615
|
+
dropAnimation: dropAnimationConfig2,
|
|
616
|
+
children
|
|
617
|
+
}
|
|
618
|
+
);
|
|
619
|
+
};
|
|
620
|
+
var SortableItemContext = createContext(null);
|
|
621
|
+
var useSortableItemContext = () => {
|
|
622
|
+
const context = useContext(SortableItemContext);
|
|
623
|
+
if (!context) {
|
|
624
|
+
throw new Error(
|
|
625
|
+
"useSortableItemContext must be used within a SortableItemContext"
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
return context;
|
|
629
|
+
};
|
|
630
|
+
var Item = ({
|
|
631
|
+
id,
|
|
632
|
+
className,
|
|
633
|
+
children
|
|
634
|
+
}) => {
|
|
635
|
+
const {
|
|
636
|
+
attributes,
|
|
637
|
+
isDragging,
|
|
638
|
+
listeners,
|
|
639
|
+
setNodeRef,
|
|
640
|
+
setActivatorNodeRef,
|
|
641
|
+
transform,
|
|
642
|
+
transition
|
|
643
|
+
} = useSortable2({ id });
|
|
644
|
+
const context = useMemo(
|
|
645
|
+
() => ({
|
|
646
|
+
attributes,
|
|
647
|
+
listeners,
|
|
648
|
+
ref: setActivatorNodeRef,
|
|
649
|
+
isDragging
|
|
650
|
+
}),
|
|
651
|
+
[attributes, listeners, setActivatorNodeRef, isDragging]
|
|
652
|
+
);
|
|
653
|
+
const style = {
|
|
654
|
+
opacity: isDragging ? 0.4 : void 0,
|
|
655
|
+
transform: CSS2.Translate.toString(transform),
|
|
656
|
+
transition
|
|
657
|
+
};
|
|
658
|
+
return /* @__PURE__ */ jsx3(SortableItemContext.Provider, { value: context, children: /* @__PURE__ */ jsx3(
|
|
659
|
+
"li",
|
|
660
|
+
{
|
|
661
|
+
className: clx("transition-fg flex flex-1 list-none", className),
|
|
662
|
+
ref: setNodeRef,
|
|
663
|
+
style,
|
|
664
|
+
children
|
|
665
|
+
}
|
|
666
|
+
) });
|
|
667
|
+
};
|
|
668
|
+
var DragHandle = () => {
|
|
669
|
+
const { attributes, listeners, ref } = useSortableItemContext();
|
|
670
|
+
return /* @__PURE__ */ jsx3(
|
|
671
|
+
IconButton2,
|
|
672
|
+
{
|
|
673
|
+
variant: "transparent",
|
|
674
|
+
size: "small",
|
|
675
|
+
...attributes,
|
|
676
|
+
...listeners,
|
|
677
|
+
ref,
|
|
678
|
+
className: "cursor-grab touch-none active:cursor-grabbing",
|
|
679
|
+
children: /* @__PURE__ */ jsx3(DotsSix2, { className: "text-ui-fg-muted" })
|
|
680
|
+
}
|
|
681
|
+
);
|
|
682
|
+
};
|
|
683
|
+
var SortableList = Object.assign(List, {
|
|
684
|
+
Item,
|
|
685
|
+
DragHandle
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
// src/pages/products/product-create/components/product-create-details-form/components/product-create-details-variant-section/product-create-details-variant-section.tsx
|
|
689
|
+
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
690
|
+
var getPermutations = (data) => {
|
|
691
|
+
if (data.length === 0) {
|
|
692
|
+
return [];
|
|
693
|
+
}
|
|
694
|
+
if (data.length === 1) {
|
|
695
|
+
return data[0].values.map((value) => ({ [data[0].title]: value }));
|
|
696
|
+
}
|
|
697
|
+
const toProcess = data[0];
|
|
698
|
+
const rest = data.slice(1);
|
|
699
|
+
return toProcess.values.flatMap((value) => {
|
|
700
|
+
return getPermutations(rest).map((permutation) => {
|
|
701
|
+
return {
|
|
702
|
+
[toProcess.title]: value,
|
|
703
|
+
...permutation
|
|
704
|
+
};
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
};
|
|
708
|
+
var getVariantName = (options) => {
|
|
709
|
+
return Object.values(options).join(" / ");
|
|
710
|
+
};
|
|
711
|
+
var ProductCreateVariantsSection = ({
|
|
712
|
+
form
|
|
713
|
+
}) => {
|
|
714
|
+
const { t } = useTranslation3();
|
|
715
|
+
const options = useFieldArray2({
|
|
716
|
+
control: form.control,
|
|
717
|
+
name: "options"
|
|
718
|
+
});
|
|
719
|
+
const variants = useFieldArray2({
|
|
720
|
+
control: form.control,
|
|
721
|
+
name: "variants"
|
|
722
|
+
});
|
|
723
|
+
const watchedAreVariantsEnabled = useWatch({
|
|
724
|
+
control: form.control,
|
|
725
|
+
name: "enable_variants",
|
|
726
|
+
defaultValue: false
|
|
727
|
+
});
|
|
728
|
+
const watchedOptions = useWatch({
|
|
729
|
+
control: form.control,
|
|
730
|
+
name: "options",
|
|
731
|
+
defaultValue: []
|
|
732
|
+
});
|
|
733
|
+
const watchedVariants = useWatch({
|
|
734
|
+
control: form.control,
|
|
735
|
+
name: "variants",
|
|
736
|
+
defaultValue: []
|
|
737
|
+
});
|
|
738
|
+
const showInvalidOptionsMessage = !!form.formState.errors.options?.length;
|
|
739
|
+
const showInvalidVariantsMessage = form.formState.errors.variants?.root?.message === "invalid_length";
|
|
740
|
+
const handleOptionValueUpdate = (index, value) => {
|
|
741
|
+
const { isTouched: hasUserSelectedVariants } = form.getFieldState("variants");
|
|
742
|
+
const newOptions = [...watchedOptions];
|
|
743
|
+
newOptions[index].values = value;
|
|
744
|
+
const permutations = getPermutations(
|
|
745
|
+
newOptions.filter(({ values }) => values.length)
|
|
746
|
+
);
|
|
747
|
+
const oldVariants = [...watchedVariants];
|
|
748
|
+
const findMatchingPermutation = (options2) => {
|
|
749
|
+
return permutations.find(
|
|
750
|
+
(permutation) => Object.keys(options2).every((key) => options2[key] === permutation[key])
|
|
751
|
+
);
|
|
752
|
+
};
|
|
753
|
+
const newVariants = oldVariants.reduce((variants2, variant) => {
|
|
754
|
+
const match = findMatchingPermutation(variant.options);
|
|
755
|
+
if (match) {
|
|
756
|
+
variants2.push({
|
|
757
|
+
...variant,
|
|
758
|
+
title: getVariantName(match),
|
|
759
|
+
options: match
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
return variants2;
|
|
763
|
+
}, []);
|
|
764
|
+
const usedPermutations = new Set(
|
|
765
|
+
newVariants.map((variant) => variant.options)
|
|
766
|
+
);
|
|
767
|
+
const unusedPermutations = permutations.filter(
|
|
768
|
+
(permutation) => !usedPermutations.has(permutation)
|
|
769
|
+
);
|
|
770
|
+
unusedPermutations.forEach((permutation) => {
|
|
771
|
+
newVariants.push({
|
|
772
|
+
title: getVariantName(permutation),
|
|
773
|
+
options: permutation,
|
|
774
|
+
should_create: hasUserSelectedVariants ? false : true,
|
|
775
|
+
variant_rank: newVariants.length,
|
|
776
|
+
// NOTE - prepare inventory array here for now so we prevent rendering issue if we append the items later
|
|
777
|
+
inventory: [{ inventory_item_id: "", required_quantity: "" }]
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
form.setValue("variants", newVariants);
|
|
781
|
+
};
|
|
782
|
+
const handleRemoveOption = (index) => {
|
|
783
|
+
if (index === 0) {
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
options.remove(index);
|
|
787
|
+
const newOptions = [...watchedOptions];
|
|
788
|
+
newOptions.splice(index, 1);
|
|
789
|
+
const validOptionTitles = new Set(newOptions.map((option) => option.title));
|
|
790
|
+
const permutations = getPermutations(newOptions);
|
|
791
|
+
const oldVariants = [...watchedVariants];
|
|
792
|
+
const newVariants = permutations.reduce((variants2, permutation) => {
|
|
793
|
+
const variant = oldVariants.find(
|
|
794
|
+
({ options: options2 }) => Object.keys(options2).filter((option) => validOptionTitles.has(option)).every((key) => options2[key] === permutation[key])
|
|
795
|
+
);
|
|
796
|
+
if (variant) {
|
|
797
|
+
variants2.push({
|
|
798
|
+
...variant,
|
|
799
|
+
title: variant.title,
|
|
800
|
+
options: permutation
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
return variants2;
|
|
804
|
+
}, []);
|
|
805
|
+
form.setValue("variants", newVariants);
|
|
806
|
+
};
|
|
807
|
+
const handleRankChange = (items) => {
|
|
808
|
+
const update = items.map((item, index) => {
|
|
809
|
+
const variant = watchedVariants.find((v) => v.title === item.title);
|
|
810
|
+
return {
|
|
811
|
+
id: item.id,
|
|
812
|
+
...variant || item,
|
|
813
|
+
variant_rank: index
|
|
814
|
+
};
|
|
815
|
+
});
|
|
816
|
+
variants.replace(update);
|
|
817
|
+
};
|
|
818
|
+
const getCheckboxState = (variants2) => {
|
|
819
|
+
if (variants2.every((variant) => variant.should_create)) {
|
|
820
|
+
return true;
|
|
821
|
+
}
|
|
822
|
+
if (variants2.some((variant) => variant.should_create)) {
|
|
823
|
+
return "indeterminate";
|
|
824
|
+
}
|
|
825
|
+
return false;
|
|
826
|
+
};
|
|
827
|
+
const onCheckboxChange = (value) => {
|
|
828
|
+
switch (value) {
|
|
829
|
+
case true: {
|
|
830
|
+
const update = watchedVariants.map((variant) => {
|
|
831
|
+
return {
|
|
832
|
+
...variant,
|
|
833
|
+
should_create: true
|
|
834
|
+
};
|
|
835
|
+
});
|
|
836
|
+
form.setValue("variants", update);
|
|
837
|
+
break;
|
|
838
|
+
}
|
|
839
|
+
case false: {
|
|
840
|
+
const update = watchedVariants.map((variant) => {
|
|
841
|
+
return {
|
|
842
|
+
...variant,
|
|
843
|
+
should_create: false
|
|
844
|
+
};
|
|
845
|
+
});
|
|
846
|
+
form.setValue("variants", decorateVariantsWithDefaultValues(update));
|
|
847
|
+
break;
|
|
848
|
+
}
|
|
849
|
+
case "indeterminate":
|
|
850
|
+
break;
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
const createDefaultOptionAndVariant = () => {
|
|
854
|
+
form.setValue("options", [
|
|
855
|
+
{
|
|
856
|
+
title: "Default option",
|
|
857
|
+
values: ["Default option value"]
|
|
858
|
+
}
|
|
859
|
+
]);
|
|
860
|
+
form.setValue(
|
|
861
|
+
"variants",
|
|
862
|
+
decorateVariantsWithDefaultValues([
|
|
863
|
+
{
|
|
864
|
+
title: "Default variant",
|
|
865
|
+
should_create: true,
|
|
866
|
+
variant_rank: 0,
|
|
867
|
+
options: {
|
|
868
|
+
"Default option": "Default option value"
|
|
869
|
+
},
|
|
870
|
+
inventory: [{ inventory_item_id: "", required_quantity: "" }],
|
|
871
|
+
is_default: true
|
|
872
|
+
}
|
|
873
|
+
])
|
|
874
|
+
);
|
|
875
|
+
};
|
|
876
|
+
return /* @__PURE__ */ jsxs4("div", { id: "variants", className: "flex flex-col gap-y-8", "data-testid": "product-create-variants-section", children: [
|
|
877
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-y-6", "data-testid": "product-create-variants-section-header", children: [
|
|
878
|
+
/* @__PURE__ */ jsx4(Heading, { level: "h2", "data-testid": "product-create-variants-section-heading", children: t("products.create.variants.header") }),
|
|
879
|
+
/* @__PURE__ */ jsx4(
|
|
880
|
+
SwitchBox,
|
|
881
|
+
{
|
|
882
|
+
control: form.control,
|
|
883
|
+
name: "enable_variants",
|
|
884
|
+
label: t("products.create.variants.subHeadingTitle"),
|
|
885
|
+
description: t("products.create.variants.subHeadingDescription"),
|
|
886
|
+
"data-testid": "product-create-variants-section-enable-switch",
|
|
887
|
+
onCheckedChange: (checked) => {
|
|
888
|
+
if (checked) {
|
|
889
|
+
form.setValue("options", [
|
|
890
|
+
{
|
|
891
|
+
title: "",
|
|
892
|
+
values: []
|
|
893
|
+
}
|
|
894
|
+
]);
|
|
895
|
+
form.setValue("variants", []);
|
|
896
|
+
} else {
|
|
897
|
+
createDefaultOptionAndVariant();
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
)
|
|
902
|
+
] }),
|
|
903
|
+
watchedAreVariantsEnabled && /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
904
|
+
/* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx4(
|
|
905
|
+
Form.Field,
|
|
906
|
+
{
|
|
907
|
+
control: form.control,
|
|
908
|
+
name: "options",
|
|
909
|
+
render: () => {
|
|
910
|
+
return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-y-6", children: [
|
|
911
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-start justify-between gap-x-4", children: [
|
|
912
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
|
|
913
|
+
/* @__PURE__ */ jsx4(Form.Label, { children: t("products.create.variants.productOptions.label") }),
|
|
914
|
+
/* @__PURE__ */ jsx4(Form.Hint, { children: t("products.create.variants.productOptions.hint") })
|
|
915
|
+
] }),
|
|
916
|
+
/* @__PURE__ */ jsx4(
|
|
917
|
+
Button,
|
|
918
|
+
{
|
|
919
|
+
size: "small",
|
|
920
|
+
variant: "secondary",
|
|
921
|
+
type: "button",
|
|
922
|
+
onClick: () => {
|
|
923
|
+
options.append({
|
|
924
|
+
title: "",
|
|
925
|
+
values: []
|
|
926
|
+
});
|
|
927
|
+
},
|
|
928
|
+
"data-testid": "product-create-variants-section-add-option-button",
|
|
929
|
+
children: t("actions.add")
|
|
930
|
+
}
|
|
931
|
+
)
|
|
932
|
+
] }),
|
|
933
|
+
showInvalidOptionsMessage && /* @__PURE__ */ jsx4(Alert, { dismissible: true, variant: "error", "data-testid": "product-create-variants-section-options-error", children: t("products.create.errors.options") }),
|
|
934
|
+
/* @__PURE__ */ jsx4("ul", { className: "flex flex-col gap-y-4", "data-testid": "product-create-variants-section-options-list", children: options.fields.map((option, index) => {
|
|
935
|
+
const hasError = !!form.formState.errors.options?.[index];
|
|
936
|
+
return /* @__PURE__ */ jsxs4(
|
|
937
|
+
"li",
|
|
938
|
+
{
|
|
939
|
+
className: clx2(
|
|
940
|
+
"bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-center gap-1.5 rounded-xl p-1.5",
|
|
941
|
+
{
|
|
942
|
+
"border-ui-border-error shadow-borders-error": hasError
|
|
943
|
+
}
|
|
944
|
+
),
|
|
945
|
+
"data-testid": `product-create-variants-section-option-${index}`,
|
|
946
|
+
children: [
|
|
947
|
+
/* @__PURE__ */ jsxs4("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
|
|
948
|
+
/* @__PURE__ */ jsx4("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx4(
|
|
949
|
+
Label,
|
|
950
|
+
{
|
|
951
|
+
size: "xsmall",
|
|
952
|
+
weight: "plus",
|
|
953
|
+
className: "text-ui-fg-subtle",
|
|
954
|
+
htmlFor: `options.${index}.title`,
|
|
955
|
+
children: t("fields.title")
|
|
956
|
+
}
|
|
957
|
+
) }),
|
|
958
|
+
/* @__PURE__ */ jsx4(
|
|
959
|
+
Input2,
|
|
960
|
+
{
|
|
961
|
+
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
962
|
+
...form.register(
|
|
963
|
+
`options.${index}.title`
|
|
964
|
+
),
|
|
965
|
+
placeholder: t(
|
|
966
|
+
"products.fields.options.optionTitlePlaceholder"
|
|
967
|
+
),
|
|
968
|
+
"data-testid": `product-create-variants-section-option-title-input-${index}`
|
|
969
|
+
}
|
|
970
|
+
),
|
|
971
|
+
/* @__PURE__ */ jsx4("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx4(
|
|
972
|
+
Label,
|
|
973
|
+
{
|
|
974
|
+
size: "xsmall",
|
|
975
|
+
weight: "plus",
|
|
976
|
+
className: "text-ui-fg-subtle",
|
|
977
|
+
htmlFor: `options.${index}.values`,
|
|
978
|
+
children: t("fields.values")
|
|
979
|
+
}
|
|
980
|
+
) }),
|
|
981
|
+
/* @__PURE__ */ jsx4(
|
|
982
|
+
Controller,
|
|
983
|
+
{
|
|
984
|
+
control: form.control,
|
|
985
|
+
name: `options.${index}.values`,
|
|
986
|
+
render: ({
|
|
987
|
+
field: { onChange, ...field }
|
|
988
|
+
}) => {
|
|
989
|
+
const handleValueChange = (value) => {
|
|
990
|
+
handleOptionValueUpdate(index, value);
|
|
991
|
+
onChange(value);
|
|
992
|
+
};
|
|
993
|
+
return /* @__PURE__ */ jsx4(
|
|
994
|
+
ChipInput,
|
|
995
|
+
{
|
|
996
|
+
...field,
|
|
997
|
+
variant: "contrast",
|
|
998
|
+
onChange: handleValueChange,
|
|
999
|
+
placeholder: t(
|
|
1000
|
+
"products.fields.options.variantionsPlaceholder"
|
|
1001
|
+
),
|
|
1002
|
+
"data-testid": `product-create-variants-section-option-values-input-${index}`
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
)
|
|
1008
|
+
] }),
|
|
1009
|
+
/* @__PURE__ */ jsx4(
|
|
1010
|
+
IconButton3,
|
|
1011
|
+
{
|
|
1012
|
+
type: "button",
|
|
1013
|
+
size: "small",
|
|
1014
|
+
variant: "transparent",
|
|
1015
|
+
className: "text-ui-fg-muted",
|
|
1016
|
+
disabled: index === 0,
|
|
1017
|
+
onClick: () => handleRemoveOption(index),
|
|
1018
|
+
"data-testid": `product-create-variants-section-option-remove-${index}`,
|
|
1019
|
+
children: /* @__PURE__ */ jsx4(XMarkMini, {})
|
|
1020
|
+
}
|
|
1021
|
+
)
|
|
1022
|
+
]
|
|
1023
|
+
},
|
|
1024
|
+
option.id
|
|
1025
|
+
);
|
|
1026
|
+
}) })
|
|
1027
|
+
] }) });
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
) }),
|
|
1031
|
+
/* @__PURE__ */ jsx4("div", { className: "grid grid-cols-1 gap-x-4 gap-y-8", children: /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-y-6", children: [
|
|
1032
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
|
|
1033
|
+
/* @__PURE__ */ jsx4(Label, { weight: "plus", children: t("products.create.variants.productVariants.label") }),
|
|
1034
|
+
/* @__PURE__ */ jsx4(Hint, { children: t("products.create.variants.productVariants.hint") })
|
|
1035
|
+
] }),
|
|
1036
|
+
!showInvalidOptionsMessage && showInvalidVariantsMessage && /* @__PURE__ */ jsx4(Alert, { dismissible: true, variant: "error", "data-testid": "product-create-variants-section-variants-error", children: t("products.create.errors.variants") }),
|
|
1037
|
+
variants.fields.length > 0 ? /* @__PURE__ */ jsxs4("div", { className: "overflow-hidden rounded-xl border", "data-testid": "product-create-variants-section-variants-list", children: [
|
|
1038
|
+
/* @__PURE__ */ jsxs4(
|
|
1039
|
+
"div",
|
|
1040
|
+
{
|
|
1041
|
+
className: "bg-ui-bg-component text-ui-fg-subtle grid items-center gap-3 border-b px-6 py-2.5",
|
|
1042
|
+
style: {
|
|
1043
|
+
gridTemplateColumns: `20px 28px repeat(${watchedOptions.length}, 1fr)`
|
|
1044
|
+
},
|
|
1045
|
+
"data-testid": "product-create-variants-section-variants-header",
|
|
1046
|
+
children: [
|
|
1047
|
+
/* @__PURE__ */ jsx4("div", { children: /* @__PURE__ */ jsx4(
|
|
1048
|
+
Checkbox,
|
|
1049
|
+
{
|
|
1050
|
+
className: "relative",
|
|
1051
|
+
checked: getCheckboxState(watchedVariants),
|
|
1052
|
+
onCheckedChange: onCheckboxChange,
|
|
1053
|
+
"data-testid": "product-create-variants-section-variants-select-all"
|
|
1054
|
+
}
|
|
1055
|
+
) }),
|
|
1056
|
+
/* @__PURE__ */ jsx4("div", {}),
|
|
1057
|
+
watchedOptions.map((option, index) => /* @__PURE__ */ jsx4("div", { children: /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", weight: "plus", children: option.title }) }, index))
|
|
1058
|
+
]
|
|
1059
|
+
}
|
|
1060
|
+
),
|
|
1061
|
+
/* @__PURE__ */ jsx4(
|
|
1062
|
+
SortableList,
|
|
1063
|
+
{
|
|
1064
|
+
items: variants.fields,
|
|
1065
|
+
onChange: handleRankChange,
|
|
1066
|
+
renderItem: (item, index) => {
|
|
1067
|
+
return /* @__PURE__ */ jsx4(
|
|
1068
|
+
SortableList.Item,
|
|
1069
|
+
{
|
|
1070
|
+
id: item.id,
|
|
1071
|
+
className: clx2("bg-ui-bg-base border-b", {
|
|
1072
|
+
"border-b-0": index === variants.fields.length - 1
|
|
1073
|
+
}),
|
|
1074
|
+
children: /* @__PURE__ */ jsxs4(
|
|
1075
|
+
"div",
|
|
1076
|
+
{
|
|
1077
|
+
className: "text-ui-fg-subtle grid w-full items-center gap-3 px-6 py-2.5",
|
|
1078
|
+
style: {
|
|
1079
|
+
gridTemplateColumns: `20px 28px repeat(${watchedOptions.length}, 1fr)`
|
|
1080
|
+
},
|
|
1081
|
+
children: [
|
|
1082
|
+
/* @__PURE__ */ jsx4(
|
|
1083
|
+
Form.Field,
|
|
1084
|
+
{
|
|
1085
|
+
control: form.control,
|
|
1086
|
+
name: `variants.${index}.should_create`,
|
|
1087
|
+
render: ({
|
|
1088
|
+
field: { value, onChange, ...field }
|
|
1089
|
+
}) => {
|
|
1090
|
+
return /* @__PURE__ */ jsx4(Form.Item, { children: /* @__PURE__ */ jsx4(Form.Control, { children: /* @__PURE__ */ jsx4(
|
|
1091
|
+
Checkbox,
|
|
1092
|
+
{
|
|
1093
|
+
className: "relative",
|
|
1094
|
+
...field,
|
|
1095
|
+
checked: value,
|
|
1096
|
+
onCheckedChange: onChange,
|
|
1097
|
+
"data-testid": `product-create-variants-section-variant-checkbox-${index}`
|
|
1098
|
+
}
|
|
1099
|
+
) }) });
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
),
|
|
1103
|
+
/* @__PURE__ */ jsx4(SortableList.DragHandle, {}),
|
|
1104
|
+
Object.values(item.options).map((value, index2) => /* @__PURE__ */ jsx4(Text2, { size: "small", leading: "compact", children: value }, index2))
|
|
1105
|
+
]
|
|
1106
|
+
}
|
|
1107
|
+
)
|
|
1108
|
+
}
|
|
1109
|
+
);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
)
|
|
1113
|
+
] }) : /* @__PURE__ */ jsx4(Alert, { "data-testid": "product-create-variants-section-variants-empty-alert", children: t("products.create.variants.productVariants.alert") }),
|
|
1114
|
+
variants.fields.length > 0 && /* @__PURE__ */ jsx4(InlineTip, { label: t("general.tip"), children: t("products.create.variants.productVariants.tip") })
|
|
1115
|
+
] }) })
|
|
1116
|
+
] })
|
|
1117
|
+
] });
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
// src/pages/products/product-create/components/product-create-details-form/product-create-details-form.tsx
|
|
1121
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1122
|
+
var ProductCreateDetailsForm = ({ form }) => {
|
|
1123
|
+
return /* @__PURE__ */ jsx5(
|
|
1124
|
+
"div",
|
|
1125
|
+
{
|
|
1126
|
+
className: "flex flex-col items-center p-16",
|
|
1127
|
+
"data-testid": "product-create-details-form",
|
|
1128
|
+
children: /* @__PURE__ */ jsxs5(
|
|
1129
|
+
"div",
|
|
1130
|
+
{
|
|
1131
|
+
className: "flex w-full max-w-[720px] flex-col gap-y-8",
|
|
1132
|
+
"data-testid": "product-create-details-form-content",
|
|
1133
|
+
children: [
|
|
1134
|
+
/* @__PURE__ */ jsx5(Header, {}),
|
|
1135
|
+
/* @__PURE__ */ jsxs5(
|
|
1136
|
+
"div",
|
|
1137
|
+
{
|
|
1138
|
+
className: "flex flex-col gap-y-6",
|
|
1139
|
+
"data-testid": "product-create-details-form-sections",
|
|
1140
|
+
children: [
|
|
1141
|
+
/* @__PURE__ */ jsx5(ProductCreateGeneralSection, { form }),
|
|
1142
|
+
/* @__PURE__ */ jsx5(ProductCreateMediaSection, { form })
|
|
1143
|
+
]
|
|
1144
|
+
}
|
|
1145
|
+
),
|
|
1146
|
+
/* @__PURE__ */ jsx5(Divider, { "data-testid": "product-create-details-form-divider" }),
|
|
1147
|
+
/* @__PURE__ */ jsx5(ProductCreateVariantsSection, { form })
|
|
1148
|
+
]
|
|
1149
|
+
}
|
|
1150
|
+
)
|
|
1151
|
+
}
|
|
1152
|
+
);
|
|
1153
|
+
};
|
|
1154
|
+
var Header = () => {
|
|
1155
|
+
const { t } = useTranslation4();
|
|
1156
|
+
return /* @__PURE__ */ jsx5(
|
|
1157
|
+
"div",
|
|
1158
|
+
{
|
|
1159
|
+
className: "flex flex-col",
|
|
1160
|
+
"data-testid": "product-create-details-form-header",
|
|
1161
|
+
children: /* @__PURE__ */ jsx5(Heading2, { "data-testid": "product-create-details-form-heading", children: t("products.create.header") })
|
|
1162
|
+
}
|
|
1163
|
+
);
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
// src/pages/products/product-create/components/product-create-inventory-kit-form/components/product-create-inventory-kit-section/product-create-inventory-kit-section.tsx
|
|
1167
|
+
import { Button as Button2, Heading as Heading3, IconButton as IconButton4, Input as Input3, Label as Label2 } from "@medusajs/ui";
|
|
1168
|
+
import { useFieldArray as useFieldArray3, useWatch as useWatch2 } from "react-hook-form";
|
|
1169
|
+
import { XMarkMini as XMarkMini2 } from "@medusajs/icons";
|
|
1170
|
+
import { useTranslation as useTranslation5 } from "react-i18next";
|
|
1171
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1172
|
+
function InventoryItemRow({
|
|
1173
|
+
form,
|
|
1174
|
+
variantIndex,
|
|
1175
|
+
inventoryIndex,
|
|
1176
|
+
inventoryItem,
|
|
1177
|
+
isItemOptionDisabled,
|
|
1178
|
+
onRemove
|
|
1179
|
+
}) {
|
|
1180
|
+
const { t } = useTranslation5();
|
|
1181
|
+
const selectedInventoryItemId = useWatch2({
|
|
1182
|
+
control: form.control,
|
|
1183
|
+
name: `variants.${variantIndex}.inventory.${inventoryIndex}.inventory_item_id`
|
|
1184
|
+
});
|
|
1185
|
+
const items = useComboboxData({
|
|
1186
|
+
queryKey: ["inventory_items"],
|
|
1187
|
+
defaultValueKey: "id",
|
|
1188
|
+
selectedValue: selectedInventoryItemId,
|
|
1189
|
+
queryFn: (params) => sdk.admin.inventoryItem.list(params),
|
|
1190
|
+
getOptions: (data) => data.inventory_items.map((item) => ({
|
|
1191
|
+
label: `${item.title} ${item.sku ? `(${item.sku})` : ""}`,
|
|
1192
|
+
value: item.id
|
|
1193
|
+
}))
|
|
1194
|
+
});
|
|
1195
|
+
return /* @__PURE__ */ jsxs6(
|
|
1196
|
+
"li",
|
|
1197
|
+
{
|
|
1198
|
+
className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-center gap-1.5 rounded-xl p-1.5",
|
|
1199
|
+
children: [
|
|
1200
|
+
/* @__PURE__ */ jsxs6("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
|
|
1201
|
+
/* @__PURE__ */ jsx6("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx6(
|
|
1202
|
+
Label2,
|
|
1203
|
+
{
|
|
1204
|
+
size: "xsmall",
|
|
1205
|
+
weight: "plus",
|
|
1206
|
+
className: "text-ui-fg-subtle",
|
|
1207
|
+
htmlFor: `variants.${variantIndex}.inventory.${inventoryIndex}.inventory_item_id`,
|
|
1208
|
+
children: t("fields.item")
|
|
1209
|
+
}
|
|
1210
|
+
) }),
|
|
1211
|
+
/* @__PURE__ */ jsx6(
|
|
1212
|
+
Form.Field,
|
|
1213
|
+
{
|
|
1214
|
+
control: form.control,
|
|
1215
|
+
name: `variants.${variantIndex}.inventory.${inventoryIndex}.inventory_item_id`,
|
|
1216
|
+
render: ({ field }) => {
|
|
1217
|
+
return /* @__PURE__ */ jsx6(Form.Item, { children: /* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(
|
|
1218
|
+
Combobox,
|
|
1219
|
+
{
|
|
1220
|
+
...field,
|
|
1221
|
+
options: items.options.map((o) => ({
|
|
1222
|
+
...o,
|
|
1223
|
+
disabled: isItemOptionDisabled(o, inventoryIndex)
|
|
1224
|
+
})),
|
|
1225
|
+
searchValue: items.searchValue,
|
|
1226
|
+
onBlur: () => items.onSearchValueChange(""),
|
|
1227
|
+
onSearchValueChange: items.onSearchValueChange,
|
|
1228
|
+
fetchNextPage: items.fetchNextPage,
|
|
1229
|
+
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
1230
|
+
placeholder: t("products.create.inventory.itemPlaceholder")
|
|
1231
|
+
}
|
|
1232
|
+
) }) });
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
),
|
|
1236
|
+
/* @__PURE__ */ jsx6("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx6(
|
|
1237
|
+
Label2,
|
|
1238
|
+
{
|
|
1239
|
+
size: "xsmall",
|
|
1240
|
+
weight: "plus",
|
|
1241
|
+
className: "text-ui-fg-subtle",
|
|
1242
|
+
htmlFor: `variants.${variantIndex}.inventory.${inventoryIndex}.required_quantity`,
|
|
1243
|
+
children: t("fields.quantity")
|
|
1244
|
+
}
|
|
1245
|
+
) }),
|
|
1246
|
+
/* @__PURE__ */ jsx6(
|
|
1247
|
+
Form.Field,
|
|
1248
|
+
{
|
|
1249
|
+
control: form.control,
|
|
1250
|
+
name: `variants.${variantIndex}.inventory.${inventoryIndex}.required_quantity`,
|
|
1251
|
+
render: ({ field: { onChange, value, ...field } }) => {
|
|
1252
|
+
return /* @__PURE__ */ jsxs6(Form.Item, { children: [
|
|
1253
|
+
/* @__PURE__ */ jsx6(Form.Control, { children: /* @__PURE__ */ jsx6(
|
|
1254
|
+
Input3,
|
|
1255
|
+
{
|
|
1256
|
+
type: "number",
|
|
1257
|
+
className: "bg-ui-bg-field-component",
|
|
1258
|
+
min: 0,
|
|
1259
|
+
value,
|
|
1260
|
+
onChange: (e) => {
|
|
1261
|
+
const value2 = e.target.value;
|
|
1262
|
+
if (value2 === "") {
|
|
1263
|
+
onChange(null);
|
|
1264
|
+
} else {
|
|
1265
|
+
onChange(Number(value2));
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
...field,
|
|
1269
|
+
placeholder: t(
|
|
1270
|
+
"products.create.inventory.quantityPlaceholder"
|
|
1271
|
+
)
|
|
1272
|
+
}
|
|
1273
|
+
) }),
|
|
1274
|
+
/* @__PURE__ */ jsx6(Form.ErrorMessage, {})
|
|
1275
|
+
] });
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
)
|
|
1279
|
+
] }),
|
|
1280
|
+
/* @__PURE__ */ jsx6(
|
|
1281
|
+
IconButton4,
|
|
1282
|
+
{
|
|
1283
|
+
type: "button",
|
|
1284
|
+
size: "small",
|
|
1285
|
+
variant: "transparent",
|
|
1286
|
+
className: "text-ui-fg-muted",
|
|
1287
|
+
onClick: onRemove,
|
|
1288
|
+
children: /* @__PURE__ */ jsx6(XMarkMini2, {})
|
|
1289
|
+
}
|
|
1290
|
+
)
|
|
1291
|
+
]
|
|
1292
|
+
},
|
|
1293
|
+
inventoryItem.id
|
|
1294
|
+
);
|
|
1295
|
+
}
|
|
1296
|
+
function VariantSection({ form, variant, index }) {
|
|
1297
|
+
const { t } = useTranslation5();
|
|
1298
|
+
const inventory = useFieldArray3({
|
|
1299
|
+
control: form.control,
|
|
1300
|
+
name: `variants.${index}.inventory`
|
|
1301
|
+
});
|
|
1302
|
+
const inventoryFormData = useWatch2({
|
|
1303
|
+
control: form.control,
|
|
1304
|
+
name: `variants.${index}.inventory`
|
|
1305
|
+
});
|
|
1306
|
+
const isItemOptionDisabled = (option, inventoryIndex) => {
|
|
1307
|
+
return !!inventoryFormData?.some(
|
|
1308
|
+
(i, index2) => index2 != inventoryIndex && i.inventory_item_id === option.value
|
|
1309
|
+
);
|
|
1310
|
+
};
|
|
1311
|
+
return /* @__PURE__ */ jsxs6("div", { className: "grid gap-y-4", children: [
|
|
1312
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-start justify-between gap-x-4", children: [
|
|
1313
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col", children: [
|
|
1314
|
+
/* @__PURE__ */ jsx6(Form.Label, { children: variant.title }),
|
|
1315
|
+
/* @__PURE__ */ jsx6(Form.Hint, { children: t("products.create.inventory.label") })
|
|
1316
|
+
] }),
|
|
1317
|
+
/* @__PURE__ */ jsx6(
|
|
1318
|
+
Button2,
|
|
1319
|
+
{
|
|
1320
|
+
size: "small",
|
|
1321
|
+
variant: "secondary",
|
|
1322
|
+
type: "button",
|
|
1323
|
+
onClick: () => {
|
|
1324
|
+
inventory.append({
|
|
1325
|
+
inventory_item_id: "",
|
|
1326
|
+
required_quantity: ""
|
|
1327
|
+
});
|
|
1328
|
+
},
|
|
1329
|
+
children: t("actions.add")
|
|
1330
|
+
}
|
|
1331
|
+
)
|
|
1332
|
+
] }),
|
|
1333
|
+
inventory.fields.map((inventoryItem, inventoryIndex) => /* @__PURE__ */ jsx6(
|
|
1334
|
+
InventoryItemRow,
|
|
1335
|
+
{
|
|
1336
|
+
form,
|
|
1337
|
+
variantIndex: index,
|
|
1338
|
+
inventoryIndex,
|
|
1339
|
+
inventoryItem,
|
|
1340
|
+
isItemOptionDisabled,
|
|
1341
|
+
onRemove: () => inventory.remove(inventoryIndex)
|
|
1342
|
+
},
|
|
1343
|
+
inventoryItem.id
|
|
1344
|
+
))
|
|
1345
|
+
] });
|
|
1346
|
+
}
|
|
1347
|
+
var ProductCreateInventoryKitSection = ({
|
|
1348
|
+
form
|
|
1349
|
+
}) => {
|
|
1350
|
+
const { t } = useTranslation5();
|
|
1351
|
+
const variants = useFieldArray3({
|
|
1352
|
+
control: form.control,
|
|
1353
|
+
name: "variants"
|
|
1354
|
+
});
|
|
1355
|
+
return /* @__PURE__ */ jsxs6("div", { id: "organize", className: "flex flex-col gap-y-8", children: [
|
|
1356
|
+
/* @__PURE__ */ jsx6(Heading3, { children: t("products.create.inventory.heading") }),
|
|
1357
|
+
variants.fields.filter((v) => v.inventory_kit).map((variant, variantIndex) => /* @__PURE__ */ jsx6(
|
|
1358
|
+
VariantSection,
|
|
1359
|
+
{
|
|
1360
|
+
form,
|
|
1361
|
+
variant,
|
|
1362
|
+
index: variantIndex
|
|
1363
|
+
},
|
|
1364
|
+
variant.id
|
|
1365
|
+
))
|
|
1366
|
+
] });
|
|
1367
|
+
};
|
|
1368
|
+
|
|
1369
|
+
// src/pages/products/product-create/components/product-create-inventory-kit-form/product-create-inventory-kit-form.tsx
|
|
1370
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1371
|
+
var ProductCreateInventoryKitForm = ({
|
|
1372
|
+
form
|
|
1373
|
+
}) => {
|
|
1374
|
+
return /* @__PURE__ */ jsx7("div", { className: "flex flex-col items-center p-16", "data-testid": "product-create-inventory-kit-form", children: /* @__PURE__ */ jsx7("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", "data-testid": "product-create-inventory-kit-form-content", children: /* @__PURE__ */ jsx7(ProductCreateInventoryKitSection, { form }) }) });
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
// src/pages/products/product-create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx
|
|
1378
|
+
import { Button as Button3, Heading as Heading4 } from "@medusajs/ui";
|
|
1379
|
+
import { useFieldArray as useFieldArray4 } from "react-hook-form";
|
|
1380
|
+
import { Trans, useTranslation as useTranslation6 } from "react-i18next";
|
|
1381
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1382
|
+
var ProductCreateOrganizationSection = ({
|
|
1383
|
+
form
|
|
1384
|
+
}) => {
|
|
1385
|
+
const { t } = useTranslation6();
|
|
1386
|
+
const collections = useComboboxData({
|
|
1387
|
+
queryKey: ["product_collections"],
|
|
1388
|
+
queryFn: (params) => sdk.admin.productCollection.list(params),
|
|
1389
|
+
getOptions: (data) => data.collections.map((collection) => ({
|
|
1390
|
+
label: collection.title,
|
|
1391
|
+
value: collection.id
|
|
1392
|
+
}))
|
|
1393
|
+
});
|
|
1394
|
+
const types = useComboboxData({
|
|
1395
|
+
queryKey: ["product_types"],
|
|
1396
|
+
queryFn: (params) => sdk.admin.productType.list(params),
|
|
1397
|
+
getOptions: (data) => data.product_types.map((type) => ({
|
|
1398
|
+
label: type.value,
|
|
1399
|
+
value: type.id
|
|
1400
|
+
}))
|
|
1401
|
+
});
|
|
1402
|
+
const tags = useComboboxData({
|
|
1403
|
+
queryKey: ["product_tags"],
|
|
1404
|
+
queryFn: (params) => sdk.admin.productTag.list(params),
|
|
1405
|
+
getOptions: (data) => data.product_tags.map((tag) => ({
|
|
1406
|
+
label: tag.value,
|
|
1407
|
+
value: tag.id
|
|
1408
|
+
}))
|
|
1409
|
+
});
|
|
1410
|
+
const shippingProfiles = useComboboxData({
|
|
1411
|
+
queryKey: ["shipping_profiles"],
|
|
1412
|
+
queryFn: (params) => sdk.admin.shippingProfile.list(params),
|
|
1413
|
+
getOptions: (data) => data.shipping_profiles.map((shippingProfile) => ({
|
|
1414
|
+
label: shippingProfile.name,
|
|
1415
|
+
value: shippingProfile.id
|
|
1416
|
+
}))
|
|
1417
|
+
});
|
|
1418
|
+
const { fields, remove, replace } = useFieldArray4({
|
|
1419
|
+
control: form.control,
|
|
1420
|
+
name: "sales_channels",
|
|
1421
|
+
keyName: "key"
|
|
1422
|
+
});
|
|
1423
|
+
const handleClearAllSalesChannels = () => {
|
|
1424
|
+
replace([]);
|
|
1425
|
+
};
|
|
1426
|
+
return /* @__PURE__ */ jsxs7("div", { id: "organize", className: "flex flex-col gap-y-8", "data-testid": "product-create-organize-section", children: [
|
|
1427
|
+
/* @__PURE__ */ jsx8(Heading4, { "data-testid": "product-create-organize-section-heading", children: t("products.organization.header") }),
|
|
1428
|
+
/* @__PURE__ */ jsx8(
|
|
1429
|
+
SwitchBox,
|
|
1430
|
+
{
|
|
1431
|
+
control: form.control,
|
|
1432
|
+
name: "discountable",
|
|
1433
|
+
label: t("products.fields.discountable.label"),
|
|
1434
|
+
description: t("products.fields.discountable.hint"),
|
|
1435
|
+
optional: true,
|
|
1436
|
+
"data-testid": "product-create-organize-section-discountable-switch"
|
|
1437
|
+
}
|
|
1438
|
+
),
|
|
1439
|
+
/* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-type-collection", children: [
|
|
1440
|
+
/* @__PURE__ */ jsx8(
|
|
1441
|
+
Form.Field,
|
|
1442
|
+
{
|
|
1443
|
+
control: form.control,
|
|
1444
|
+
name: "type_id",
|
|
1445
|
+
render: ({ field }) => {
|
|
1446
|
+
return /* @__PURE__ */ jsxs7(Form.Item, { "data-testid": "product-create-organize-section-type-item", children: [
|
|
1447
|
+
/* @__PURE__ */ jsx8(Form.Label, { optional: true, "data-testid": "product-create-organize-section-type-label", children: t("products.fields.type.label") }),
|
|
1448
|
+
/* @__PURE__ */ jsx8(Form.Control, { "data-testid": "product-create-organize-section-type-control", children: /* @__PURE__ */ jsx8(
|
|
1449
|
+
Combobox,
|
|
1450
|
+
{
|
|
1451
|
+
...field,
|
|
1452
|
+
options: types.options,
|
|
1453
|
+
searchValue: types.searchValue,
|
|
1454
|
+
onSearchValueChange: types.onSearchValueChange,
|
|
1455
|
+
fetchNextPage: types.fetchNextPage,
|
|
1456
|
+
"data-testid": "product-create-organize-section-type-input"
|
|
1457
|
+
}
|
|
1458
|
+
) }),
|
|
1459
|
+
/* @__PURE__ */ jsx8(Form.ErrorMessage, {})
|
|
1460
|
+
] });
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
),
|
|
1464
|
+
/* @__PURE__ */ jsx8(
|
|
1465
|
+
Form.Field,
|
|
1466
|
+
{
|
|
1467
|
+
control: form.control,
|
|
1468
|
+
name: "collection_id",
|
|
1469
|
+
render: ({ field }) => {
|
|
1470
|
+
return /* @__PURE__ */ jsxs7(Form.Item, { "data-testid": "product-create-organize-section-collection-item", children: [
|
|
1471
|
+
/* @__PURE__ */ jsx8(Form.Label, { optional: true, "data-testid": "product-create-organize-section-collection-label", children: t("products.fields.collection.label") }),
|
|
1472
|
+
/* @__PURE__ */ jsx8(Form.Control, { "data-testid": "product-create-organize-section-collection-control", children: /* @__PURE__ */ jsx8(
|
|
1473
|
+
Combobox,
|
|
1474
|
+
{
|
|
1475
|
+
...field,
|
|
1476
|
+
options: collections.options,
|
|
1477
|
+
searchValue: collections.searchValue,
|
|
1478
|
+
onSearchValueChange: collections.onSearchValueChange,
|
|
1479
|
+
fetchNextPage: collections.fetchNextPage,
|
|
1480
|
+
"data-testid": "product-create-organize-section-collection-input"
|
|
1481
|
+
}
|
|
1482
|
+
) }),
|
|
1483
|
+
/* @__PURE__ */ jsx8(Form.ErrorMessage, {})
|
|
1484
|
+
] });
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
)
|
|
1488
|
+
] }),
|
|
1489
|
+
/* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", "data-testid": "product-create-organize-section-categories-tags", children: [
|
|
1490
|
+
/* @__PURE__ */ jsx8(
|
|
1491
|
+
Form.Field,
|
|
1492
|
+
{
|
|
1493
|
+
control: form.control,
|
|
1494
|
+
name: "categories",
|
|
1495
|
+
render: ({ field }) => {
|
|
1496
|
+
return /* @__PURE__ */ jsxs7(Form.Item, { "data-testid": "product-create-organize-section-categories-item", children: [
|
|
1497
|
+
/* @__PURE__ */ jsx8(Form.Label, { optional: true, "data-testid": "product-create-organize-section-categories-label", children: t("products.fields.categories.label") }),
|
|
1498
|
+
/* @__PURE__ */ jsx8(Form.Control, { "data-testid": "product-create-organize-section-categories-control", children: /* @__PURE__ */ jsx8(CategoryCombobox, { ...field, "data-testid": "product-create-organize-section-categories-input" }) }),
|
|
1499
|
+
/* @__PURE__ */ jsx8(Form.ErrorMessage, {})
|
|
1500
|
+
] });
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
),
|
|
1504
|
+
/* @__PURE__ */ jsx8(
|
|
1505
|
+
Form.Field,
|
|
1506
|
+
{
|
|
1507
|
+
control: form.control,
|
|
1508
|
+
name: "tags",
|
|
1509
|
+
render: ({ field }) => {
|
|
1510
|
+
return /* @__PURE__ */ jsxs7(Form.Item, { "data-testid": "product-create-organize-section-tags-item", children: [
|
|
1511
|
+
/* @__PURE__ */ jsx8(Form.Label, { optional: true, "data-testid": "product-create-organize-section-tags-label", children: t("products.fields.tags.label") }),
|
|
1512
|
+
/* @__PURE__ */ jsx8(Form.Control, { "data-testid": "product-create-organize-section-tags-control", children: /* @__PURE__ */ jsx8(
|
|
1513
|
+
Combobox,
|
|
1514
|
+
{
|
|
1515
|
+
...field,
|
|
1516
|
+
options: tags.options,
|
|
1517
|
+
searchValue: tags.searchValue,
|
|
1518
|
+
onSearchValueChange: tags.onSearchValueChange,
|
|
1519
|
+
fetchNextPage: tags.fetchNextPage,
|
|
1520
|
+
"data-testid": "product-create-organize-section-tags-input"
|
|
1521
|
+
}
|
|
1522
|
+
) }),
|
|
1523
|
+
/* @__PURE__ */ jsx8(Form.ErrorMessage, {})
|
|
1524
|
+
] });
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
)
|
|
1528
|
+
] }),
|
|
1529
|
+
/* @__PURE__ */ jsxs7("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
1530
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
1531
|
+
/* @__PURE__ */ jsx8(Form.Label, { optional: true, children: t("products.fields.shipping_profile.label") }),
|
|
1532
|
+
/* @__PURE__ */ jsx8(Form.Hint, { children: /* @__PURE__ */ jsx8(Trans, { i18nKey: "products.fields.shipping_profile.hint" }) })
|
|
1533
|
+
] }),
|
|
1534
|
+
/* @__PURE__ */ jsx8(
|
|
1535
|
+
Form.Field,
|
|
1536
|
+
{
|
|
1537
|
+
control: form.control,
|
|
1538
|
+
name: "shipping_profile_id",
|
|
1539
|
+
render: ({ field }) => {
|
|
1540
|
+
return /* @__PURE__ */ jsxs7(Form.Item, { children: [
|
|
1541
|
+
/* @__PURE__ */ jsx8(Form.Control, { children: /* @__PURE__ */ jsx8(
|
|
1542
|
+
Combobox,
|
|
1543
|
+
{
|
|
1544
|
+
...field,
|
|
1545
|
+
options: shippingProfiles.options,
|
|
1546
|
+
searchValue: shippingProfiles.searchValue,
|
|
1547
|
+
onSearchValueChange: shippingProfiles.onSearchValueChange,
|
|
1548
|
+
fetchNextPage: shippingProfiles.fetchNextPage
|
|
1549
|
+
}
|
|
1550
|
+
) }),
|
|
1551
|
+
/* @__PURE__ */ jsx8(Form.ErrorMessage, {})
|
|
1552
|
+
] });
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
)
|
|
1556
|
+
] }),
|
|
1557
|
+
/* @__PURE__ */ jsx8("div", { className: "grid grid-cols-1 gap-y-4", children: /* @__PURE__ */ jsx8(
|
|
1558
|
+
Form.Field,
|
|
1559
|
+
{
|
|
1560
|
+
control: form.control,
|
|
1561
|
+
name: "sales_channels",
|
|
1562
|
+
render: () => {
|
|
1563
|
+
return /* @__PURE__ */ jsxs7(Form.Item, { children: [
|
|
1564
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-start justify-between gap-x-4", children: [
|
|
1565
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
1566
|
+
/* @__PURE__ */ jsx8(Form.Label, { optional: true, children: t("products.fields.sales_channels.label") }),
|
|
1567
|
+
/* @__PURE__ */ jsx8(Form.Hint, { children: /* @__PURE__ */ jsx8(Trans, { i18nKey: "products.fields.sales_channels.hint" }) })
|
|
1568
|
+
] }),
|
|
1569
|
+
/* @__PURE__ */ jsx8(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx8(Button3, { size: "small", variant: "secondary", type: "button", "data-testid": "product-create-organize-section-sales-channels-add-button", children: t("actions.add") }) })
|
|
1570
|
+
] }),
|
|
1571
|
+
/* @__PURE__ */ jsx8(Form.Control, { className: "mt-0", children: fields.length > 0 && /* @__PURE__ */ jsx8(
|
|
1572
|
+
ChipGroup,
|
|
1573
|
+
{
|
|
1574
|
+
onClearAll: handleClearAllSalesChannels,
|
|
1575
|
+
onRemove: remove,
|
|
1576
|
+
className: "py-4",
|
|
1577
|
+
children: fields.map((field, index) => /* @__PURE__ */ jsx8(ChipGroup.Chip, { index, children: field.name }, field.key))
|
|
1578
|
+
}
|
|
1579
|
+
) })
|
|
1580
|
+
] });
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
) })
|
|
1584
|
+
] });
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
// src/pages/products/product-create/components/product-create-organize-form/components/product-create-sales-channel-stacked-modal/product-create-sales-channel-drawer.tsx
|
|
1588
|
+
import {
|
|
1589
|
+
Button as Button4,
|
|
1590
|
+
createDataTableColumnHelper
|
|
1591
|
+
} from "@medusajs/ui";
|
|
1592
|
+
import { useEffect, useMemo as useMemo2, useState as useState3 } from "react";
|
|
1593
|
+
import { useTranslation as useTranslation7 } from "react-i18next";
|
|
1594
|
+
import { keepPreviousData } from "@tanstack/react-query";
|
|
1595
|
+
|
|
1596
|
+
// src/pages/products/product-create/components/product-create-organize-form/constants.ts
|
|
1597
|
+
var SC_STACKED_MODAL_ID = "sc";
|
|
1598
|
+
|
|
1599
|
+
// src/pages/products/product-create/components/product-create-organize-form/components/product-create-sales-channel-stacked-modal/product-create-sales-channel-drawer.tsx
|
|
1600
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1601
|
+
var PAGE_SIZE = 20;
|
|
1602
|
+
var ProductCreateSalesChannelStackedModal = ({
|
|
1603
|
+
form
|
|
1604
|
+
}) => {
|
|
1605
|
+
const { t } = useTranslation7();
|
|
1606
|
+
const { getValues, setValue } = form;
|
|
1607
|
+
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
1608
|
+
const [rowSelection, setRowSelection] = useState3(
|
|
1609
|
+
{}
|
|
1610
|
+
);
|
|
1611
|
+
const [state, setState] = useState3([]);
|
|
1612
|
+
const searchParams = useSalesChannelTableQuery({
|
|
1613
|
+
pageSize: PAGE_SIZE,
|
|
1614
|
+
prefix: SC_STACKED_MODAL_ID
|
|
1615
|
+
});
|
|
1616
|
+
const { sales_channels, count, isLoading, isError, error } = useSalesChannels(
|
|
1617
|
+
searchParams,
|
|
1618
|
+
{
|
|
1619
|
+
placeholderData: keepPreviousData
|
|
1620
|
+
}
|
|
1621
|
+
);
|
|
1622
|
+
const open = getIsOpen(SC_STACKED_MODAL_ID);
|
|
1623
|
+
useEffect(() => {
|
|
1624
|
+
if (!open) {
|
|
1625
|
+
return;
|
|
1626
|
+
}
|
|
1627
|
+
const salesChannels = getValues("sales_channels");
|
|
1628
|
+
if (salesChannels) {
|
|
1629
|
+
setState(
|
|
1630
|
+
salesChannels.map((channel) => ({
|
|
1631
|
+
id: channel.id,
|
|
1632
|
+
name: channel.name
|
|
1633
|
+
}))
|
|
1634
|
+
);
|
|
1635
|
+
setRowSelection(
|
|
1636
|
+
salesChannels.reduce(
|
|
1637
|
+
(acc, channel) => ({
|
|
1638
|
+
...acc,
|
|
1639
|
+
[channel.id]: true
|
|
1640
|
+
}),
|
|
1641
|
+
{}
|
|
1642
|
+
)
|
|
1643
|
+
);
|
|
1644
|
+
}
|
|
1645
|
+
}, [open, getValues]);
|
|
1646
|
+
const onRowSelectionChange = (state2) => {
|
|
1647
|
+
const ids = Object.keys(state2);
|
|
1648
|
+
const addedIdsSet = new Set(
|
|
1649
|
+
ids.filter((id) => state2[id] && !rowSelection[id])
|
|
1650
|
+
);
|
|
1651
|
+
let addedSalesChannels = [];
|
|
1652
|
+
if (addedIdsSet.size > 0) {
|
|
1653
|
+
addedSalesChannels = sales_channels?.filter((channel) => addedIdsSet.has(channel.id)) ?? [];
|
|
1654
|
+
}
|
|
1655
|
+
setState((prev) => {
|
|
1656
|
+
const filteredPrev = prev.filter((channel) => state2[channel.id]);
|
|
1657
|
+
return Array.from(/* @__PURE__ */ new Set([...filteredPrev, ...addedSalesChannels]));
|
|
1658
|
+
});
|
|
1659
|
+
setRowSelection(state2);
|
|
1660
|
+
};
|
|
1661
|
+
const handleAdd = () => {
|
|
1662
|
+
setValue("sales_channels", state, {
|
|
1663
|
+
shouldDirty: true,
|
|
1664
|
+
shouldTouch: true
|
|
1665
|
+
});
|
|
1666
|
+
setIsOpen(SC_STACKED_MODAL_ID, false);
|
|
1667
|
+
};
|
|
1668
|
+
const filters = useSalesChannelTableFilters();
|
|
1669
|
+
const columns = useColumns();
|
|
1670
|
+
const emptyState = useSalesChannelTableEmptyState();
|
|
1671
|
+
if (isError) {
|
|
1672
|
+
throw error;
|
|
1673
|
+
}
|
|
1674
|
+
return /* @__PURE__ */ jsxs8(StackedFocusModal.Content, { className: "flex flex-col overflow-hidden", children: [
|
|
1675
|
+
/* @__PURE__ */ jsx9(StackedFocusModal.Header, {}),
|
|
1676
|
+
/* @__PURE__ */ jsx9(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx9(
|
|
1677
|
+
DataTable,
|
|
1678
|
+
{
|
|
1679
|
+
data: sales_channels,
|
|
1680
|
+
columns,
|
|
1681
|
+
filters,
|
|
1682
|
+
emptyState,
|
|
1683
|
+
rowCount: count,
|
|
1684
|
+
pageSize: PAGE_SIZE,
|
|
1685
|
+
getRowId: (row) => row.id,
|
|
1686
|
+
rowSelection: {
|
|
1687
|
+
state: rowSelection,
|
|
1688
|
+
onRowSelectionChange
|
|
1689
|
+
},
|
|
1690
|
+
isLoading,
|
|
1691
|
+
layout: "fill",
|
|
1692
|
+
prefix: SC_STACKED_MODAL_ID
|
|
1693
|
+
}
|
|
1694
|
+
) }),
|
|
1695
|
+
/* @__PURE__ */ jsx9(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
1696
|
+
/* @__PURE__ */ jsx9(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx9(Button4, { size: "small", variant: "secondary", type: "button", children: t("actions.cancel") }) }),
|
|
1697
|
+
/* @__PURE__ */ jsx9(Button4, { size: "small", onClick: handleAdd, type: "button", children: t("actions.save") })
|
|
1698
|
+
] }) })
|
|
1699
|
+
] });
|
|
1700
|
+
};
|
|
1701
|
+
var columnHelper = createDataTableColumnHelper();
|
|
1702
|
+
var useColumns = () => {
|
|
1703
|
+
const base = useSalesChannelTableColumns();
|
|
1704
|
+
return useMemo2(() => [columnHelper.select(), ...base], [base]);
|
|
1705
|
+
};
|
|
1706
|
+
|
|
1707
|
+
// src/pages/products/product-create/components/product-create-organize-form/product-create-organize-form.tsx
|
|
1708
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1709
|
+
var ProductCreateOrganizeForm = ({ form }) => {
|
|
1710
|
+
return /* @__PURE__ */ jsxs9(StackedFocusModal, { id: SC_STACKED_MODAL_ID, children: [
|
|
1711
|
+
/* @__PURE__ */ jsx10(
|
|
1712
|
+
"div",
|
|
1713
|
+
{
|
|
1714
|
+
className: "flex flex-col items-center p-16",
|
|
1715
|
+
"data-testid": "product-create-organize-form",
|
|
1716
|
+
children: /* @__PURE__ */ jsx10(
|
|
1717
|
+
"div",
|
|
1718
|
+
{
|
|
1719
|
+
className: "flex w-full max-w-[720px] flex-col gap-y-8",
|
|
1720
|
+
"data-testid": "product-create-organize-form-content",
|
|
1721
|
+
children: /* @__PURE__ */ jsx10(ProductCreateOrganizationSection, { form })
|
|
1722
|
+
}
|
|
1723
|
+
)
|
|
1724
|
+
}
|
|
1725
|
+
),
|
|
1726
|
+
/* @__PURE__ */ jsx10(ProductCreateSalesChannelStackedModal, { form })
|
|
1727
|
+
] });
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
// src/pages/products/product-create/components/product-create-variants-form/product-create-variants-form.tsx
|
|
1731
|
+
import { useMemo as useMemo3 } from "react";
|
|
1732
|
+
import { useWatch as useWatch3 } from "react-hook-form";
|
|
1733
|
+
import { useTranslation as useTranslation8 } from "react-i18next";
|
|
1734
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1735
|
+
var ProductCreateVariantsForm = ({
|
|
1736
|
+
form,
|
|
1737
|
+
regions,
|
|
1738
|
+
store,
|
|
1739
|
+
pricePreferences
|
|
1740
|
+
}) => {
|
|
1741
|
+
const { setCloseOnEscape } = useRouteModal();
|
|
1742
|
+
const currencyCodes = useMemo3(
|
|
1743
|
+
() => store?.supported_currencies?.map((c) => c.currency_code) || [],
|
|
1744
|
+
[store]
|
|
1745
|
+
);
|
|
1746
|
+
const variants = useWatch3({
|
|
1747
|
+
control: form.control,
|
|
1748
|
+
name: "variants",
|
|
1749
|
+
defaultValue: []
|
|
1750
|
+
});
|
|
1751
|
+
const options = useWatch3({
|
|
1752
|
+
control: form.control,
|
|
1753
|
+
name: "options",
|
|
1754
|
+
defaultValue: []
|
|
1755
|
+
});
|
|
1756
|
+
const columns = useColumns2({
|
|
1757
|
+
options,
|
|
1758
|
+
currencies: currencyCodes,
|
|
1759
|
+
regions,
|
|
1760
|
+
pricePreferences
|
|
1761
|
+
});
|
|
1762
|
+
const variantData = useMemo3(() => {
|
|
1763
|
+
const ret = [];
|
|
1764
|
+
variants.forEach((v, i) => {
|
|
1765
|
+
if (v.should_create) {
|
|
1766
|
+
ret.push({ ...v, originalIndex: i });
|
|
1767
|
+
}
|
|
1768
|
+
});
|
|
1769
|
+
return ret;
|
|
1770
|
+
}, [variants]);
|
|
1771
|
+
return /* @__PURE__ */ jsx11("div", { className: "flex size-full flex-col divide-y overflow-hidden", "data-testid": "product-create-variants-form", children: /* @__PURE__ */ jsx11("div", { "data-testid": "product-create-variants-form-datagrid", children: /* @__PURE__ */ jsx11(
|
|
1772
|
+
DataGrid,
|
|
1773
|
+
{
|
|
1774
|
+
columns,
|
|
1775
|
+
data: variantData,
|
|
1776
|
+
state: form,
|
|
1777
|
+
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
1778
|
+
}
|
|
1779
|
+
) }) });
|
|
1780
|
+
};
|
|
1781
|
+
var columnHelper2 = createDataGridHelper();
|
|
1782
|
+
var useColumns2 = ({
|
|
1783
|
+
options,
|
|
1784
|
+
currencies = [],
|
|
1785
|
+
regions = [],
|
|
1786
|
+
pricePreferences = []
|
|
1787
|
+
}) => {
|
|
1788
|
+
const { t } = useTranslation8();
|
|
1789
|
+
return useMemo3(
|
|
1790
|
+
() => [
|
|
1791
|
+
columnHelper2.column({
|
|
1792
|
+
id: "options",
|
|
1793
|
+
header: () => /* @__PURE__ */ jsx11("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx11("span", { className: "truncate", children: options.map((o) => o.title).join(" / ") }) }),
|
|
1794
|
+
cell: (context) => {
|
|
1795
|
+
return /* @__PURE__ */ jsx11(DataGrid.ReadonlyCell, { context, children: options.map((o) => context.row.original.options[o.title]).join(" / ") });
|
|
1796
|
+
},
|
|
1797
|
+
disableHiding: true
|
|
1798
|
+
}),
|
|
1799
|
+
columnHelper2.column({
|
|
1800
|
+
id: "title",
|
|
1801
|
+
name: t("fields.title"),
|
|
1802
|
+
header: t("fields.title"),
|
|
1803
|
+
field: (context) => `variants.${context.row.original.originalIndex}.title`,
|
|
1804
|
+
type: "text",
|
|
1805
|
+
cell: (context) => {
|
|
1806
|
+
return /* @__PURE__ */ jsx11(DataGrid.TextCell, { context });
|
|
1807
|
+
}
|
|
1808
|
+
}),
|
|
1809
|
+
columnHelper2.column({
|
|
1810
|
+
id: "sku",
|
|
1811
|
+
name: t("fields.sku"),
|
|
1812
|
+
header: t("fields.sku"),
|
|
1813
|
+
field: (context) => `variants.${context.row.original.originalIndex}.sku`,
|
|
1814
|
+
type: "text",
|
|
1815
|
+
cell: (context) => {
|
|
1816
|
+
return /* @__PURE__ */ jsx11(DataGrid.TextCell, { context });
|
|
1817
|
+
}
|
|
1818
|
+
}),
|
|
1819
|
+
columnHelper2.column({
|
|
1820
|
+
id: "manage_inventory",
|
|
1821
|
+
name: t("fields.managedInventory"),
|
|
1822
|
+
header: t("fields.managedInventory"),
|
|
1823
|
+
field: (context) => `variants.${context.row.original.originalIndex}.manage_inventory`,
|
|
1824
|
+
type: "boolean",
|
|
1825
|
+
cell: (context) => {
|
|
1826
|
+
return /* @__PURE__ */ jsx11(DataGrid.BooleanCell, { context });
|
|
1827
|
+
}
|
|
1828
|
+
}),
|
|
1829
|
+
columnHelper2.column({
|
|
1830
|
+
id: "allow_backorder",
|
|
1831
|
+
name: t("fields.allowBackorder"),
|
|
1832
|
+
header: t("fields.allowBackorder"),
|
|
1833
|
+
field: (context) => `variants.${context.row.original.originalIndex}.allow_backorder`,
|
|
1834
|
+
type: "boolean",
|
|
1835
|
+
cell: (context) => {
|
|
1836
|
+
return /* @__PURE__ */ jsx11(DataGrid.BooleanCell, { context });
|
|
1837
|
+
}
|
|
1838
|
+
}),
|
|
1839
|
+
columnHelper2.column({
|
|
1840
|
+
id: "inventory_kit",
|
|
1841
|
+
name: t("fields.inventoryKit"),
|
|
1842
|
+
header: t("fields.inventoryKit"),
|
|
1843
|
+
field: (context) => `variants.${context.row.original.originalIndex}.inventory_kit`,
|
|
1844
|
+
type: "boolean",
|
|
1845
|
+
cell: (context) => {
|
|
1846
|
+
return /* @__PURE__ */ jsx11(
|
|
1847
|
+
DataGrid.BooleanCell,
|
|
1848
|
+
{
|
|
1849
|
+
context,
|
|
1850
|
+
disabled: !context.row.original.manage_inventory
|
|
1851
|
+
}
|
|
1852
|
+
);
|
|
1853
|
+
}
|
|
1854
|
+
}),
|
|
1855
|
+
...createDataGridPriceColumns({
|
|
1856
|
+
currencies,
|
|
1857
|
+
regions,
|
|
1858
|
+
pricePreferences,
|
|
1859
|
+
getFieldName: (context, value) => {
|
|
1860
|
+
if (context.column.id?.startsWith("currency_prices")) {
|
|
1861
|
+
return `variants.${context.row.original.originalIndex}.prices.${value}`;
|
|
1862
|
+
}
|
|
1863
|
+
return `variants.${context.row.original.originalIndex}.prices.${value}`;
|
|
1864
|
+
},
|
|
1865
|
+
t
|
|
1866
|
+
})
|
|
1867
|
+
],
|
|
1868
|
+
[currencies, regions, options, pricePreferences, t]
|
|
1869
|
+
);
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
// src/pages/products/product-create/components/product-create-form/product-create-form.tsx
|
|
1873
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
1874
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1875
|
+
var SAVE_DRAFT_BUTTON = "save-draft-button";
|
|
1876
|
+
var ProductCreateForm = ({
|
|
1877
|
+
defaultChannel,
|
|
1878
|
+
regions,
|
|
1879
|
+
store,
|
|
1880
|
+
pricePreferences
|
|
1881
|
+
}) => {
|
|
1882
|
+
const [tab, setTab] = useState4("details" /* DETAILS */);
|
|
1883
|
+
const [tabState, setTabState] = useState4({
|
|
1884
|
+
["details" /* DETAILS */]: "in-progress",
|
|
1885
|
+
["organize" /* ORGANIZE */]: "not-started",
|
|
1886
|
+
["variants" /* VARIANTS */]: "not-started",
|
|
1887
|
+
["inventory" /* INVENTORY */]: "not-started"
|
|
1888
|
+
});
|
|
1889
|
+
const { t } = useTranslation9();
|
|
1890
|
+
const { handleSuccess } = useRouteModal();
|
|
1891
|
+
const direction = useDocumentDirection();
|
|
1892
|
+
const form = useForm({
|
|
1893
|
+
defaultValues: {
|
|
1894
|
+
...PRODUCT_CREATE_FORM_DEFAULTS,
|
|
1895
|
+
sales_channels: defaultChannel ? [{ id: defaultChannel.id, name: defaultChannel.name }] : []
|
|
1896
|
+
},
|
|
1897
|
+
resolver: zodResolver(ProductCreateSchema)
|
|
1898
|
+
});
|
|
1899
|
+
const { mutateAsync, isPending } = useCreateProduct();
|
|
1900
|
+
const regionsCurrencyMap = useMemo4(() => {
|
|
1901
|
+
if (!regions?.length) {
|
|
1902
|
+
return {};
|
|
1903
|
+
}
|
|
1904
|
+
return regions.reduce(
|
|
1905
|
+
(acc, reg) => {
|
|
1906
|
+
acc[reg.id] = reg.currency_code;
|
|
1907
|
+
return acc;
|
|
1908
|
+
},
|
|
1909
|
+
{}
|
|
1910
|
+
);
|
|
1911
|
+
}, [regions]);
|
|
1912
|
+
const watchedVariants = useWatch4({
|
|
1913
|
+
control: form.control,
|
|
1914
|
+
name: "variants"
|
|
1915
|
+
});
|
|
1916
|
+
const showInventoryTab = useMemo4(
|
|
1917
|
+
() => watchedVariants.some((v) => v.manage_inventory && v.inventory_kit),
|
|
1918
|
+
[watchedVariants]
|
|
1919
|
+
);
|
|
1920
|
+
const handleSubmit = form.handleSubmit(async (values, e) => {
|
|
1921
|
+
let isDraftSubmission = false;
|
|
1922
|
+
if (e?.nativeEvent instanceof SubmitEvent) {
|
|
1923
|
+
const submitter = e?.nativeEvent?.submitter;
|
|
1924
|
+
isDraftSubmission = submitter.dataset.name === SAVE_DRAFT_BUTTON;
|
|
1925
|
+
}
|
|
1926
|
+
const media = values.media || [];
|
|
1927
|
+
const payload = { ...values, media: void 0 };
|
|
1928
|
+
let uploadedMedia = [];
|
|
1929
|
+
try {
|
|
1930
|
+
if (media.length) {
|
|
1931
|
+
const thumbnailReq = media.find((m) => m.isThumbnail);
|
|
1932
|
+
const otherMediaReq = media.filter((m) => !m.isThumbnail);
|
|
1933
|
+
const fileReqs = [];
|
|
1934
|
+
if (thumbnailReq) {
|
|
1935
|
+
fileReqs.push(
|
|
1936
|
+
sdk.admin.uploads.mutate({ files: [thumbnailReq.file] }).then((r) => r.files.map((f) => ({ ...f, isThumbnail: true })))
|
|
1937
|
+
);
|
|
1938
|
+
}
|
|
1939
|
+
if (otherMediaReq?.length) {
|
|
1940
|
+
fileReqs.push(
|
|
1941
|
+
sdk.admin.uploads.mutate({
|
|
1942
|
+
files: otherMediaReq.map((m) => m.file)
|
|
1943
|
+
}).then((r) => r.files.map((f) => ({ ...f, isThumbnail: false })))
|
|
1944
|
+
);
|
|
1945
|
+
}
|
|
1946
|
+
uploadedMedia = (await Promise.all(fileReqs)).flat();
|
|
1947
|
+
}
|
|
1948
|
+
} catch (error) {
|
|
1949
|
+
if (error instanceof Error) {
|
|
1950
|
+
toast.error(error.message);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
await mutateAsync(
|
|
1954
|
+
normalizeProductFormValues({
|
|
1955
|
+
...payload,
|
|
1956
|
+
media: uploadedMedia,
|
|
1957
|
+
status: isDraftSubmission ? "draft" : "published",
|
|
1958
|
+
regionsCurrencyMap
|
|
1959
|
+
}),
|
|
1960
|
+
{
|
|
1961
|
+
onSuccess: (data) => {
|
|
1962
|
+
toast.success(
|
|
1963
|
+
t("products.create.successToast", {
|
|
1964
|
+
title: data.product.title
|
|
1965
|
+
})
|
|
1966
|
+
);
|
|
1967
|
+
handleSuccess(`../${data.product.id}`);
|
|
1968
|
+
},
|
|
1969
|
+
onError: (error) => {
|
|
1970
|
+
toast.error(error.message);
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
);
|
|
1974
|
+
});
|
|
1975
|
+
const onNext = async (currentTab) => {
|
|
1976
|
+
const valid = await form.trigger();
|
|
1977
|
+
if (!valid) {
|
|
1978
|
+
return;
|
|
1979
|
+
}
|
|
1980
|
+
if (currentTab === "details" /* DETAILS */) {
|
|
1981
|
+
setTab("organize" /* ORGANIZE */);
|
|
1982
|
+
}
|
|
1983
|
+
if (currentTab === "organize" /* ORGANIZE */) {
|
|
1984
|
+
setTab("variants" /* VARIANTS */);
|
|
1985
|
+
}
|
|
1986
|
+
if (currentTab === "variants" /* VARIANTS */) {
|
|
1987
|
+
setTab("inventory" /* INVENTORY */);
|
|
1988
|
+
}
|
|
1989
|
+
};
|
|
1990
|
+
useEffect2(() => {
|
|
1991
|
+
const currentState = { ...tabState };
|
|
1992
|
+
if (tab === "details" /* DETAILS */) {
|
|
1993
|
+
currentState["details" /* DETAILS */] = "in-progress";
|
|
1994
|
+
}
|
|
1995
|
+
if (tab === "organize" /* ORGANIZE */) {
|
|
1996
|
+
currentState["details" /* DETAILS */] = "completed";
|
|
1997
|
+
currentState["organize" /* ORGANIZE */] = "in-progress";
|
|
1998
|
+
}
|
|
1999
|
+
if (tab === "variants" /* VARIANTS */) {
|
|
2000
|
+
currentState["details" /* DETAILS */] = "completed";
|
|
2001
|
+
currentState["organize" /* ORGANIZE */] = "completed";
|
|
2002
|
+
currentState["variants" /* VARIANTS */] = "in-progress";
|
|
2003
|
+
}
|
|
2004
|
+
if (tab === "inventory" /* INVENTORY */) {
|
|
2005
|
+
currentState["details" /* DETAILS */] = "completed";
|
|
2006
|
+
currentState["organize" /* ORGANIZE */] = "completed";
|
|
2007
|
+
currentState["variants" /* VARIANTS */] = "completed";
|
|
2008
|
+
currentState["inventory" /* INVENTORY */] = "in-progress";
|
|
2009
|
+
}
|
|
2010
|
+
setTabState({ ...currentState });
|
|
2011
|
+
}, [tab]);
|
|
2012
|
+
return /* @__PURE__ */ jsx12(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs10(
|
|
2013
|
+
KeyboundForm,
|
|
2014
|
+
{
|
|
2015
|
+
"data-testid": "product-create-form",
|
|
2016
|
+
onKeyDown: (e) => {
|
|
2017
|
+
if (e.key === "Enter") {
|
|
2018
|
+
if (e.target instanceof HTMLTextAreaElement && !(e.metaKey || e.ctrlKey)) {
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
e.preventDefault();
|
|
2022
|
+
if (e.metaKey || e.ctrlKey) {
|
|
2023
|
+
if (tab !== "variants" /* VARIANTS */) {
|
|
2024
|
+
e.preventDefault();
|
|
2025
|
+
e.stopPropagation();
|
|
2026
|
+
onNext(tab);
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
handleSubmit();
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
},
|
|
2033
|
+
onSubmit: handleSubmit,
|
|
2034
|
+
className: "flex h-full flex-col",
|
|
2035
|
+
children: [
|
|
2036
|
+
/* @__PURE__ */ jsxs10(
|
|
2037
|
+
ProgressTabs,
|
|
2038
|
+
{
|
|
2039
|
+
dir: direction,
|
|
2040
|
+
value: tab,
|
|
2041
|
+
onValueChange: async (tab2) => {
|
|
2042
|
+
const valid = await form.trigger();
|
|
2043
|
+
if (!valid) {
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
setTab(tab2);
|
|
2047
|
+
},
|
|
2048
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
2049
|
+
"data-testid": "product-create-form-tabs",
|
|
2050
|
+
children: [
|
|
2051
|
+
/* @__PURE__ */ jsx12(RouteFocusModal.Header, { children: /* @__PURE__ */ jsx12(
|
|
2052
|
+
"div",
|
|
2053
|
+
{
|
|
2054
|
+
className: "-my-2 w-full border-l",
|
|
2055
|
+
"data-testid": "product-create-form-tabs-header",
|
|
2056
|
+
children: /* @__PURE__ */ jsxs10(
|
|
2057
|
+
ProgressTabs.List,
|
|
2058
|
+
{
|
|
2059
|
+
className: "justify-start-start flex w-full items-center",
|
|
2060
|
+
"data-testid": "product-create-form-tabs-list",
|
|
2061
|
+
children: [
|
|
2062
|
+
/* @__PURE__ */ jsx12(
|
|
2063
|
+
ProgressTabs.Trigger,
|
|
2064
|
+
{
|
|
2065
|
+
status: tabState["details" /* DETAILS */],
|
|
2066
|
+
value: "details" /* DETAILS */,
|
|
2067
|
+
className: "max-w-[200px] truncate",
|
|
2068
|
+
"data-testid": "product-create-form-tab-details",
|
|
2069
|
+
children: t("products.create.tabs.details")
|
|
2070
|
+
}
|
|
2071
|
+
),
|
|
2072
|
+
/* @__PURE__ */ jsx12(
|
|
2073
|
+
ProgressTabs.Trigger,
|
|
2074
|
+
{
|
|
2075
|
+
status: tabState["organize" /* ORGANIZE */],
|
|
2076
|
+
value: "organize" /* ORGANIZE */,
|
|
2077
|
+
className: "max-w-[200px] truncate",
|
|
2078
|
+
"data-testid": "product-create-form-tab-organize",
|
|
2079
|
+
children: t("products.create.tabs.organize")
|
|
2080
|
+
}
|
|
2081
|
+
),
|
|
2082
|
+
/* @__PURE__ */ jsx12(
|
|
2083
|
+
ProgressTabs.Trigger,
|
|
2084
|
+
{
|
|
2085
|
+
status: tabState["variants" /* VARIANTS */],
|
|
2086
|
+
value: "variants" /* VARIANTS */,
|
|
2087
|
+
className: "max-w-[200px] truncate",
|
|
2088
|
+
"data-testid": "product-create-form-tab-variants",
|
|
2089
|
+
children: t("products.create.tabs.variants")
|
|
2090
|
+
}
|
|
2091
|
+
),
|
|
2092
|
+
showInventoryTab && /* @__PURE__ */ jsx12(
|
|
2093
|
+
ProgressTabs.Trigger,
|
|
2094
|
+
{
|
|
2095
|
+
status: tabState["inventory" /* INVENTORY */],
|
|
2096
|
+
value: "inventory" /* INVENTORY */,
|
|
2097
|
+
className: "max-w-[200px] truncate",
|
|
2098
|
+
"data-testid": "product-create-form-tab-inventory",
|
|
2099
|
+
children: t("products.create.tabs.inventory")
|
|
2100
|
+
}
|
|
2101
|
+
)
|
|
2102
|
+
]
|
|
2103
|
+
}
|
|
2104
|
+
)
|
|
2105
|
+
}
|
|
2106
|
+
) }),
|
|
2107
|
+
/* @__PURE__ */ jsxs10(
|
|
2108
|
+
RouteFocusModal.Body,
|
|
2109
|
+
{
|
|
2110
|
+
className: "size-full overflow-hidden",
|
|
2111
|
+
"data-testid": "product-create-form-body",
|
|
2112
|
+
children: [
|
|
2113
|
+
/* @__PURE__ */ jsx12(
|
|
2114
|
+
ProgressTabs.Content,
|
|
2115
|
+
{
|
|
2116
|
+
className: "size-full overflow-y-auto",
|
|
2117
|
+
value: "details" /* DETAILS */,
|
|
2118
|
+
"data-testid": "product-create-form-tab-content-details",
|
|
2119
|
+
children: /* @__PURE__ */ jsx12(ProductCreateDetailsForm, { form })
|
|
2120
|
+
}
|
|
2121
|
+
),
|
|
2122
|
+
/* @__PURE__ */ jsx12(
|
|
2123
|
+
ProgressTabs.Content,
|
|
2124
|
+
{
|
|
2125
|
+
className: "size-full overflow-y-auto",
|
|
2126
|
+
value: "organize" /* ORGANIZE */,
|
|
2127
|
+
"data-testid": "product-create-form-tab-content-organize",
|
|
2128
|
+
children: /* @__PURE__ */ jsx12(ProductCreateOrganizeForm, { form })
|
|
2129
|
+
}
|
|
2130
|
+
),
|
|
2131
|
+
/* @__PURE__ */ jsx12(
|
|
2132
|
+
ProgressTabs.Content,
|
|
2133
|
+
{
|
|
2134
|
+
className: "size-full overflow-y-auto",
|
|
2135
|
+
value: "variants" /* VARIANTS */,
|
|
2136
|
+
"data-testid": "product-create-form-tab-content-variants",
|
|
2137
|
+
children: /* @__PURE__ */ jsx12(
|
|
2138
|
+
ProductCreateVariantsForm,
|
|
2139
|
+
{
|
|
2140
|
+
form,
|
|
2141
|
+
store,
|
|
2142
|
+
regions,
|
|
2143
|
+
pricePreferences
|
|
2144
|
+
}
|
|
2145
|
+
)
|
|
2146
|
+
}
|
|
2147
|
+
),
|
|
2148
|
+
showInventoryTab && /* @__PURE__ */ jsx12(
|
|
2149
|
+
ProgressTabs.Content,
|
|
2150
|
+
{
|
|
2151
|
+
className: "size-full overflow-y-auto",
|
|
2152
|
+
value: "inventory" /* INVENTORY */,
|
|
2153
|
+
"data-testid": "product-create-form-tab-content-inventory",
|
|
2154
|
+
children: /* @__PURE__ */ jsx12(ProductCreateInventoryKitForm, { form })
|
|
2155
|
+
}
|
|
2156
|
+
)
|
|
2157
|
+
]
|
|
2158
|
+
}
|
|
2159
|
+
)
|
|
2160
|
+
]
|
|
2161
|
+
}
|
|
2162
|
+
),
|
|
2163
|
+
/* @__PURE__ */ jsx12(RouteFocusModal.Footer, { "data-testid": "product-create-form-footer", children: /* @__PURE__ */ jsxs10(
|
|
2164
|
+
"div",
|
|
2165
|
+
{
|
|
2166
|
+
className: "flex items-center justify-end gap-x-2",
|
|
2167
|
+
"data-testid": "product-create-form-footer-actions",
|
|
2168
|
+
children: [
|
|
2169
|
+
/* @__PURE__ */ jsx12(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx12(
|
|
2170
|
+
Button5,
|
|
2171
|
+
{
|
|
2172
|
+
variant: "secondary",
|
|
2173
|
+
size: "small",
|
|
2174
|
+
"data-testid": "product-create-form-cancel-button",
|
|
2175
|
+
children: t("actions.cancel")
|
|
2176
|
+
}
|
|
2177
|
+
) }),
|
|
2178
|
+
/* @__PURE__ */ jsx12(
|
|
2179
|
+
Button5,
|
|
2180
|
+
{
|
|
2181
|
+
"data-name": SAVE_DRAFT_BUTTON,
|
|
2182
|
+
size: "small",
|
|
2183
|
+
type: "submit",
|
|
2184
|
+
isLoading: isPending,
|
|
2185
|
+
className: "whitespace-nowrap",
|
|
2186
|
+
"data-testid": "product-create-form-save-draft-button",
|
|
2187
|
+
children: t("actions.saveAsDraft")
|
|
2188
|
+
}
|
|
2189
|
+
),
|
|
2190
|
+
/* @__PURE__ */ jsx12(
|
|
2191
|
+
PrimaryButton,
|
|
2192
|
+
{
|
|
2193
|
+
tab,
|
|
2194
|
+
next: onNext,
|
|
2195
|
+
isLoading: isPending,
|
|
2196
|
+
showInventoryTab
|
|
2197
|
+
}
|
|
2198
|
+
)
|
|
2199
|
+
]
|
|
2200
|
+
}
|
|
2201
|
+
) })
|
|
2202
|
+
]
|
|
2203
|
+
}
|
|
2204
|
+
) });
|
|
2205
|
+
};
|
|
2206
|
+
var PrimaryButton = ({
|
|
2207
|
+
tab,
|
|
2208
|
+
next,
|
|
2209
|
+
isLoading,
|
|
2210
|
+
showInventoryTab
|
|
2211
|
+
}) => {
|
|
2212
|
+
const { t } = useTranslation9();
|
|
2213
|
+
if (tab === "variants" /* VARIANTS */ && !showInventoryTab || tab === "inventory" /* INVENTORY */ && showInventoryTab) {
|
|
2214
|
+
return /* @__PURE__ */ jsx12(
|
|
2215
|
+
Button5,
|
|
2216
|
+
{
|
|
2217
|
+
"data-name": "publish-button",
|
|
2218
|
+
type: "submit",
|
|
2219
|
+
variant: "primary",
|
|
2220
|
+
size: "small",
|
|
2221
|
+
isLoading,
|
|
2222
|
+
"data-testid": "product-create-form-publish-button",
|
|
2223
|
+
children: t("actions.publish")
|
|
2224
|
+
},
|
|
2225
|
+
"submit-button"
|
|
2226
|
+
);
|
|
2227
|
+
}
|
|
2228
|
+
return /* @__PURE__ */ jsx12(
|
|
2229
|
+
Button5,
|
|
2230
|
+
{
|
|
2231
|
+
type: "button",
|
|
2232
|
+
variant: "primary",
|
|
2233
|
+
size: "small",
|
|
2234
|
+
onClick: () => next(tab),
|
|
2235
|
+
"data-testid": "product-create-form-continue-button",
|
|
2236
|
+
children: t("actions.continue")
|
|
2237
|
+
},
|
|
2238
|
+
"next-button"
|
|
2239
|
+
);
|
|
2240
|
+
};
|
|
2241
|
+
|
|
2242
|
+
// src/pages/products/product-create/product-create.tsx
|
|
2243
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2244
|
+
var ProductCreate = () => {
|
|
2245
|
+
const { t } = useTranslation10();
|
|
2246
|
+
const {
|
|
2247
|
+
store,
|
|
2248
|
+
isPending: isStorePending,
|
|
2249
|
+
isError: isStoreError,
|
|
2250
|
+
error: storeError
|
|
2251
|
+
} = useStore({
|
|
2252
|
+
fields: "+default_sales_channel"
|
|
2253
|
+
});
|
|
2254
|
+
const {
|
|
2255
|
+
sales_channel,
|
|
2256
|
+
isPending: isSalesChannelPending,
|
|
2257
|
+
isError: isSalesChannelError,
|
|
2258
|
+
error: salesChannelError
|
|
2259
|
+
} = useSalesChannel(store?.default_sales_channel_id, {
|
|
2260
|
+
enabled: !!store?.default_sales_channel_id
|
|
2261
|
+
});
|
|
2262
|
+
const {
|
|
2263
|
+
regions,
|
|
2264
|
+
isPending: isRegionsPending,
|
|
2265
|
+
isError: isRegionsError,
|
|
2266
|
+
error: regionsError
|
|
2267
|
+
} = useRegions({ limit: 9999 });
|
|
2268
|
+
const {
|
|
2269
|
+
price_preferences,
|
|
2270
|
+
isPending: isPricePreferencesPending,
|
|
2271
|
+
isError: isPricePreferencesError,
|
|
2272
|
+
error: pricePreferencesError
|
|
2273
|
+
} = usePricePreferences({
|
|
2274
|
+
limit: 9999
|
|
2275
|
+
});
|
|
2276
|
+
const ready = !!store && !isStorePending && !!regions && !isRegionsPending && !!sales_channel && !isSalesChannelPending && !!price_preferences && !isPricePreferencesPending;
|
|
2277
|
+
if (isStoreError) {
|
|
2278
|
+
throw storeError;
|
|
2279
|
+
}
|
|
2280
|
+
if (isRegionsError) {
|
|
2281
|
+
throw regionsError;
|
|
2282
|
+
}
|
|
2283
|
+
if (isSalesChannelError) {
|
|
2284
|
+
throw salesChannelError;
|
|
2285
|
+
}
|
|
2286
|
+
if (isPricePreferencesError) {
|
|
2287
|
+
throw pricePreferencesError;
|
|
2288
|
+
}
|
|
2289
|
+
return /* @__PURE__ */ jsxs11(RouteFocusModal, { children: [
|
|
2290
|
+
/* @__PURE__ */ jsx13(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx13("span", { className: "sr-only", children: t("products.create.title") }) }),
|
|
2291
|
+
/* @__PURE__ */ jsx13(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx13("span", { className: "sr-only", children: t("products.create.description") }) }),
|
|
2292
|
+
ready && /* @__PURE__ */ jsx13(
|
|
2293
|
+
ProductCreateForm,
|
|
2294
|
+
{
|
|
2295
|
+
defaultChannel: sales_channel,
|
|
2296
|
+
store,
|
|
2297
|
+
pricePreferences: price_preferences,
|
|
2298
|
+
regions
|
|
2299
|
+
}
|
|
2300
|
+
)
|
|
2301
|
+
] });
|
|
2302
|
+
};
|
|
2303
|
+
export {
|
|
2304
|
+
ProductCreate as Component
|
|
2305
|
+
};
|