@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,1258 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DeprecatedPercentageInput
|
|
3
|
+
} from "./chunk-MAEP2UCK.js";
|
|
4
|
+
import {
|
|
5
|
+
AddCampaignPromotionFields
|
|
6
|
+
} from "./chunk-3LDJURK5.js";
|
|
7
|
+
import {
|
|
8
|
+
RulesFormField
|
|
9
|
+
} from "./chunk-RPIJY6TT.js";
|
|
10
|
+
import {
|
|
11
|
+
CreateCampaignSchema,
|
|
12
|
+
DEFAULT_CAMPAIGN_VALUES
|
|
13
|
+
} from "./chunk-PX675AEP.js";
|
|
14
|
+
import "./chunk-54TMLQH3.js";
|
|
15
|
+
import "./chunk-BMNW3AEU.js";
|
|
16
|
+
import "./chunk-O67KME6D.js";
|
|
17
|
+
import "./chunk-AW77UWCZ.js";
|
|
18
|
+
import {
|
|
19
|
+
currencies,
|
|
20
|
+
getCurrencySymbol
|
|
21
|
+
} from "./chunk-IQPN4PZJ.js";
|
|
22
|
+
import "./chunk-TKGWSUEI.js";
|
|
23
|
+
import {
|
|
24
|
+
KeyboundForm
|
|
25
|
+
} from "./chunk-U2ZFCAPX.js";
|
|
26
|
+
import {
|
|
27
|
+
RouteFocusModal,
|
|
28
|
+
useRouteModal
|
|
29
|
+
} from "./chunk-MWOKFNRO.js";
|
|
30
|
+
import {
|
|
31
|
+
Form
|
|
32
|
+
} from "./chunk-3QSRE5LS.js";
|
|
33
|
+
import {
|
|
34
|
+
useDocumentDirection
|
|
35
|
+
} from "./chunk-Y7QKP6QU.js";
|
|
36
|
+
import "./chunk-ORW4HNX5.js";
|
|
37
|
+
import "./chunk-ODBDAABQ.js";
|
|
38
|
+
import "./chunk-YGQUBTKR.js";
|
|
39
|
+
import "./chunk-362QMJZM.js";
|
|
40
|
+
import "./chunk-FODCCP6C.js";
|
|
41
|
+
import "./chunk-AWZFIP25.js";
|
|
42
|
+
import "./chunk-2QKPRGNK.js";
|
|
43
|
+
import "./chunk-XBMLI2YI.js";
|
|
44
|
+
import "./chunk-XL52SYWY.js";
|
|
45
|
+
import "./chunk-NS5CHWOH.js";
|
|
46
|
+
import "./chunk-WDZFLCSQ.js";
|
|
47
|
+
import "./chunk-VVTSF42Z.js";
|
|
48
|
+
import "./chunk-D3KDXELJ.js";
|
|
49
|
+
import "./chunk-2MKZ4HD4.js";
|
|
50
|
+
import "./chunk-OGYWOPHZ.js";
|
|
51
|
+
import {
|
|
52
|
+
useCampaigns,
|
|
53
|
+
useCreatePromotion
|
|
54
|
+
} from "./chunk-U62GYN4A.js";
|
|
55
|
+
import "./chunk-KTKL7M34.js";
|
|
56
|
+
import "./chunk-JJVGCTKT.js";
|
|
57
|
+
import "./chunk-I43SCBL3.js";
|
|
58
|
+
import "./chunk-LLWK3OR6.js";
|
|
59
|
+
import "./chunk-HYUGYB23.js";
|
|
60
|
+
import "./chunk-XCMR2HTV.js";
|
|
61
|
+
import "./chunk-CI5Z6FGV.js";
|
|
62
|
+
import "./chunk-LCZXAT4Q.js";
|
|
63
|
+
import "./chunk-S6LPCNXQ.js";
|
|
64
|
+
import "./chunk-T435NFHC.js";
|
|
65
|
+
import "./chunk-2KCF3ZIB.js";
|
|
66
|
+
import "./chunk-ZYNBKBY3.js";
|
|
67
|
+
import "./chunk-NBMM2TZK.js";
|
|
68
|
+
|
|
69
|
+
// src/pages/promotions/promotion-create/components/create-promotion-form/create-promotion-form.tsx
|
|
70
|
+
import { useEffect, useMemo, useState } from "react";
|
|
71
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
72
|
+
import {
|
|
73
|
+
Alert,
|
|
74
|
+
Badge,
|
|
75
|
+
Button,
|
|
76
|
+
clx,
|
|
77
|
+
CurrencyInput,
|
|
78
|
+
Divider,
|
|
79
|
+
Heading,
|
|
80
|
+
Input,
|
|
81
|
+
ProgressTabs,
|
|
82
|
+
RadioGroup,
|
|
83
|
+
Switch,
|
|
84
|
+
Text,
|
|
85
|
+
toast
|
|
86
|
+
} from "@medusajs/ui";
|
|
87
|
+
import { useForm, useWatch } from "react-hook-form";
|
|
88
|
+
import { Trans, useTranslation } from "react-i18next";
|
|
89
|
+
|
|
90
|
+
// src/pages/promotions/promotion-create/components/create-promotion-form/form-schema.ts
|
|
91
|
+
import { z } from "zod";
|
|
92
|
+
var RuleSchema = z.array(
|
|
93
|
+
z.object({
|
|
94
|
+
id: z.string().optional(),
|
|
95
|
+
attribute: z.string().min(1, { message: "Required field" }),
|
|
96
|
+
operator: z.string().min(1, { message: "Required field" }),
|
|
97
|
+
values: z.union([
|
|
98
|
+
z.number().min(1, { message: "Required field" }),
|
|
99
|
+
z.string().min(1, { message: "Required field" }),
|
|
100
|
+
z.array(z.string()).min(1, { message: "Required field" })
|
|
101
|
+
]),
|
|
102
|
+
required: z.boolean().optional(),
|
|
103
|
+
disguised: z.boolean().optional(),
|
|
104
|
+
field_type: z.string().optional()
|
|
105
|
+
})
|
|
106
|
+
);
|
|
107
|
+
var CreatePromotionSchema = z.object({
|
|
108
|
+
template_id: z.string().optional(),
|
|
109
|
+
campaign_id: z.string().optional(),
|
|
110
|
+
campaign_choice: z.enum(["none", "existing", "new"]).optional(),
|
|
111
|
+
is_automatic: z.string().toLowerCase(),
|
|
112
|
+
code: z.string().min(1),
|
|
113
|
+
type: z.enum(["buyget", "standard"]),
|
|
114
|
+
status: z.enum(["draft", "active", "inactive"]),
|
|
115
|
+
rules: RuleSchema,
|
|
116
|
+
is_tax_inclusive: z.boolean().optional(),
|
|
117
|
+
application_method: z.object({
|
|
118
|
+
allocation: z.enum(["each", "across", "once"]),
|
|
119
|
+
value: z.number().min(0).or(z.string().min(1)),
|
|
120
|
+
currency_code: z.string().optional(),
|
|
121
|
+
max_quantity: z.number().optional().nullable(),
|
|
122
|
+
target_rules: RuleSchema,
|
|
123
|
+
buy_rules: RuleSchema,
|
|
124
|
+
type: z.enum(["fixed", "percentage"]),
|
|
125
|
+
target_type: z.enum(["order", "shipping_methods", "items"])
|
|
126
|
+
}),
|
|
127
|
+
campaign: CreateCampaignSchema.optional()
|
|
128
|
+
}).refine(
|
|
129
|
+
(data) => {
|
|
130
|
+
if (data.application_method.allocation === "across") {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
return typeof data.application_method.max_quantity === "number";
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
path: ["application_method.max_quantity"],
|
|
137
|
+
message: `required field`
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// src/pages/promotions/promotion-create/components/create-promotion-form/templates.ts
|
|
142
|
+
var commonHiddenFields = [
|
|
143
|
+
"type",
|
|
144
|
+
"application_method.type"
|
|
145
|
+
];
|
|
146
|
+
var amountOfOrderHiddenFields = [...commonHiddenFields];
|
|
147
|
+
var amountOfProductHiddenFields = [...commonHiddenFields];
|
|
148
|
+
var percentageOfOrderHiddenFields = [
|
|
149
|
+
...commonHiddenFields,
|
|
150
|
+
"is_tax_inclusive"
|
|
151
|
+
];
|
|
152
|
+
var percentageOfProductHiddenFields = [
|
|
153
|
+
...commonHiddenFields,
|
|
154
|
+
"is_tax_inclusive"
|
|
155
|
+
];
|
|
156
|
+
var buyGetHiddenFields = [
|
|
157
|
+
...commonHiddenFields,
|
|
158
|
+
"application_method.value",
|
|
159
|
+
"is_tax_inclusive"
|
|
160
|
+
];
|
|
161
|
+
var freeShippingHiddenFields = [
|
|
162
|
+
...commonHiddenFields,
|
|
163
|
+
"application_method.value",
|
|
164
|
+
"application_method.allocation",
|
|
165
|
+
"is_tax_inclusive"
|
|
166
|
+
];
|
|
167
|
+
var templates = [
|
|
168
|
+
{
|
|
169
|
+
id: "amount_off_products",
|
|
170
|
+
type: "standard",
|
|
171
|
+
title: "Amount off products",
|
|
172
|
+
description: "Discount specific products or collection of products",
|
|
173
|
+
hiddenFields: amountOfProductHiddenFields,
|
|
174
|
+
defaults: {
|
|
175
|
+
is_automatic: "false",
|
|
176
|
+
type: "standard",
|
|
177
|
+
application_method: {
|
|
178
|
+
allocation: "each",
|
|
179
|
+
target_type: "items",
|
|
180
|
+
type: "fixed"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: "amount_off_order",
|
|
186
|
+
type: "standard",
|
|
187
|
+
title: "Amount off order",
|
|
188
|
+
description: "Discounts the total order amount",
|
|
189
|
+
hiddenFields: amountOfOrderHiddenFields,
|
|
190
|
+
defaults: {
|
|
191
|
+
is_automatic: "false",
|
|
192
|
+
type: "standard",
|
|
193
|
+
application_method: {
|
|
194
|
+
allocation: "across",
|
|
195
|
+
target_type: "order",
|
|
196
|
+
type: "fixed"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: "percentage_off_product",
|
|
202
|
+
type: "standard",
|
|
203
|
+
title: "Percentage off product",
|
|
204
|
+
description: "Discounts a percentage off selected products",
|
|
205
|
+
hiddenFields: percentageOfProductHiddenFields,
|
|
206
|
+
defaults: {
|
|
207
|
+
is_automatic: "false",
|
|
208
|
+
type: "standard",
|
|
209
|
+
application_method: {
|
|
210
|
+
allocation: "each",
|
|
211
|
+
target_type: "items",
|
|
212
|
+
type: "percentage"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
id: "percentage_off_order",
|
|
218
|
+
type: "standard",
|
|
219
|
+
title: "Percentage off order",
|
|
220
|
+
description: "Discounts a percentage of the total order amount",
|
|
221
|
+
hiddenFields: percentageOfOrderHiddenFields,
|
|
222
|
+
defaults: {
|
|
223
|
+
is_automatic: "false",
|
|
224
|
+
type: "standard",
|
|
225
|
+
application_method: {
|
|
226
|
+
allocation: "across",
|
|
227
|
+
target_type: "order",
|
|
228
|
+
type: "percentage"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: "buy_get",
|
|
234
|
+
type: "buy_get",
|
|
235
|
+
title: "Buy X Get Y",
|
|
236
|
+
description: "Buy X product(s), get Y product(s)",
|
|
237
|
+
hiddenFields: buyGetHiddenFields,
|
|
238
|
+
defaults: {
|
|
239
|
+
is_automatic: "false",
|
|
240
|
+
type: "buyget",
|
|
241
|
+
application_method: {
|
|
242
|
+
type: "percentage",
|
|
243
|
+
value: 100,
|
|
244
|
+
apply_to_quantity: 1,
|
|
245
|
+
max_quantity: 1
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: "shipping_discount",
|
|
251
|
+
type: "standard",
|
|
252
|
+
title: "Free shipping",
|
|
253
|
+
description: "Applies a 100% discount to shipping fees",
|
|
254
|
+
hiddenFields: freeShippingHiddenFields,
|
|
255
|
+
defaults: {
|
|
256
|
+
is_automatic: "false",
|
|
257
|
+
type: "standard",
|
|
258
|
+
application_method: {
|
|
259
|
+
allocation: "across",
|
|
260
|
+
target_type: "shipping_methods",
|
|
261
|
+
type: "percentage",
|
|
262
|
+
value: 100
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
];
|
|
267
|
+
|
|
268
|
+
// src/pages/promotions/promotion-create/components/create-promotion-form/create-promotion-form.tsx
|
|
269
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
270
|
+
var defaultValues = {
|
|
271
|
+
campaign_id: void 0,
|
|
272
|
+
template_id: templates[0].id,
|
|
273
|
+
campaign_choice: "none",
|
|
274
|
+
is_automatic: "false",
|
|
275
|
+
code: "",
|
|
276
|
+
type: "standard",
|
|
277
|
+
status: "draft",
|
|
278
|
+
rules: [],
|
|
279
|
+
is_tax_inclusive: false,
|
|
280
|
+
application_method: {
|
|
281
|
+
allocation: "each",
|
|
282
|
+
type: "fixed",
|
|
283
|
+
target_type: "items",
|
|
284
|
+
max_quantity: 1,
|
|
285
|
+
target_rules: [],
|
|
286
|
+
buy_rules: []
|
|
287
|
+
},
|
|
288
|
+
campaign: void 0
|
|
289
|
+
};
|
|
290
|
+
var CreatePromotionForm = () => {
|
|
291
|
+
const [tab, setTab] = useState("type" /* TYPE */);
|
|
292
|
+
const [tabState, setTabState] = useState({
|
|
293
|
+
["type" /* TYPE */]: "in-progress",
|
|
294
|
+
["promotion" /* PROMOTION */]: "not-started",
|
|
295
|
+
["campaign" /* CAMPAIGN */]: "not-started"
|
|
296
|
+
});
|
|
297
|
+
const { t } = useTranslation();
|
|
298
|
+
const { handleSuccess } = useRouteModal();
|
|
299
|
+
const direction = useDocumentDirection();
|
|
300
|
+
const form = useForm({
|
|
301
|
+
defaultValues,
|
|
302
|
+
resolver: zodResolver(CreatePromotionSchema)
|
|
303
|
+
});
|
|
304
|
+
const { setValue, reset, getValues } = form;
|
|
305
|
+
const [allocationMode, setAllocationMode] = useState("each");
|
|
306
|
+
const { mutateAsync: createPromotion } = useCreatePromotion();
|
|
307
|
+
const handleSubmit = form.handleSubmit(
|
|
308
|
+
async (data) => {
|
|
309
|
+
if (data.campaign_choice === "existing" && !data.campaign_id) {
|
|
310
|
+
form.setError("campaign_id", { message: t("promotions.errors.requiredField") });
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const {
|
|
314
|
+
campaign_choice: _campaignChoice,
|
|
315
|
+
is_automatic,
|
|
316
|
+
is_tax_inclusive,
|
|
317
|
+
template_id: _templateId,
|
|
318
|
+
application_method,
|
|
319
|
+
rules,
|
|
320
|
+
...promotionData
|
|
321
|
+
} = data;
|
|
322
|
+
const {
|
|
323
|
+
target_rules: targetRulesData = [],
|
|
324
|
+
buy_rules: buyRulesData = [],
|
|
325
|
+
...applicationMethodData
|
|
326
|
+
} = application_method;
|
|
327
|
+
const allocationTyped = applicationMethodData.allocation;
|
|
328
|
+
const disguisedRules = [
|
|
329
|
+
...targetRulesData.filter((r) => !!r.disguised),
|
|
330
|
+
...buyRulesData.filter((r) => !!r.disguised),
|
|
331
|
+
...rules.filter((r) => !!r.disguised)
|
|
332
|
+
];
|
|
333
|
+
const applicationMethodRuleData = {};
|
|
334
|
+
for (const rule of disguisedRules) {
|
|
335
|
+
applicationMethodRuleData[rule.attribute] = rule.field_type === "number" ? parseInt(rule.values) : rule.values;
|
|
336
|
+
}
|
|
337
|
+
const buildRulesData = (rules2) => {
|
|
338
|
+
return rules2.filter((r) => !r.disguised).map((rule) => ({
|
|
339
|
+
operator: rule.operator,
|
|
340
|
+
attribute: rule.attribute,
|
|
341
|
+
values: rule.values
|
|
342
|
+
}));
|
|
343
|
+
};
|
|
344
|
+
if (data.campaign) {
|
|
345
|
+
data.campaign.budget.attribute = data.campaign.budget.attribute || null;
|
|
346
|
+
data.campaign.budget.type = data.campaign.budget.attribute ? "use_by_attribute" : data.campaign.budget.type;
|
|
347
|
+
}
|
|
348
|
+
createPromotion(
|
|
349
|
+
{
|
|
350
|
+
...promotionData,
|
|
351
|
+
rules: buildRulesData(rules),
|
|
352
|
+
application_method: {
|
|
353
|
+
...applicationMethodData,
|
|
354
|
+
allocation: allocationTyped,
|
|
355
|
+
...applicationMethodRuleData,
|
|
356
|
+
value: parseFloat(applicationMethodData.value),
|
|
357
|
+
target_rules: buildRulesData(targetRulesData),
|
|
358
|
+
buy_rules: buildRulesData(buyRulesData),
|
|
359
|
+
max_quantity: allocationTyped === "across" ? void 0 : applicationMethodData.max_quantity
|
|
360
|
+
},
|
|
361
|
+
is_tax_inclusive,
|
|
362
|
+
is_automatic: is_automatic === "true"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
onSuccess: ({ promotion }) => {
|
|
366
|
+
toast.success(
|
|
367
|
+
t("promotions.toasts.promotionCreateSuccess", {
|
|
368
|
+
code: promotion.code
|
|
369
|
+
})
|
|
370
|
+
);
|
|
371
|
+
handleSuccess(`/promotions/${promotion.id}`);
|
|
372
|
+
},
|
|
373
|
+
onError: (e) => {
|
|
374
|
+
toast.error(e.message);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
},
|
|
379
|
+
async (error) => {
|
|
380
|
+
const { campaign: _campaign, ...rest } = error || {};
|
|
381
|
+
const errorInPromotionTab = !!Object.keys(rest || {}).length;
|
|
382
|
+
if (errorInPromotionTab) {
|
|
383
|
+
toast.error(t("promotions.errors.promotionTabError"));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
const handleTabChange = async (tab2) => {
|
|
388
|
+
switch (tab2) {
|
|
389
|
+
case "type" /* TYPE */:
|
|
390
|
+
setTabState((prev) => ({
|
|
391
|
+
...prev,
|
|
392
|
+
["type" /* TYPE */]: "in-progress"
|
|
393
|
+
}));
|
|
394
|
+
setTab(tab2);
|
|
395
|
+
break;
|
|
396
|
+
case "promotion" /* PROMOTION */:
|
|
397
|
+
setTabState((prev) => ({
|
|
398
|
+
...prev,
|
|
399
|
+
["type" /* TYPE */]: "completed",
|
|
400
|
+
["promotion" /* PROMOTION */]: "in-progress"
|
|
401
|
+
}));
|
|
402
|
+
setTab(tab2);
|
|
403
|
+
break;
|
|
404
|
+
case "campaign" /* CAMPAIGN */: {
|
|
405
|
+
const valid = await form.trigger();
|
|
406
|
+
if (!valid) {
|
|
407
|
+
setTabState({
|
|
408
|
+
["type" /* TYPE */]: "completed",
|
|
409
|
+
["promotion" /* PROMOTION */]: "in-progress",
|
|
410
|
+
["campaign" /* CAMPAIGN */]: "not-started"
|
|
411
|
+
});
|
|
412
|
+
setTab("promotion" /* PROMOTION */);
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
setTabState((prev) => ({
|
|
416
|
+
...prev,
|
|
417
|
+
["promotion" /* PROMOTION */]: "completed",
|
|
418
|
+
["campaign" /* CAMPAIGN */]: "in-progress"
|
|
419
|
+
}));
|
|
420
|
+
setTab(tab2);
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const handleContinue = async () => {
|
|
426
|
+
switch (tab) {
|
|
427
|
+
case "type" /* TYPE */:
|
|
428
|
+
handleTabChange("promotion" /* PROMOTION */);
|
|
429
|
+
break;
|
|
430
|
+
case "promotion" /* PROMOTION */: {
|
|
431
|
+
const valid = await form.trigger();
|
|
432
|
+
if (valid) {
|
|
433
|
+
handleTabChange("campaign" /* CAMPAIGN */);
|
|
434
|
+
}
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
case "campaign" /* CAMPAIGN */:
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
const watchTemplateId = useWatch({
|
|
442
|
+
control: form.control,
|
|
443
|
+
name: "template_id"
|
|
444
|
+
});
|
|
445
|
+
const currentTemplate = useMemo(() => {
|
|
446
|
+
const currentTemplate2 = templates.find((template) => template.id === watchTemplateId);
|
|
447
|
+
if (!currentTemplate2) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
reset({ ...defaultValues, template_id: watchTemplateId });
|
|
451
|
+
for (const [key, value] of Object.entries(currentTemplate2.defaults)) {
|
|
452
|
+
if (typeof value === "object") {
|
|
453
|
+
for (const [subKey, subValue] of Object.entries(value)) {
|
|
454
|
+
setValue(`application_method.${subKey}`, subValue);
|
|
455
|
+
}
|
|
456
|
+
} else {
|
|
457
|
+
setValue(key, value);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return currentTemplate2;
|
|
461
|
+
}, [watchTemplateId, setValue, reset]);
|
|
462
|
+
const watchValueType = useWatch({
|
|
463
|
+
control: form.control,
|
|
464
|
+
name: "application_method.type"
|
|
465
|
+
});
|
|
466
|
+
const isFixedValueType = watchValueType === "fixed";
|
|
467
|
+
const watchAllocation = useWatch({
|
|
468
|
+
control: form.control,
|
|
469
|
+
name: "application_method.allocation"
|
|
470
|
+
});
|
|
471
|
+
useEffect(() => {
|
|
472
|
+
if (watchAllocation) {
|
|
473
|
+
setAllocationMode(watchAllocation);
|
|
474
|
+
}
|
|
475
|
+
}, [watchAllocation]);
|
|
476
|
+
const watchType = useWatch({
|
|
477
|
+
control: form.control,
|
|
478
|
+
name: "type"
|
|
479
|
+
});
|
|
480
|
+
const isTypeStandard = watchType === "standard";
|
|
481
|
+
const isTypeBuyGet = watchType === "buyget";
|
|
482
|
+
const targetType = useWatch({
|
|
483
|
+
control: form.control,
|
|
484
|
+
name: "application_method.target_type"
|
|
485
|
+
});
|
|
486
|
+
const isTargetTypeOrder = targetType === "order";
|
|
487
|
+
const formData = form.getValues();
|
|
488
|
+
let campaignQuery = {};
|
|
489
|
+
if (formData.application_method.currency_code) {
|
|
490
|
+
campaignQuery = {
|
|
491
|
+
budget: { currency_code: formData.application_method.currency_code }
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
const { campaigns } = useCampaigns(campaignQuery);
|
|
495
|
+
const watchCampaignChoice = useWatch({
|
|
496
|
+
control: form.control,
|
|
497
|
+
name: "campaign_choice"
|
|
498
|
+
});
|
|
499
|
+
useEffect(() => {
|
|
500
|
+
const formData2 = getValues();
|
|
501
|
+
if (watchCampaignChoice !== "existing") {
|
|
502
|
+
setValue("campaign_id", void 0);
|
|
503
|
+
form.clearErrors("campaign_id");
|
|
504
|
+
}
|
|
505
|
+
if (watchCampaignChoice !== "new") {
|
|
506
|
+
setValue("campaign", void 0);
|
|
507
|
+
}
|
|
508
|
+
if (watchCampaignChoice === "new") {
|
|
509
|
+
if (!formData2.campaign || !formData2.campaign?.budget?.type) {
|
|
510
|
+
setValue("campaign", {
|
|
511
|
+
...DEFAULT_CAMPAIGN_VALUES,
|
|
512
|
+
budget: {
|
|
513
|
+
...DEFAULT_CAMPAIGN_VALUES.budget,
|
|
514
|
+
currency_code: formData2.application_method.currency_code
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}, [watchCampaignChoice, getValues, setValue]);
|
|
520
|
+
const watchRules = useWatch({
|
|
521
|
+
control: form.control,
|
|
522
|
+
name: "rules"
|
|
523
|
+
});
|
|
524
|
+
const watchCurrencyRule = watchRules.find((rule) => rule.attribute === "currency_code");
|
|
525
|
+
if (watchCurrencyRule) {
|
|
526
|
+
const formData2 = form.getValues();
|
|
527
|
+
const currencyCode = formData2.application_method.currency_code;
|
|
528
|
+
const ruleValue = watchCurrencyRule.values;
|
|
529
|
+
if (!Array.isArray(ruleValue) && currencyCode !== ruleValue) {
|
|
530
|
+
form.setValue("application_method.currency_code", ruleValue);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return /* @__PURE__ */ jsx(
|
|
534
|
+
RouteFocusModal.Form,
|
|
535
|
+
{
|
|
536
|
+
form,
|
|
537
|
+
"data-testid": "promotion-create-form",
|
|
538
|
+
children: /* @__PURE__ */ jsxs(
|
|
539
|
+
KeyboundForm,
|
|
540
|
+
{
|
|
541
|
+
className: "flex h-full flex-col",
|
|
542
|
+
onSubmit: handleSubmit,
|
|
543
|
+
children: [
|
|
544
|
+
/* @__PURE__ */ jsxs(
|
|
545
|
+
ProgressTabs,
|
|
546
|
+
{
|
|
547
|
+
dir: direction,
|
|
548
|
+
value: tab,
|
|
549
|
+
onValueChange: (tab2) => handleTabChange(tab2),
|
|
550
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
551
|
+
"data-testid": "promotion-create-form-tabs",
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, { "data-testid": "promotion-create-form-header", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-x-4", children: /* @__PURE__ */ jsx("div", { className: "-my-2 w-full max-w-[600px] border-l", children: /* @__PURE__ */ jsxs(
|
|
554
|
+
ProgressTabs.List,
|
|
555
|
+
{
|
|
556
|
+
className: "grid w-full grid-cols-3",
|
|
557
|
+
"data-testid": "promotion-create-form-tabs-list",
|
|
558
|
+
children: [
|
|
559
|
+
/* @__PURE__ */ jsx(
|
|
560
|
+
ProgressTabs.Trigger,
|
|
561
|
+
{
|
|
562
|
+
className: "w-full",
|
|
563
|
+
value: "type" /* TYPE */,
|
|
564
|
+
status: tabState["type" /* TYPE */],
|
|
565
|
+
"data-testid": "promotion-create-form-tab-type",
|
|
566
|
+
children: t("promotions.tabs.template")
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
/* @__PURE__ */ jsx(
|
|
570
|
+
ProgressTabs.Trigger,
|
|
571
|
+
{
|
|
572
|
+
className: "w-full",
|
|
573
|
+
value: "promotion" /* PROMOTION */,
|
|
574
|
+
status: tabState["promotion" /* PROMOTION */],
|
|
575
|
+
"data-testid": "promotion-create-form-tab-promotion",
|
|
576
|
+
children: t("promotions.tabs.details")
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
/* @__PURE__ */ jsx(
|
|
580
|
+
ProgressTabs.Trigger,
|
|
581
|
+
{
|
|
582
|
+
className: "w-full",
|
|
583
|
+
value: "campaign" /* CAMPAIGN */,
|
|
584
|
+
status: tabState["campaign" /* CAMPAIGN */],
|
|
585
|
+
"data-testid": "promotion-create-form-tab-campaign",
|
|
586
|
+
children: t("promotions.tabs.campaign")
|
|
587
|
+
}
|
|
588
|
+
)
|
|
589
|
+
]
|
|
590
|
+
}
|
|
591
|
+
) }) }) }),
|
|
592
|
+
/* @__PURE__ */ jsxs(
|
|
593
|
+
RouteFocusModal.Body,
|
|
594
|
+
{
|
|
595
|
+
className: "size-full overflow-hidden",
|
|
596
|
+
"data-testid": "promotion-create-form-body",
|
|
597
|
+
children: [
|
|
598
|
+
/* @__PURE__ */ jsx(
|
|
599
|
+
ProgressTabs.Content,
|
|
600
|
+
{
|
|
601
|
+
value: "type" /* TYPE */,
|
|
602
|
+
className: "size-full overflow-y-auto",
|
|
603
|
+
"data-testid": "promotion-create-form-content-type",
|
|
604
|
+
children: /* @__PURE__ */ jsx("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsx("div", { className: "w-full max-w-[720px] py-16", children: /* @__PURE__ */ jsx(
|
|
605
|
+
Form.Field,
|
|
606
|
+
{
|
|
607
|
+
control: form.control,
|
|
608
|
+
name: "template_id",
|
|
609
|
+
render: ({ field }) => {
|
|
610
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "promotion-create-form-template-item", children: [
|
|
611
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "promotion-create-form-template-label", children: t("promotions.fields.type") }),
|
|
612
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "promotion-create-form-template-control", children: /* @__PURE__ */ jsx(
|
|
613
|
+
RadioGroup,
|
|
614
|
+
{
|
|
615
|
+
dir: direction,
|
|
616
|
+
className: "flex-col gap-y-3",
|
|
617
|
+
...field,
|
|
618
|
+
onValueChange: field.onChange,
|
|
619
|
+
"data-testid": "promotion-create-form-template-radio-group",
|
|
620
|
+
children: templates.map((template) => {
|
|
621
|
+
return /* @__PURE__ */ jsx(
|
|
622
|
+
RadioGroup.ChoiceBox,
|
|
623
|
+
{
|
|
624
|
+
value: template.id,
|
|
625
|
+
label: template.title,
|
|
626
|
+
description: template.description,
|
|
627
|
+
"data-testid": `promotion-create-form-template-option-${template.id}`
|
|
628
|
+
},
|
|
629
|
+
template.id
|
|
630
|
+
);
|
|
631
|
+
})
|
|
632
|
+
},
|
|
633
|
+
"template_id"
|
|
634
|
+
) }),
|
|
635
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-template-error" })
|
|
636
|
+
] });
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
) }) })
|
|
640
|
+
}
|
|
641
|
+
),
|
|
642
|
+
/* @__PURE__ */ jsx(
|
|
643
|
+
ProgressTabs.Content,
|
|
644
|
+
{
|
|
645
|
+
value: "promotion" /* PROMOTION */,
|
|
646
|
+
className: "size-full overflow-y-auto",
|
|
647
|
+
"data-testid": "promotion-create-form-content-promotion",
|
|
648
|
+
children: /* @__PURE__ */ jsx("div", { className: "flex size-full flex-col items-center", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8 py-16", children: [
|
|
649
|
+
/* @__PURE__ */ jsxs(
|
|
650
|
+
Heading,
|
|
651
|
+
{
|
|
652
|
+
level: "h1",
|
|
653
|
+
className: "text-fg-base",
|
|
654
|
+
"data-testid": "promotion-create-form-promotion-heading",
|
|
655
|
+
children: [
|
|
656
|
+
t(`promotions.sections.details`),
|
|
657
|
+
currentTemplate?.title && /* @__PURE__ */ jsx(
|
|
658
|
+
Badge,
|
|
659
|
+
{
|
|
660
|
+
className: "ml-2 align-middle",
|
|
661
|
+
color: "grey",
|
|
662
|
+
size: "2xsmall",
|
|
663
|
+
rounded: "full",
|
|
664
|
+
"data-testid": "promotion-create-form-promotion-template-badge",
|
|
665
|
+
children: currentTemplate?.title
|
|
666
|
+
}
|
|
667
|
+
)
|
|
668
|
+
]
|
|
669
|
+
}
|
|
670
|
+
),
|
|
671
|
+
form.formState.errors.root && /* @__PURE__ */ jsx(
|
|
672
|
+
Alert,
|
|
673
|
+
{
|
|
674
|
+
variant: "error",
|
|
675
|
+
dismissible: false,
|
|
676
|
+
className: "text-balance",
|
|
677
|
+
"data-testid": "promotion-create-form-promotion-error-alert",
|
|
678
|
+
children: form.formState.errors.root.message
|
|
679
|
+
}
|
|
680
|
+
),
|
|
681
|
+
/* @__PURE__ */ jsx(
|
|
682
|
+
Form.Field,
|
|
683
|
+
{
|
|
684
|
+
control: form.control,
|
|
685
|
+
name: "is_automatic",
|
|
686
|
+
render: ({ field }) => {
|
|
687
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "promotion-create-form-method-item", children: [
|
|
688
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "promotion-create-form-method-label", children: t("promotions.form.method.label") }),
|
|
689
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "promotion-create-form-method-control", children: /* @__PURE__ */ jsxs(
|
|
690
|
+
RadioGroup,
|
|
691
|
+
{
|
|
692
|
+
dir: direction,
|
|
693
|
+
className: "flex gap-y-3",
|
|
694
|
+
...field,
|
|
695
|
+
value: field.value,
|
|
696
|
+
onValueChange: field.onChange,
|
|
697
|
+
"data-testid": "promotion-create-form-method-radio-group",
|
|
698
|
+
children: [
|
|
699
|
+
/* @__PURE__ */ jsx(
|
|
700
|
+
RadioGroup.ChoiceBox,
|
|
701
|
+
{
|
|
702
|
+
value: "false",
|
|
703
|
+
label: t("promotions.form.method.code.title"),
|
|
704
|
+
description: t("promotions.form.method.code.description"),
|
|
705
|
+
className: clx("basis-1/2"),
|
|
706
|
+
"data-testid": "promotion-create-form-method-option-code"
|
|
707
|
+
}
|
|
708
|
+
),
|
|
709
|
+
/* @__PURE__ */ jsx(
|
|
710
|
+
RadioGroup.ChoiceBox,
|
|
711
|
+
{
|
|
712
|
+
value: "true",
|
|
713
|
+
label: t("promotions.form.method.automatic.title"),
|
|
714
|
+
description: t("promotions.form.method.automatic.description"),
|
|
715
|
+
className: clx("basis-1/2"),
|
|
716
|
+
"data-testid": "promotion-create-form-method-option-automatic"
|
|
717
|
+
}
|
|
718
|
+
)
|
|
719
|
+
]
|
|
720
|
+
}
|
|
721
|
+
) }),
|
|
722
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-method-error" })
|
|
723
|
+
] });
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
),
|
|
727
|
+
/* @__PURE__ */ jsx(
|
|
728
|
+
Form.Field,
|
|
729
|
+
{
|
|
730
|
+
control: form.control,
|
|
731
|
+
name: "status",
|
|
732
|
+
render: ({ field }) => {
|
|
733
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "promotion-create-form-status-item", children: [
|
|
734
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "promotion-create-form-status-label", children: t("promotions.form.status.label") }),
|
|
735
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "promotion-create-form-status-control", children: /* @__PURE__ */ jsxs(
|
|
736
|
+
RadioGroup,
|
|
737
|
+
{
|
|
738
|
+
dir: direction,
|
|
739
|
+
className: "flex gap-y-3",
|
|
740
|
+
...field,
|
|
741
|
+
value: field.value,
|
|
742
|
+
onValueChange: field.onChange,
|
|
743
|
+
"data-testid": "promotion-create-form-status-radio-group",
|
|
744
|
+
children: [
|
|
745
|
+
/* @__PURE__ */ jsx(
|
|
746
|
+
RadioGroup.ChoiceBox,
|
|
747
|
+
{
|
|
748
|
+
value: "draft",
|
|
749
|
+
label: t("promotions.form.status.draft.title"),
|
|
750
|
+
description: t("promotions.form.status.draft.description"),
|
|
751
|
+
className: clx("basis-1/2"),
|
|
752
|
+
"data-testid": "promotion-create-form-status-option-draft"
|
|
753
|
+
}
|
|
754
|
+
),
|
|
755
|
+
/* @__PURE__ */ jsx(
|
|
756
|
+
RadioGroup.ChoiceBox,
|
|
757
|
+
{
|
|
758
|
+
value: "active",
|
|
759
|
+
label: t("promotions.form.status.active.title"),
|
|
760
|
+
description: t("promotions.form.status.active.description"),
|
|
761
|
+
className: clx("basis-1/2"),
|
|
762
|
+
"data-testid": "promotion-create-form-status-option-active"
|
|
763
|
+
}
|
|
764
|
+
)
|
|
765
|
+
]
|
|
766
|
+
}
|
|
767
|
+
) }),
|
|
768
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-status-error" })
|
|
769
|
+
] });
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
),
|
|
773
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-y-4", children: /* @__PURE__ */ jsx(
|
|
774
|
+
Form.Field,
|
|
775
|
+
{
|
|
776
|
+
control: form.control,
|
|
777
|
+
name: "code",
|
|
778
|
+
render: ({ field }) => {
|
|
779
|
+
return /* @__PURE__ */ jsxs(
|
|
780
|
+
Form.Item,
|
|
781
|
+
{
|
|
782
|
+
className: "basis-1/2",
|
|
783
|
+
"data-testid": "promotion-create-form-code-item",
|
|
784
|
+
children: [
|
|
785
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "promotion-create-form-code-label", children: t("promotions.form.code.title") }),
|
|
786
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "promotion-create-form-code-control", children: /* @__PURE__ */ jsx(
|
|
787
|
+
Input,
|
|
788
|
+
{
|
|
789
|
+
...field,
|
|
790
|
+
placeholder: "SUMMER15",
|
|
791
|
+
"data-testid": "promotion-create-form-code-input"
|
|
792
|
+
}
|
|
793
|
+
) }),
|
|
794
|
+
/* @__PURE__ */ jsx(
|
|
795
|
+
Text,
|
|
796
|
+
{
|
|
797
|
+
size: "small",
|
|
798
|
+
leading: "compact",
|
|
799
|
+
className: "text-ui-fg-subtle",
|
|
800
|
+
"data-testid": "promotion-create-form-code-description",
|
|
801
|
+
children: /* @__PURE__ */ jsx(
|
|
802
|
+
Trans,
|
|
803
|
+
{
|
|
804
|
+
t,
|
|
805
|
+
i18nKey: "promotions.form.code.description",
|
|
806
|
+
components: [/* @__PURE__ */ jsx("br", {}, "break")]
|
|
807
|
+
}
|
|
808
|
+
)
|
|
809
|
+
}
|
|
810
|
+
),
|
|
811
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-code-error" })
|
|
812
|
+
]
|
|
813
|
+
}
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
) }),
|
|
818
|
+
!currentTemplate?.hiddenFields?.includes("is_tax_inclusive") && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
819
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
820
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-x-2 gap-y-4", children: /* @__PURE__ */ jsx(
|
|
821
|
+
Form.Field,
|
|
822
|
+
{
|
|
823
|
+
control: form.control,
|
|
824
|
+
name: "is_tax_inclusive",
|
|
825
|
+
render: ({ field: { onChange, value, ...field } }) => {
|
|
826
|
+
return /* @__PURE__ */ jsxs(
|
|
827
|
+
Form.Item,
|
|
828
|
+
{
|
|
829
|
+
className: "basis-full",
|
|
830
|
+
"data-testid": "promotion-create-form-tax-inclusive-item",
|
|
831
|
+
children: [
|
|
832
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
833
|
+
/* @__PURE__ */ jsxs("div", { className: "block", children: [
|
|
834
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "promotion-create-form-tax-inclusive-label", children: t("promotions.form.taxInclusive.title") }),
|
|
835
|
+
/* @__PURE__ */ jsx(
|
|
836
|
+
Form.Hint,
|
|
837
|
+
{
|
|
838
|
+
className: "!mt-1",
|
|
839
|
+
"data-testid": "promotion-create-form-tax-inclusive-hint",
|
|
840
|
+
children: t("promotions.form.taxInclusive.description")
|
|
841
|
+
}
|
|
842
|
+
)
|
|
843
|
+
] }),
|
|
844
|
+
/* @__PURE__ */ jsx(
|
|
845
|
+
Form.Control,
|
|
846
|
+
{
|
|
847
|
+
className: "mr-2 self-center",
|
|
848
|
+
"data-testid": "promotion-create-form-tax-inclusive-control",
|
|
849
|
+
children: /* @__PURE__ */ jsx(
|
|
850
|
+
Switch,
|
|
851
|
+
{
|
|
852
|
+
dir: "ltr",
|
|
853
|
+
className: "mt-[2px] rtl:rotate-180",
|
|
854
|
+
checked: !!value,
|
|
855
|
+
onCheckedChange: onChange,
|
|
856
|
+
...field,
|
|
857
|
+
"data-testid": "promotion-create-form-tax-inclusive-switch"
|
|
858
|
+
}
|
|
859
|
+
)
|
|
860
|
+
}
|
|
861
|
+
)
|
|
862
|
+
] }),
|
|
863
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-tax-inclusive-error" })
|
|
864
|
+
]
|
|
865
|
+
}
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
) })
|
|
870
|
+
] }),
|
|
871
|
+
!currentTemplate?.hiddenFields?.includes("type") && /* @__PURE__ */ jsx(
|
|
872
|
+
Form.Field,
|
|
873
|
+
{
|
|
874
|
+
control: form.control,
|
|
875
|
+
name: "type",
|
|
876
|
+
render: ({ field }) => {
|
|
877
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "promotion-create-form-type-item", children: [
|
|
878
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "promotion-create-form-type-label", children: t("promotions.fields.type") }),
|
|
879
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "promotion-create-form-type-control", children: /* @__PURE__ */ jsxs(
|
|
880
|
+
RadioGroup,
|
|
881
|
+
{
|
|
882
|
+
dir: direction,
|
|
883
|
+
className: "flex gap-y-3",
|
|
884
|
+
...field,
|
|
885
|
+
onValueChange: field.onChange,
|
|
886
|
+
"data-testid": "promotion-create-form-type-radio-group",
|
|
887
|
+
children: [
|
|
888
|
+
/* @__PURE__ */ jsx(
|
|
889
|
+
RadioGroup.ChoiceBox,
|
|
890
|
+
{
|
|
891
|
+
value: "standard",
|
|
892
|
+
label: t("promotions.form.type.standard.title"),
|
|
893
|
+
description: t("promotions.form.type.standard.description"),
|
|
894
|
+
className: clx("basis-1/2"),
|
|
895
|
+
"data-testid": "promotion-create-form-type-option-standard"
|
|
896
|
+
}
|
|
897
|
+
),
|
|
898
|
+
/* @__PURE__ */ jsx(
|
|
899
|
+
RadioGroup.ChoiceBox,
|
|
900
|
+
{
|
|
901
|
+
value: "buyget",
|
|
902
|
+
label: t("promotions.form.type.buyget.title"),
|
|
903
|
+
description: t("promotions.form.type.buyget.description"),
|
|
904
|
+
className: clx("basis-1/2"),
|
|
905
|
+
"data-testid": "promotion-create-form-type-option-buyget"
|
|
906
|
+
}
|
|
907
|
+
)
|
|
908
|
+
]
|
|
909
|
+
}
|
|
910
|
+
) }),
|
|
911
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-type-error" })
|
|
912
|
+
] });
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
),
|
|
916
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
917
|
+
/* @__PURE__ */ jsx(
|
|
918
|
+
RulesFormField,
|
|
919
|
+
{
|
|
920
|
+
form,
|
|
921
|
+
ruleType: "rules"
|
|
922
|
+
}
|
|
923
|
+
),
|
|
924
|
+
!currentTemplate?.hiddenFields?.includes("application_method.type") && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
925
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
926
|
+
/* @__PURE__ */ jsx(
|
|
927
|
+
Form.Field,
|
|
928
|
+
{
|
|
929
|
+
control: form.control,
|
|
930
|
+
name: "application_method.type",
|
|
931
|
+
render: ({ field }) => {
|
|
932
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "promotion-create-form-value-type-item", children: [
|
|
933
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "promotion-create-form-value-type-label", children: t("promotions.fields.value_type") }),
|
|
934
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "promotion-create-form-value-type-control", children: /* @__PURE__ */ jsxs(
|
|
935
|
+
RadioGroup,
|
|
936
|
+
{
|
|
937
|
+
dir: direction,
|
|
938
|
+
className: "flex gap-y-3",
|
|
939
|
+
...field,
|
|
940
|
+
onValueChange: field.onChange,
|
|
941
|
+
"data-testid": "promotion-create-form-value-type-radio-group",
|
|
942
|
+
children: [
|
|
943
|
+
/* @__PURE__ */ jsx(
|
|
944
|
+
RadioGroup.ChoiceBox,
|
|
945
|
+
{
|
|
946
|
+
value: "fixed",
|
|
947
|
+
label: t("promotions.form.value_type.fixed.title"),
|
|
948
|
+
description: t("promotions.form.value_type.fixed.description"),
|
|
949
|
+
className: clx("basis-1/2"),
|
|
950
|
+
"data-testid": "promotion-create-form-value-type-option-fixed"
|
|
951
|
+
}
|
|
952
|
+
),
|
|
953
|
+
/* @__PURE__ */ jsx(
|
|
954
|
+
RadioGroup.ChoiceBox,
|
|
955
|
+
{
|
|
956
|
+
value: "percentage",
|
|
957
|
+
label: t("promotions.form.value_type.percentage.title"),
|
|
958
|
+
description: t(
|
|
959
|
+
"promotions.form.value_type.percentage.description"
|
|
960
|
+
),
|
|
961
|
+
className: clx("basis-1/2"),
|
|
962
|
+
"data-testid": "promotion-create-form-value-type-option-percentage"
|
|
963
|
+
}
|
|
964
|
+
)
|
|
965
|
+
]
|
|
966
|
+
}
|
|
967
|
+
) }),
|
|
968
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-value-type-error" })
|
|
969
|
+
] });
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
)
|
|
973
|
+
] }),
|
|
974
|
+
!currentTemplate?.hiddenFields?.includes("application_method.value") && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
975
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
976
|
+
/* @__PURE__ */ jsx(
|
|
977
|
+
Form.Field,
|
|
978
|
+
{
|
|
979
|
+
control: form.control,
|
|
980
|
+
name: "application_method.value",
|
|
981
|
+
render: ({ field: { onChange, value, ...field } }) => {
|
|
982
|
+
const currencyCode = form.getValues().application_method.currency_code;
|
|
983
|
+
const currencyInfo = currencies[currencyCode?.toUpperCase() || "USD"];
|
|
984
|
+
return /* @__PURE__ */ jsxs(
|
|
985
|
+
Form.Item,
|
|
986
|
+
{
|
|
987
|
+
className: "basis-1/2",
|
|
988
|
+
"data-testid": "promotion-create-form-value-item",
|
|
989
|
+
children: [
|
|
990
|
+
/* @__PURE__ */ jsx(
|
|
991
|
+
Form.Label,
|
|
992
|
+
{
|
|
993
|
+
tooltip: currencyCode || !isFixedValueType ? void 0 : t("promotions.fields.amount.tooltip"),
|
|
994
|
+
"data-testid": "promotion-create-form-value-label",
|
|
995
|
+
children: t("promotions.form.value.title")
|
|
996
|
+
}
|
|
997
|
+
),
|
|
998
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "promotion-create-form-value-control", children: isFixedValueType ? /* @__PURE__ */ jsx(
|
|
999
|
+
CurrencyInput,
|
|
1000
|
+
{
|
|
1001
|
+
...field,
|
|
1002
|
+
min: 0,
|
|
1003
|
+
code: currencyCode || "USD",
|
|
1004
|
+
onValueChange: (_value, _name, values) => onChange(values?.value),
|
|
1005
|
+
decimalScale: currencyInfo?.decimal_digits ?? 2,
|
|
1006
|
+
decimalsLimit: currencyInfo?.decimal_digits ?? 2,
|
|
1007
|
+
symbol: currencyCode ? getCurrencySymbol(currencyCode) : "$",
|
|
1008
|
+
value,
|
|
1009
|
+
disabled: !currencyCode,
|
|
1010
|
+
"data-testid": "promotion-create-form-value-currency-input"
|
|
1011
|
+
}
|
|
1012
|
+
) : /* @__PURE__ */ jsx(
|
|
1013
|
+
DeprecatedPercentageInput,
|
|
1014
|
+
{
|
|
1015
|
+
className: "text-right",
|
|
1016
|
+
min: 0,
|
|
1017
|
+
max: 100,
|
|
1018
|
+
...field,
|
|
1019
|
+
value,
|
|
1020
|
+
onChange: (e) => {
|
|
1021
|
+
onChange(
|
|
1022
|
+
e.target.value === "" ? null : parseFloat(e.target.value)
|
|
1023
|
+
);
|
|
1024
|
+
},
|
|
1025
|
+
"data-testid": "promotion-create-form-value-percentage-input"
|
|
1026
|
+
},
|
|
1027
|
+
"amount"
|
|
1028
|
+
) }),
|
|
1029
|
+
/* @__PURE__ */ jsx(
|
|
1030
|
+
Text,
|
|
1031
|
+
{
|
|
1032
|
+
size: "small",
|
|
1033
|
+
leading: "compact",
|
|
1034
|
+
className: "text-ui-fg-subtle",
|
|
1035
|
+
"data-testid": "promotion-create-form-value-description",
|
|
1036
|
+
children: /* @__PURE__ */ jsx(
|
|
1037
|
+
Trans,
|
|
1038
|
+
{
|
|
1039
|
+
t,
|
|
1040
|
+
i18nKey: isFixedValueType ? "promotions.form.value_type.fixed.description" : "promotions.form.value_type.percentage.description",
|
|
1041
|
+
components: [/* @__PURE__ */ jsx("br", {}, "break")]
|
|
1042
|
+
}
|
|
1043
|
+
)
|
|
1044
|
+
}
|
|
1045
|
+
),
|
|
1046
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-value-error" })
|
|
1047
|
+
]
|
|
1048
|
+
}
|
|
1049
|
+
);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
)
|
|
1053
|
+
] }),
|
|
1054
|
+
(isTypeStandard || isTypeBuyGet) && allocationMode !== "across" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1055
|
+
isTypeBuyGet && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Divider, {}) }),
|
|
1056
|
+
/* @__PURE__ */ jsx(
|
|
1057
|
+
Form.Field,
|
|
1058
|
+
{
|
|
1059
|
+
control: form.control,
|
|
1060
|
+
name: "application_method.max_quantity",
|
|
1061
|
+
render: () => {
|
|
1062
|
+
return /* @__PURE__ */ jsxs(
|
|
1063
|
+
Form.Item,
|
|
1064
|
+
{
|
|
1065
|
+
className: "basis-1/2",
|
|
1066
|
+
"data-testid": "promotion-create-form-max-quantity-item",
|
|
1067
|
+
children: [
|
|
1068
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "promotion-create-form-max-quantity-label", children: t("promotions.form.max_quantity.title") }),
|
|
1069
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "promotion-create-form-max-quantity-control", children: /* @__PURE__ */ jsx(
|
|
1070
|
+
Input,
|
|
1071
|
+
{
|
|
1072
|
+
...form.register("application_method.max_quantity", {
|
|
1073
|
+
valueAsNumber: true
|
|
1074
|
+
}),
|
|
1075
|
+
type: "number",
|
|
1076
|
+
min: 1,
|
|
1077
|
+
placeholder: "3",
|
|
1078
|
+
"data-testid": "promotion-create-form-max-quantity-input"
|
|
1079
|
+
}
|
|
1080
|
+
) }),
|
|
1081
|
+
/* @__PURE__ */ jsx(
|
|
1082
|
+
Text,
|
|
1083
|
+
{
|
|
1084
|
+
size: "small",
|
|
1085
|
+
leading: "compact",
|
|
1086
|
+
className: "text-ui-fg-subtle",
|
|
1087
|
+
"data-testid": "promotion-create-form-max-quantity-description",
|
|
1088
|
+
children: /* @__PURE__ */ jsx(
|
|
1089
|
+
Trans,
|
|
1090
|
+
{
|
|
1091
|
+
t,
|
|
1092
|
+
i18nKey: "promotions.form.max_quantity.description",
|
|
1093
|
+
components: [/* @__PURE__ */ jsx("br", {}, "break")]
|
|
1094
|
+
}
|
|
1095
|
+
)
|
|
1096
|
+
}
|
|
1097
|
+
),
|
|
1098
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-max-quantity-error" })
|
|
1099
|
+
]
|
|
1100
|
+
}
|
|
1101
|
+
);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
)
|
|
1105
|
+
] }),
|
|
1106
|
+
!currentTemplate?.hiddenFields?.includes("application_method.allocation") && /* @__PURE__ */ jsx(
|
|
1107
|
+
Form.Field,
|
|
1108
|
+
{
|
|
1109
|
+
control: form.control,
|
|
1110
|
+
name: "application_method.allocation",
|
|
1111
|
+
render: ({ field }) => {
|
|
1112
|
+
const handleAllocationChange = (value) => {
|
|
1113
|
+
setAllocationMode(value);
|
|
1114
|
+
setValue(
|
|
1115
|
+
"application_method.allocation",
|
|
1116
|
+
value
|
|
1117
|
+
);
|
|
1118
|
+
field.onChange(value);
|
|
1119
|
+
if (value === "once") {
|
|
1120
|
+
setValue("application_method.max_quantity", 1);
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "promotion-create-form-allocation-item", children: [
|
|
1124
|
+
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "promotion-create-form-allocation-label", children: t("promotions.fields.allocation") }),
|
|
1125
|
+
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "promotion-create-form-allocation-control", children: /* @__PURE__ */ jsxs(
|
|
1126
|
+
RadioGroup,
|
|
1127
|
+
{
|
|
1128
|
+
dir: direction,
|
|
1129
|
+
className: "flex gap-y-3",
|
|
1130
|
+
value: allocationMode,
|
|
1131
|
+
onValueChange: (val) => handleAllocationChange(val),
|
|
1132
|
+
"data-testid": "promotion-create-form-allocation-radio-group",
|
|
1133
|
+
children: [
|
|
1134
|
+
/* @__PURE__ */ jsx(
|
|
1135
|
+
RadioGroup.ChoiceBox,
|
|
1136
|
+
{
|
|
1137
|
+
value: "each",
|
|
1138
|
+
label: t("promotions.form.allocation.each.title"),
|
|
1139
|
+
description: t("promotions.form.allocation.each.description"),
|
|
1140
|
+
className: clx("basis-1/2"),
|
|
1141
|
+
"data-testid": "promotion-create-form-allocation-option-each"
|
|
1142
|
+
}
|
|
1143
|
+
),
|
|
1144
|
+
/* @__PURE__ */ jsx(
|
|
1145
|
+
RadioGroup.ChoiceBox,
|
|
1146
|
+
{
|
|
1147
|
+
value: "once",
|
|
1148
|
+
label: t("promotions.form.allocation.once.title", {
|
|
1149
|
+
defaultValue: "Once"
|
|
1150
|
+
}),
|
|
1151
|
+
description: t("promotions.form.allocation.once.description", {
|
|
1152
|
+
defaultValue: "Limit discount to max quantity"
|
|
1153
|
+
}),
|
|
1154
|
+
className: clx("basis-1/2"),
|
|
1155
|
+
"data-testid": "promotion-create-form-allocation-option-once"
|
|
1156
|
+
}
|
|
1157
|
+
)
|
|
1158
|
+
]
|
|
1159
|
+
}
|
|
1160
|
+
) }),
|
|
1161
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "promotion-create-form-allocation-error" })
|
|
1162
|
+
] });
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
),
|
|
1166
|
+
!isTypeStandard && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1167
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
1168
|
+
/* @__PURE__ */ jsx(
|
|
1169
|
+
RulesFormField,
|
|
1170
|
+
{
|
|
1171
|
+
form,
|
|
1172
|
+
ruleType: "buy-rules",
|
|
1173
|
+
scope: "application_method.buy_rules"
|
|
1174
|
+
}
|
|
1175
|
+
)
|
|
1176
|
+
] }),
|
|
1177
|
+
!isTargetTypeOrder && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1178
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
1179
|
+
/* @__PURE__ */ jsx(
|
|
1180
|
+
RulesFormField,
|
|
1181
|
+
{
|
|
1182
|
+
form,
|
|
1183
|
+
ruleType: "target-rules",
|
|
1184
|
+
scope: "application_method.target_rules"
|
|
1185
|
+
}
|
|
1186
|
+
)
|
|
1187
|
+
] })
|
|
1188
|
+
] }) })
|
|
1189
|
+
}
|
|
1190
|
+
),
|
|
1191
|
+
/* @__PURE__ */ jsx(
|
|
1192
|
+
ProgressTabs.Content,
|
|
1193
|
+
{
|
|
1194
|
+
value: "campaign" /* CAMPAIGN */,
|
|
1195
|
+
className: "size-full overflow-auto",
|
|
1196
|
+
"data-testid": "promotion-create-form-content-campaign",
|
|
1197
|
+
children: /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center", children: /* @__PURE__ */ jsx("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8 py-16", children: /* @__PURE__ */ jsx(
|
|
1198
|
+
AddCampaignPromotionFields,
|
|
1199
|
+
{
|
|
1200
|
+
form,
|
|
1201
|
+
campaigns: campaigns || []
|
|
1202
|
+
}
|
|
1203
|
+
) }) })
|
|
1204
|
+
}
|
|
1205
|
+
)
|
|
1206
|
+
]
|
|
1207
|
+
}
|
|
1208
|
+
)
|
|
1209
|
+
]
|
|
1210
|
+
}
|
|
1211
|
+
),
|
|
1212
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { "data-testid": "promotion-create-form-footer", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
1213
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
1214
|
+
Button,
|
|
1215
|
+
{
|
|
1216
|
+
variant: "secondary",
|
|
1217
|
+
size: "small",
|
|
1218
|
+
"data-testid": "promotion-create-form-cancel-button",
|
|
1219
|
+
children: t("actions.cancel")
|
|
1220
|
+
}
|
|
1221
|
+
) }),
|
|
1222
|
+
tab === "campaign" /* CAMPAIGN */ ? /* @__PURE__ */ jsx(
|
|
1223
|
+
Button,
|
|
1224
|
+
{
|
|
1225
|
+
type: "submit",
|
|
1226
|
+
size: "small",
|
|
1227
|
+
isLoading: false,
|
|
1228
|
+
"data-testid": "promotion-create-form-save-button",
|
|
1229
|
+
children: t("actions.save")
|
|
1230
|
+
},
|
|
1231
|
+
"save-btn"
|
|
1232
|
+
) : /* @__PURE__ */ jsx(
|
|
1233
|
+
Button,
|
|
1234
|
+
{
|
|
1235
|
+
type: "button",
|
|
1236
|
+
onClick: handleContinue,
|
|
1237
|
+
size: "small",
|
|
1238
|
+
"data-testid": "promotion-create-form-continue-button",
|
|
1239
|
+
children: t("actions.continue")
|
|
1240
|
+
},
|
|
1241
|
+
"continue-btn"
|
|
1242
|
+
)
|
|
1243
|
+
] }) })
|
|
1244
|
+
]
|
|
1245
|
+
}
|
|
1246
|
+
)
|
|
1247
|
+
}
|
|
1248
|
+
);
|
|
1249
|
+
};
|
|
1250
|
+
|
|
1251
|
+
// src/pages/promotions/promotion-create/promotion-create.tsx
|
|
1252
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
1253
|
+
var PromotionCreate = () => {
|
|
1254
|
+
return /* @__PURE__ */ jsx2(RouteFocusModal, { children: /* @__PURE__ */ jsx2(CreatePromotionForm, {}) });
|
|
1255
|
+
};
|
|
1256
|
+
export {
|
|
1257
|
+
PromotionCreate as Component
|
|
1258
|
+
};
|