diff --git a/CHANGELOG.md b/CHANGELOG.md index e5117f796..709853045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,3 +30,4 @@ All notable, unreleased changes to this project will be documented in this file. - Fix product type selection - #189 by @dominik-zeglen - Fix staff return link - #190 by @dominik-zeglen - Allow sorting products by attribute - #180 by @dominik-zeglen +- Hide variants and attributes if product has none - #179 by @dominik-zeglen diff --git a/src/products/components/ProductCreatePage/ProductCreatePage.tsx b/src/products/components/ProductCreatePage/ProductCreatePage.tsx index 97cbb189a..3874ae966 100644 --- a/src/products/components/ProductCreatePage/ProductCreatePage.tsx +++ b/src/products/components/ProductCreatePage/ProductCreatePage.tsx @@ -78,7 +78,6 @@ interface ProductCreatePageProps { fetchCategories: (data: string) => void; fetchCollections: (data: string) => void; fetchProductTypes: (data: string) => void; - onAttributesEdit: () => void; onBack?(); onSubmit?(data: ProductCreatePageSubmitData); } @@ -220,12 +219,14 @@ export const ProductCreatePage: React.StatelessComponent< onChange={change} /> - + {attributes.length > 0 && ( + + )} void; onVariantShow: (id: string) => () => void; onImageDelete: (id: string) => () => void; - onAttributesEdit: () => void; onBack?(); onDelete(); onImageEdit?(id: string); @@ -92,7 +91,6 @@ export const ProductUpdatePage: React.FC = ({ product, saveButtonBarState, variants, - onAttributesEdit, onBack, onDelete, onImageDelete, @@ -215,12 +213,14 @@ export const ProductUpdatePage: React.FC = ({ onImageUpload={onImageUpload} /> - + {attributes.length > 0 && ( + + )} = ({ disabled={disabled} variants={variants} fallbackPrice={product ? product.basePrice : undefined} - onAttributesEdit={onAttributesEdit} onRowClick={onVariantShow} onVariantAdd={onVariantAdd} toolbar={toolbar} diff --git a/src/products/components/ProductVariants/ProductVariants.tsx b/src/products/components/ProductVariants/ProductVariants.tsx index 803b46e7f..bf6332396 100644 --- a/src/products/components/ProductVariants/ProductVariants.tsx +++ b/src/products/components/ProductVariants/ProductVariants.tsx @@ -67,7 +67,6 @@ interface ProductVariantsProps extends ListActions, WithStyles { disabled: boolean; variants: ProductDetails_product_variants[]; fallbackPrice?: ProductVariant_costPrice; - onAttributesEdit: () => void; onRowClick: (id: string) => () => void; onVariantAdd?(); } @@ -80,7 +79,6 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })( disabled, variants, fallbackPrice, - onAttributesEdit, onRowClick, onVariantAdd, isChecked, @@ -90,6 +88,8 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })( toolbar }: ProductVariantsProps) => { const intl = useIntl(); + const hasVariants = maybe(() => variants.length > 0, true); + return ( - - - -
@@ -83483,71 +83418,6 @@ Ctrl + K"
-
-
- - Attributes - -
-
-
-
-
-
-
- - 0 Attributes - -
- -
-
-
@@ -84577,71 +84447,6 @@ Ctrl + K"
-
-
- - Attributes - -
-
-
-
-
-
-
- - 0 Attributes - -
- -
-
-
@@ -87189,6 +86994,3253 @@ exports[`Storyshots Views / Products / Create product variant with errors 1`] =
`; +exports[`Storyshots Views / Products / Product edit no product attributes 1`] = ` +
+
+
+
+
+ Ergonomic Plastic Bacon +
+
+
+
+
+
+
+
+
+ + General Informations + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ + Description + +
+ +
+
+
+
+
+
+ + + bold + + +
+
+
+
+ + + italic + + +
+
+
+
+ + + strikethrough + + +
+
+

+
+ + + h1 + + +
+

+

+
+ + + h2 + + +
+

+

+
+ + + h3 + + +
+

+
+
+ + + blockquote + + +
+
+
    +
  • +
    + + + ul + + +
    +
  • +
+
    +
  1. +
    + + + ol + + +
    +
  2. +
+
+
+ + + link + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Images + +
+ + +
+
+
+
+
+
+
+ + +

+ Drop here to upload +

+
+
+
+
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+
+
+
+
+ + Pricing + +
+
+
+ +
+
+
+
+
+ +
+ + +
+

+ NZD +

+
+
+
+
+
+
+
+
+
+ + Variants + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + Name + + Status + + SKU +
+
+
+
+
+ + Search Engine Preview + +
+ +
+
+
+
+
+

+ Add search engine title and description to make this product easier to find +

+
+
+
+
+
+
+ + Organize Product + +
+
+
+
+
+ + Product Type + +

+ Versatile +

+
+ + Product Type + +

+ Configurable +

+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + +

+ *Optional. Adding product to collection helps users find it. +

+
+
+
+
+
+

+ Winter sale +

+ +
+
+
+
+
+
+
+
+ + Visibility + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ +
+`; + +exports[`Storyshots Views / Products / Product edit no variants 1`] = ` +
+
+
+
+
+ Ergonomic Plastic Bacon +
+
+
+
+
+
+
+
+
+ + General Informations + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ + Description + +
+ +
+
+
+
+
+
+ + + bold + + +
+
+
+
+ + + italic + + +
+
+
+
+ + + strikethrough + + +
+
+

+
+ + + h1 + + +
+

+

+
+ + + h2 + + +
+

+

+
+ + + h3 + + +
+

+
+
+ + + blockquote + + +
+
+
    +
  • +
    + + + ul + + +
    +
  • +
+
    +
  1. +
    + + + ol + + +
    +
  2. +
+
+
+ + + link + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Images + +
+ + +
+
+
+
+
+
+
+ + +

+ Drop here to upload +

+
+
+
+
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+ Id sit dolores adipisci +
+
+
+
+
+
+
+
+ + Attributes + +
+
+
+
+
+
+
+ + 2 Attributes + +
+ +
+
+
+
+

+ Borders +

+
+
+
+
+ + +
+
+
+
+
+
+
+

+ Legacy +

+
+
+
+
+ + +
+
+
+
+
+

+ Auto Loan Account +

+ +
+
+
+
+
+
+
+
+
+
+ + Pricing + +
+
+
+ +
+
+
+
+
+ +
+ + +
+

+ NZD +

+
+
+
+
+
+
+
+
+
+ + Variants + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + Name + + Status + + SKU +
+
+
+
+
+ + Search Engine Preview + +
+ +
+
+
+
+
+

+ Add search engine title and description to make this product easier to find +

+
+
+
+
+
+
+ + Organize Product + +
+
+
+
+
+ + Product Type + +

+ Versatile +

+
+ + Product Type + +

+ Configurable +

+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + +

+ *Optional. Adding product to collection helps users find it. +

+
+
+
+
+
+

+ Winter sale +

+ +
+
+
+
+
+
+
+
+ + Visibility + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ +
+`; + exports[`Storyshots Views / Products / Product edit when data is fully loaded 1`] = `
- -
-
-
@@ -91174,18 +94149,6 @@ Ctrl + K"
-