Hide variants and attributes if none
This commit is contained in:
parent
7b0b99fbcd
commit
d19a07f319
8 changed files with 3305 additions and 371 deletions
|
@ -78,7 +78,6 @@ interface ProductCreatePageProps {
|
||||||
fetchCategories: (data: string) => void;
|
fetchCategories: (data: string) => void;
|
||||||
fetchCollections: (data: string) => void;
|
fetchCollections: (data: string) => void;
|
||||||
fetchProductTypes: (data: string) => void;
|
fetchProductTypes: (data: string) => void;
|
||||||
onAttributesEdit: () => void;
|
|
||||||
onBack?();
|
onBack?();
|
||||||
onSubmit?(data: ProductCreatePageSubmitData);
|
onSubmit?(data: ProductCreatePageSubmitData);
|
||||||
}
|
}
|
||||||
|
@ -220,12 +219,14 @@ export const ProductCreatePage: React.StatelessComponent<
|
||||||
onChange={change}
|
onChange={change}
|
||||||
/>
|
/>
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
|
{attributes.length > 0 && (
|
||||||
<ProductAttributes
|
<ProductAttributes
|
||||||
attributes={attributes}
|
attributes={attributes}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onChange={handleAttributeChange}
|
onChange={handleAttributeChange}
|
||||||
onMultiChange={handleAttributeMultiChange}
|
onMultiChange={handleAttributeMultiChange}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
<ProductPricing
|
<ProductPricing
|
||||||
currency={currency}
|
currency={currency}
|
||||||
|
|
|
@ -62,7 +62,6 @@ export interface ProductUpdatePageProps extends ListActions {
|
||||||
fetchCollections: (query: string) => void;
|
fetchCollections: (query: string) => void;
|
||||||
onVariantShow: (id: string) => () => void;
|
onVariantShow: (id: string) => () => void;
|
||||||
onImageDelete: (id: string) => () => void;
|
onImageDelete: (id: string) => () => void;
|
||||||
onAttributesEdit: () => void;
|
|
||||||
onBack?();
|
onBack?();
|
||||||
onDelete();
|
onDelete();
|
||||||
onImageEdit?(id: string);
|
onImageEdit?(id: string);
|
||||||
|
@ -92,7 +91,6 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
|
||||||
product,
|
product,
|
||||||
saveButtonBarState,
|
saveButtonBarState,
|
||||||
variants,
|
variants,
|
||||||
onAttributesEdit,
|
|
||||||
onBack,
|
onBack,
|
||||||
onDelete,
|
onDelete,
|
||||||
onImageDelete,
|
onImageDelete,
|
||||||
|
@ -215,12 +213,14 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
|
||||||
onImageUpload={onImageUpload}
|
onImageUpload={onImageUpload}
|
||||||
/>
|
/>
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
|
{attributes.length > 0 && (
|
||||||
<ProductAttributes
|
<ProductAttributes
|
||||||
attributes={attributes}
|
attributes={attributes}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onChange={handleAttributeChange}
|
onChange={handleAttributeChange}
|
||||||
onMultiChange={handleAttributeMultiChange}
|
onMultiChange={handleAttributeMultiChange}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
<ProductPricing
|
<ProductPricing
|
||||||
currency={currency}
|
currency={currency}
|
||||||
|
@ -234,7 +234,6 @@ export const ProductUpdatePage: React.FC<ProductUpdatePageProps> = ({
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
variants={variants}
|
variants={variants}
|
||||||
fallbackPrice={product ? product.basePrice : undefined}
|
fallbackPrice={product ? product.basePrice : undefined}
|
||||||
onAttributesEdit={onAttributesEdit}
|
|
||||||
onRowClick={onVariantShow}
|
onRowClick={onVariantShow}
|
||||||
onVariantAdd={onVariantAdd}
|
onVariantAdd={onVariantAdd}
|
||||||
toolbar={toolbar}
|
toolbar={toolbar}
|
||||||
|
|
|
@ -67,7 +67,6 @@ interface ProductVariantsProps extends ListActions, WithStyles<typeof styles> {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
variants: ProductDetails_product_variants[];
|
variants: ProductDetails_product_variants[];
|
||||||
fallbackPrice?: ProductVariant_costPrice;
|
fallbackPrice?: ProductVariant_costPrice;
|
||||||
onAttributesEdit: () => void;
|
|
||||||
onRowClick: (id: string) => () => void;
|
onRowClick: (id: string) => () => void;
|
||||||
onVariantAdd?();
|
onVariantAdd?();
|
||||||
}
|
}
|
||||||
|
@ -80,7 +79,6 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })(
|
||||||
disabled,
|
disabled,
|
||||||
variants,
|
variants,
|
||||||
fallbackPrice,
|
fallbackPrice,
|
||||||
onAttributesEdit,
|
|
||||||
onRowClick,
|
onRowClick,
|
||||||
onVariantAdd,
|
onVariantAdd,
|
||||||
isChecked,
|
isChecked,
|
||||||
|
@ -90,6 +88,8 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })(
|
||||||
toolbar
|
toolbar
|
||||||
}: ProductVariantsProps) => {
|
}: ProductVariantsProps) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const hasVariants = maybe(() => variants.length > 0, true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardTitle
|
<CardTitle
|
||||||
|
@ -99,17 +99,6 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })(
|
||||||
})}
|
})}
|
||||||
toolbar={
|
toolbar={
|
||||||
<>
|
<>
|
||||||
<Button
|
|
||||||
onClick={onAttributesEdit}
|
|
||||||
variant="text"
|
|
||||||
color="primary"
|
|
||||||
data-tc="button-edit-attributes"
|
|
||||||
>
|
|
||||||
<FormattedMessage
|
|
||||||
defaultMessage="Edit attributes"
|
|
||||||
description="product variant attributes, button"
|
|
||||||
/>
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
onClick={onVariantAdd}
|
onClick={onVariantAdd}
|
||||||
variant="text"
|
variant="text"
|
||||||
|
@ -126,11 +115,12 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })(
|
||||||
/>
|
/>
|
||||||
{!variants.length && (
|
{!variants.length && (
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Typography>
|
<Typography color={hasVariants ? "default" : "textSecondary"}>
|
||||||
<FormattedMessage defaultMessage="Use variants for products that come in a variety of versions for example different sizes or colors" />
|
<FormattedMessage defaultMessage="Use variants for products that come in a variety of versions for example different sizes or colors" />
|
||||||
</Typography>
|
</Typography>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
)}
|
)}
|
||||||
|
{hasVariants && (
|
||||||
<Table className={classes.denseTable}>
|
<Table className={classes.denseTable}>
|
||||||
<TableHead
|
<TableHead
|
||||||
colSpan={numberOfColumns}
|
colSpan={numberOfColumns}
|
||||||
|
@ -165,9 +155,7 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })(
|
||||||
</Hidden>
|
</Hidden>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{renderCollection(
|
{renderCollection(variants, variant => {
|
||||||
variants,
|
|
||||||
variant => {
|
|
||||||
const isSelected = variant ? isChecked(variant.id) : false;
|
const isSelected = variant ? isChecked(variant.id) : false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -237,17 +225,10 @@ export const ProductVariants = withStyles(styles, { name: "ProductVariants" })(
|
||||||
</Hidden>
|
</Hidden>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
},
|
})}
|
||||||
() => (
|
|
||||||
<TableRow>
|
|
||||||
<TableCell colSpan={numberOfColumns}>
|
|
||||||
<FormattedMessage defaultMessage="This product has no variants" />
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ export const ProductUpdate: React.StatelessComponent<
|
||||||
const shop = useShop();
|
const shop = useShop();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const handleAttributesEdit = undefined;
|
|
||||||
const handleBack = () => navigate(productListUrl());
|
const handleBack = () => navigate(productListUrl());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -146,7 +145,6 @@ export const ProductUpdate: React.StatelessComponent<
|
||||||
edge => edge.node
|
edge => edge.node
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
onAttributesEdit={handleAttributesEdit}
|
|
||||||
onBack={handleBack}
|
onBack={handleBack}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
saveButtonBarState={formTransitionState}
|
saveButtonBarState={formTransitionState}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import { DEFAULT_INITIAL_SEARCH_DATA } from "../../../config";
|
||||||
import SearchCategories from "../../../containers/SearchCategories";
|
import SearchCategories from "../../../containers/SearchCategories";
|
||||||
import SearchCollections from "../../../containers/SearchCollections";
|
import SearchCollections from "../../../containers/SearchCollections";
|
||||||
import { getMutationState, maybe } from "../../../misc";
|
import { getMutationState, maybe } from "../../../misc";
|
||||||
import { productTypeUrl } from "../../../productTypes/urls";
|
|
||||||
import ProductUpdatePage from "../../components/ProductUpdatePage";
|
import ProductUpdatePage from "../../components/ProductUpdatePage";
|
||||||
import ProductUpdateOperations from "../../containers/ProductUpdateOperations";
|
import ProductUpdateOperations from "../../containers/ProductUpdateOperations";
|
||||||
import { TypedProductDetailsQuery } from "../../queries";
|
import { TypedProductDetailsQuery } from "../../queries";
|
||||||
|
@ -234,11 +233,6 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
|
||||||
placeholderImage={placeholderImg}
|
placeholderImage={placeholderImg}
|
||||||
product={product}
|
product={product}
|
||||||
variants={maybe(() => product.variants)}
|
variants={maybe(() => product.variants)}
|
||||||
onAttributesEdit={() =>
|
|
||||||
navigate(
|
|
||||||
productTypeUrl(data.product.productType.id)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
onBack={() => {
|
onBack={() => {
|
||||||
navigate(productListUrl());
|
navigate(productListUrl());
|
||||||
}}
|
}}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -27,7 +27,6 @@ storiesOf("Views / Products / Create product", module)
|
||||||
fetchProductTypes={() => undefined}
|
fetchProductTypes={() => undefined}
|
||||||
productTypes={productTypes}
|
productTypes={productTypes}
|
||||||
categories={[product.category]}
|
categories={[product.category]}
|
||||||
onAttributesEdit={undefined}
|
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
@ -45,7 +44,6 @@ storiesOf("Views / Products / Create product", module)
|
||||||
fetchProductTypes={() => undefined}
|
fetchProductTypes={() => undefined}
|
||||||
productTypes={productTypes}
|
productTypes={productTypes}
|
||||||
categories={[product.category]}
|
categories={[product.category]}
|
||||||
onAttributesEdit={undefined}
|
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
@ -65,7 +63,6 @@ storiesOf("Views / Products / Create product", module)
|
||||||
fetchProductTypes={() => undefined}
|
fetchProductTypes={() => undefined}
|
||||||
productTypes={productTypes}
|
productTypes={productTypes}
|
||||||
categories={[product.category]}
|
categories={[product.category]}
|
||||||
onAttributesEdit={undefined}
|
|
||||||
onBack={() => undefined}
|
onBack={() => undefined}
|
||||||
onSubmit={() => undefined}
|
onSubmit={() => undefined}
|
||||||
saveButtonBarState="default"
|
saveButtonBarState="default"
|
||||||
|
|
|
@ -22,7 +22,6 @@ const props: ProductUpdatePageProps = {
|
||||||
fetchCollections: () => undefined,
|
fetchCollections: () => undefined,
|
||||||
header: product.name,
|
header: product.name,
|
||||||
images: product.images,
|
images: product.images,
|
||||||
onAttributesEdit: () => undefined,
|
|
||||||
onBack: () => undefined,
|
onBack: () => undefined,
|
||||||
onDelete: () => undefined,
|
onDelete: () => undefined,
|
||||||
onImageDelete: () => undefined,
|
onImageDelete: () => undefined,
|
||||||
|
@ -63,4 +62,22 @@ storiesOf("Views / Products / Product edit", module)
|
||||||
collections={undefined}
|
collections={undefined}
|
||||||
images={undefined}
|
images={undefined}
|
||||||
/>
|
/>
|
||||||
|
))
|
||||||
|
.add("no variants", () => (
|
||||||
|
<ProductUpdatePage
|
||||||
|
{...props}
|
||||||
|
product={{
|
||||||
|
...props.product,
|
||||||
|
variants: []
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
.add("no product attributes", () => (
|
||||||
|
<ProductUpdatePage
|
||||||
|
{...props}
|
||||||
|
product={{
|
||||||
|
...props.product,
|
||||||
|
attributes: []
|
||||||
|
}}
|
||||||
|
/>
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in a new issue