@mercurjs/admin 2.3.7-canary.0 → 2.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-campaign-promotions-HHMISUZB.js → add-campaign-promotions-6BYWL6AA.js} +1 -1
- package/dist/{api-key-management-list-D3W4HEBM.js → api-key-management-list-7L7OLDGO.js} +2 -2
- package/dist/{attribute-detail-4B2P7UFG.js → attribute-detail-5AB2NEZE.js} +1 -1
- package/dist/{attribute-list-TZH5MVDT.js → attribute-list-QPJM77HR.js} +2 -2
- package/dist/{campaign-detail-W57XZ472.js → campaign-detail-VT62HOSX.js} +2 -2
- package/dist/{campaign-list-QVXUWMO5.js → campaign-list-4UPMYKLS.js} +2 -2
- package/dist/{category-detail-T27AGZ6B.js → category-detail-WM5PKZHS.js} +2 -2
- package/dist/{category-list-F6ZFHTGZ.js → category-list-67JSNVXT.js} +2 -2
- package/dist/{category-products-UE5Y3VG3.js → category-products-RYOQ5TM5.js} +1 -1
- package/dist/{chunk-W76OQ4UW.js → chunk-2D5NZTA6.js} +1 -1
- package/dist/chunk-35TFC2OI.js +210 -0
- package/dist/{chunk-OIMNVZDF.js → chunk-37GE6N5V.js} +1 -1
- package/dist/{chunk-DL3P6W63.js → chunk-4NMCASJ4.js} +1 -1
- package/dist/{chunk-OIWWUZDL.js → chunk-64EWPXUL.js} +1 -1
- package/dist/{chunk-K6WZ5WW5.js → chunk-66YS5LUL.js} +1 -1
- package/dist/{chunk-46WZTQ36.js → chunk-6QXWDLBA.js} +1 -1
- package/dist/{chunk-FCV5FSUM.js → chunk-7CNMMPNC.js} +1 -1
- package/dist/{chunk-BIL56N3K.js → chunk-7WTDVMPJ.js} +1 -1
- package/dist/{chunk-F6OU2QCY.js → chunk-7ZFSINKL.js} +1 -1
- package/dist/{chunk-SU36MZXC.js → chunk-AJZPQDDW.js} +12 -4
- package/dist/{chunk-DM52HEOD.js → chunk-BJCD2G3U.js} +1 -1
- package/dist/{chunk-YIFUH266.js → chunk-BRC3VJXF.js} +1 -1
- package/dist/{chunk-EHNOBH5I.js → chunk-CDFZKJSC.js} +1 -1
- package/dist/{chunk-AXCRJBUY.js → chunk-D7PXCIZX.js} +1 -1
- package/dist/{chunk-EP5CUH4C.js → chunk-FVC2Z3LR.js} +1 -1
- package/dist/{chunk-ATZPWIEI.js → chunk-GF4BJFSQ.js} +1 -1
- package/dist/{chunk-6A4PFRRO.js → chunk-GIFVQPFT.js} +1 -1
- package/dist/{chunk-D2VI737U.js → chunk-IG6ODEES.js} +1 -1
- package/dist/{chunk-GMJLK3IK.js → chunk-JOIE6CIR.js} +20 -1
- package/dist/{chunk-X6NX7BIG.js → chunk-MXIRZGYW.js} +1 -1
- package/dist/{chunk-4CGY6T44.js → chunk-NGYIAHMG.js} +1 -1
- package/dist/{chunk-22WJ7M7K.js → chunk-O3JRFTHJ.js} +1 -1
- package/dist/{chunk-AR3A6ZV4.js → chunk-O4L5V6TE.js} +1 -1
- package/dist/{chunk-6BX43GXE.js → chunk-ODBRDDOZ.js} +1 -1
- package/dist/{chunk-YQUS4QOS.js → chunk-OHL76ICJ.js} +1 -1
- package/dist/{chunk-BB4C372O.js → chunk-OHTFAHSD.js} +1 -1
- package/dist/{chunk-PQJ2KGLD.js → chunk-PFP6ZXLY.js} +2 -2
- package/dist/{chunk-AAVL5MJC.js → chunk-PTE652T6.js} +1 -1
- package/dist/{chunk-HZ4ADOD4.js → chunk-PTEWKH52.js} +1 -1
- package/dist/{chunk-MXMLUPAQ.js → chunk-Q254WWFS.js} +1 -1
- package/dist/{chunk-FHZ6TGFK.js → chunk-Q2ZJOBFJ.js} +1 -1
- package/dist/{chunk-6HHWBWQS.js → chunk-QHWI5KGN.js} +1 -1
- package/dist/{chunk-XZ2I74IZ.js → chunk-QPMAY54N.js} +1 -1
- package/dist/{chunk-MBSBOJFI.js → chunk-T3IV6KW3.js} +1 -1
- package/dist/{chunk-NRR55ZC2.js → chunk-UUQEZYGA.js} +1 -1
- package/dist/{chunk-5R457J2W.js → chunk-V2N6JLWD.js} +1 -1
- package/dist/{chunk-WXZYC4LI.js → chunk-V6OUOIBQ.js} +1 -1
- package/dist/{chunk-TSYSLFEE.js → chunk-VHO5PEEO.js} +1 -1
- package/dist/{chunk-NJAKCRO2.js → chunk-WDTE56OU.js} +1 -1
- package/dist/{chunk-AMRK755L.js → chunk-WISQFAJG.js} +177 -176
- package/dist/{chunk-CGKIYXZ6.js → chunk-WUCZ7VH3.js} +1 -1
- package/dist/{chunk-GOHCQWAJ.js → chunk-Y3P5VQ64.js} +1 -1
- package/dist/{chunk-AHRICJVV.js → chunk-YRMMQMSK.js} +1 -1
- package/dist/{chunk-TVCHVG2A.js → chunk-YZ7TYYVL.js} +1 -1
- package/dist/{chunk-J7FYKWJU.js → chunk-ZCPG6OV7.js} +1 -1
- package/dist/{chunk-R7LXMTIT.js → chunk-ZPKQWWCF.js} +2 -2
- package/dist/{chunk-QE36PNTV.js → chunk-ZQMCTQ2T.js} +1 -1
- package/dist/{collection-add-products-VNSPLNGL.js → collection-add-products-YQP5YOZO.js} +1 -1
- package/dist/{collection-detail-2XGAQMMS.js → collection-detail-IQV54EVJ.js} +2 -2
- package/dist/{collection-list-D23O4C7N.js → collection-list-Z7IA57OF.js} +2 -2
- package/dist/{commissions-list-ENJJOKHU.js → commissions-list-4MRDFAN6.js} +2 -2
- package/dist/{customer-detail-DROF3TFM.js → customer-detail-KOWSLCSV.js} +4 -3
- package/dist/{customer-group-add-customers-BRAX5VEC.js → customer-group-add-customers-KF432FE3.js} +1 -1
- package/dist/{customer-group-detail-7SRN7XGR.js → customer-group-detail-KYEP2WK5.js} +2 -2
- package/dist/{customer-group-list-3UV4JFIC.js → customer-group-list-GOAFY7WR.js} +2 -2
- package/dist/{customer-list-IF5HB6CU.js → customer-list-NVJX3U6Z.js} +2 -2
- package/dist/{customers-add-customer-group-7XSK3ZI6.js → customers-add-customer-group-CAPDOFBQ.js} +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +86 -86
- package/dist/{inventory-detail-YMY427YA.js → inventory-detail-5MBZ3WUH.js} +2 -2
- package/dist/{inventory-list-RNA7PFS5.js → inventory-list-PUHEUY6U.js} +2 -2
- package/dist/{location-fulfillment-providers-RI6OE65I.js → location-fulfillment-providers-RHFROGUA.js} +1 -1
- package/dist/{location-service-zone-create-Y3QEVCV2.js → location-service-zone-create-76EAFAJQ.js} +2 -2
- package/dist/{location-service-zone-manage-areas-7GT26QCN.js → location-service-zone-manage-areas-AU6O2R7D.js} +2 -2
- package/dist/{marketplace-add-currencies-2LCP4XJV.js → marketplace-add-currencies-LP54QP2F.js} +1 -1
- package/dist/{marketplace-detail-J7GVUZ7T.js → marketplace-detail-XIWEU2BP.js} +2 -2
- package/dist/{offer-detail-page-3H5APJUL.js → offer-detail-page-XNA63LSW.js} +2 -2
- package/dist/{offer-variant-detail-page-V6MP4SDN.js → offer-variant-detail-page-UATB4UIF.js} +2 -2
- package/dist/{offers-V4LY624Q.js → offers-3VVLBXXT.js} +1 -1
- package/dist/{order-create-claim-HRKNY4UI.js → order-create-claim-SA7G3BF7.js} +1 -1
- package/dist/{order-create-edit-LRHRGV4I.js → order-create-edit-MTLZ4MH6.js} +1 -1
- package/dist/{order-create-exchange-O23CVHIT.js → order-create-exchange-EY5GJP46.js} +1 -1
- package/dist/{order-create-return-R7YVDNVA.js → order-create-return-A7F4OQUD.js} +1 -1
- package/dist/{order-detail-56D3JKHO.js → order-detail-RJFKE5JR.js} +2 -2
- package/dist/{order-list-WJBA7YQN.js → order-list-V5SXVY4C.js} +4 -3
- package/dist/pages/index.js +45 -45
- package/dist/{payout-list-RYMCSVCT.js → payout-list-J5QBFBDQ.js} +2 -2
- package/dist/{price-list-create-UM63JWQQ.js → price-list-create-M7DT7DIB.js} +2 -2
- package/dist/{price-list-detail-G74QPX4O.js → price-list-detail-K5GT75MR.js} +2 -2
- package/dist/{price-list-list-IRVQYOHC.js → price-list-list-RVA2BXQB.js} +2 -2
- package/dist/{price-list-prices-add-H2MEQ2QR.js → price-list-prices-add-MNDRESKR.js} +2 -2
- package/dist/{product-create-WNSDDRLU.js → product-create-UZOSX5CO.js} +3 -3
- package/dist/{product-detail-3BCNKITT.js → product-detail-P5TG7T7B.js} +2 -2
- package/dist/{product-list-7CP6FHMX.js → product-list-YDYL765G.js} +2 -2
- package/dist/{product-media-SHV2VX7L.js → product-media-K2EC5Z2P.js} +1 -1
- package/dist/{product-tag-detail-LIAIYUDS.js → product-tag-detail-VJW4TMI6.js} +2 -2
- package/dist/{product-tag-list-BHRUK7QW.js → product-tag-list-ZF44FBU3.js} +2 -2
- package/dist/{product-type-detail-2K3HSKEC.js → product-type-detail-O5MQCKY2.js} +2 -2
- package/dist/{product-type-list-QA4OOOCL.js → product-type-list-B6RRMREU.js} +2 -2
- package/dist/{promotion-list-FXWF6U3M.js → promotion-list-AKK3OZJO.js} +2 -2
- package/dist/{region-add-countries-DV54R2PN.js → region-add-countries-IA2HWUQX.js} +1 -1
- package/dist/{region-create-CJM7NXOM.js → region-create-HRJDZSAK.js} +1 -1
- package/dist/{region-detail-3RF2GD3W.js → region-detail-UDNWHURY.js} +2 -2
- package/dist/{region-list-3QKAMIKS.js → region-list-QQ3XRZBU.js} +2 -2
- package/dist/{reservation-list-X4C45DYL.js → reservation-list-FJEIO3S2.js} +2 -2
- package/dist/{return-reason-list-OKMBV3IZ.js → return-reason-list-3PS25BKE.js} +2 -2
- package/dist/{review-list-M7LNFCKQ.js → review-list-TWXSIZOP.js} +2 -2
- package/dist/{sales-channel-add-products-Q6TSFJKU.js → sales-channel-add-products-KC4RYJT3.js} +1 -1
- package/dist/{sales-channel-detail-IISFMMEN.js → sales-channel-detail-2NIKTQNB.js} +2 -2
- package/dist/{shipping-option-type-list-TR3OGBEP.js → shipping-option-type-list-SC3AKZ3A.js} +2 -2
- package/dist/{shipping-profiles-list-WJI2DCLN.js → shipping-profiles-list-OC45TR2L.js} +2 -2
- package/dist/{store-details-GR4XNG6J.js → store-details-CGAKQDWN.js} +2 -2
- package/dist/{store-edit-JMRDCFIC.js → store-edit-XBWOY5CE.js} +1 -1
- package/dist/{store-list-6UMZQV5N.js → store-list-7FX5VPU2.js} +2 -2
- package/dist/{tax-region-tax-override-create-WPCZ47CE.js → tax-region-tax-override-create-5FUN3FYU.js} +2 -2
- package/dist/{tax-region-tax-override-edit-O5CTVPCG.js → tax-region-tax-override-edit-AGHJ76KK.js} +2 -2
- package/dist/{user-invite-S3SL2HJF.js → user-invite-DMUC4EQ4.js} +1 -1
- package/dist/{user-list-7P2ZSQGM.js → user-list-ZK63T6SJ.js} +2 -2
- package/package.json +6 -6
- package/dist/chunk-W7TEZYU7.js +0 -98
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useOrderGroupTableFilters
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-35TFC2OI.js";
|
|
4
4
|
import {
|
|
5
5
|
useOrderTableQuery
|
|
6
6
|
} from "./chunk-QUHSHIAC.js";
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
import {
|
|
28
28
|
_DataTable,
|
|
29
29
|
useDataTable
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-AJZPQDDW.js";
|
|
31
31
|
import {
|
|
32
32
|
useOrderGroups
|
|
33
33
|
} from "./chunk-37XW63IZ.js";
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
PRODUCT_CREATE_FORM_DEFAULTS,
|
|
9
9
|
ProductCreateSchema,
|
|
10
10
|
decorateVariantsWithDefaultValues,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
11
|
+
normalizeProductFormValues,
|
|
12
|
+
subscribeVariantsToAttributes
|
|
13
|
+
} from "./chunk-JOIE6CIR.js";
|
|
14
14
|
import {
|
|
15
15
|
HandleInput
|
|
16
16
|
} from "./chunk-HJ56YXBU.js";
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
import {
|
|
66
66
|
_DataTable,
|
|
67
67
|
useDataTable
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-AJZPQDDW.js";
|
|
69
69
|
import {
|
|
70
70
|
ActionMenu
|
|
71
71
|
} from "./chunk-3UOYBH5O.js";
|
|
@@ -99,7 +99,7 @@ import { useCan as useCan4 } from "@mercurjs/dashboard-shared";
|
|
|
99
99
|
// src/pages/products/product-create/components/product-create-form/product-create-form.tsx
|
|
100
100
|
import { Button as Button3, toast } from "@medusajs/ui";
|
|
101
101
|
import { useEffect as useEffect3, useMemo as useMemo4, Children } from "react";
|
|
102
|
-
import { useForm
|
|
102
|
+
import { useForm } from "react-hook-form";
|
|
103
103
|
import { useTranslation as useTranslation9 } from "react-i18next";
|
|
104
104
|
import { isForbidden as isForbidden2, useCan as useCan3 } from "@mercurjs/dashboard-shared";
|
|
105
105
|
|
|
@@ -123,7 +123,8 @@ import {
|
|
|
123
123
|
import { useEffect as useEffect2 } from "react";
|
|
124
124
|
import {
|
|
125
125
|
Controller,
|
|
126
|
-
useFieldArray
|
|
126
|
+
useFieldArray,
|
|
127
|
+
useWatch
|
|
127
128
|
} from "react-hook-form";
|
|
128
129
|
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
129
130
|
|
|
@@ -461,137 +462,16 @@ var Root = () => {
|
|
|
461
462
|
{
|
|
462
463
|
className: "flex flex-col gap-y-4",
|
|
463
464
|
"data-testid": "product-create-attributes-list",
|
|
464
|
-
children: fields.map(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
`attributes.${index}.use_for_variants`
|
|
468
|
-
);
|
|
469
|
-
return /* @__PURE__ */ jsxs2(
|
|
470
|
-
"li",
|
|
465
|
+
children: fields.map(
|
|
466
|
+
(field, index) => field.is_custom ? /* @__PURE__ */ jsx2(
|
|
467
|
+
CustomAttributeRow,
|
|
471
468
|
{
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
children: [
|
|
475
|
-
/* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
|
|
476
|
-
/* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
|
|
477
|
-
Label,
|
|
478
|
-
{
|
|
479
|
-
size: "xsmall",
|
|
480
|
-
weight: "plus",
|
|
481
|
-
className: "text-ui-fg-subtle",
|
|
482
|
-
htmlFor: `attributes.${index}.title`,
|
|
483
|
-
children: t("fields.title")
|
|
484
|
-
}
|
|
485
|
-
) }),
|
|
486
|
-
/* @__PURE__ */ jsx2(
|
|
487
|
-
Input,
|
|
488
|
-
{
|
|
489
|
-
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
490
|
-
...form.register(
|
|
491
|
-
`attributes.${index}.title`
|
|
492
|
-
),
|
|
493
|
-
placeholder: t(
|
|
494
|
-
"products.create.attributes.titlePlaceholder"
|
|
495
|
-
),
|
|
496
|
-
"data-testid": `product-create-attribute-title-${index}`
|
|
497
|
-
}
|
|
498
|
-
),
|
|
499
|
-
/* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
|
|
500
|
-
Label,
|
|
501
|
-
{
|
|
502
|
-
size: "xsmall",
|
|
503
|
-
weight: "plus",
|
|
504
|
-
className: "text-ui-fg-subtle",
|
|
505
|
-
htmlFor: `attributes.${index}.values`,
|
|
506
|
-
children: t("fields.values")
|
|
507
|
-
}
|
|
508
|
-
) }),
|
|
509
|
-
/* @__PURE__ */ jsx2(
|
|
510
|
-
Controller,
|
|
511
|
-
{
|
|
512
|
-
control: form.control,
|
|
513
|
-
name: `attributes.${index}.values`,
|
|
514
|
-
render: ({ field: { onChange, value, ...field2 } }) => useForVariants ? /* @__PURE__ */ jsx2(
|
|
515
|
-
ChipInput,
|
|
516
|
-
{
|
|
517
|
-
...field2,
|
|
518
|
-
variant: "contrast",
|
|
519
|
-
value: Array.isArray(value) ? value : [],
|
|
520
|
-
onChange,
|
|
521
|
-
placeholder: t(
|
|
522
|
-
"products.create.attributes.valuePlaceholder"
|
|
523
|
-
),
|
|
524
|
-
"data-testid": `product-create-attribute-values-${index}`
|
|
525
|
-
}
|
|
526
|
-
) : /* @__PURE__ */ jsx2(
|
|
527
|
-
Textarea,
|
|
528
|
-
{
|
|
529
|
-
...field2,
|
|
530
|
-
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
531
|
-
value: Array.isArray(value) ? value[0] ?? "" : value ?? "",
|
|
532
|
-
onChange: (e) => onChange(e.target.value),
|
|
533
|
-
placeholder: t(
|
|
534
|
-
"products.create.attributes.valuePlaceholder"
|
|
535
|
-
),
|
|
536
|
-
"data-testid": `product-create-attribute-values-${index}`
|
|
537
|
-
}
|
|
538
|
-
)
|
|
539
|
-
}
|
|
540
|
-
),
|
|
541
|
-
/* @__PURE__ */ jsx2("div", {}),
|
|
542
|
-
/* @__PURE__ */ jsx2(
|
|
543
|
-
Form.Field,
|
|
544
|
-
{
|
|
545
|
-
control: form.control,
|
|
546
|
-
name: `attributes.${index}.use_for_variants`,
|
|
547
|
-
render: ({
|
|
548
|
-
field: { value, onChange, ref }
|
|
549
|
-
}) => /* @__PURE__ */ jsx2(Form.Item, { children: /* @__PURE__ */ jsxs2(
|
|
550
|
-
"div",
|
|
551
|
-
{
|
|
552
|
-
className: "flex items-start gap-x-3 py-1.5",
|
|
553
|
-
"data-testid": `product-create-attribute-use-for-variants-${index}`,
|
|
554
|
-
children: [
|
|
555
|
-
/* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(
|
|
556
|
-
Switch,
|
|
557
|
-
{
|
|
558
|
-
ref,
|
|
559
|
-
className: "shrink-0 rtl:rotate-180",
|
|
560
|
-
checked: value,
|
|
561
|
-
onCheckedChange: onChange
|
|
562
|
-
}
|
|
563
|
-
) }),
|
|
564
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
|
|
565
|
-
/* @__PURE__ */ jsx2(Label, { size: "xsmall", weight: "plus", children: t(
|
|
566
|
-
"products.create.attributes.useForVariants"
|
|
567
|
-
) }),
|
|
568
|
-
/* @__PURE__ */ jsx2(Hint, { className: "!txt-small", children: t(
|
|
569
|
-
"products.create.attributes.useForVariantsDescription"
|
|
570
|
-
) })
|
|
571
|
-
] })
|
|
572
|
-
]
|
|
573
|
-
}
|
|
574
|
-
) })
|
|
575
|
-
}
|
|
576
|
-
)
|
|
577
|
-
] }),
|
|
578
|
-
/* @__PURE__ */ jsx2(
|
|
579
|
-
IconButton,
|
|
580
|
-
{
|
|
581
|
-
type: "button",
|
|
582
|
-
size: "small",
|
|
583
|
-
variant: "transparent",
|
|
584
|
-
className: "text-ui-fg-muted",
|
|
585
|
-
onClick: () => remove(index),
|
|
586
|
-
"data-testid": `product-create-attribute-remove-${index}`,
|
|
587
|
-
children: /* @__PURE__ */ jsx2(XMarkMini, {})
|
|
588
|
-
}
|
|
589
|
-
)
|
|
590
|
-
]
|
|
469
|
+
index,
|
|
470
|
+
remove
|
|
591
471
|
},
|
|
592
472
|
field.id
|
|
593
|
-
)
|
|
594
|
-
|
|
473
|
+
) : null
|
|
474
|
+
)
|
|
595
475
|
}
|
|
596
476
|
),
|
|
597
477
|
/* @__PURE__ */ jsx2(RequiredAttributes, {})
|
|
@@ -600,6 +480,141 @@ var Root = () => {
|
|
|
600
480
|
}
|
|
601
481
|
);
|
|
602
482
|
};
|
|
483
|
+
var CustomAttributeRow = ({
|
|
484
|
+
index,
|
|
485
|
+
remove
|
|
486
|
+
}) => {
|
|
487
|
+
const { t } = useTranslation2();
|
|
488
|
+
const form = useTabbedForm();
|
|
489
|
+
const useForVariants = useWatch({
|
|
490
|
+
control: form.control,
|
|
491
|
+
name: `attributes.${index}.use_for_variants`
|
|
492
|
+
});
|
|
493
|
+
return /* @__PURE__ */ jsxs2(
|
|
494
|
+
"li",
|
|
495
|
+
{
|
|
496
|
+
className: "bg-ui-bg-component shadow-elevation-card-rest grid grid-cols-[1fr_28px] items-start gap-1.5 rounded-xl p-1.5",
|
|
497
|
+
"data-testid": `product-create-attribute-row-${index}`,
|
|
498
|
+
children: [
|
|
499
|
+
/* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[min-content,1fr] items-center gap-1.5", children: [
|
|
500
|
+
/* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
|
|
501
|
+
Label,
|
|
502
|
+
{
|
|
503
|
+
size: "xsmall",
|
|
504
|
+
weight: "plus",
|
|
505
|
+
className: "text-ui-fg-subtle",
|
|
506
|
+
htmlFor: `attributes.${index}.title`,
|
|
507
|
+
children: t("fields.title")
|
|
508
|
+
}
|
|
509
|
+
) }),
|
|
510
|
+
/* @__PURE__ */ jsx2(
|
|
511
|
+
Input,
|
|
512
|
+
{
|
|
513
|
+
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
514
|
+
...form.register(
|
|
515
|
+
`attributes.${index}.title`
|
|
516
|
+
),
|
|
517
|
+
placeholder: t(
|
|
518
|
+
"products.create.attributes.titlePlaceholder"
|
|
519
|
+
),
|
|
520
|
+
"data-testid": `product-create-attribute-title-${index}`
|
|
521
|
+
}
|
|
522
|
+
),
|
|
523
|
+
/* @__PURE__ */ jsx2("div", { className: "flex items-center px-2 py-1.5", children: /* @__PURE__ */ jsx2(
|
|
524
|
+
Label,
|
|
525
|
+
{
|
|
526
|
+
size: "xsmall",
|
|
527
|
+
weight: "plus",
|
|
528
|
+
className: "text-ui-fg-subtle",
|
|
529
|
+
htmlFor: `attributes.${index}.values`,
|
|
530
|
+
children: t("fields.values")
|
|
531
|
+
}
|
|
532
|
+
) }),
|
|
533
|
+
/* @__PURE__ */ jsx2(
|
|
534
|
+
Controller,
|
|
535
|
+
{
|
|
536
|
+
control: form.control,
|
|
537
|
+
name: `attributes.${index}.values`,
|
|
538
|
+
render: ({ field: { onChange, value, ...field } }) => useForVariants ? /* @__PURE__ */ jsx2(
|
|
539
|
+
ChipInput,
|
|
540
|
+
{
|
|
541
|
+
...field,
|
|
542
|
+
variant: "contrast",
|
|
543
|
+
value: Array.isArray(value) ? value : [],
|
|
544
|
+
onChange,
|
|
545
|
+
placeholder: t(
|
|
546
|
+
"products.create.attributes.valuePlaceholder"
|
|
547
|
+
),
|
|
548
|
+
"data-testid": `product-create-attribute-values-${index}`
|
|
549
|
+
}
|
|
550
|
+
) : /* @__PURE__ */ jsx2(
|
|
551
|
+
Textarea,
|
|
552
|
+
{
|
|
553
|
+
...field,
|
|
554
|
+
className: "bg-ui-bg-field-component hover:bg-ui-bg-field-component-hover",
|
|
555
|
+
value: Array.isArray(value) ? value[0] ?? "" : value ?? "",
|
|
556
|
+
onChange: (e) => onChange(e.target.value),
|
|
557
|
+
placeholder: t(
|
|
558
|
+
"products.create.attributes.valuePlaceholder"
|
|
559
|
+
),
|
|
560
|
+
"data-testid": `product-create-attribute-values-${index}`
|
|
561
|
+
}
|
|
562
|
+
)
|
|
563
|
+
}
|
|
564
|
+
),
|
|
565
|
+
/* @__PURE__ */ jsx2("div", {}),
|
|
566
|
+
/* @__PURE__ */ jsx2(
|
|
567
|
+
Form.Field,
|
|
568
|
+
{
|
|
569
|
+
control: form.control,
|
|
570
|
+
name: `attributes.${index}.use_for_variants`,
|
|
571
|
+
render: ({
|
|
572
|
+
field: { value, onChange, ref }
|
|
573
|
+
}) => /* @__PURE__ */ jsx2(Form.Item, { children: /* @__PURE__ */ jsxs2(
|
|
574
|
+
"div",
|
|
575
|
+
{
|
|
576
|
+
className: "flex items-start gap-x-3 py-1.5",
|
|
577
|
+
"data-testid": `product-create-attribute-use-for-variants-${index}`,
|
|
578
|
+
children: [
|
|
579
|
+
/* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(
|
|
580
|
+
Switch,
|
|
581
|
+
{
|
|
582
|
+
ref,
|
|
583
|
+
className: "shrink-0 rtl:rotate-180",
|
|
584
|
+
checked: value,
|
|
585
|
+
onCheckedChange: onChange
|
|
586
|
+
}
|
|
587
|
+
) }),
|
|
588
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex flex-col", children: [
|
|
589
|
+
/* @__PURE__ */ jsx2(Label, { size: "xsmall", weight: "plus", children: t(
|
|
590
|
+
"products.create.attributes.useForVariants"
|
|
591
|
+
) }),
|
|
592
|
+
/* @__PURE__ */ jsx2(Hint, { className: "!txt-small", children: t(
|
|
593
|
+
"products.create.attributes.useForVariantsDescription"
|
|
594
|
+
) })
|
|
595
|
+
] })
|
|
596
|
+
]
|
|
597
|
+
}
|
|
598
|
+
) })
|
|
599
|
+
}
|
|
600
|
+
)
|
|
601
|
+
] }),
|
|
602
|
+
/* @__PURE__ */ jsx2(
|
|
603
|
+
IconButton,
|
|
604
|
+
{
|
|
605
|
+
type: "button",
|
|
606
|
+
size: "small",
|
|
607
|
+
variant: "transparent",
|
|
608
|
+
className: "text-ui-fg-muted",
|
|
609
|
+
onClick: () => remove(index),
|
|
610
|
+
"data-testid": `product-create-attribute-remove-${index}`,
|
|
611
|
+
children: /* @__PURE__ */ jsx2(XMarkMini, {})
|
|
612
|
+
}
|
|
613
|
+
)
|
|
614
|
+
]
|
|
615
|
+
}
|
|
616
|
+
);
|
|
617
|
+
};
|
|
603
618
|
var SelectedAttributes = ({
|
|
604
619
|
fields,
|
|
605
620
|
remove
|
|
@@ -1350,7 +1365,7 @@ import {
|
|
|
1350
1365
|
Label as Label2,
|
|
1351
1366
|
Text as Text3
|
|
1352
1367
|
} from "@medusajs/ui";
|
|
1353
|
-
import { useFieldArray as useFieldArray3, useWatch } from "react-hook-form";
|
|
1368
|
+
import { useFieldArray as useFieldArray3, useWatch as useWatch2 } from "react-hook-form";
|
|
1354
1369
|
import { useTranslation as useTranslation5 } from "react-i18next";
|
|
1355
1370
|
import { useMemo as useMemo2 } from "react";
|
|
1356
1371
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
@@ -1361,12 +1376,12 @@ var ProductCreateVariantsSection = () => {
|
|
|
1361
1376
|
control: form.control,
|
|
1362
1377
|
name: "variants"
|
|
1363
1378
|
});
|
|
1364
|
-
const watchedAttributes =
|
|
1379
|
+
const watchedAttributes = useWatch2({
|
|
1365
1380
|
control: form.control,
|
|
1366
1381
|
name: "attributes",
|
|
1367
1382
|
defaultValue: []
|
|
1368
1383
|
});
|
|
1369
|
-
const watchedVariants =
|
|
1384
|
+
const watchedVariants = useWatch2({
|
|
1370
1385
|
control: form.control,
|
|
1371
1386
|
name: "variants",
|
|
1372
1387
|
defaultValue: []
|
|
@@ -1571,7 +1586,7 @@ var Header = () => {
|
|
|
1571
1586
|
// src/pages/products/product-create/components/product-create-organize-form/components/product-create-organize-section/product-create-details-organize-section.tsx
|
|
1572
1587
|
import { usePermissionGate } from "@mercurjs/dashboard-shared";
|
|
1573
1588
|
import { Heading as Heading4 } from "@medusajs/ui";
|
|
1574
|
-
import { useWatch as
|
|
1589
|
+
import { useWatch as useWatch3 } from "react-hook-form";
|
|
1575
1590
|
import { useTranslation as useTranslation7 } from "react-i18next";
|
|
1576
1591
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1577
1592
|
var ProductCreateOrganizationSection = () => {
|
|
@@ -1617,7 +1632,7 @@ var ProductCreateOrganizationSection = () => {
|
|
|
1617
1632
|
})),
|
|
1618
1633
|
enabled: sellersGate.allowed
|
|
1619
1634
|
});
|
|
1620
|
-
const isGloballyAvailable =
|
|
1635
|
+
const isGloballyAvailable = useWatch3({
|
|
1621
1636
|
control: form.control,
|
|
1622
1637
|
name: "globally_available"
|
|
1623
1638
|
});
|
|
@@ -1847,7 +1862,7 @@ var ProductCreateOrganizeForm = Root3;
|
|
|
1847
1862
|
// src/pages/products/product-create/components/product-create-variants-form/product-create-variants-form.tsx
|
|
1848
1863
|
import { Input as Input3 } from "@medusajs/ui";
|
|
1849
1864
|
import { useMemo as useMemo3, useState as useState3 } from "react";
|
|
1850
|
-
import { useWatch as
|
|
1865
|
+
import { useWatch as useWatch4 } from "react-hook-form";
|
|
1851
1866
|
import { useTranslation as useTranslation8 } from "react-i18next";
|
|
1852
1867
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1853
1868
|
var Root4 = () => {
|
|
@@ -1855,12 +1870,12 @@ var Root4 = () => {
|
|
|
1855
1870
|
const form = useTabbedForm();
|
|
1856
1871
|
const { setCloseOnEscape } = useRouteModal();
|
|
1857
1872
|
const [search, setSearch] = useState3("");
|
|
1858
|
-
const variants =
|
|
1873
|
+
const variants = useWatch4({
|
|
1859
1874
|
control: form.control,
|
|
1860
1875
|
name: "variants",
|
|
1861
1876
|
defaultValue: []
|
|
1862
1877
|
});
|
|
1863
|
-
const watchedAttributes =
|
|
1878
|
+
const watchedAttributes = useWatch4({
|
|
1864
1879
|
control: form.control,
|
|
1865
1880
|
name: "attributes",
|
|
1866
1881
|
defaultValue: []
|
|
@@ -2021,20 +2036,7 @@ var ProductCreateForm = ({
|
|
|
2021
2036
|
{}
|
|
2022
2037
|
);
|
|
2023
2038
|
}, [regions]);
|
|
2024
|
-
|
|
2025
|
-
control: form.control,
|
|
2026
|
-
name: "attributes"
|
|
2027
|
-
});
|
|
2028
|
-
useEffect3(() => {
|
|
2029
|
-
const currentVariants = form.getValues("variants") ?? [];
|
|
2030
|
-
const newVariants = generateVariantsFromAttributes(
|
|
2031
|
-
watchedAttributes ?? [],
|
|
2032
|
-
currentVariants
|
|
2033
|
-
);
|
|
2034
|
-
if (JSON.stringify(newVariants.map((v) => v.options)) !== JSON.stringify(currentVariants.map((v) => v.options))) {
|
|
2035
|
-
form.setValue("variants", newVariants);
|
|
2036
|
-
}
|
|
2037
|
-
}, [watchedAttributes, form]);
|
|
2039
|
+
useEffect3(() => subscribeVariantsToAttributes(form), [form]);
|
|
2038
2040
|
const handleSubmit = form.handleSubmit(async (values, e) => {
|
|
2039
2041
|
if (isRegionsPending) {
|
|
2040
2042
|
return;
|
|
@@ -2071,27 +2073,26 @@ var ProductCreateForm = ({
|
|
|
2071
2073
|
toast.error(error.message);
|
|
2072
2074
|
}
|
|
2073
2075
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
}
|
|
2076
|
+
try {
|
|
2077
|
+
const data = await mutateAsync(
|
|
2078
|
+
normalizeProductFormValues({
|
|
2079
|
+
...payload,
|
|
2080
|
+
media: uploadedMedia,
|
|
2081
|
+
status: isDraftSubmission ? "draft" : "published",
|
|
2082
|
+
regionsCurrencyMap
|
|
2083
|
+
})
|
|
2084
|
+
);
|
|
2085
|
+
toast.success(
|
|
2086
|
+
t("products.create.successToast", {
|
|
2087
|
+
title: data.product.title
|
|
2088
|
+
})
|
|
2089
|
+
);
|
|
2090
|
+
handleSuccess(`../${data.product.id}`);
|
|
2091
|
+
} catch (error) {
|
|
2092
|
+
if (error instanceof Error) {
|
|
2093
|
+
toast.error(error.message);
|
|
2093
2094
|
}
|
|
2094
|
-
|
|
2095
|
+
}
|
|
2095
2096
|
});
|
|
2096
2097
|
const defaultTabs = useMemo4(
|
|
2097
2098
|
() => [
|