@mercurjs/vendor 2.0.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/[id]-23D3HY3G.js +444 -0
- package/dist/[id]-2VBOAZM4.js +1215 -0
- package/dist/[id]-A4FSDRER.js +325 -0
- package/dist/[id]-E45G2SDA.js +213 -0
- package/dist/[id]-FXKSI52D.js +477 -0
- package/dist/[id]-HHZ3BSXV.js +1166 -0
- package/dist/[id]-MIV4U5UW.js +137 -0
- package/dist/[id]-QSRIPPIP.js +612 -0
- package/dist/[id]-RGDXOC7T.js +499 -0
- package/dist/[id]-TI2MOR2C.js +377 -0
- package/dist/[id]-U5DT2ZLS.js +301 -0
- package/dist/[id]-UMFGLDM2.js +354 -0
- package/dist/[id]-VTFOP3BF.js +97 -0
- package/dist/[id]-ZYF75L6G.js +479 -0
- package/dist/[location_id]-4UIEW5KM.js +685 -0
- package/dist/[province_id]-ZCHPXXQN.js +205 -0
- package/dist/add-KNDQL6YN.js +660 -0
- package/dist/add-customer-groups-JA346MTF.js +275 -0
- package/dist/add-products-2VB57KXV.js +273 -0
- package/dist/add-promotions-KVKEP6EO.js +260 -0
- package/dist/add-to-campaign-V6D7JKRS.js +44 -0
- package/dist/additional-attributes-E36EZX4V.js +219 -0
- package/dist/adjust-inventory-P7AB7VIB.js +228 -0
- package/dist/allocate-items-QAS5PZLR.js +529 -0
- package/dist/areas-Y7VDWH7G.js +151 -0
- package/dist/attributes-UEM2VJKV.js +277 -0
- package/dist/breadcrumb-3QTVWXZB.js +27 -0
- package/dist/breadcrumb-5OTOCYNL.js +38 -0
- package/dist/breadcrumb-6NAAOPIY.js +11 -0
- package/dist/breadcrumb-ASB2YCNV.js +25 -0
- package/dist/breadcrumb-CIGKLKKS.js +28 -0
- package/dist/breadcrumb-EOYLR3IQ.js +22 -0
- package/dist/breadcrumb-LENACUAA.js +22 -0
- package/dist/breadcrumb-LIXGWUQF.js +44 -0
- package/dist/breadcrumb-MOQ7GI3Z.js +27 -0
- package/dist/breadcrumb-NCBGPQML.js +23 -0
- package/dist/breadcrumb-OVMEC5OZ.js +33 -0
- package/dist/breadcrumb-RIXJ5QSX.js +45 -0
- package/dist/breadcrumb-TZB6EWNC.js +31 -0
- package/dist/breadcrumb-WP34OXGQ.js +23 -0
- package/dist/campaigns-PMVKUFEA.js +28 -0
- package/dist/categories-CKKIUMYG.js +27 -0
- package/dist/chunk-26OOAKQ6.js +18 -0
- package/dist/chunk-2C3HUJ3Z.js +222 -0
- package/dist/chunk-2F3H6ORE.js +36 -0
- package/dist/chunk-2ZFELO2L.js +13 -0
- package/dist/chunk-3CK6OINO.js +448 -0
- package/dist/chunk-3EF54XFY.js +64 -0
- package/dist/chunk-3LPVUPZZ.js +74 -0
- package/dist/chunk-3QSRE5LS.js +161 -0
- package/dist/chunk-3SIDRPKT.js +185 -0
- package/dist/chunk-4F5GP7J7.js +45 -0
- package/dist/chunk-4GPAS5GW.js +36 -0
- package/dist/chunk-4MFMCZEJ.js +70 -0
- package/dist/chunk-4TBDDMFP.js +425 -0
- package/dist/chunk-4TLP3TAA.js +34 -0
- package/dist/chunk-54TMLQH3.js +9 -0
- package/dist/chunk-5NF4OTVV.js +169 -0
- package/dist/chunk-66V3GFSW.js +138 -0
- package/dist/chunk-6EYGH3TB.js +26 -0
- package/dist/chunk-6IJMSVC6.js +16 -0
- package/dist/chunk-6YA3C4NB.js +55 -0
- package/dist/chunk-7AV5EJJ5.js +29 -0
- package/dist/chunk-7RPRNVBS.js +45 -0
- package/dist/chunk-A2SY5L5G.js +183 -0
- package/dist/chunk-A5DJIOHN.js +4 -0
- package/dist/chunk-AIFLEWO2.js +56 -0
- package/dist/chunk-ASVMGV2B.js +80 -0
- package/dist/chunk-AW77UWCZ.js +363 -0
- package/dist/chunk-AYUG34XF.js +84 -0
- package/dist/chunk-AYVH6Q5O.js +31 -0
- package/dist/chunk-B2RVONU7.js +160 -0
- package/dist/chunk-BCU3FKP2.js +18 -0
- package/dist/chunk-BDGZ4EQO.js +86 -0
- package/dist/chunk-BDZOSMAX.js +23 -0
- package/dist/chunk-C6SUTRP2.js +13 -0
- package/dist/chunk-CDIZEXFJ.js +145 -0
- package/dist/chunk-CFETU5BI.js +261 -0
- package/dist/chunk-CMHI2RPL.js +20 -0
- package/dist/chunk-CP5IL4P6.js +98 -0
- package/dist/chunk-CUO22GTM.js +96 -0
- package/dist/chunk-CVVYQI5F.js +41 -0
- package/dist/chunk-DARJTN4I.js +60 -0
- package/dist/chunk-DB6ANJBO.js +35 -0
- package/dist/chunk-DC2K6CFQ.js +86 -0
- package/dist/chunk-DDEIH66R.js +123 -0
- package/dist/chunk-DY3XQPHC.js +31 -0
- package/dist/chunk-DYUTYBAQ.js +67 -0
- package/dist/chunk-E3MNEQID.js +24 -0
- package/dist/chunk-FBZHM2QZ.js +247 -0
- package/dist/chunk-FDZC3TFZ.js +717 -0
- package/dist/chunk-FGCKXH45.js +263 -0
- package/dist/chunk-FMFVTERD.js +0 -0
- package/dist/chunk-FOMEBUX6.js +89 -0
- package/dist/chunk-FQERBIVS.js +0 -0
- package/dist/chunk-GC33DBKG.js +143 -0
- package/dist/chunk-GDMNHL7E.js +144 -0
- package/dist/chunk-GTUR4HSV.js +53 -0
- package/dist/chunk-H35HHFTB.js +225 -0
- package/dist/chunk-HB3BP55W.js +25 -0
- package/dist/chunk-HHD2VUED.js +29 -0
- package/dist/chunk-HUNGNEPY.js +312 -0
- package/dist/chunk-HUZG6A3X.js +127 -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-J2XP7VRG.js +1080 -0
- package/dist/chunk-JHIMVLB2.js +42 -0
- package/dist/chunk-JKXAL7WR.js +92 -0
- package/dist/chunk-JRTZWK77.js +1764 -0
- package/dist/chunk-JVBLYMY2.js +268 -0
- package/dist/chunk-JXP5YZ77.js +86 -0
- package/dist/chunk-KAZ5BYTQ.js +132 -0
- package/dist/chunk-KHHY7EEM.js +267 -0
- package/dist/chunk-LAVHRER2.js +17 -0
- package/dist/chunk-LQSLDDPT.js +67 -0
- package/dist/chunk-LWVBKUUL.js +77 -0
- package/dist/chunk-LYUCDASZ.js +115 -0
- package/dist/chunk-LZ7QV42C.js +37 -0
- package/dist/chunk-MAEP2UCK.js +110 -0
- package/dist/chunk-MG4GKUJW.js +31 -0
- package/dist/chunk-N2TQXB44.js +1280 -0
- package/dist/chunk-N3T24SEK.js +32 -0
- package/dist/chunk-NANYVBFI.js +106 -0
- package/dist/chunk-NCMUZ6BQ.js +0 -0
- package/dist/chunk-NCYTM57J.js +160 -0
- package/dist/chunk-NX26QE2O.js +47 -0
- package/dist/chunk-NYDJTWRL.js +389 -0
- package/dist/chunk-O5LRZEG6.js +253 -0
- package/dist/chunk-O6PRBSFL.js +115 -0
- package/dist/chunk-OJCDB3N5.js +539 -0
- package/dist/chunk-OSFOX7MG.js +176 -0
- package/dist/chunk-OVPAOBZB.js +110 -0
- package/dist/chunk-PADOWAXM.js +118 -0
- package/dist/chunk-PHOCVOZ5.js +9 -0
- package/dist/chunk-PKBMQBKP.js +7 -0
- package/dist/chunk-PLSJ74T2.js +298 -0
- package/dist/chunk-PVZBDWLK.js +41 -0
- package/dist/chunk-PWZKFTJS.js +247 -0
- package/dist/chunk-PXYDR7WQ.js +48 -0
- package/dist/chunk-PYQJ5N25.js +191 -0
- package/dist/chunk-Q4UVXS46.js +14 -0
- package/dist/chunk-QDPLZDMX.js +17 -0
- package/dist/chunk-QSGR43JM.js +30 -0
- package/dist/chunk-QUNDGPF7.js +92801 -0
- package/dist/chunk-R65A4P4H.js +136 -0
- package/dist/chunk-RE7YXVFG.js +128 -0
- package/dist/chunk-RETT6WME.js +37 -0
- package/dist/chunk-RHKRREUU.js +15 -0
- package/dist/chunk-RIILGKYR.js +32 -0
- package/dist/chunk-RM5RSDYP.js +353 -0
- package/dist/chunk-RNC4NFVK.js +170 -0
- package/dist/chunk-RSMZHZI2.js +2078 -0
- package/dist/chunk-RXM4B6HR.js +8 -0
- package/dist/chunk-S2WEYEQR.js +14 -0
- package/dist/chunk-S3PQKKNV.js +49 -0
- package/dist/chunk-S5GQ2SES.js +276 -0
- package/dist/chunk-SECZTXSU.js +31 -0
- package/dist/chunk-SI4ALL7W.js +180 -0
- package/dist/chunk-SID3COTK.js +21 -0
- package/dist/chunk-SMQT3ZNO.js +8 -0
- package/dist/chunk-SOZMJA7V.js +61 -0
- package/dist/chunk-TG3TCIL6.js +207 -0
- package/dist/chunk-THHRRYRS.js +16 -0
- package/dist/chunk-TKGWSUEI.js +0 -0
- package/dist/chunk-TTFCO5HU.js +173 -0
- package/dist/chunk-TXEPCJEQ.js +430 -0
- package/dist/chunk-U2EI2ZLM.js +32 -0
- package/dist/chunk-U2ZFCAPX.js +34 -0
- package/dist/chunk-U3X4DNV6.js +179 -0
- package/dist/chunk-UXKKD4AD.js +437 -0
- package/dist/chunk-UYJ65N46.js +261 -0
- package/dist/chunk-VDWGP2U6.js +71 -0
- package/dist/chunk-VGJTARSA.js +89 -0
- package/dist/chunk-VHMGJUYN.js +28 -0
- package/dist/chunk-VKC3XKFF.js +283 -0
- package/dist/chunk-VKOE5J66.js +31 -0
- package/dist/chunk-VOHEQ7B5.js +31 -0
- package/dist/chunk-VW56KWO2.js +9 -0
- package/dist/chunk-W4KHJ4D6.js +74 -0
- package/dist/chunk-W6Y3PPU5.js +73 -0
- package/dist/chunk-W6ZVQJYB.js +311 -0
- package/dist/chunk-WA3IVAUC.js +123 -0
- package/dist/chunk-WHTS4G5K.js +1551 -0
- package/dist/chunk-WIYFXWRI.js +30 -0
- package/dist/chunk-WPFTRRWV.js +455 -0
- package/dist/chunk-WQZ4ONQV.js +6 -0
- package/dist/chunk-WS652CCV.js +893 -0
- package/dist/chunk-XG4PTPRM.js +0 -0
- package/dist/chunk-XRNDVICA.js +85 -0
- package/dist/chunk-XXZJISPX.js +48 -0
- package/dist/chunk-Y224F4UU.js +81 -0
- package/dist/chunk-Y3FR5JC7.js +437 -0
- package/dist/chunk-Y4VBOHAP.js +111 -0
- package/dist/chunk-Y7QKP6QU.js +35 -0
- package/dist/chunk-YVCBMOJG.js +50 -0
- package/dist/chunk-Z2WPXJ6J.js +146 -0
- package/dist/chunk-ZA2KFUFR.js +19 -0
- package/dist/chunk-ZEKV7LGF.js +6 -0
- package/dist/chunk-ZFFA36DB.js +186 -0
- package/dist/chunk-ZPGWTLF2.js +499 -0
- package/dist/chunk-ZVT2QSWR.js +263 -0
- package/dist/chunk-ZZ7VKT2S.js +4113 -0
- package/dist/collections-TREF67TO.js +63 -0
- package/dist/configuration-KWAL2QZ5.js +152 -0
- package/dist/configuration-RNWBTRAH.js +205 -0
- package/dist/create-7UEEO5TM.js +125 -0
- package/dist/create-DTCDJMIT.js +634 -0
- package/dist/create-DYDRAY6V.js +622 -0
- package/dist/create-EJM5C2XP.js +27 -0
- package/dist/create-F7OMPGZV.js +853 -0
- package/dist/create-G4UJOJJ6.js +69 -0
- package/dist/create-IE6MYOIY.js +170 -0
- package/dist/create-L23TGTBH.js +225 -0
- package/dist/create-LOBCFTCT.js +583 -0
- package/dist/create-MKBBF2V3.js +150 -0
- package/dist/create-TFDUNJSI.js +163 -0
- package/dist/create-TMTZDKII.js +711 -0
- package/dist/create-XGF6DB5F.js +239 -0
- package/dist/create-YAAK7JQ3.js +1052 -0
- package/dist/create-YPCVTXAK.js +194 -0
- package/dist/create-ZU362U3B.js +310 -0
- package/dist/customers-4QWR5UOL.js +27 -0
- package/dist/edit-2QA5BVOY.js +735 -0
- package/dist/edit-47I7VVNB.js +167 -0
- package/dist/edit-5BUGSOTL.js +255 -0
- package/dist/edit-7LQATDUD.js +193 -0
- package/dist/edit-AQAPYMDY.js +260 -0
- package/dist/edit-BQLSTFTQ.js +138 -0
- package/dist/edit-BYXHU3IG.js +308 -0
- package/dist/edit-DG3MY3ZH.js +244 -0
- package/dist/edit-J3LD76JS.js +192 -0
- package/dist/edit-J6WCPHDS.js +205 -0
- package/dist/edit-KCZVZLSZ.js +131 -0
- package/dist/edit-LOKLQGM2.js +181 -0
- package/dist/edit-MDTTTB33.js +104 -0
- package/dist/edit-NFSU2K3O.js +413 -0
- package/dist/edit-RHNZWNXD.js +89 -0
- package/dist/edit-XU33IVZH.js +204 -0
- package/dist/edit-ZMINDMGM.js +116 -0
- package/dist/edit-budget-Z5USV462.js +145 -0
- package/dist/edit-inventory-item-YFW2AFRD.js +128 -0
- package/dist/edit-inventory-item-attributes-IYAMJDTB.js +278 -0
- package/dist/fulfillment-SKXAF3BZ.js +545 -0
- package/dist/fulfillment-providers-ACERVITQ.js +279 -0
- package/dist/home-PP7YYCSB.js +16 -0
- package/dist/index.css +6 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +3656 -0
- package/dist/inventory-AIRQ2KNS.js +26 -0
- package/dist/locations-SQKM7JWN.js +23 -0
- package/dist/login-LKFCRHXN.js +35 -0
- package/dist/manage-locations-4PQS4QY7.js +195 -0
- package/dist/media-PL477QJO.js +703 -0
- package/dist/metadata-42MU3H7T.js +60 -0
- package/dist/metadata-DIJTVDF7.js +45 -0
- package/dist/metadata-NX3LEEB3.js +64 -0
- package/dist/metadata-RBDSM567.js +65 -0
- package/dist/metadata-VZTWNZPG.js +66 -0
- package/dist/metadata-X3XGQ563.js +67 -0
- package/dist/no-match-BO2NNLCM.js +33 -0
- package/dist/orders-2KHCHNO5.js +59 -0
- package/dist/organization-VQXCKHCN.js +233 -0
- package/dist/organize-3F5ZUIGB.js +23 -0
- package/dist/organize-WPWEPCF7.js +23 -0
- package/dist/pages/index.d.ts +1153 -0
- package/dist/pages/index.js +198 -0
- package/dist/payouts-3BY73LZ3.js +27 -0
- package/dist/price-lists-G256JJN7.js +34 -0
- package/dist/prices-EW7KBY6R.js +269 -0
- package/dist/pricing-3PUJDOZN.js +313 -0
- package/dist/product-tags-PI3RENEX.js +80 -0
- package/dist/product-types-WJPLJI7H.js +32 -0
- package/dist/product-variant-detail-EYTE7PHL.js +377 -0
- package/dist/product-variant-edit-PW7W5J5E.js +402 -0
- package/dist/products-GSN4I7BT.js +272 -0
- package/dist/products-RFYNEY57.js +85 -0
- package/dist/promotions-CIZIDQ64.js +31 -0
- package/dist/reset-password-OFUSH363.js +299 -0
- package/dist/return-reasons-4V2KVSRI.js +52 -0
- package/dist/sales-channels-MBWVM3X2.js +184 -0
- package/dist/sales-channels-ZKA62EAW.js +156 -0
- package/dist/seller-ZFDLKF5Y.js +36 -0
- package/dist/settings-NP2IAID5.js +111 -0
- package/dist/shipping-profile-7FTHSPY2.js +145 -0
- package/dist/shipping-profiles-7R6L65WG.js +43 -0
- package/dist/stock-ENMBCZRY.js +502 -0
- package/dist/stock-VYDJY46S.js +278 -0
- package/dist/tax-regions-V6G6244H.js +87 -0
- package/package.json +87 -0
|
@@ -0,0 +1,853 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PriceListCreateProductsSchema,
|
|
3
|
+
PriceListRulesSchema,
|
|
4
|
+
usePriceListCurrencyData,
|
|
5
|
+
usePriceListGridColumns
|
|
6
|
+
} from "./chunk-TTFCO5HU.js";
|
|
7
|
+
import {
|
|
8
|
+
exctractPricesFromProducts,
|
|
9
|
+
isProductRow
|
|
10
|
+
} from "./chunk-XRNDVICA.js";
|
|
11
|
+
import "./chunk-6IJMSVC6.js";
|
|
12
|
+
import {
|
|
13
|
+
useProductTableColumns
|
|
14
|
+
} from "./chunk-GC33DBKG.js";
|
|
15
|
+
import {
|
|
16
|
+
useProductTableQuery
|
|
17
|
+
} from "./chunk-4MFMCZEJ.js";
|
|
18
|
+
import "./chunk-FQERBIVS.js";
|
|
19
|
+
import {
|
|
20
|
+
useProductTableFilters
|
|
21
|
+
} from "./chunk-WA3IVAUC.js";
|
|
22
|
+
import "./chunk-DB6ANJBO.js";
|
|
23
|
+
import "./chunk-PHOCVOZ5.js";
|
|
24
|
+
import {
|
|
25
|
+
_DataTable,
|
|
26
|
+
useDataTable
|
|
27
|
+
} from "./chunk-WHTS4G5K.js";
|
|
28
|
+
import "./chunk-LYUCDASZ.js";
|
|
29
|
+
import "./chunk-KAZ5BYTQ.js";
|
|
30
|
+
import "./chunk-3EF54XFY.js";
|
|
31
|
+
import {
|
|
32
|
+
DataGrid
|
|
33
|
+
} from "./chunk-ZZ7VKT2S.js";
|
|
34
|
+
import "./chunk-IQPN4PZJ.js";
|
|
35
|
+
import "./chunk-SMQT3ZNO.js";
|
|
36
|
+
import "./chunk-TKGWSUEI.js";
|
|
37
|
+
import {
|
|
38
|
+
KeyboundForm
|
|
39
|
+
} from "./chunk-U2ZFCAPX.js";
|
|
40
|
+
import {
|
|
41
|
+
RouteFocusModal,
|
|
42
|
+
useRouteModal,
|
|
43
|
+
useStackedModal
|
|
44
|
+
} from "./chunk-3CK6OINO.js";
|
|
45
|
+
import {
|
|
46
|
+
Form
|
|
47
|
+
} from "./chunk-3QSRE5LS.js";
|
|
48
|
+
import "./chunk-WIYFXWRI.js";
|
|
49
|
+
import "./chunk-THHRRYRS.js";
|
|
50
|
+
import "./chunk-CFETU5BI.js";
|
|
51
|
+
import "./chunk-LAVHRER2.js";
|
|
52
|
+
import "./chunk-Y7QKP6QU.js";
|
|
53
|
+
import "./chunk-INNFZYX2.js";
|
|
54
|
+
import "./chunk-OSFOX7MG.js";
|
|
55
|
+
import "./chunk-W4KHJ4D6.js";
|
|
56
|
+
import "./chunk-VGJTARSA.js";
|
|
57
|
+
import "./chunk-DYUTYBAQ.js";
|
|
58
|
+
import "./chunk-Y4VBOHAP.js";
|
|
59
|
+
import "./chunk-JKXAL7WR.js";
|
|
60
|
+
import "./chunk-DC2K6CFQ.js";
|
|
61
|
+
import "./chunk-VDWGP2U6.js";
|
|
62
|
+
import {
|
|
63
|
+
useCreatePriceList
|
|
64
|
+
} from "./chunk-RE7YXVFG.js";
|
|
65
|
+
import "./chunk-HUNGNEPY.js";
|
|
66
|
+
import "./chunk-PADOWAXM.js";
|
|
67
|
+
import "./chunk-LWVBKUUL.js";
|
|
68
|
+
import "./chunk-RIILGKYR.js";
|
|
69
|
+
import "./chunk-6EYGH3TB.js";
|
|
70
|
+
import "./chunk-GTUR4HSV.js";
|
|
71
|
+
import "./chunk-SI4ALL7W.js";
|
|
72
|
+
import "./chunk-ZFFA36DB.js";
|
|
73
|
+
import "./chunk-VHMGJUYN.js";
|
|
74
|
+
import "./chunk-ASVMGV2B.js";
|
|
75
|
+
import {
|
|
76
|
+
useProducts
|
|
77
|
+
} from "./chunk-WPFTRRWV.js";
|
|
78
|
+
import "./chunk-A5DJIOHN.js";
|
|
79
|
+
import "./chunk-RHKRREUU.js";
|
|
80
|
+
import "./chunk-ZA2KFUFR.js";
|
|
81
|
+
import "./chunk-Y224F4UU.js";
|
|
82
|
+
import "./chunk-PKBMQBKP.js";
|
|
83
|
+
|
|
84
|
+
// src/pages/price-lists/create/price-list-create-form/price-list-create-form.tsx
|
|
85
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
86
|
+
import { Button as Button2, ProgressTabs, toast } from "@medusajs/ui";
|
|
87
|
+
import { useForm } from "react-hook-form";
|
|
88
|
+
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
89
|
+
import { useState as useState2 } from "react";
|
|
90
|
+
|
|
91
|
+
// src/pages/price-lists/create/price-list-create-form/price-list-details-form.tsx
|
|
92
|
+
import {
|
|
93
|
+
DatePicker,
|
|
94
|
+
Divider,
|
|
95
|
+
Heading,
|
|
96
|
+
Input,
|
|
97
|
+
RadioGroup,
|
|
98
|
+
Select,
|
|
99
|
+
Text,
|
|
100
|
+
Textarea
|
|
101
|
+
} from "@medusajs/ui";
|
|
102
|
+
import { useFieldArray } from "react-hook-form";
|
|
103
|
+
import { useTranslation } from "react-i18next";
|
|
104
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
105
|
+
var PriceListDetailsForm = ({ form }) => {
|
|
106
|
+
const { t } = useTranslation();
|
|
107
|
+
const { fields, remove, append } = useFieldArray({
|
|
108
|
+
control: form.control,
|
|
109
|
+
name: "rules.customer_group_id",
|
|
110
|
+
keyName: "cg_id"
|
|
111
|
+
});
|
|
112
|
+
const { setIsOpen } = useStackedModal();
|
|
113
|
+
const handleAddCustomerGroup = (groups) => {
|
|
114
|
+
const newIds = groups.map((group) => group.id);
|
|
115
|
+
const fieldsToAdd = groups.filter(
|
|
116
|
+
(group) => !fields.some((field) => field.id === group.id)
|
|
117
|
+
);
|
|
118
|
+
for (const field of fields) {
|
|
119
|
+
if (!newIds.includes(field.id)) {
|
|
120
|
+
remove(fields.indexOf(field));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
append(fieldsToAdd);
|
|
124
|
+
setIsOpen("cg", false);
|
|
125
|
+
};
|
|
126
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8 px-8 py-16", children: [
|
|
127
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
128
|
+
/* @__PURE__ */ jsx(Heading, { children: t("priceLists.create.header") }),
|
|
129
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: t("priceLists.create.subheader") })
|
|
130
|
+
] }),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
Form.Field,
|
|
133
|
+
{
|
|
134
|
+
control: form.control,
|
|
135
|
+
name: "type",
|
|
136
|
+
render: ({ field: { onChange, ...rest } }) => {
|
|
137
|
+
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
138
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
140
|
+
/* @__PURE__ */ jsx(Form.Label, { children: t("priceLists.fields.type.label") }),
|
|
141
|
+
/* @__PURE__ */ jsx(Form.Hint, { children: t("priceLists.fields.type.hint") })
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(
|
|
144
|
+
RadioGroup,
|
|
145
|
+
{
|
|
146
|
+
onValueChange: onChange,
|
|
147
|
+
...rest,
|
|
148
|
+
className: "grid grid-cols-1 gap-4 md:grid-cols-2",
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
RadioGroup.ChoiceBox,
|
|
152
|
+
{
|
|
153
|
+
value: "sale",
|
|
154
|
+
label: t("priceLists.fields.type.options.sale.label"),
|
|
155
|
+
description: t(
|
|
156
|
+
"priceLists.fields.type.options.sale.description"
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ jsx(
|
|
161
|
+
RadioGroup.ChoiceBox,
|
|
162
|
+
{
|
|
163
|
+
value: "override",
|
|
164
|
+
label: t(
|
|
165
|
+
"priceLists.fields.type.options.override.label"
|
|
166
|
+
),
|
|
167
|
+
description: t(
|
|
168
|
+
"priceLists.fields.type.options.override.description"
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
) })
|
|
175
|
+
] }),
|
|
176
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
177
|
+
] });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
),
|
|
181
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
182
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
183
|
+
/* @__PURE__ */ jsx(
|
|
184
|
+
Form.Field,
|
|
185
|
+
{
|
|
186
|
+
control: form.control,
|
|
187
|
+
name: "title",
|
|
188
|
+
render: ({ field }) => {
|
|
189
|
+
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
190
|
+
/* @__PURE__ */ jsx(Form.Label, { children: t("fields.title") }),
|
|
191
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
192
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
193
|
+
] });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
/* @__PURE__ */ jsx(
|
|
198
|
+
Form.Field,
|
|
199
|
+
{
|
|
200
|
+
control: form.control,
|
|
201
|
+
name: "status",
|
|
202
|
+
render: ({ field: { onChange, ref, ...field } }) => {
|
|
203
|
+
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
204
|
+
/* @__PURE__ */ jsx(Form.Label, { children: t("priceLists.fields.status.label") }),
|
|
205
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
|
|
206
|
+
/* @__PURE__ */ jsx(Select.Trigger, { ref, children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
207
|
+
/* @__PURE__ */ jsxs(Select.Content, { children: [
|
|
208
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "active", children: t("priceLists.fields.status.options.active") }),
|
|
209
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "draft", children: t("priceLists.fields.status.options.draft") })
|
|
210
|
+
] })
|
|
211
|
+
] }) }),
|
|
212
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
213
|
+
] });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
] }),
|
|
218
|
+
/* @__PURE__ */ jsx(
|
|
219
|
+
Form.Field,
|
|
220
|
+
{
|
|
221
|
+
control: form.control,
|
|
222
|
+
name: "description",
|
|
223
|
+
render: ({ field }) => {
|
|
224
|
+
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
225
|
+
/* @__PURE__ */ jsx(Form.Label, { children: t("fields.description") }),
|
|
226
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
227
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
228
|
+
] });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
] }),
|
|
233
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
234
|
+
/* @__PURE__ */ jsx(
|
|
235
|
+
Form.Field,
|
|
236
|
+
{
|
|
237
|
+
control: form.control,
|
|
238
|
+
name: "starts_at",
|
|
239
|
+
render: ({ field }) => {
|
|
240
|
+
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
241
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-2", children: [
|
|
242
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
243
|
+
/* @__PURE__ */ jsx(Form.Label, { optional: true, children: t("priceLists.fields.startsAt.label") }),
|
|
244
|
+
/* @__PURE__ */ jsx(Form.Hint, { children: t("priceLists.fields.startsAt.hint") })
|
|
245
|
+
] }),
|
|
246
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
|
|
247
|
+
DatePicker,
|
|
248
|
+
{
|
|
249
|
+
granularity: "minute",
|
|
250
|
+
shouldCloseOnSelect: false,
|
|
251
|
+
...field
|
|
252
|
+
}
|
|
253
|
+
) })
|
|
254
|
+
] }),
|
|
255
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
256
|
+
] });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
261
|
+
/* @__PURE__ */ jsx(
|
|
262
|
+
Form.Field,
|
|
263
|
+
{
|
|
264
|
+
control: form.control,
|
|
265
|
+
name: "ends_at",
|
|
266
|
+
render: ({ field }) => {
|
|
267
|
+
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
268
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-3 md:grid-cols-2", children: [
|
|
269
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
270
|
+
/* @__PURE__ */ jsx(Form.Label, { optional: true, children: t("priceLists.fields.endsAt.label") }),
|
|
271
|
+
/* @__PURE__ */ jsx(Form.Hint, { children: t("priceLists.fields.endsAt.hint") })
|
|
272
|
+
] }),
|
|
273
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
|
|
274
|
+
DatePicker,
|
|
275
|
+
{
|
|
276
|
+
granularity: "minute",
|
|
277
|
+
shouldCloseOnSelect: false,
|
|
278
|
+
...field
|
|
279
|
+
}
|
|
280
|
+
) })
|
|
281
|
+
] }),
|
|
282
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
283
|
+
] });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
)
|
|
287
|
+
] }) });
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// src/pages/price-lists/create/price-list-create-form/price-list-prices-form.tsx
|
|
291
|
+
import { useEffect } from "react";
|
|
292
|
+
import { useWatch } from "react-hook-form";
|
|
293
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
294
|
+
var PriceListPricesForm = ({
|
|
295
|
+
form,
|
|
296
|
+
currencies,
|
|
297
|
+
regions,
|
|
298
|
+
pricePreferences
|
|
299
|
+
}) => {
|
|
300
|
+
const ids = useWatch({
|
|
301
|
+
control: form.control,
|
|
302
|
+
name: "product_ids"
|
|
303
|
+
});
|
|
304
|
+
const existingProducts = useWatch({
|
|
305
|
+
control: form.control,
|
|
306
|
+
name: "products"
|
|
307
|
+
});
|
|
308
|
+
const {
|
|
309
|
+
products: productsRaw,
|
|
310
|
+
isLoading,
|
|
311
|
+
isError,
|
|
312
|
+
error
|
|
313
|
+
} = useProducts({
|
|
314
|
+
fields: "title,thumbnail,*variants,+status,*variants.prices"
|
|
315
|
+
});
|
|
316
|
+
const products = productsRaw?.filter(
|
|
317
|
+
(product) => ids.some((id) => id.id === product.id)
|
|
318
|
+
);
|
|
319
|
+
const { setCloseOnEscape } = useRouteModal();
|
|
320
|
+
const { setValue } = form;
|
|
321
|
+
useEffect(() => {
|
|
322
|
+
if (!isLoading && products) {
|
|
323
|
+
products.forEach((product) => {
|
|
324
|
+
if (existingProducts[product.id] || !product.variants) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
setValue(`products.${product.id}.variants`, {
|
|
328
|
+
...product.variants.reduce((variants, variant) => {
|
|
329
|
+
variants[variant.id] = {
|
|
330
|
+
currency_prices: {},
|
|
331
|
+
region_prices: {}
|
|
332
|
+
};
|
|
333
|
+
return variants;
|
|
334
|
+
}, {})
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}, [products, existingProducts, isLoading, setValue]);
|
|
339
|
+
const columns = usePriceListGridColumns({
|
|
340
|
+
currencies,
|
|
341
|
+
regions,
|
|
342
|
+
pricePreferences
|
|
343
|
+
});
|
|
344
|
+
if (isError) {
|
|
345
|
+
throw error;
|
|
346
|
+
}
|
|
347
|
+
return /* @__PURE__ */ jsx2("div", { className: "flex size-full flex-col divide-y overflow-hidden", children: /* @__PURE__ */ jsx2(
|
|
348
|
+
DataGrid,
|
|
349
|
+
{
|
|
350
|
+
isLoading,
|
|
351
|
+
columns,
|
|
352
|
+
data: products,
|
|
353
|
+
getSubRows: (row) => {
|
|
354
|
+
if (isProductRow(row) && row.variants) {
|
|
355
|
+
return row.variants;
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
state: form,
|
|
359
|
+
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
360
|
+
}
|
|
361
|
+
) });
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// src/pages/price-lists/create/price-list-create-form/price-list-products-form.tsx
|
|
365
|
+
import { Checkbox } from "@medusajs/ui";
|
|
366
|
+
import { keepPreviousData } from "@tanstack/react-query";
|
|
367
|
+
import {
|
|
368
|
+
createColumnHelper
|
|
369
|
+
} from "@tanstack/react-table";
|
|
370
|
+
import { useMemo, useState } from "react";
|
|
371
|
+
import { useWatch as useWatch2 } from "react-hook-form";
|
|
372
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
373
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
374
|
+
var PAGE_SIZE = 50;
|
|
375
|
+
var PREFIX = "p";
|
|
376
|
+
function getInitialSelection(products) {
|
|
377
|
+
return products.reduce((acc, curr) => {
|
|
378
|
+
acc[curr.id] = true;
|
|
379
|
+
return acc;
|
|
380
|
+
}, {});
|
|
381
|
+
}
|
|
382
|
+
var PriceListProductsForm = ({ form }) => {
|
|
383
|
+
const { t } = useTranslation2();
|
|
384
|
+
const { control, setValue } = form;
|
|
385
|
+
const selectedIds = useWatch2({
|
|
386
|
+
control,
|
|
387
|
+
name: "product_ids"
|
|
388
|
+
});
|
|
389
|
+
const productRecords = useWatch2({
|
|
390
|
+
control,
|
|
391
|
+
name: "products"
|
|
392
|
+
});
|
|
393
|
+
const [rowSelection, setRowSelection] = useState(
|
|
394
|
+
getInitialSelection(selectedIds)
|
|
395
|
+
);
|
|
396
|
+
const { searchParams, raw } = useProductTableQuery({
|
|
397
|
+
pageSize: PAGE_SIZE,
|
|
398
|
+
prefix: PREFIX
|
|
399
|
+
});
|
|
400
|
+
const { products, count, isLoading, isError, error } = useProducts(
|
|
401
|
+
{ ...searchParams, fields: "+thumbnail" },
|
|
402
|
+
{
|
|
403
|
+
placeholderData: keepPreviousData
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
const updater = (fn) => {
|
|
407
|
+
const state = typeof fn === "function" ? fn(rowSelection) : fn;
|
|
408
|
+
const ids = Object.keys(state);
|
|
409
|
+
const productRecordKeys = Object.keys(productRecords);
|
|
410
|
+
const updatedRecords = productRecordKeys.reduce((acc, key) => {
|
|
411
|
+
if (ids.includes(key)) {
|
|
412
|
+
acc[key] = productRecords[key];
|
|
413
|
+
}
|
|
414
|
+
return acc;
|
|
415
|
+
}, {});
|
|
416
|
+
const update = ids.map((id) => ({ id }));
|
|
417
|
+
setValue("product_ids", update, {
|
|
418
|
+
shouldDirty: true,
|
|
419
|
+
shouldTouch: true
|
|
420
|
+
});
|
|
421
|
+
setValue("products", updatedRecords, {
|
|
422
|
+
shouldDirty: true,
|
|
423
|
+
shouldTouch: true
|
|
424
|
+
});
|
|
425
|
+
setRowSelection(state);
|
|
426
|
+
};
|
|
427
|
+
const columns = useColumns();
|
|
428
|
+
const filters = useProductTableFilters();
|
|
429
|
+
const { table } = useDataTable({
|
|
430
|
+
data: products || [],
|
|
431
|
+
columns,
|
|
432
|
+
count,
|
|
433
|
+
enablePagination: true,
|
|
434
|
+
enableRowSelection: (row) => {
|
|
435
|
+
return !!row.original.variants?.length;
|
|
436
|
+
},
|
|
437
|
+
getRowId: (row) => row.id,
|
|
438
|
+
rowSelection: {
|
|
439
|
+
state: rowSelection,
|
|
440
|
+
updater
|
|
441
|
+
},
|
|
442
|
+
pageSize: PAGE_SIZE
|
|
443
|
+
});
|
|
444
|
+
if (isError) {
|
|
445
|
+
throw error;
|
|
446
|
+
}
|
|
447
|
+
return /* @__PURE__ */ jsx3("div", { className: "flex size-full flex-col", children: /* @__PURE__ */ jsx3(
|
|
448
|
+
_DataTable,
|
|
449
|
+
{
|
|
450
|
+
table,
|
|
451
|
+
columns,
|
|
452
|
+
filters,
|
|
453
|
+
pageSize: PAGE_SIZE,
|
|
454
|
+
prefix: PREFIX,
|
|
455
|
+
count,
|
|
456
|
+
isLoading,
|
|
457
|
+
layout: "fill",
|
|
458
|
+
orderBy: [
|
|
459
|
+
{ key: "title", label: t("fields.title") },
|
|
460
|
+
{ key: "status", label: t("fields.status") },
|
|
461
|
+
{
|
|
462
|
+
key: "created_at",
|
|
463
|
+
label: t("fields.createdAt")
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
key: "updated_at",
|
|
467
|
+
label: t("fields.updatedAt")
|
|
468
|
+
}
|
|
469
|
+
],
|
|
470
|
+
pagination: true,
|
|
471
|
+
search: true,
|
|
472
|
+
queryObject: raw,
|
|
473
|
+
noRecords: {
|
|
474
|
+
message: t("priceLists.create.products.list.noRecordsMessage")
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
) });
|
|
478
|
+
};
|
|
479
|
+
var columnHelper = createColumnHelper();
|
|
480
|
+
var useColumns = () => {
|
|
481
|
+
const base = useProductTableColumns();
|
|
482
|
+
return useMemo(
|
|
483
|
+
() => [
|
|
484
|
+
columnHelper.display({
|
|
485
|
+
id: "select",
|
|
486
|
+
header: ({ table }) => {
|
|
487
|
+
return /* @__PURE__ */ jsx3(
|
|
488
|
+
Checkbox,
|
|
489
|
+
{
|
|
490
|
+
checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
|
|
491
|
+
onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value)
|
|
492
|
+
}
|
|
493
|
+
);
|
|
494
|
+
},
|
|
495
|
+
cell: ({ row }) => {
|
|
496
|
+
return /* @__PURE__ */ jsx3(
|
|
497
|
+
Checkbox,
|
|
498
|
+
{
|
|
499
|
+
checked: row.getIsSelected(),
|
|
500
|
+
disabled: !row.getCanSelect(),
|
|
501
|
+
onCheckedChange: (value) => row.toggleSelected(!!value),
|
|
502
|
+
onClick: (e) => {
|
|
503
|
+
e.stopPropagation();
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
}),
|
|
509
|
+
...base
|
|
510
|
+
],
|
|
511
|
+
[base]
|
|
512
|
+
);
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
// src/pages/price-lists/create/price-list-create-form/schema.ts
|
|
516
|
+
import { z } from "zod";
|
|
517
|
+
var PricingCustomerGroupsArray = z.array(
|
|
518
|
+
z.object({
|
|
519
|
+
id: z.string(),
|
|
520
|
+
name: z.string()
|
|
521
|
+
})
|
|
522
|
+
);
|
|
523
|
+
var PricingCreateSchema = z.object({
|
|
524
|
+
type: z.enum(["sale", "override"]),
|
|
525
|
+
status: z.enum(["draft", "active"]),
|
|
526
|
+
title: z.string().min(1),
|
|
527
|
+
description: z.string().min(1),
|
|
528
|
+
starts_at: z.date().nullish(),
|
|
529
|
+
ends_at: z.date().nullish(),
|
|
530
|
+
product_ids: z.array(z.object({ id: z.string() })).min(1),
|
|
531
|
+
products: PriceListCreateProductsSchema,
|
|
532
|
+
rules: PriceListRulesSchema.nullish()
|
|
533
|
+
});
|
|
534
|
+
var PricingDetailsSchema = PricingCreateSchema.pick({
|
|
535
|
+
type: true,
|
|
536
|
+
title: true,
|
|
537
|
+
description: true,
|
|
538
|
+
starts_at: true,
|
|
539
|
+
ends_at: true,
|
|
540
|
+
customer_group_ids: true
|
|
541
|
+
});
|
|
542
|
+
var PricingDetailsFields = Object.keys(
|
|
543
|
+
PricingDetailsSchema.shape
|
|
544
|
+
);
|
|
545
|
+
var PricingProductsSchema = PricingCreateSchema.pick({
|
|
546
|
+
product_ids: true
|
|
547
|
+
});
|
|
548
|
+
var PricingProductsFields = Object.keys(
|
|
549
|
+
PricingProductsSchema.shape
|
|
550
|
+
);
|
|
551
|
+
var PricingPricesSchema = PricingCreateSchema.pick({
|
|
552
|
+
products: true
|
|
553
|
+
});
|
|
554
|
+
var PricingPricesFields = Object.keys(
|
|
555
|
+
PricingPricesSchema.shape
|
|
556
|
+
);
|
|
557
|
+
|
|
558
|
+
// src/pages/price-lists/create/price-list-create-form/price-list-create-form.tsx
|
|
559
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
560
|
+
var tabOrder = ["detail" /* DETAIL */, "product" /* PRODUCT */, "price" /* PRICE */];
|
|
561
|
+
var initialTabState = {
|
|
562
|
+
["detail" /* DETAIL */]: "in-progress",
|
|
563
|
+
["product" /* PRODUCT */]: "not-started",
|
|
564
|
+
["price" /* PRICE */]: "not-started"
|
|
565
|
+
};
|
|
566
|
+
var PriceListCreateForm = ({
|
|
567
|
+
regions,
|
|
568
|
+
currencies,
|
|
569
|
+
pricePreferences
|
|
570
|
+
}) => {
|
|
571
|
+
const [tab, setTab] = useState2("detail" /* DETAIL */);
|
|
572
|
+
const [tabState, setTabState] = useState2(initialTabState);
|
|
573
|
+
const { t } = useTranslation3();
|
|
574
|
+
const { handleSuccess } = useRouteModal();
|
|
575
|
+
const form = useForm({
|
|
576
|
+
defaultValues: {
|
|
577
|
+
type: "sale",
|
|
578
|
+
status: "active",
|
|
579
|
+
title: "",
|
|
580
|
+
description: "",
|
|
581
|
+
starts_at: null,
|
|
582
|
+
ends_at: null,
|
|
583
|
+
product_ids: [],
|
|
584
|
+
products: {},
|
|
585
|
+
rules: {
|
|
586
|
+
customer_group_id: []
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
resolver: zodResolver(PricingCreateSchema)
|
|
590
|
+
});
|
|
591
|
+
const { mutateAsync, isPending } = useCreatePriceList();
|
|
592
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
593
|
+
const { rules, products } = data;
|
|
594
|
+
const rulesPayload = rules?.customer_group_id?.length ? { "customer.groups.id": rules.customer_group_id.map((cg) => cg.id) } : void 0;
|
|
595
|
+
const prices = exctractPricesFromProducts(products, regions);
|
|
596
|
+
await mutateAsync(
|
|
597
|
+
{
|
|
598
|
+
title: data.title,
|
|
599
|
+
type: data.type,
|
|
600
|
+
status: data.status,
|
|
601
|
+
description: data.description,
|
|
602
|
+
starts_at: data.starts_at ? data.starts_at.toISOString() : null,
|
|
603
|
+
ends_at: data.ends_at ? data.ends_at.toISOString() : null,
|
|
604
|
+
rules: rulesPayload,
|
|
605
|
+
prices
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
onSuccess: ({ price_list }) => {
|
|
609
|
+
toast.success(
|
|
610
|
+
t("priceLists.create.successToast", {
|
|
611
|
+
title: price_list.title
|
|
612
|
+
})
|
|
613
|
+
);
|
|
614
|
+
handleSuccess(`../${price_list.id}`);
|
|
615
|
+
},
|
|
616
|
+
onError: (error) => {
|
|
617
|
+
toast.error(error.message);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
);
|
|
621
|
+
});
|
|
622
|
+
const partialFormValidation = (fields, schema) => {
|
|
623
|
+
form.clearErrors(fields);
|
|
624
|
+
const values = fields.reduce(
|
|
625
|
+
(acc, key) => {
|
|
626
|
+
acc[key] = form.getValues(key);
|
|
627
|
+
return acc;
|
|
628
|
+
},
|
|
629
|
+
{}
|
|
630
|
+
);
|
|
631
|
+
const validationResult = schema.safeParse(values);
|
|
632
|
+
if (!validationResult.success) {
|
|
633
|
+
validationResult.error.errors.forEach(({ path, message, code }) => {
|
|
634
|
+
form.setError(path.join("."), {
|
|
635
|
+
type: code,
|
|
636
|
+
message
|
|
637
|
+
});
|
|
638
|
+
});
|
|
639
|
+
return false;
|
|
640
|
+
}
|
|
641
|
+
return true;
|
|
642
|
+
};
|
|
643
|
+
const isTabDirty = (tab2) => {
|
|
644
|
+
switch (tab2) {
|
|
645
|
+
case "detail" /* DETAIL */: {
|
|
646
|
+
const fields = PricingDetailsFields;
|
|
647
|
+
return fields.some((field) => {
|
|
648
|
+
return form.getFieldState(field).isDirty;
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
case "product" /* PRODUCT */: {
|
|
652
|
+
const fields = PricingProductsFields;
|
|
653
|
+
return fields.some((field) => {
|
|
654
|
+
return form.getFieldState(field).isDirty;
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
case "price" /* PRICE */: {
|
|
658
|
+
const fields = PricingPricesFields;
|
|
659
|
+
return fields.some((field) => {
|
|
660
|
+
return form.getFieldState(field).isDirty;
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
const handleChangeTab = (update) => {
|
|
666
|
+
if (tab === update) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
if (tabOrder.indexOf(update) < tabOrder.indexOf(tab)) {
|
|
670
|
+
const isCurrentTabDirty = isTabDirty(tab);
|
|
671
|
+
setTabState((prev) => ({
|
|
672
|
+
...prev,
|
|
673
|
+
[tab]: isCurrentTabDirty ? prev[tab] : "not-started",
|
|
674
|
+
[update]: "in-progress"
|
|
675
|
+
}));
|
|
676
|
+
setTab(update);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
const tabs = tabOrder.slice(0, tabOrder.indexOf(update));
|
|
680
|
+
for (const tab2 of tabs) {
|
|
681
|
+
if (tab2 === "detail" /* DETAIL */) {
|
|
682
|
+
if (!partialFormValidation(PricingDetailsFields, PricingDetailsSchema)) {
|
|
683
|
+
setTabState((prev) => ({
|
|
684
|
+
...prev,
|
|
685
|
+
[tab2]: "in-progress"
|
|
686
|
+
}));
|
|
687
|
+
setTab(tab2);
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
setTabState((prev) => ({
|
|
691
|
+
...prev,
|
|
692
|
+
[tab2]: "completed"
|
|
693
|
+
}));
|
|
694
|
+
} else if (tab2 === "product" /* PRODUCT */) {
|
|
695
|
+
if (!partialFormValidation(PricingProductsFields, PricingProductsSchema)) {
|
|
696
|
+
toast.error(t("priceLists.create.products.errors.noProducts"));
|
|
697
|
+
setTabState((prev) => ({
|
|
698
|
+
...prev,
|
|
699
|
+
[tab2]: "in-progress"
|
|
700
|
+
}));
|
|
701
|
+
setTab(tab2);
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
setTabState((prev) => ({
|
|
705
|
+
...prev,
|
|
706
|
+
[tab2]: "completed"
|
|
707
|
+
}));
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
setTabState((prev) => ({
|
|
711
|
+
...prev,
|
|
712
|
+
[tab]: "completed",
|
|
713
|
+
[update]: "in-progress"
|
|
714
|
+
}));
|
|
715
|
+
setTab(update);
|
|
716
|
+
};
|
|
717
|
+
const handleNextTab = (tab2) => {
|
|
718
|
+
if (tabOrder.indexOf(tab2) + 1 >= tabOrder.length) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
const nextTab = tabOrder[tabOrder.indexOf(tab2) + 1];
|
|
722
|
+
handleChangeTab(nextTab);
|
|
723
|
+
};
|
|
724
|
+
return /* @__PURE__ */ jsx4(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsx4(
|
|
725
|
+
ProgressTabs,
|
|
726
|
+
{
|
|
727
|
+
value: tab,
|
|
728
|
+
onValueChange: (tab2) => handleChangeTab(tab2),
|
|
729
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
730
|
+
children: /* @__PURE__ */ jsxs2(KeyboundForm, { onSubmit: handleSubmit, className: "flex h-full flex-col", children: [
|
|
731
|
+
/* @__PURE__ */ jsx4(RouteFocusModal.Header, { children: /* @__PURE__ */ jsx4("div", { className: "flex w-full items-center justify-between gap-x-4", children: /* @__PURE__ */ jsx4("div", { className: "-my-2 w-full max-w-[600px] border-l", children: /* @__PURE__ */ jsxs2(ProgressTabs.List, { className: "grid w-full grid-cols-3", children: [
|
|
732
|
+
/* @__PURE__ */ jsx4(
|
|
733
|
+
ProgressTabs.Trigger,
|
|
734
|
+
{
|
|
735
|
+
status: tabState.detail,
|
|
736
|
+
value: "detail" /* DETAIL */,
|
|
737
|
+
children: t("priceLists.create.tabs.details")
|
|
738
|
+
}
|
|
739
|
+
),
|
|
740
|
+
/* @__PURE__ */ jsx4(
|
|
741
|
+
ProgressTabs.Trigger,
|
|
742
|
+
{
|
|
743
|
+
status: tabState.product,
|
|
744
|
+
value: "product" /* PRODUCT */,
|
|
745
|
+
children: t("priceLists.create.tabs.products")
|
|
746
|
+
}
|
|
747
|
+
),
|
|
748
|
+
/* @__PURE__ */ jsx4(
|
|
749
|
+
ProgressTabs.Trigger,
|
|
750
|
+
{
|
|
751
|
+
status: tabState.price,
|
|
752
|
+
value: "price" /* PRICE */,
|
|
753
|
+
children: t("priceLists.create.tabs.prices")
|
|
754
|
+
}
|
|
755
|
+
)
|
|
756
|
+
] }) }) }) }),
|
|
757
|
+
/* @__PURE__ */ jsxs2(RouteFocusModal.Body, { className: "size-full overflow-hidden", children: [
|
|
758
|
+
/* @__PURE__ */ jsx4(
|
|
759
|
+
ProgressTabs.Content,
|
|
760
|
+
{
|
|
761
|
+
className: "size-full overflow-y-auto",
|
|
762
|
+
value: "detail" /* DETAIL */,
|
|
763
|
+
children: /* @__PURE__ */ jsx4(PriceListDetailsForm, { form })
|
|
764
|
+
}
|
|
765
|
+
),
|
|
766
|
+
/* @__PURE__ */ jsx4(
|
|
767
|
+
ProgressTabs.Content,
|
|
768
|
+
{
|
|
769
|
+
className: "size-full overflow-y-auto",
|
|
770
|
+
value: "product" /* PRODUCT */,
|
|
771
|
+
children: /* @__PURE__ */ jsx4(PriceListProductsForm, { form })
|
|
772
|
+
}
|
|
773
|
+
),
|
|
774
|
+
/* @__PURE__ */ jsx4(
|
|
775
|
+
ProgressTabs.Content,
|
|
776
|
+
{
|
|
777
|
+
className: "size-full overflow-hidden",
|
|
778
|
+
value: "price" /* PRICE */,
|
|
779
|
+
children: /* @__PURE__ */ jsx4(
|
|
780
|
+
PriceListPricesForm,
|
|
781
|
+
{
|
|
782
|
+
form,
|
|
783
|
+
regions,
|
|
784
|
+
currencies,
|
|
785
|
+
pricePreferences
|
|
786
|
+
}
|
|
787
|
+
)
|
|
788
|
+
}
|
|
789
|
+
)
|
|
790
|
+
] }),
|
|
791
|
+
/* @__PURE__ */ jsx4(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
792
|
+
/* @__PURE__ */ jsx4(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx4(Button2, { variant: "secondary", size: "small", children: t("actions.cancel") }) }),
|
|
793
|
+
/* @__PURE__ */ jsx4(
|
|
794
|
+
PrimaryButton,
|
|
795
|
+
{
|
|
796
|
+
tab,
|
|
797
|
+
next: handleNextTab,
|
|
798
|
+
isLoading: isPending
|
|
799
|
+
}
|
|
800
|
+
)
|
|
801
|
+
] }) })
|
|
802
|
+
] })
|
|
803
|
+
}
|
|
804
|
+
) });
|
|
805
|
+
};
|
|
806
|
+
var PrimaryButton = ({ tab, next, isLoading }) => {
|
|
807
|
+
const { t } = useTranslation3();
|
|
808
|
+
if (tab === "price" /* PRICE */) {
|
|
809
|
+
return /* @__PURE__ */ jsx4(
|
|
810
|
+
Button2,
|
|
811
|
+
{
|
|
812
|
+
type: "submit",
|
|
813
|
+
variant: "primary",
|
|
814
|
+
size: "small",
|
|
815
|
+
isLoading,
|
|
816
|
+
children: t("actions.save")
|
|
817
|
+
},
|
|
818
|
+
"submit-button"
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
return /* @__PURE__ */ jsx4(
|
|
822
|
+
Button2,
|
|
823
|
+
{
|
|
824
|
+
type: "button",
|
|
825
|
+
variant: "primary",
|
|
826
|
+
size: "small",
|
|
827
|
+
onClick: () => next(tab),
|
|
828
|
+
children: t("actions.continue")
|
|
829
|
+
},
|
|
830
|
+
"next-button"
|
|
831
|
+
);
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
// src/pages/price-lists/create/index.tsx
|
|
835
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
836
|
+
var Component = () => {
|
|
837
|
+
const { isReady, regions, currencies, pricePreferences } = usePriceListCurrencyData();
|
|
838
|
+
return /* @__PURE__ */ jsxs3(RouteFocusModal, { children: [
|
|
839
|
+
/* @__PURE__ */ jsx5(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx5("span", { className: "sr-only", children: "Create Price List" }) }),
|
|
840
|
+
/* @__PURE__ */ jsx5(RouteFocusModal.Description, { className: "sr-only", children: "Create a new price list with custom pricing" }),
|
|
841
|
+
isReady && /* @__PURE__ */ jsx5(
|
|
842
|
+
PriceListCreateForm,
|
|
843
|
+
{
|
|
844
|
+
regions,
|
|
845
|
+
currencies,
|
|
846
|
+
pricePreferences
|
|
847
|
+
}
|
|
848
|
+
)
|
|
849
|
+
] });
|
|
850
|
+
};
|
|
851
|
+
export {
|
|
852
|
+
Component
|
|
853
|
+
};
|