@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,1166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SectionRow
|
|
3
|
+
} from "./chunk-4TLP3TAA.js";
|
|
4
|
+
import {
|
|
5
|
+
SidebarLink
|
|
6
|
+
} from "./chunk-4GPAS5GW.js";
|
|
7
|
+
import "./chunk-U2EI2ZLM.js";
|
|
8
|
+
import {
|
|
9
|
+
getFormattedCountry
|
|
10
|
+
} from "./chunk-W6Y3PPU5.js";
|
|
11
|
+
import {
|
|
12
|
+
TwoColumnPage
|
|
13
|
+
} from "./chunk-RM5RSDYP.js";
|
|
14
|
+
import {
|
|
15
|
+
Thumbnail
|
|
16
|
+
} from "./chunk-WIYFXWRI.js";
|
|
17
|
+
import {
|
|
18
|
+
DataTable,
|
|
19
|
+
useDataTableDateFilters
|
|
20
|
+
} from "./chunk-Y3FR5JC7.js";
|
|
21
|
+
import {
|
|
22
|
+
useQueryParams
|
|
23
|
+
} from "./chunk-THHRRYRS.js";
|
|
24
|
+
import {
|
|
25
|
+
ActionMenu
|
|
26
|
+
} from "./chunk-BDGZ4EQO.js";
|
|
27
|
+
import "./chunk-CFETU5BI.js";
|
|
28
|
+
import "./chunk-JRTZWK77.js";
|
|
29
|
+
import "./chunk-LAVHRER2.js";
|
|
30
|
+
import "./chunk-Y7QKP6QU.js";
|
|
31
|
+
import {
|
|
32
|
+
TwoColumnPageSkeleton
|
|
33
|
+
} from "./chunk-INNFZYX2.js";
|
|
34
|
+
import "./chunk-OSFOX7MG.js";
|
|
35
|
+
import "./chunk-W4KHJ4D6.js";
|
|
36
|
+
import "./chunk-VGJTARSA.js";
|
|
37
|
+
import "./chunk-DYUTYBAQ.js";
|
|
38
|
+
import "./chunk-Y4VBOHAP.js";
|
|
39
|
+
import "./chunk-JKXAL7WR.js";
|
|
40
|
+
import "./chunk-DC2K6CFQ.js";
|
|
41
|
+
import "./chunk-VDWGP2U6.js";
|
|
42
|
+
import "./chunk-RE7YXVFG.js";
|
|
43
|
+
import "./chunk-HUNGNEPY.js";
|
|
44
|
+
import "./chunk-PADOWAXM.js";
|
|
45
|
+
import "./chunk-LWVBKUUL.js";
|
|
46
|
+
import "./chunk-RIILGKYR.js";
|
|
47
|
+
import "./chunk-6EYGH3TB.js";
|
|
48
|
+
import "./chunk-GTUR4HSV.js";
|
|
49
|
+
import "./chunk-SI4ALL7W.js";
|
|
50
|
+
import "./chunk-ZFFA36DB.js";
|
|
51
|
+
import {
|
|
52
|
+
useSalesChannels
|
|
53
|
+
} from "./chunk-VHMGJUYN.js";
|
|
54
|
+
import "./chunk-ASVMGV2B.js";
|
|
55
|
+
import {
|
|
56
|
+
productsQueryKeys,
|
|
57
|
+
useDeleteProduct,
|
|
58
|
+
useDeleteProductOption,
|
|
59
|
+
useDeleteVariantLazy,
|
|
60
|
+
useProduct,
|
|
61
|
+
useProductAttributes,
|
|
62
|
+
useProductVariants,
|
|
63
|
+
useUpdateProduct
|
|
64
|
+
} from "./chunk-WPFTRRWV.js";
|
|
65
|
+
import "./chunk-A5DJIOHN.js";
|
|
66
|
+
import {
|
|
67
|
+
queryClient
|
|
68
|
+
} from "./chunk-RHKRREUU.js";
|
|
69
|
+
import "./chunk-ZA2KFUFR.js";
|
|
70
|
+
import {
|
|
71
|
+
sdk
|
|
72
|
+
} from "./chunk-Y224F4UU.js";
|
|
73
|
+
import "./chunk-PKBMQBKP.js";
|
|
74
|
+
|
|
75
|
+
// src/pages/products/[id]/loader.tsx
|
|
76
|
+
var productDetailQuery = (id) => ({
|
|
77
|
+
queryKey: productsQueryKeys.detail(id),
|
|
78
|
+
queryFn: async () => sdk.vendor.products.$id.query({ $id: id })
|
|
79
|
+
});
|
|
80
|
+
var loader = async ({ params }) => {
|
|
81
|
+
const id = params.id;
|
|
82
|
+
const query = productDetailQuery(id);
|
|
83
|
+
const response = await queryClient.ensureQueryData({
|
|
84
|
+
...query,
|
|
85
|
+
staleTime: 9e4
|
|
86
|
+
});
|
|
87
|
+
return response;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// src/pages/products/[id]/product-detail-page.tsx
|
|
91
|
+
import { Children } from "react";
|
|
92
|
+
import { useParams as useParams2 } from "react-router-dom";
|
|
93
|
+
|
|
94
|
+
// src/pages/products/[id]/context.tsx
|
|
95
|
+
import { createContext, useContext } from "react";
|
|
96
|
+
import { jsx } from "react/jsx-runtime";
|
|
97
|
+
var ProductDetailContext = createContext(
|
|
98
|
+
null
|
|
99
|
+
);
|
|
100
|
+
var useProductDetailContext = () => {
|
|
101
|
+
const context = useContext(ProductDetailContext);
|
|
102
|
+
if (!context) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
"useProductDetailContext must be used within a ProductDetailPage"
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return context;
|
|
108
|
+
};
|
|
109
|
+
var ProductDetailProvider = ({
|
|
110
|
+
product,
|
|
111
|
+
children
|
|
112
|
+
}) => {
|
|
113
|
+
return /* @__PURE__ */ jsx(ProductDetailContext.Provider, { value: { product }, children });
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// src/pages/products/[id]/_components/product-general-section/product-general-section.tsx
|
|
117
|
+
import { PencilSquare, Trash } from "@medusajs/icons";
|
|
118
|
+
import { Container, Heading, StatusBadge, usePrompt } from "@medusajs/ui";
|
|
119
|
+
import { useTranslation } from "react-i18next";
|
|
120
|
+
import { useNavigate } from "react-router-dom";
|
|
121
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
122
|
+
var productStatusColor = (status) => {
|
|
123
|
+
switch (status) {
|
|
124
|
+
case "draft":
|
|
125
|
+
return "grey";
|
|
126
|
+
case "proposed":
|
|
127
|
+
return "orange";
|
|
128
|
+
case "published":
|
|
129
|
+
return "green";
|
|
130
|
+
case "rejected":
|
|
131
|
+
return "red";
|
|
132
|
+
default:
|
|
133
|
+
return "grey";
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var ProductGeneralSection = () => {
|
|
137
|
+
const { product } = useProductDetailContext();
|
|
138
|
+
const { t } = useTranslation();
|
|
139
|
+
const prompt = usePrompt();
|
|
140
|
+
const navigate = useNavigate();
|
|
141
|
+
const { mutateAsync } = useDeleteProduct(product.id);
|
|
142
|
+
const handleDelete = async () => {
|
|
143
|
+
const res = await prompt({
|
|
144
|
+
title: t("general.areYouSure"),
|
|
145
|
+
description: t("products.deleteWarning", {
|
|
146
|
+
title: product.title
|
|
147
|
+
}),
|
|
148
|
+
confirmText: t("actions.delete"),
|
|
149
|
+
cancelText: t("actions.cancel")
|
|
150
|
+
});
|
|
151
|
+
if (!res) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
await mutateAsync(void 0, {
|
|
155
|
+
onSuccess: () => {
|
|
156
|
+
navigate("..");
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
161
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
162
|
+
/* @__PURE__ */ jsx2(Heading, { children: product.title }),
|
|
163
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
|
|
164
|
+
/* @__PURE__ */ jsx2(StatusBadge, { color: productStatusColor(product.status), children: t(`products.productStatus.${product.status}`) }),
|
|
165
|
+
/* @__PURE__ */ jsx2(
|
|
166
|
+
ActionMenu,
|
|
167
|
+
{
|
|
168
|
+
groups: [
|
|
169
|
+
{
|
|
170
|
+
actions: [
|
|
171
|
+
{
|
|
172
|
+
label: t("actions.edit"),
|
|
173
|
+
to: "edit",
|
|
174
|
+
icon: /* @__PURE__ */ jsx2(PencilSquare, {})
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
actions: [
|
|
180
|
+
{
|
|
181
|
+
label: t("actions.delete"),
|
|
182
|
+
onClick: handleDelete,
|
|
183
|
+
icon: /* @__PURE__ */ jsx2(Trash, {})
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
] })
|
|
191
|
+
] }),
|
|
192
|
+
/* @__PURE__ */ jsx2(SectionRow, { title: t("fields.description"), value: product.description }),
|
|
193
|
+
/* @__PURE__ */ jsx2(SectionRow, { title: t("fields.handle"), value: `/${product.handle}` }),
|
|
194
|
+
/* @__PURE__ */ jsx2(
|
|
195
|
+
SectionRow,
|
|
196
|
+
{
|
|
197
|
+
title: t("fields.discountable"),
|
|
198
|
+
value: product.discountable ? t("fields.true") : t("fields.false")
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
] });
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// src/pages/products/[id]/_components/product-media-section/product-media-section.tsx
|
|
205
|
+
import { useState } from "react";
|
|
206
|
+
import { PencilSquare as PencilSquare2, ThumbnailBadge } from "@medusajs/icons";
|
|
207
|
+
import {
|
|
208
|
+
Button,
|
|
209
|
+
Checkbox,
|
|
210
|
+
clx,
|
|
211
|
+
CommandBar,
|
|
212
|
+
Container as Container2,
|
|
213
|
+
Heading as Heading2,
|
|
214
|
+
Text,
|
|
215
|
+
Tooltip,
|
|
216
|
+
usePrompt as usePrompt2
|
|
217
|
+
} from "@medusajs/ui";
|
|
218
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
219
|
+
import { Link } from "react-router-dom";
|
|
220
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
221
|
+
var ProductMediaSection = () => {
|
|
222
|
+
const { product } = useProductDetailContext();
|
|
223
|
+
const { t } = useTranslation2();
|
|
224
|
+
const prompt = usePrompt2();
|
|
225
|
+
const [selection, setSelection] = useState({});
|
|
226
|
+
const media = getMedia(product);
|
|
227
|
+
const handleCheckedChange = (id) => {
|
|
228
|
+
setSelection((prev) => {
|
|
229
|
+
if (prev[id]) {
|
|
230
|
+
const { [id]: _, ...rest } = prev;
|
|
231
|
+
return rest;
|
|
232
|
+
} else {
|
|
233
|
+
return { ...prev, [id]: true };
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
const { mutateAsync } = useUpdateProduct(product.id);
|
|
238
|
+
const handleDelete = async () => {
|
|
239
|
+
const ids = Object.keys(selection);
|
|
240
|
+
const includingThumbnail = ids.some((id) => media.find((m) => m.id === id)?.isThumbnail);
|
|
241
|
+
const res = await prompt({
|
|
242
|
+
title: t("general.areYouSure"),
|
|
243
|
+
description: includingThumbnail ? t("products.media.deleteWarningWithThumbnail", {
|
|
244
|
+
count: ids.length
|
|
245
|
+
}) : t("products.media.deleteWarning", {
|
|
246
|
+
count: ids.length
|
|
247
|
+
}),
|
|
248
|
+
confirmText: t("actions.delete"),
|
|
249
|
+
cancelText: t("actions.cancel")
|
|
250
|
+
});
|
|
251
|
+
if (!res) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const mediaToKeep = product.images?.filter((i) => !ids.includes(i.id)).map((i) => ({ url: i.url }));
|
|
255
|
+
await mutateAsync(
|
|
256
|
+
{
|
|
257
|
+
images: mediaToKeep,
|
|
258
|
+
thumbnail: includingThumbnail ? "" : void 0
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
onSuccess: () => {
|
|
262
|
+
setSelection({});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
};
|
|
267
|
+
return /* @__PURE__ */ jsxs2(Container2, { className: "divide-y p-0", children: [
|
|
268
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
269
|
+
/* @__PURE__ */ jsx3(Heading2, { level: "h2", children: t("products.media.label") }),
|
|
270
|
+
/* @__PURE__ */ jsx3(
|
|
271
|
+
ActionMenu,
|
|
272
|
+
{
|
|
273
|
+
groups: [
|
|
274
|
+
{
|
|
275
|
+
actions: [
|
|
276
|
+
{
|
|
277
|
+
label: t("actions.edit"),
|
|
278
|
+
to: "media?view=edit",
|
|
279
|
+
icon: /* @__PURE__ */ jsx3(PencilSquare2, {})
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
] }),
|
|
287
|
+
media.length > 0 ? /* @__PURE__ */ jsx3("div", { className: "grid grid-cols-[repeat(auto-fill,minmax(96px,1fr))] gap-4 px-6 py-4", children: media.map((i, index) => {
|
|
288
|
+
const isSelected = selection[i.id];
|
|
289
|
+
return /* @__PURE__ */ jsxs2(
|
|
290
|
+
"div",
|
|
291
|
+
{
|
|
292
|
+
className: "group relative aspect-square size-full cursor-pointer overflow-hidden rounded-[8px] shadow-elevation-card-rest transition-fg hover:shadow-elevation-card-hover",
|
|
293
|
+
children: [
|
|
294
|
+
/* @__PURE__ */ jsx3(
|
|
295
|
+
"div",
|
|
296
|
+
{
|
|
297
|
+
className: clx(
|
|
298
|
+
"invisible absolute right-2 top-2 opacity-0 transition-fg group-hover:visible group-hover:opacity-100",
|
|
299
|
+
{
|
|
300
|
+
"visible opacity-100": isSelected
|
|
301
|
+
}
|
|
302
|
+
),
|
|
303
|
+
children: /* @__PURE__ */ jsx3(
|
|
304
|
+
Checkbox,
|
|
305
|
+
{
|
|
306
|
+
checked: selection[i.id] || false,
|
|
307
|
+
onCheckedChange: () => handleCheckedChange(i.id)
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
),
|
|
312
|
+
i.isThumbnail && /* @__PURE__ */ jsx3("div", { className: "absolute left-2 top-2", children: /* @__PURE__ */ jsx3(Tooltip, { content: t("fields.thumbnail"), children: /* @__PURE__ */ jsx3(ThumbnailBadge, {}) }) }),
|
|
313
|
+
/* @__PURE__ */ jsx3(
|
|
314
|
+
Link,
|
|
315
|
+
{
|
|
316
|
+
to: `media`,
|
|
317
|
+
state: { curr: index },
|
|
318
|
+
children: /* @__PURE__ */ jsx3(
|
|
319
|
+
"img",
|
|
320
|
+
{
|
|
321
|
+
src: i.url,
|
|
322
|
+
alt: `${product.title} image`,
|
|
323
|
+
className: "size-full object-cover"
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
}
|
|
327
|
+
)
|
|
328
|
+
]
|
|
329
|
+
},
|
|
330
|
+
i.id
|
|
331
|
+
);
|
|
332
|
+
}) }) : /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-y-4 pb-8 pt-6", children: [
|
|
333
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center", children: [
|
|
334
|
+
/* @__PURE__ */ jsx3(
|
|
335
|
+
Text,
|
|
336
|
+
{
|
|
337
|
+
size: "small",
|
|
338
|
+
leading: "compact",
|
|
339
|
+
weight: "plus",
|
|
340
|
+
className: "text-ui-fg-subtle",
|
|
341
|
+
children: t("products.media.emptyState.header")
|
|
342
|
+
}
|
|
343
|
+
),
|
|
344
|
+
/* @__PURE__ */ jsx3(
|
|
345
|
+
Text,
|
|
346
|
+
{
|
|
347
|
+
size: "small",
|
|
348
|
+
className: "text-ui-fg-muted",
|
|
349
|
+
children: t("products.media.emptyState.description")
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
] }),
|
|
353
|
+
/* @__PURE__ */ jsx3(
|
|
354
|
+
Button,
|
|
355
|
+
{
|
|
356
|
+
size: "small",
|
|
357
|
+
variant: "secondary",
|
|
358
|
+
asChild: true,
|
|
359
|
+
children: /* @__PURE__ */ jsx3(Link, { to: "media?view=edit", children: t("products.media.emptyState.action") })
|
|
360
|
+
}
|
|
361
|
+
)
|
|
362
|
+
] }),
|
|
363
|
+
/* @__PURE__ */ jsx3(CommandBar, { open: !!Object.keys(selection).length, children: /* @__PURE__ */ jsxs2(CommandBar.Bar, { children: [
|
|
364
|
+
/* @__PURE__ */ jsx3(CommandBar.Value, { children: t("general.countSelected", {
|
|
365
|
+
count: Object.keys(selection).length
|
|
366
|
+
}) }),
|
|
367
|
+
/* @__PURE__ */ jsx3(CommandBar.Seperator, {}),
|
|
368
|
+
/* @__PURE__ */ jsx3(
|
|
369
|
+
CommandBar.Command,
|
|
370
|
+
{
|
|
371
|
+
action: handleDelete,
|
|
372
|
+
label: t("actions.delete"),
|
|
373
|
+
shortcut: "d"
|
|
374
|
+
}
|
|
375
|
+
)
|
|
376
|
+
] }) })
|
|
377
|
+
] });
|
|
378
|
+
};
|
|
379
|
+
var getMedia = (product) => {
|
|
380
|
+
const { images = [], thumbnail } = product;
|
|
381
|
+
const media = (images || []).map((image) => ({
|
|
382
|
+
id: image.id,
|
|
383
|
+
url: image.url,
|
|
384
|
+
isThumbnail: image.url === thumbnail
|
|
385
|
+
}));
|
|
386
|
+
if (thumbnail && !media.some((mediaItem) => mediaItem.url === thumbnail)) {
|
|
387
|
+
media.unshift({
|
|
388
|
+
id: "img_thumbnail",
|
|
389
|
+
url: thumbnail,
|
|
390
|
+
isThumbnail: true
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
return media;
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
// src/pages/products/[id]/_components/product-option-section/product-option-section.tsx
|
|
397
|
+
import { PencilSquare as PencilSquare3, Plus, Trash as Trash2 } from "@medusajs/icons";
|
|
398
|
+
import { Badge, Container as Container3, Heading as Heading3, usePrompt as usePrompt3 } from "@medusajs/ui";
|
|
399
|
+
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
400
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
401
|
+
var OptionActions = ({
|
|
402
|
+
option
|
|
403
|
+
}) => {
|
|
404
|
+
const { product } = useProductDetailContext();
|
|
405
|
+
const { t } = useTranslation3();
|
|
406
|
+
const { mutateAsync } = useDeleteProductOption(product.id, option.id);
|
|
407
|
+
const prompt = usePrompt3();
|
|
408
|
+
const handleDelete = async () => {
|
|
409
|
+
const res = await prompt({
|
|
410
|
+
title: t("general.areYouSure"),
|
|
411
|
+
description: t("products.options.deleteWarning", {
|
|
412
|
+
title: option.title
|
|
413
|
+
}),
|
|
414
|
+
confirmText: t("actions.delete"),
|
|
415
|
+
cancelText: t("actions.cancel")
|
|
416
|
+
});
|
|
417
|
+
if (!res) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
await mutateAsync();
|
|
421
|
+
};
|
|
422
|
+
return /* @__PURE__ */ jsx4(
|
|
423
|
+
ActionMenu,
|
|
424
|
+
{
|
|
425
|
+
groups: [
|
|
426
|
+
{
|
|
427
|
+
actions: [
|
|
428
|
+
{
|
|
429
|
+
label: t("actions.edit"),
|
|
430
|
+
to: `options/${option.id}/edit`,
|
|
431
|
+
icon: /* @__PURE__ */ jsx4(PencilSquare3, {})
|
|
432
|
+
}
|
|
433
|
+
]
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
actions: [
|
|
437
|
+
{
|
|
438
|
+
label: t("actions.delete"),
|
|
439
|
+
onClick: handleDelete,
|
|
440
|
+
icon: /* @__PURE__ */ jsx4(Trash2, {})
|
|
441
|
+
}
|
|
442
|
+
]
|
|
443
|
+
}
|
|
444
|
+
]
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
};
|
|
448
|
+
var ProductOptionSection = () => {
|
|
449
|
+
const { product } = useProductDetailContext();
|
|
450
|
+
const { t } = useTranslation3();
|
|
451
|
+
return /* @__PURE__ */ jsxs3(Container3, { className: "divide-y p-0", children: [
|
|
452
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
453
|
+
/* @__PURE__ */ jsx4(Heading3, { level: "h2", children: t("products.options.header") }),
|
|
454
|
+
/* @__PURE__ */ jsx4(
|
|
455
|
+
ActionMenu,
|
|
456
|
+
{
|
|
457
|
+
groups: [
|
|
458
|
+
{
|
|
459
|
+
actions: [
|
|
460
|
+
{
|
|
461
|
+
label: t("actions.create"),
|
|
462
|
+
to: "options/create",
|
|
463
|
+
icon: /* @__PURE__ */ jsx4(Plus, {})
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
}
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
)
|
|
470
|
+
] }),
|
|
471
|
+
product.options?.map((option) => {
|
|
472
|
+
return /* @__PURE__ */ jsx4(
|
|
473
|
+
SectionRow,
|
|
474
|
+
{
|
|
475
|
+
title: option.title,
|
|
476
|
+
value: option.values?.map((val) => {
|
|
477
|
+
return /* @__PURE__ */ jsx4(
|
|
478
|
+
Badge,
|
|
479
|
+
{
|
|
480
|
+
size: "2xsmall",
|
|
481
|
+
className: "flex min-w-[20px] items-center justify-center",
|
|
482
|
+
children: val.value
|
|
483
|
+
},
|
|
484
|
+
val.value
|
|
485
|
+
);
|
|
486
|
+
}),
|
|
487
|
+
actions: /* @__PURE__ */ jsx4(OptionActions, { option })
|
|
488
|
+
},
|
|
489
|
+
option.id
|
|
490
|
+
);
|
|
491
|
+
})
|
|
492
|
+
] });
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// src/pages/products/[id]/_components/product-organization-section/product-organization-section.tsx
|
|
496
|
+
import { PencilSquare as PencilSquare4 } from "@medusajs/icons";
|
|
497
|
+
import { Badge as Badge2, Container as Container4, Heading as Heading4, Tooltip as Tooltip2 } from "@medusajs/ui";
|
|
498
|
+
import { useTranslation as useTranslation4 } from "react-i18next";
|
|
499
|
+
import { Link as Link2 } from "react-router-dom";
|
|
500
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
501
|
+
var ProductOrganizationSection = () => {
|
|
502
|
+
const { product } = useProductDetailContext();
|
|
503
|
+
const { t } = useTranslation4();
|
|
504
|
+
return /* @__PURE__ */ jsxs4(Container4, { className: "divide-y p-0", children: [
|
|
505
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
506
|
+
/* @__PURE__ */ jsx5(Heading4, { level: "h2", children: t("products.organization.header") }),
|
|
507
|
+
/* @__PURE__ */ jsx5(
|
|
508
|
+
ActionMenu,
|
|
509
|
+
{
|
|
510
|
+
groups: [
|
|
511
|
+
{
|
|
512
|
+
actions: [
|
|
513
|
+
{
|
|
514
|
+
label: t("actions.edit"),
|
|
515
|
+
to: "organization",
|
|
516
|
+
icon: /* @__PURE__ */ jsx5(PencilSquare4, {})
|
|
517
|
+
}
|
|
518
|
+
]
|
|
519
|
+
}
|
|
520
|
+
]
|
|
521
|
+
}
|
|
522
|
+
)
|
|
523
|
+
] }),
|
|
524
|
+
/* @__PURE__ */ jsx5(
|
|
525
|
+
SectionRow,
|
|
526
|
+
{
|
|
527
|
+
title: t("fields.tags"),
|
|
528
|
+
value: product.tags?.length ? product.tags.map((tag) => /* @__PURE__ */ jsx5(
|
|
529
|
+
OrganizationTag,
|
|
530
|
+
{
|
|
531
|
+
label: tag.value,
|
|
532
|
+
to: `/settings/product-tags/${tag.id}`
|
|
533
|
+
},
|
|
534
|
+
tag.id
|
|
535
|
+
)) : void 0
|
|
536
|
+
}
|
|
537
|
+
),
|
|
538
|
+
/* @__PURE__ */ jsx5(
|
|
539
|
+
SectionRow,
|
|
540
|
+
{
|
|
541
|
+
title: t("fields.type"),
|
|
542
|
+
value: product.type ? /* @__PURE__ */ jsx5(
|
|
543
|
+
OrganizationTag,
|
|
544
|
+
{
|
|
545
|
+
label: product.type.value,
|
|
546
|
+
to: `/settings/product-types/${product.type_id}`
|
|
547
|
+
}
|
|
548
|
+
) : void 0
|
|
549
|
+
}
|
|
550
|
+
),
|
|
551
|
+
/* @__PURE__ */ jsx5(
|
|
552
|
+
SectionRow,
|
|
553
|
+
{
|
|
554
|
+
title: t("fields.collection"),
|
|
555
|
+
value: product.collection ? /* @__PURE__ */ jsx5(
|
|
556
|
+
OrganizationTag,
|
|
557
|
+
{
|
|
558
|
+
label: product.collection.title,
|
|
559
|
+
to: `/collections/${product.collection.id}`
|
|
560
|
+
}
|
|
561
|
+
) : void 0
|
|
562
|
+
}
|
|
563
|
+
),
|
|
564
|
+
/* @__PURE__ */ jsx5(
|
|
565
|
+
SectionRow,
|
|
566
|
+
{
|
|
567
|
+
title: t("fields.categories"),
|
|
568
|
+
value: product.categories?.length ? product.categories.map((pcat) => /* @__PURE__ */ jsx5(
|
|
569
|
+
OrganizationTag,
|
|
570
|
+
{
|
|
571
|
+
label: pcat.name,
|
|
572
|
+
to: `/categories/${pcat.id}`
|
|
573
|
+
},
|
|
574
|
+
pcat.id
|
|
575
|
+
)) : void 0
|
|
576
|
+
}
|
|
577
|
+
)
|
|
578
|
+
] });
|
|
579
|
+
};
|
|
580
|
+
var OrganizationTag = ({ label, to }) => {
|
|
581
|
+
return /* @__PURE__ */ jsx5(Tooltip2, { content: label, children: /* @__PURE__ */ jsx5(Badge2, { size: "2xsmall", className: "block w-fit truncate", asChild: true, children: /* @__PURE__ */ jsx5(Link2, { to, children: label }) }) });
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
// src/pages/products/[id]/_components/product-variant-section/product-variant-section.tsx
|
|
585
|
+
import { Buildings, Component, PencilSquare as PencilSquare5, Trash as Trash3 } from "@medusajs/icons";
|
|
586
|
+
import {
|
|
587
|
+
Badge as Badge3,
|
|
588
|
+
clx as clx2,
|
|
589
|
+
Container as Container5,
|
|
590
|
+
createDataTableColumnHelper,
|
|
591
|
+
createDataTableCommandHelper,
|
|
592
|
+
createDataTableFilterHelper,
|
|
593
|
+
Tooltip as Tooltip3,
|
|
594
|
+
usePrompt as usePrompt4
|
|
595
|
+
} from "@medusajs/ui";
|
|
596
|
+
import { keepPreviousData } from "@tanstack/react-query";
|
|
597
|
+
import { useCallback, useMemo } from "react";
|
|
598
|
+
import { useTranslation as useTranslation5 } from "react-i18next";
|
|
599
|
+
import { useNavigate as useNavigate2, useParams, useSearchParams } from "react-router-dom";
|
|
600
|
+
|
|
601
|
+
// src/pages/products/common/constants.ts
|
|
602
|
+
var PRODUCT_VARIANT_IDS_KEY = "product_variant_ids";
|
|
603
|
+
|
|
604
|
+
// src/pages/products/[id]/_components/product-variant-section/product-variant-section.tsx
|
|
605
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
606
|
+
var PAGE_SIZE = 10;
|
|
607
|
+
var PREFIX = "pv";
|
|
608
|
+
var ProductVariantSection = () => {
|
|
609
|
+
const { id } = useParams();
|
|
610
|
+
const { product } = useProduct(id);
|
|
611
|
+
const { t } = useTranslation5();
|
|
612
|
+
const { q, order, offset, allow_backorder, manage_inventory } = useQueryParams(
|
|
613
|
+
["q", "order", "offset", "manage_inventory", "allow_backorder"],
|
|
614
|
+
PREFIX
|
|
615
|
+
);
|
|
616
|
+
const columns = useColumns(product);
|
|
617
|
+
const filters = useFilters();
|
|
618
|
+
const commands = useCommands();
|
|
619
|
+
const { variants, count, isPending, isError, error } = useProductVariants(
|
|
620
|
+
product.id,
|
|
621
|
+
{
|
|
622
|
+
q,
|
|
623
|
+
order: order ? order : "variant_rank",
|
|
624
|
+
offset: offset ? parseInt(offset) : void 0,
|
|
625
|
+
limit: PAGE_SIZE,
|
|
626
|
+
allow_backorder: allow_backorder ? JSON.parse(allow_backorder) : void 0,
|
|
627
|
+
manage_inventory: manage_inventory ? JSON.parse(manage_inventory) : void 0,
|
|
628
|
+
fields: "title,sku,thumbnail,*options,created_at,*inventory_items.inventory.location_levels,inventory_quantity,manage_inventory"
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
placeholderData: keepPreviousData
|
|
632
|
+
}
|
|
633
|
+
);
|
|
634
|
+
if (isError) {
|
|
635
|
+
throw error;
|
|
636
|
+
}
|
|
637
|
+
return /* @__PURE__ */ jsx6(Container5, { className: "divide-y p-0", children: /* @__PURE__ */ jsx6(
|
|
638
|
+
DataTable,
|
|
639
|
+
{
|
|
640
|
+
data: variants,
|
|
641
|
+
columns,
|
|
642
|
+
filters,
|
|
643
|
+
rowCount: count,
|
|
644
|
+
getRowId: (row) => row.id,
|
|
645
|
+
rowHref: (row) => `/products/${product.id}/variants/${row.id}`,
|
|
646
|
+
pageSize: PAGE_SIZE,
|
|
647
|
+
isLoading: isPending,
|
|
648
|
+
heading: t("products.variants.header"),
|
|
649
|
+
headingLevel: "h2",
|
|
650
|
+
emptyState: {
|
|
651
|
+
empty: {
|
|
652
|
+
heading: t("products.variants.empty.heading"),
|
|
653
|
+
description: t("products.variants.empty.description")
|
|
654
|
+
},
|
|
655
|
+
filtered: {
|
|
656
|
+
heading: t("products.variants.filtered.heading"),
|
|
657
|
+
description: t("products.variants.filtered.description")
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
action: {
|
|
661
|
+
label: t("actions.create"),
|
|
662
|
+
to: `variants/create`
|
|
663
|
+
},
|
|
664
|
+
actionMenu: {
|
|
665
|
+
groups: [
|
|
666
|
+
{
|
|
667
|
+
actions: [
|
|
668
|
+
{
|
|
669
|
+
label: t("products.editPrices"),
|
|
670
|
+
to: `prices`,
|
|
671
|
+
icon: /* @__PURE__ */ jsx6(PencilSquare5, {})
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
label: t("inventory.stock.action"),
|
|
675
|
+
to: `stock`,
|
|
676
|
+
icon: /* @__PURE__ */ jsx6(Buildings, {})
|
|
677
|
+
}
|
|
678
|
+
]
|
|
679
|
+
}
|
|
680
|
+
]
|
|
681
|
+
},
|
|
682
|
+
commands,
|
|
683
|
+
prefix: PREFIX
|
|
684
|
+
}
|
|
685
|
+
) });
|
|
686
|
+
};
|
|
687
|
+
var columnHelper = createDataTableColumnHelper();
|
|
688
|
+
var useColumns = (product) => {
|
|
689
|
+
const { t } = useTranslation5();
|
|
690
|
+
const navigate = useNavigate2();
|
|
691
|
+
const { mutateAsync } = useDeleteVariantLazy(product.id);
|
|
692
|
+
const prompt = usePrompt4();
|
|
693
|
+
const [searchParams] = useSearchParams();
|
|
694
|
+
const tableSearchParams = useMemo(() => {
|
|
695
|
+
const filtered = new URLSearchParams();
|
|
696
|
+
for (const [key, value] of searchParams.entries()) {
|
|
697
|
+
if (key.startsWith(`${PREFIX}_`)) {
|
|
698
|
+
filtered.append(key, value);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return filtered;
|
|
702
|
+
}, [searchParams]);
|
|
703
|
+
const handleDelete = useCallback(
|
|
704
|
+
async (id, title) => {
|
|
705
|
+
const res = await prompt({
|
|
706
|
+
title: t("general.areYouSure"),
|
|
707
|
+
description: t("products.deleteVariantWarning", {
|
|
708
|
+
title
|
|
709
|
+
}),
|
|
710
|
+
confirmText: t("actions.delete"),
|
|
711
|
+
cancelText: t("actions.cancel")
|
|
712
|
+
});
|
|
713
|
+
if (!res) {
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
await mutateAsync({ variantId: id });
|
|
717
|
+
},
|
|
718
|
+
[mutateAsync, prompt, t]
|
|
719
|
+
);
|
|
720
|
+
const optionColumns = useMemo(() => {
|
|
721
|
+
if (!product?.options) {
|
|
722
|
+
return [];
|
|
723
|
+
}
|
|
724
|
+
return product.options.map((option) => {
|
|
725
|
+
return columnHelper.display({
|
|
726
|
+
id: option.id,
|
|
727
|
+
header: option.title,
|
|
728
|
+
cell: ({ row }) => {
|
|
729
|
+
const variantOpt = row.original.options?.find(
|
|
730
|
+
(opt) => opt.option_id === option.id
|
|
731
|
+
);
|
|
732
|
+
if (!variantOpt) {
|
|
733
|
+
return /* @__PURE__ */ jsx6("span", { className: "text-ui-fg-muted", children: "-" });
|
|
734
|
+
}
|
|
735
|
+
return /* @__PURE__ */ jsx6("div", { className: "flex items-center", children: /* @__PURE__ */ jsx6(Tooltip3, { content: variantOpt.value, children: /* @__PURE__ */ jsx6(
|
|
736
|
+
Badge3,
|
|
737
|
+
{
|
|
738
|
+
size: "2xsmall",
|
|
739
|
+
title: variantOpt.value,
|
|
740
|
+
className: "inline-flex min-w-[20px] max-w-[140px] items-center justify-center overflow-hidden truncate",
|
|
741
|
+
children: variantOpt.value
|
|
742
|
+
}
|
|
743
|
+
) }) });
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
});
|
|
747
|
+
}, [product]);
|
|
748
|
+
const getActions = useCallback(
|
|
749
|
+
(ctx) => {
|
|
750
|
+
const variant = ctx.row.original;
|
|
751
|
+
const mainActions = [
|
|
752
|
+
{
|
|
753
|
+
icon: /* @__PURE__ */ jsx6(PencilSquare5, {}),
|
|
754
|
+
label: t("actions.edit"),
|
|
755
|
+
onClick: () => {
|
|
756
|
+
navigate(`variants/${variant.id}/edit`);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
];
|
|
760
|
+
if (variant.manage_inventory && variant.inventory_items?.length) {
|
|
761
|
+
mainActions.push({
|
|
762
|
+
label: t("products.variant.inventory.actions.inventoryItems"),
|
|
763
|
+
onClick: () => {
|
|
764
|
+
navigate(`variants/${variant.id}`);
|
|
765
|
+
},
|
|
766
|
+
icon: /* @__PURE__ */ jsx6(Buildings, {})
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
const secondaryActions = [
|
|
770
|
+
{
|
|
771
|
+
icon: /* @__PURE__ */ jsx6(Trash3, {}),
|
|
772
|
+
label: t("actions.delete"),
|
|
773
|
+
onClick: () => handleDelete(variant.id, variant.title)
|
|
774
|
+
}
|
|
775
|
+
];
|
|
776
|
+
return [mainActions, secondaryActions];
|
|
777
|
+
},
|
|
778
|
+
[handleDelete, navigate, t, tableSearchParams]
|
|
779
|
+
);
|
|
780
|
+
const getInventory = useCallback(
|
|
781
|
+
(variant) => {
|
|
782
|
+
const castVariant = variant;
|
|
783
|
+
if (!variant.manage_inventory) {
|
|
784
|
+
return {
|
|
785
|
+
text: t("products.variant.inventory.notManaged"),
|
|
786
|
+
hasInventoryKit: false,
|
|
787
|
+
notManaged: true
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
const quantity = variant.inventory_quantity;
|
|
791
|
+
const inventoryItems = castVariant.inventory_items?.map((i) => i.inventory).filter(Boolean);
|
|
792
|
+
const hasInventoryKit = inventoryItems.length > 1;
|
|
793
|
+
const locations = {};
|
|
794
|
+
inventoryItems.forEach((i) => {
|
|
795
|
+
i.location_levels?.forEach((l) => {
|
|
796
|
+
locations[l.id] = true;
|
|
797
|
+
});
|
|
798
|
+
});
|
|
799
|
+
const locationCount = Object.keys(locations).length;
|
|
800
|
+
const text = hasInventoryKit ? t("products.variant.tableItemAvailable", {
|
|
801
|
+
availableCount: quantity
|
|
802
|
+
}) : t("products.variant.tableItem", {
|
|
803
|
+
availableCount: quantity,
|
|
804
|
+
locationCount,
|
|
805
|
+
count: locationCount
|
|
806
|
+
});
|
|
807
|
+
return { text, hasInventoryKit, quantity, notManaged: false };
|
|
808
|
+
},
|
|
809
|
+
[t]
|
|
810
|
+
);
|
|
811
|
+
return useMemo(() => {
|
|
812
|
+
return [
|
|
813
|
+
columnHelper.accessor("thumbnail", {
|
|
814
|
+
header: "",
|
|
815
|
+
headerAlign: "center",
|
|
816
|
+
maxSize: 72,
|
|
817
|
+
cell: ({ row }) => {
|
|
818
|
+
return /* @__PURE__ */ jsx6("div", { className: "flex items-center pl-[1px]", children: /* @__PURE__ */ jsx6(Thumbnail, { src: row.original.thumbnail }) });
|
|
819
|
+
}
|
|
820
|
+
}),
|
|
821
|
+
columnHelper.accessor("title", {
|
|
822
|
+
header: t("fields.title"),
|
|
823
|
+
enableSorting: true,
|
|
824
|
+
sortAscLabel: t("filters.sorting.alphabeticallyAsc"),
|
|
825
|
+
sortDescLabel: t("filters.sorting.alphabeticallyDesc")
|
|
826
|
+
}),
|
|
827
|
+
columnHelper.accessor("sku", {
|
|
828
|
+
header: t("fields.sku"),
|
|
829
|
+
enableSorting: true,
|
|
830
|
+
sortAscLabel: t("filters.sorting.alphabeticallyAsc"),
|
|
831
|
+
sortDescLabel: t("filters.sorting.alphabeticallyDesc")
|
|
832
|
+
}),
|
|
833
|
+
...optionColumns,
|
|
834
|
+
columnHelper.display({
|
|
835
|
+
id: "inventory",
|
|
836
|
+
header: t("fields.inventory"),
|
|
837
|
+
cell: ({ row }) => {
|
|
838
|
+
const { text, hasInventoryKit, quantity, notManaged } = getInventory(
|
|
839
|
+
row.original
|
|
840
|
+
);
|
|
841
|
+
return /* @__PURE__ */ jsx6(Tooltip3, { content: text, children: /* @__PURE__ */ jsxs5("div", { className: "flex h-full w-full items-center gap-2 overflow-hidden", children: [
|
|
842
|
+
hasInventoryKit && /* @__PURE__ */ jsx6(Component, {}),
|
|
843
|
+
/* @__PURE__ */ jsx6(
|
|
844
|
+
"span",
|
|
845
|
+
{
|
|
846
|
+
className: clx2("truncate", {
|
|
847
|
+
"text-ui-fg-error": !quantity && !notManaged
|
|
848
|
+
}),
|
|
849
|
+
children: text
|
|
850
|
+
}
|
|
851
|
+
)
|
|
852
|
+
] }) });
|
|
853
|
+
},
|
|
854
|
+
maxSize: 250
|
|
855
|
+
}),
|
|
856
|
+
columnHelper.action({
|
|
857
|
+
actions: getActions
|
|
858
|
+
})
|
|
859
|
+
];
|
|
860
|
+
}, [t, optionColumns, getActions, getInventory]);
|
|
861
|
+
};
|
|
862
|
+
var filterHelper = createDataTableFilterHelper();
|
|
863
|
+
var useFilters = () => {
|
|
864
|
+
const { t } = useTranslation5();
|
|
865
|
+
const dateFilters = useDataTableDateFilters();
|
|
866
|
+
return useMemo(() => {
|
|
867
|
+
return [
|
|
868
|
+
filterHelper.accessor("allow_backorder", {
|
|
869
|
+
type: "radio",
|
|
870
|
+
label: t("fields.allowBackorder"),
|
|
871
|
+
options: [
|
|
872
|
+
{ label: t("filters.radio.yes"), value: "true" },
|
|
873
|
+
{ label: t("filters.radio.no"), value: "false" }
|
|
874
|
+
]
|
|
875
|
+
}),
|
|
876
|
+
filterHelper.accessor("manage_inventory", {
|
|
877
|
+
type: "radio",
|
|
878
|
+
label: t("fields.manageInventory"),
|
|
879
|
+
options: [
|
|
880
|
+
{ label: t("filters.radio.yes"), value: "true" },
|
|
881
|
+
{ label: t("filters.radio.no"), value: "false" }
|
|
882
|
+
]
|
|
883
|
+
}),
|
|
884
|
+
...dateFilters
|
|
885
|
+
];
|
|
886
|
+
}, [t, dateFilters]);
|
|
887
|
+
};
|
|
888
|
+
var commandHelper = createDataTableCommandHelper();
|
|
889
|
+
var useCommands = () => {
|
|
890
|
+
const { t } = useTranslation5();
|
|
891
|
+
const navigate = useNavigate2();
|
|
892
|
+
return [
|
|
893
|
+
commandHelper.command({
|
|
894
|
+
label: t("inventory.stock.action"),
|
|
895
|
+
shortcut: "i",
|
|
896
|
+
action: async (selection) => {
|
|
897
|
+
navigate(
|
|
898
|
+
`stock?${PRODUCT_VARIANT_IDS_KEY}=${Object.keys(selection).join(",")}`
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
})
|
|
902
|
+
];
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
// src/pages/products/[id]/_components/product-attribute-section/product-attribute-section.tsx
|
|
906
|
+
import { PencilSquare as PencilSquare6 } from "@medusajs/icons";
|
|
907
|
+
import { Container as Container6, Heading as Heading5 } from "@medusajs/ui";
|
|
908
|
+
import { useTranslation as useTranslation6 } from "react-i18next";
|
|
909
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
910
|
+
var ProductAttributeSection = () => {
|
|
911
|
+
const { product } = useProductDetailContext();
|
|
912
|
+
const { t } = useTranslation6();
|
|
913
|
+
return /* @__PURE__ */ jsxs6(Container6, { className: "divide-y p-0", children: [
|
|
914
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
915
|
+
/* @__PURE__ */ jsx7(Heading5, { level: "h2", children: t("products.attributes") }),
|
|
916
|
+
/* @__PURE__ */ jsx7(
|
|
917
|
+
ActionMenu,
|
|
918
|
+
{
|
|
919
|
+
groups: [
|
|
920
|
+
{
|
|
921
|
+
actions: [
|
|
922
|
+
{
|
|
923
|
+
label: t("actions.edit"),
|
|
924
|
+
to: "attributes",
|
|
925
|
+
icon: /* @__PURE__ */ jsx7(PencilSquare6, {})
|
|
926
|
+
}
|
|
927
|
+
]
|
|
928
|
+
}
|
|
929
|
+
]
|
|
930
|
+
}
|
|
931
|
+
)
|
|
932
|
+
] }),
|
|
933
|
+
/* @__PURE__ */ jsx7(SectionRow, { title: t("fields.height"), value: product.height }),
|
|
934
|
+
/* @__PURE__ */ jsx7(SectionRow, { title: t("fields.width"), value: product.width }),
|
|
935
|
+
/* @__PURE__ */ jsx7(SectionRow, { title: t("fields.length"), value: product.length }),
|
|
936
|
+
/* @__PURE__ */ jsx7(SectionRow, { title: t("fields.weight"), value: product.weight }),
|
|
937
|
+
/* @__PURE__ */ jsx7(SectionRow, { title: t("fields.midCode"), value: product.mid_code }),
|
|
938
|
+
/* @__PURE__ */ jsx7(SectionRow, { title: t("fields.hsCode"), value: product.hs_code }),
|
|
939
|
+
/* @__PURE__ */ jsx7(
|
|
940
|
+
SectionRow,
|
|
941
|
+
{
|
|
942
|
+
title: t("fields.countryOfOrigin"),
|
|
943
|
+
value: getFormattedCountry(product.origin_country)
|
|
944
|
+
}
|
|
945
|
+
)
|
|
946
|
+
] });
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
// src/pages/products/[id]/_components/product-additional-attribute-section/ProductAdditionalAttributesSection.tsx
|
|
950
|
+
import { Container as Container7, Heading as Heading6 } from "@medusajs/ui";
|
|
951
|
+
import { PencilSquare as PencilSquare7 } from "@medusajs/icons";
|
|
952
|
+
import { useMemo as useMemo2 } from "react";
|
|
953
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
954
|
+
var ProductAdditionalAttributesSection = () => {
|
|
955
|
+
const { product } = useProductDetailContext();
|
|
956
|
+
const { attributes, isLoading } = useProductAttributes(product.id);
|
|
957
|
+
const attributeList = useMemo2(() => {
|
|
958
|
+
return attributes?.map((attribute) => {
|
|
959
|
+
const value = product.attribute_values?.find((av) => av && av.attribute_id === attribute.id)?.value || "-";
|
|
960
|
+
return {
|
|
961
|
+
...attribute,
|
|
962
|
+
value
|
|
963
|
+
};
|
|
964
|
+
});
|
|
965
|
+
}, [attributes, product.attribute_values]);
|
|
966
|
+
if (isLoading) return;
|
|
967
|
+
return /* @__PURE__ */ jsxs7(Container7, { className: "divide-y p-0", children: [
|
|
968
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
969
|
+
/* @__PURE__ */ jsx8(Heading6, { level: "h2", children: "Attributes" }),
|
|
970
|
+
/* @__PURE__ */ jsx8(
|
|
971
|
+
ActionMenu,
|
|
972
|
+
{
|
|
973
|
+
groups: [
|
|
974
|
+
{
|
|
975
|
+
actions: [
|
|
976
|
+
{
|
|
977
|
+
label: "Edit",
|
|
978
|
+
to: "additional-attributes",
|
|
979
|
+
icon: /* @__PURE__ */ jsx8(PencilSquare7, {})
|
|
980
|
+
}
|
|
981
|
+
]
|
|
982
|
+
}
|
|
983
|
+
]
|
|
984
|
+
}
|
|
985
|
+
)
|
|
986
|
+
] }),
|
|
987
|
+
attributeList?.map((attribute) => /* @__PURE__ */ jsx8(
|
|
988
|
+
SectionRow,
|
|
989
|
+
{
|
|
990
|
+
title: attribute.name,
|
|
991
|
+
value: attribute.value,
|
|
992
|
+
tooltip: attribute.description
|
|
993
|
+
},
|
|
994
|
+
attribute.id
|
|
995
|
+
))
|
|
996
|
+
] });
|
|
997
|
+
};
|
|
998
|
+
|
|
999
|
+
// src/pages/products/[id]/_components/product-shipping-profile-section/product-shipping-profile-section.tsx
|
|
1000
|
+
import { PencilSquare as PencilSquare8, ShoppingBag } from "@medusajs/icons";
|
|
1001
|
+
import { Container as Container8, Heading as Heading7 } from "@medusajs/ui";
|
|
1002
|
+
import { useTranslation as useTranslation7 } from "react-i18next";
|
|
1003
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1004
|
+
var ProductShippingProfileSection = () => {
|
|
1005
|
+
const { product } = useProductDetailContext();
|
|
1006
|
+
const { t } = useTranslation7();
|
|
1007
|
+
const shippingProfile = product.shipping_profile;
|
|
1008
|
+
return /* @__PURE__ */ jsxs8(Container8, { className: "p-0", children: [
|
|
1009
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
1010
|
+
/* @__PURE__ */ jsx9(Heading7, { level: "h2", children: t("products.shippingProfile.header") }),
|
|
1011
|
+
/* @__PURE__ */ jsx9(
|
|
1012
|
+
ActionMenu,
|
|
1013
|
+
{
|
|
1014
|
+
groups: [
|
|
1015
|
+
{
|
|
1016
|
+
actions: [
|
|
1017
|
+
{
|
|
1018
|
+
label: t("actions.edit"),
|
|
1019
|
+
to: "shipping-profile",
|
|
1020
|
+
icon: /* @__PURE__ */ jsx9(PencilSquare8, {})
|
|
1021
|
+
}
|
|
1022
|
+
]
|
|
1023
|
+
}
|
|
1024
|
+
]
|
|
1025
|
+
}
|
|
1026
|
+
)
|
|
1027
|
+
] }),
|
|
1028
|
+
shippingProfile && /* @__PURE__ */ jsx9(
|
|
1029
|
+
SidebarLink,
|
|
1030
|
+
{
|
|
1031
|
+
to: `/settings/locations/shipping-profiles/${shippingProfile.id}`,
|
|
1032
|
+
labelKey: shippingProfile.name,
|
|
1033
|
+
descriptionKey: shippingProfile.type,
|
|
1034
|
+
icon: /* @__PURE__ */ jsx9(ShoppingBag, {})
|
|
1035
|
+
}
|
|
1036
|
+
)
|
|
1037
|
+
] });
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
// src/pages/products/[id]/_components/product-sales-channel-section/product-sales-channel-section.tsx
|
|
1041
|
+
import { Channels, PencilSquare as PencilSquare9 } from "@medusajs/icons";
|
|
1042
|
+
import { Container as Container9, Heading as Heading8, Text as Text2, Tooltip as Tooltip4 } from "@medusajs/ui";
|
|
1043
|
+
import { Trans, useTranslation as useTranslation8 } from "react-i18next";
|
|
1044
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1045
|
+
var ProductSalesChannelSection = () => {
|
|
1046
|
+
const { product } = useProductDetailContext();
|
|
1047
|
+
const { count } = useSalesChannels();
|
|
1048
|
+
const { t } = useTranslation8();
|
|
1049
|
+
const availableInSalesChannels = product.sales_channels?.map((sc) => ({
|
|
1050
|
+
id: sc.id,
|
|
1051
|
+
name: sc.name
|
|
1052
|
+
})) ?? [];
|
|
1053
|
+
const firstChannels = availableInSalesChannels.slice(0, 3);
|
|
1054
|
+
const restChannels = availableInSalesChannels.slice(3);
|
|
1055
|
+
return /* @__PURE__ */ jsxs9(Container9, { className: "flex flex-col gap-y-4 px-6 py-4", children: [
|
|
1056
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between", children: [
|
|
1057
|
+
/* @__PURE__ */ jsx10(Heading8, { level: "h2", children: t("fields.sales_channels") }),
|
|
1058
|
+
/* @__PURE__ */ jsx10(
|
|
1059
|
+
ActionMenu,
|
|
1060
|
+
{
|
|
1061
|
+
groups: [
|
|
1062
|
+
{
|
|
1063
|
+
actions: [
|
|
1064
|
+
{
|
|
1065
|
+
label: t("actions.edit"),
|
|
1066
|
+
to: "sales-channels",
|
|
1067
|
+
icon: /* @__PURE__ */ jsx10(PencilSquare9, {})
|
|
1068
|
+
}
|
|
1069
|
+
]
|
|
1070
|
+
}
|
|
1071
|
+
]
|
|
1072
|
+
}
|
|
1073
|
+
)
|
|
1074
|
+
] }),
|
|
1075
|
+
/* @__PURE__ */ jsxs9("div", { className: "grid grid-cols-[28px_1fr] items-center gap-x-3", children: [
|
|
1076
|
+
/* @__PURE__ */ jsx10("div", { className: "bg-ui-bg-base shadow-borders-base flex size-7 items-center justify-center rounded-md", children: /* @__PURE__ */ jsx10("div", { className: "bg-ui-bg-component flex size-6 items-center justify-center rounded-[4px]", children: /* @__PURE__ */ jsx10(Channels, { className: "text-ui-fg-subtle" }) }) }),
|
|
1077
|
+
availableInSalesChannels.length > 0 ? /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-x-1", children: [
|
|
1078
|
+
/* @__PURE__ */ jsx10(Text2, { size: "small", leading: "compact", children: firstChannels.map((sc) => sc.name).join(", ") }),
|
|
1079
|
+
restChannels.length > 0 && /* @__PURE__ */ jsx10(
|
|
1080
|
+
Tooltip4,
|
|
1081
|
+
{
|
|
1082
|
+
content: /* @__PURE__ */ jsx10("ul", { children: restChannels.map((sc) => /* @__PURE__ */ jsx10("li", { children: sc.name }, sc.id)) }),
|
|
1083
|
+
children: /* @__PURE__ */ jsx10(
|
|
1084
|
+
Text2,
|
|
1085
|
+
{
|
|
1086
|
+
size: "small",
|
|
1087
|
+
leading: "compact",
|
|
1088
|
+
className: "text-ui-fg-subtle",
|
|
1089
|
+
children: `+${restChannels.length}`
|
|
1090
|
+
}
|
|
1091
|
+
)
|
|
1092
|
+
}
|
|
1093
|
+
)
|
|
1094
|
+
] }) : /* @__PURE__ */ jsx10(Text2, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: t("products.noSalesChannels") })
|
|
1095
|
+
] }),
|
|
1096
|
+
/* @__PURE__ */ jsx10("div", { children: /* @__PURE__ */ jsx10(Text2, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: /* @__PURE__ */ jsx10(
|
|
1097
|
+
Trans,
|
|
1098
|
+
{
|
|
1099
|
+
i18nKey: "sales_channels.availableIn",
|
|
1100
|
+
values: {
|
|
1101
|
+
x: availableInSalesChannels.length,
|
|
1102
|
+
y: count ?? 0
|
|
1103
|
+
},
|
|
1104
|
+
components: [
|
|
1105
|
+
/* @__PURE__ */ jsx10(
|
|
1106
|
+
"span",
|
|
1107
|
+
{
|
|
1108
|
+
className: "text-ui-fg-base txt-compact-medium-plus"
|
|
1109
|
+
},
|
|
1110
|
+
"x"
|
|
1111
|
+
),
|
|
1112
|
+
/* @__PURE__ */ jsx10(
|
|
1113
|
+
"span",
|
|
1114
|
+
{
|
|
1115
|
+
className: "text-ui-fg-base txt-compact-medium-plus"
|
|
1116
|
+
},
|
|
1117
|
+
"y"
|
|
1118
|
+
)
|
|
1119
|
+
]
|
|
1120
|
+
}
|
|
1121
|
+
) }) })
|
|
1122
|
+
] });
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
// src/pages/products/[id]/product-detail-page.tsx
|
|
1126
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1127
|
+
var Root = ({ children }) => {
|
|
1128
|
+
const { id } = useParams2();
|
|
1129
|
+
const { product, isLoading, isError, error } = useProduct(id);
|
|
1130
|
+
if (isLoading || !product) {
|
|
1131
|
+
return /* @__PURE__ */ jsx11(TwoColumnPageSkeleton, { mainSections: 4, sidebarSections: 3 });
|
|
1132
|
+
}
|
|
1133
|
+
if (isError) {
|
|
1134
|
+
throw error;
|
|
1135
|
+
}
|
|
1136
|
+
return /* @__PURE__ */ jsx11(ProductDetailProvider, { product, children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs10(TwoColumnPage, { data: product, children: [
|
|
1137
|
+
/* @__PURE__ */ jsxs10(TwoColumnPage.Main, { children: [
|
|
1138
|
+
/* @__PURE__ */ jsx11(ProductGeneralSection, {}),
|
|
1139
|
+
/* @__PURE__ */ jsx11(ProductMediaSection, {}),
|
|
1140
|
+
/* @__PURE__ */ jsx11(ProductOptionSection, {}),
|
|
1141
|
+
/* @__PURE__ */ jsx11(ProductVariantSection, {})
|
|
1142
|
+
] }),
|
|
1143
|
+
/* @__PURE__ */ jsxs10(TwoColumnPage.Sidebar, { children: [
|
|
1144
|
+
/* @__PURE__ */ jsx11(ProductShippingProfileSection, {}),
|
|
1145
|
+
/* @__PURE__ */ jsx11(ProductOrganizationSection, {})
|
|
1146
|
+
] })
|
|
1147
|
+
] }) });
|
|
1148
|
+
};
|
|
1149
|
+
var ProductDetailPage = Object.assign(Root, {
|
|
1150
|
+
Main: TwoColumnPage.Main,
|
|
1151
|
+
Sidebar: TwoColumnPage.Sidebar,
|
|
1152
|
+
MainGeneralSection: ProductGeneralSection,
|
|
1153
|
+
MainMediaSection: ProductMediaSection,
|
|
1154
|
+
MainOptionSection: ProductOptionSection,
|
|
1155
|
+
MainVariantSection: ProductVariantSection,
|
|
1156
|
+
MainAttributeSection: ProductAttributeSection,
|
|
1157
|
+
MainAdditionalAttributeSection: ProductAdditionalAttributesSection,
|
|
1158
|
+
SidebarShippingProfileSection: ProductShippingProfileSection,
|
|
1159
|
+
SidebarOrganizationSection: ProductOrganizationSection,
|
|
1160
|
+
SidebarSalesChannelSection: ProductSalesChannelSection,
|
|
1161
|
+
useContext: useProductDetailContext
|
|
1162
|
+
});
|
|
1163
|
+
export {
|
|
1164
|
+
ProductDetailPage,
|
|
1165
|
+
loader
|
|
1166
|
+
};
|