@open-mercato/core 0.4.9-develop-b2b88cde69 → 0.4.9-develop-0ee01461f9

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.
@@ -52,8 +52,12 @@ import {
52
52
  sanitizeProductDimensions,
53
53
  sanitizeProductWeight,
54
54
  updateDimensionValue,
55
- updateWeightValue
55
+ updateWeightValue,
56
+ isConfigurableProductType
56
57
  } from "@open-mercato/core/modules/catalog/components/products/productForm";
58
+ import {
59
+ CATALOG_PRODUCT_TYPES
60
+ } from "@open-mercato/core/modules/catalog/data/types";
57
61
  import { MetadataEditor } from "@open-mercato/core/modules/catalog/components/products/MetadataEditor";
58
62
  import {
59
63
  buildAttachmentImageUrl,
@@ -361,6 +365,8 @@ function EditCatalogProductPage({
361
365
  title: typeof record.title === "string" ? record.title : "",
362
366
  subtitle: typeof record.subtitle === "string" ? record.subtitle : "",
363
367
  handle: typeof record.handle === "string" ? record.handle : "",
368
+ sku: typeof record.sku === "string" ? record.sku : "",
369
+ productType: typeof record.product_type === "string" ? record.product_type : typeof record.productType === "string" ? record.productType : "simple",
364
370
  description: typeof record.description === "string" ? record.description : "",
365
371
  useMarkdown: Boolean(metadata.__useMarkdown),
366
372
  taxRateId,
@@ -628,6 +634,7 @@ function EditCatalogProductPage({
628
634
  mediaItems: Array.isArray(parsed.data.mediaItems) ? parsed.data.mediaItems : [],
629
635
  defaultMediaId: parsed.data.defaultMediaId ?? null,
630
636
  defaultMediaUrl: parsed.data.defaultMediaUrl ?? "",
637
+ productType: parsed.data.productType ?? "simple",
631
638
  hasVariants: parsed.data.hasVariants ?? false,
632
639
  options: Array.isArray(parsed.data.options) ? parsed.data.options : [],
633
640
  variants: Array.isArray(parsed.data.variants) ? parsed.data.variants : [],
@@ -762,9 +769,13 @@ function EditCatalogProductPage({
762
769
  subtitle: values.subtitle?.trim() || void 0,
763
770
  description,
764
771
  handle,
772
+ sku: values.sku?.trim() || null,
773
+ productType: values.productType || "simple",
765
774
  taxRateId: values.taxRateId ?? null,
766
775
  taxRate: productTaxRateValue ?? null,
767
- isConfigurable: Boolean(values.hasVariants),
776
+ isConfigurable: isConfigurableProductType(
777
+ values.productType || "simple"
778
+ ),
768
779
  metadata,
769
780
  dimensions,
770
781
  weightValue: weight?.value ?? null,
@@ -1867,6 +1878,65 @@ function ProductMetaSection({
1867
1878
  ) }),
1868
1879
  errors.handle ? /* @__PURE__ */ jsx("p", { className: "text-xs text-red-600", children: errors.handle }) : null
1869
1880
  ] }),
1881
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1882
+ /* @__PURE__ */ jsx(Label, { children: t("catalog.products.form.sku", "SKU") }),
1883
+ /* @__PURE__ */ jsx(
1884
+ Input,
1885
+ {
1886
+ value: values.sku,
1887
+ onChange: (event) => setValue("sku", event.target.value),
1888
+ placeholder: t(
1889
+ "catalog.products.create.placeholders.sku",
1890
+ "e.g., PROD-001"
1891
+ ),
1892
+ className: "font-mono"
1893
+ }
1894
+ ),
1895
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t(
1896
+ "catalog.products.create.skuHelp",
1897
+ "Unique product identifier. Letters, numbers, hyphens, underscores, periods."
1898
+ ) }),
1899
+ errors.sku ? /* @__PURE__ */ jsx("p", { className: "text-xs text-red-600", children: errors.sku }) : null
1900
+ ] }),
1901
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1902
+ /* @__PURE__ */ jsx(Label, { children: t("catalog.products.form.productType", "Product type") }),
1903
+ /* @__PURE__ */ jsx(
1904
+ "select",
1905
+ {
1906
+ 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",
1907
+ value: values.productType || "simple",
1908
+ onChange: (event) => {
1909
+ const nextType = event.target.value;
1910
+ setValue("productType", nextType);
1911
+ const nextIsConfigurable = isConfigurableProductType(nextType);
1912
+ if (nextIsConfigurable && !values.hasVariants) {
1913
+ setValue("hasVariants", true);
1914
+ } else if (!nextIsConfigurable && values.hasVariants) {
1915
+ setValue("hasVariants", false);
1916
+ }
1917
+ },
1918
+ children: CATALOG_PRODUCT_TYPES.map((type) => {
1919
+ const isDisabled = type === "bundle" || type === "grouped";
1920
+ return /* @__PURE__ */ jsxs(
1921
+ "option",
1922
+ {
1923
+ value: type,
1924
+ disabled: isDisabled,
1925
+ children: [
1926
+ t(
1927
+ `catalog.products.types.${type}`,
1928
+ type
1929
+ ),
1930
+ isDisabled ? ` (${t("common.comingSoon", "Coming soon")})` : ""
1931
+ ]
1932
+ },
1933
+ type
1934
+ );
1935
+ })
1936
+ }
1937
+ ),
1938
+ errors.productType ? /* @__PURE__ */ jsx("p", { className: "text-xs text-red-600", children: errors.productType }) : null
1939
+ ] }),
1870
1940
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1871
1941
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1872
1942
  /* @__PURE__ */ jsx(Label, { children: t("catalog.products.create.taxRates.label", "Tax class") }),