@open-mercato/core 0.4.9-develop-b2b88cde69 → 0.4.9-develop-d1d38e26fb
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/modules/catalog/backend/catalog/products/[id]/page.js +72 -2
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/create/page.js +82 -3
- package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
- package/dist/modules/catalog/components/products/productForm.js +12 -0
- package/dist/modules/catalog/components/products/productForm.js.map +2 -2
- package/dist/modules/catalog/data/validators.js +1 -1
- package/dist/modules/catalog/data/validators.js.map +2 -2
- package/dist/modules/currencies/lib/exchangeRateFormConfig.js +0 -1
- package/dist/modules/currencies/lib/exchangeRateFormConfig.js.map +2 -2
- package/package.json +3 -3
- package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +91 -2
- package/src/modules/catalog/backend/catalog/products/create/page.tsx +99 -4
- package/src/modules/catalog/components/products/productForm.ts +22 -1
- package/src/modules/catalog/data/validators.ts +1 -1
- package/src/modules/catalog/i18n/de.json +3 -0
- package/src/modules/catalog/i18n/en.json +3 -0
- package/src/modules/catalog/i18n/es.json +3 -0
- package/src/modules/catalog/i18n/pl.json +3 -0
- package/src/modules/currencies/lib/exchangeRateFormConfig.ts +0 -1
|
@@ -53,8 +53,10 @@ import {
|
|
|
53
53
|
sanitizeProductDimensions,
|
|
54
54
|
sanitizeProductWeight,
|
|
55
55
|
updateDimensionValue,
|
|
56
|
-
updateWeightValue
|
|
56
|
+
updateWeightValue,
|
|
57
|
+
isConfigurableProductType
|
|
57
58
|
} from "@open-mercato/core/modules/catalog/components/products/productForm";
|
|
59
|
+
import { CATALOG_PRODUCT_TYPES } from "@open-mercato/core/modules/catalog/data/types";
|
|
58
60
|
import {
|
|
59
61
|
buildAttachmentImageUrl,
|
|
60
62
|
slugifyAttachmentFileName
|
|
@@ -78,6 +80,8 @@ const matchPrefix = (prefix) => (value) => value.startsWith(prefix);
|
|
|
78
80
|
const STEP_FIELD_MATCHERS = {
|
|
79
81
|
general: [
|
|
80
82
|
matchField("title"),
|
|
83
|
+
matchField("sku"),
|
|
84
|
+
matchField("productType"),
|
|
81
85
|
matchField("description"),
|
|
82
86
|
matchField("mediaItems"),
|
|
83
87
|
matchField("mediaDraftId"),
|
|
@@ -403,9 +407,13 @@ function CreateCatalogProductPage() {
|
|
|
403
407
|
subtitle: formValues.subtitle?.trim() || void 0,
|
|
404
408
|
description,
|
|
405
409
|
handle,
|
|
410
|
+
sku: formValues.sku?.trim() || void 0,
|
|
411
|
+
productType: formValues.productType || "simple",
|
|
406
412
|
taxRateId: formValues.taxRateId ?? null,
|
|
407
413
|
taxRate: productTaxRate ?? null,
|
|
408
|
-
isConfigurable:
|
|
414
|
+
isConfigurable: isConfigurableProductType(
|
|
415
|
+
formValues.productType || "simple"
|
|
416
|
+
),
|
|
409
417
|
defaultMediaId: defaultMediaId ?? void 0,
|
|
410
418
|
defaultMediaUrl: defaultMediaUrl ?? void 0,
|
|
411
419
|
dimensions,
|
|
@@ -1192,7 +1200,19 @@ function ProductBuilder({
|
|
|
1192
1200
|
type: "checkbox",
|
|
1193
1201
|
className: "h-4 w-4 rounded border",
|
|
1194
1202
|
checked: values.hasVariants,
|
|
1195
|
-
onChange: (event) =>
|
|
1203
|
+
onChange: (event) => {
|
|
1204
|
+
const checked = event.target.checked;
|
|
1205
|
+
setValue("hasVariants", checked);
|
|
1206
|
+
if (checked && !isConfigurableProductType(
|
|
1207
|
+
values.productType || "simple"
|
|
1208
|
+
)) {
|
|
1209
|
+
setValue("productType", "configurable");
|
|
1210
|
+
} else if (!checked && isConfigurableProductType(
|
|
1211
|
+
values.productType || "simple"
|
|
1212
|
+
)) {
|
|
1213
|
+
setValue("productType", "simple");
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1196
1216
|
}
|
|
1197
1217
|
),
|
|
1198
1218
|
t(
|
|
@@ -1595,6 +1615,65 @@ function ProductMetaSection({
|
|
|
1595
1615
|
) }),
|
|
1596
1616
|
errors.handle ? /* @__PURE__ */ jsx("p", { className: "text-xs text-red-600", children: errors.handle }) : null
|
|
1597
1617
|
] }),
|
|
1618
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
1619
|
+
/* @__PURE__ */ jsx(Label, { children: t("catalog.products.form.sku", "SKU") }),
|
|
1620
|
+
/* @__PURE__ */ jsx(
|
|
1621
|
+
Input,
|
|
1622
|
+
{
|
|
1623
|
+
value: values.sku,
|
|
1624
|
+
onChange: (event) => setValue("sku", event.target.value),
|
|
1625
|
+
placeholder: t(
|
|
1626
|
+
"catalog.products.create.placeholders.sku",
|
|
1627
|
+
"e.g., PROD-001"
|
|
1628
|
+
),
|
|
1629
|
+
className: "font-mono"
|
|
1630
|
+
}
|
|
1631
|
+
),
|
|
1632
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t(
|
|
1633
|
+
"catalog.products.create.skuHelp",
|
|
1634
|
+
"Unique product identifier. Letters, numbers, hyphens, underscores, periods."
|
|
1635
|
+
) }),
|
|
1636
|
+
errors.sku ? /* @__PURE__ */ jsx("p", { className: "text-xs text-red-600", children: errors.sku }) : null
|
|
1637
|
+
] }),
|
|
1638
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
1639
|
+
/* @__PURE__ */ jsx(Label, { children: t("catalog.products.form.productType", "Product type") }),
|
|
1640
|
+
/* @__PURE__ */ jsx(
|
|
1641
|
+
"select",
|
|
1642
|
+
{
|
|
1643
|
+
className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
1644
|
+
value: values.productType || "simple",
|
|
1645
|
+
onChange: (event) => {
|
|
1646
|
+
const nextType = event.target.value;
|
|
1647
|
+
setValue("productType", nextType);
|
|
1648
|
+
const nextIsConfigurable = isConfigurableProductType(nextType);
|
|
1649
|
+
if (nextIsConfigurable && !values.hasVariants) {
|
|
1650
|
+
setValue("hasVariants", true);
|
|
1651
|
+
} else if (!nextIsConfigurable && values.hasVariants) {
|
|
1652
|
+
setValue("hasVariants", false);
|
|
1653
|
+
}
|
|
1654
|
+
},
|
|
1655
|
+
children: CATALOG_PRODUCT_TYPES.map((type) => {
|
|
1656
|
+
const isDisabled = type === "bundle" || type === "grouped";
|
|
1657
|
+
return /* @__PURE__ */ jsxs(
|
|
1658
|
+
"option",
|
|
1659
|
+
{
|
|
1660
|
+
value: type,
|
|
1661
|
+
disabled: isDisabled,
|
|
1662
|
+
children: [
|
|
1663
|
+
t(
|
|
1664
|
+
`catalog.products.types.${type}`,
|
|
1665
|
+
type
|
|
1666
|
+
),
|
|
1667
|
+
isDisabled ? ` (${t("common.comingSoon", "Coming soon")})` : ""
|
|
1668
|
+
]
|
|
1669
|
+
},
|
|
1670
|
+
type
|
|
1671
|
+
);
|
|
1672
|
+
})
|
|
1673
|
+
}
|
|
1674
|
+
),
|
|
1675
|
+
errors.productType ? /* @__PURE__ */ jsx("p", { className: "text-xs text-red-600", children: errors.productType }) : null
|
|
1676
|
+
] }),
|
|
1598
1677
|
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
1599
1678
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1600
1679
|
/* @__PURE__ */ jsx(Label, { children: t("catalog.products.create.taxRates.label", "Tax class") }),
|