Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Replace collection, page, products visibility component

Krzysztof Bialoglowicze3cd68eb8c92
diff --git a/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx b/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx
index df29e0396c..03ef19e74a 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx
@@ -8,12 +8,12 @@ import { CardSpacer } from "../../../components/CardSpacer";
import CardTitle from "../../../components/CardTitle";
import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton/ConfirmButton";
import { Container } from "../../../components/Container";
-import { ControlledSwitch } from "../../../components/ControlledSwitch";
import Form from "../../../components/Form";
import Grid from "../../../components/Grid";
import PageHeader from "../../../components/PageHeader";
import SaveButtonBar from "../../../components/SaveButtonBar";
import SeoForm from "../../../components/SeoForm";
+import VisibilityCard from "../../../components/VisibilityCard";
import i18n from "../../../i18n";
import { UserError } from "../../../types";
import CollectionDetails from "../CollectionDetails/CollectionDetails";
@@ -27,6 +27,7 @@ export interface CollectionCreatePageFormData {
backgroundImageAlt: string;
description: RawDraftContentState;
name: string;
+ publicationDate: string;
isPublished: boolean;
seoDescription: string;
seoTitle: string;
@@ -49,6 +50,7 @@ const initialForm: CollectionCreatePageFormData = {
description: null,
isPublished: false,
name: "",
+ publicationDate: "",
seoDescription: "",
seoTitle: ""
};
@@ -140,14 +142,11 @@ const CollectionCreatePage: React.StatelessComponent<
})}
/>
<CardContent>
- <ControlledSwitch
- checked={data.isPublished}
- disabled={disabled}
- name="isPublished"
+ <VisibilityCard
+ data={data}
+ errors={formErrors}
+ loading={disabled}
onChange={change}
- label={i18n.t("Publish on storefront", {
- context: "button"
- })}
/>
</CardContent>
</Card>
diff --git a/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx b/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx
index 9ecb20cb22..a34ca57885 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx
@@ -5,11 +5,13 @@ import AppHeader from "../../../components/AppHeader";
import { CardSpacer } from "../../../components/CardSpacer";
import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton/ConfirmButton";
import { Container } from "../../../components/Container";
+import { ControlledSwitch } from "../../../components/ControlledSwitch";
import Form from "../../../components/Form";
import Grid from "../../../components/Grid";
import PageHeader from "../../../components/PageHeader";
import SaveButtonBar from "../../../components/SaveButtonBar";
import SeoForm from "../../../components/SeoForm";
+import VisibilityCard from "../../../components/VisibilityCard";
import i18n from "../../../i18n";
import { maybe } from "../../../misc";
import { ListActions, PageListProps } from "../../../types";
@@ -17,12 +19,12 @@ import { CollectionDetails_collection } from "../../types/CollectionDetails";
import CollectionDetails from "../CollectionDetails/CollectionDetails";
import { CollectionImage } from "../CollectionImage/CollectionImage";
import CollectionProducts from "../CollectionProducts/CollectionProducts";
-import CollectionStatus from "../CollectionStatus/CollectionStatus";
export interface CollectionDetailsPageFormData {
backgroundImageAlt: string;
description: RawDraftContentState;
name: string;
+ publicationDate: string;
seoDescription: string;
seoTitle: string;
isFeatured: boolean;
@@ -54,83 +56,97 @@ const CollectionDetailsPage: React.StatelessComponent<
onImageUpload,
onSubmit,
...collectionProductsProps
-}: CollectionDetailsPageProps) => (
- <Form
- initial={{
- backgroundImageAlt: maybe(() => collection.backgroundImage.alt, ""),
- description: maybe(() => JSON.parse(collection.descriptionJson)),
- isFeatured,
- isPublished: maybe(() => collection.isPublished, false),
- name: maybe(() => collection.name, ""),
- seoDescription: maybe(() => collection.seoDescription, ""),
- seoTitle: maybe(() => collection.seoTitle, "")
- }}
- onSubmit={onSubmit}
- confirmLeave
- >
- {({ change, data, errors: formErrors, hasChanged, submit }) => (
- <Container>
- <AppHeader onBack={onBack}>{i18n.t("Collections")}</AppHeader>
- <PageHeader title={maybe(() => collection.name)} />
- <Grid>
- <div>
- <CollectionDetails
- collection={collection}
- data={data}
- disabled={disabled}
- errors={formErrors}
- onChange={change}
- />
- <CardSpacer />
- <CollectionImage
- data={data}
- image={maybe(() => collection.backgroundImage)}
- onImageDelete={onImageDelete}
- onImageUpload={onImageUpload}
- onChange={change}
- />
- <CardSpacer />
- <CollectionProducts
- disabled={disabled}
- collection={collection}
- {...collectionProductsProps}
- />
- <CardSpacer />
- <SeoForm
- description={data.seoDescription}
- disabled={disabled}
- descriptionPlaceholder=""
- helperText={i18n.t(
- "Add search engine title and description to make this collection easier to find",
- {
- context: "help text"
- }
- )}
- title={data.seoTitle}
- titlePlaceholder={maybe(() => collection.name)}
- onChange={change}
- />
- </div>
- <div>
+}: CollectionDetailsPageProps) => {
+ return (
+ <Form
+ initial={{
+ backgroundImageAlt: maybe(() => collection.backgroundImage.alt, ""),
+ description: maybe(() => JSON.parse(collection.descriptionJson)),
+ isFeatured,
+ isPublished: maybe(() => collection.isPublished, false),
+ name: maybe(() => collection.name, ""),
+ publicationDate: maybe(() => collection.publicationDate, ""),
+ seoDescription: maybe(() => collection.seoDescription, ""),
+ seoTitle: maybe(() => collection.seoTitle, "")
+ }}
+ onSubmit={onSubmit}
+ confirmLeave
+ >
+ {({ change, data, errors: formErrors, hasChanged, submit }) => (
+ <Container>
+ <AppHeader onBack={onBack}>{i18n.t("Collections")}</AppHeader>
+ <PageHeader title={maybe(() => collection.name)} />
+ <Grid>
<div>
- <CollectionStatus
+ <CollectionDetails
+ collection={collection}
data={data}
disabled={disabled}
+ errors={formErrors}
onChange={change}
/>
+ <CardSpacer />
+ <CollectionImage
+ data={data}
+ image={maybe(() => collection.backgroundImage)}
+ onImageDelete={onImageDelete}
+ onImageUpload={onImageUpload}
+ onChange={change}
+ />
+ <CardSpacer />
+ <CollectionProducts
+ disabled={disabled}
+ collection={collection}
+ {...collectionProductsProps}
+ />
+ <CardSpacer />
+ <SeoForm
+ description={data.seoDescription}
+ disabled={disabled}
+ descriptionPlaceholder=""
+ helperText={i18n.t(
+ "Add search engine title and description to make this collection easier to find",
+ {
+ context: "help text"
+ }
+ )}
+ title={data.seoTitle}
+ titlePlaceholder={maybe(() => collection.name)}
+ onChange={change}
+ />
+ </div>
+ <div>
+ <div>
+ <VisibilityCard
+ data={data}
+ errors={formErrors}
+ loading={disabled}
+ onChange={change}
+ >
+ <ControlledSwitch
+ checked={data.isFeatured}
+ disabled={disabled}
+ name="isFeatured"
+ onChange={change}
+ label={i18n.t("Feature on Homepage", {
+ context: "button"
+ })}
+ />
+ </VisibilityCard>
+ </div>
</div>
- </div>
- </Grid>
- <SaveButtonBar
- state={saveButtonBarState}
- disabled={disabled || !hasChanged}
- onCancel={onBack}
- onDelete={onCollectionRemove}
- onSave={submit}
- />
- </Container>
- )}
- </Form>
-);
+ </Grid>
+ <SaveButtonBar
+ state={saveButtonBarState}
+ disabled={disabled || !hasChanged}
+ onCancel={onBack}
+ onDelete={onCollectionRemove}
+ onSave={submit}
+ />
+ </Container>
+ )}
+ </Form>
+ );
+};
CollectionDetailsPage.displayName = "CollectionDetailsPage";
export default CollectionDetailsPage;
diff --git a/saleor/static/dashboard-next/collections/components/CollectionStatus/CollectionStatus.tsx b/saleor/static/dashboard-next/collections/components/CollectionStatus/CollectionStatus.tsx
deleted file mode 100644
index b443b6543a..0000000000
--- a/saleor/static/dashboard-next/collections/components/CollectionStatus/CollectionStatus.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import Card from "@material-ui/core/Card";
-import CardContent from "@material-ui/core/CardContent";
-import * as React from "react";
-
-import CardTitle from "../../../components/CardTitle";
-import { ControlledSwitch } from "../../../components/ControlledSwitch";
-import { FormSpacer } from "../../../components/FormSpacer";
-import i18n from "../../../i18n";
-
-export interface CollectionStatusProps {
- data: {
- isFeatured: boolean;
- isPublished: boolean;
- };
- disabled: boolean;
- onChange: (event: React.ChangeEvent<any>) => void;
-}
-
-const CollectionStatus: React.StatelessComponent<CollectionStatusProps> = ({
- data,
- disabled,
- onChange
-}) => (
- <Card>
- <CardTitle
- title={i18n.t("Availability", {
- context: "collection status"
- })}
- />
- <CardContent>
- <ControlledSwitch
- checked={data.isPublished}
- disabled={disabled}
- name="isPublished"
- onChange={onChange}
- label={i18n.t("Publish on storefront", {
- context: "button"
- })}
- />
- <FormSpacer />
- <ControlledSwitch
- checked={data.isFeatured}
- disabled={disabled}
- name="isFeatured"
- onChange={onChange}
- label={i18n.t("Feature on Homepage", {
- context: "button"
- })}
- />
- </CardContent>
- </Card>
-);
-CollectionStatus.displayName = "CollectionStatus";
-export default CollectionStatus;
diff --git a/saleor/static/dashboard-next/collections/components/CollectionStatus/index.ts b/saleor/static/dashboard-next/collections/components/CollectionStatus/index.ts
deleted file mode 100644
index 6ac9c935bd..0000000000
--- a/saleor/static/dashboard-next/collections/components/CollectionStatus/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./CollectionStatus";
-export * from "./CollectionStatus";
diff --git a/saleor/static/dashboard-next/collections/fixtures.ts b/saleor/static/dashboard-next/collections/fixtures.ts
index 168f35b962..423cf82fc8 100644
--- a/saleor/static/dashboard-next/collections/fixtures.ts
+++ b/saleor/static/dashboard-next/collections/fixtures.ts
@@ -117,6 +117,7 @@ export const collection: (
startCursor: ""
}
},
+ publicationDate: "2018-08-25T18:45:54.125Z",
seoDescription: "",
seoTitle: ""
});
diff --git a/saleor/static/dashboard-next/collections/queries.ts b/saleor/static/dashboard-next/collections/queries.ts
index 283a6ea8a1..f13bcc24e5 100644
--- a/saleor/static/dashboard-next/collections/queries.ts
+++ b/saleor/static/dashboard-next/collections/queries.ts
@@ -27,6 +27,7 @@ export const collectionDetailsFragment = gql`
url
}
descriptionJson
+ publicationDate
seoDescription
seoTitle
isPublished
diff --git a/saleor/static/dashboard-next/collections/types/CollectionDetails.ts b/saleor/static/dashboard-next/collections/types/CollectionDetails.ts
index c0ae5fdf29..bfbc9441c2 100644
--- a/saleor/static/dashboard-next/collections/types/CollectionDetails.ts
+++ b/saleor/static/dashboard-next/collections/types/CollectionDetails.ts
@@ -58,6 +58,7 @@ export interface CollectionDetails_collection {
name: string;
backgroundImage: CollectionDetails_collection_backgroundImage | null;
descriptionJson: any;
+ publicationDate: any | null;
seoDescription: string | null;
seoTitle: string | null;
products: CollectionDetails_collection_products | null;
diff --git a/saleor/static/dashboard-next/collections/types/CollectionDetailsFragment.ts b/saleor/static/dashboard-next/collections/types/CollectionDetailsFragment.ts
index dabeaeb944..24ae24d14f 100644
--- a/saleor/static/dashboard-next/collections/types/CollectionDetailsFragment.ts
+++ b/saleor/static/dashboard-next/collections/types/CollectionDetailsFragment.ts
@@ -19,6 +19,7 @@ export interface CollectionDetailsFragment {
name: string;
backgroundImage: CollectionDetailsFragment_backgroundImage | null;
descriptionJson: any;
+ publicationDate: any | null;
seoDescription: string | null;
seoTitle: string | null;
}
diff --git a/saleor/static/dashboard-next/collections/types/CollectionUpdate.ts b/saleor/static/dashboard-next/collections/types/CollectionUpdate.ts
index 924a4b4c0d..91453df7d7 100644
--- a/saleor/static/dashboard-next/collections/types/CollectionUpdate.ts
+++ b/saleor/static/dashboard-next/collections/types/CollectionUpdate.ts
@@ -27,6 +27,7 @@ export interface CollectionUpdate_collectionUpdate_collection {
name: string;
backgroundImage: CollectionUpdate_collectionUpdate_collection_backgroundImage | null;
descriptionJson: any;
+ publicationDate: any | null;
seoDescription: string | null;
seoTitle: string | null;
}
diff --git a/saleor/static/dashboard-next/collections/types/CollectionUpdateWithHomepage.ts b/saleor/static/dashboard-next/collections/types/CollectionUpdateWithHomepage.ts
index 04556c6926..f378cc9045 100644
--- a/saleor/static/dashboard-next/collections/types/CollectionUpdateWithHomepage.ts
+++ b/saleor/static/dashboard-next/collections/types/CollectionUpdateWithHomepage.ts
@@ -49,6 +49,7 @@ export interface CollectionUpdateWithHomepage_collectionUpdate_collection {
name: string;
backgroundImage: CollectionUpdateWithHomepage_collectionUpdate_collection_backgroundImage | null;
descriptionJson: any;
+ publicationDate: any | null;
seoDescription: string | null;
seoTitle: string | null;
}
diff --git a/saleor/static/dashboard-next/collections/types/CreateCollection.ts b/saleor/static/dashboard-next/collections/types/CreateCollection.ts
index 8f9622c888..25987de780 100644
--- a/saleor/static/dashboard-next/collections/types/CreateCollection.ts
+++ b/saleor/static/dashboard-next/collections/types/CreateCollection.ts
@@ -27,6 +27,7 @@ export interface CreateCollection_collectionCreate_collection {
name: string;
backgroundImage: CreateCollection_collectionCreate_collection_backgroundImage | null;
descriptionJson: any;
+ publicationDate: any | null;
seoDescription: string | null;
seoTitle: string | null;
}
diff --git a/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx b/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx
index 0f21f9b047..741e9c2ecf 100644
--- a/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx
+++ b/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx
@@ -144,11 +144,12 @@ export const CollectionDetails: React.StatelessComponent<
const handleSubmit = (
formData: CollectionDetailsPageFormData
) => {
- const input = {
+ const input: CollectionInput = {
backgroundImageAlt: formData.backgroundImageAlt,
descriptionJson: JSON.stringify(formData.description),
isPublished: formData.isPublished,
name: formData.name,
+ publicationDate: formData.publicationDate,
seo: {
description: formData.seoDescription,
title: formData.seoTitle
diff --git a/saleor/static/dashboard-next/components/VisibilityCard/VisibilityCard.tsx b/saleor/static/dashboard-next/components/VisibilityCard/VisibilityCard.tsx
index b0a395f4e7..c27aad7346 100644
--- a/saleor/static/dashboard-next/components/VisibilityCard/VisibilityCard.tsx
+++ b/saleor/static/dashboard-next/components/VisibilityCard/VisibilityCard.tsx
@@ -1,100 +1,109 @@
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
+import {
+ createStyles,
+ Theme,
+ withStyles,
+ WithStyles
+} from "@material-ui/core/styles";
import TextField from "@material-ui/core/TextField";
-import Typography from "@material-ui/core/Typography";
-import * as moment from "moment-timezone";
import * as React from "react";
import CardTitle from "../../components/CardTitle";
import ControlledSwitch from "../../components/ControlledSwitch";
-import FormSpacer from "../../components/FormSpacer";
-import { LocaleConsumer } from "../../components/Locale";
+import { FormSpacer } from "../../components/FormSpacer";
import i18n from "../../i18n";
-export interface FormData {
- isPublished: boolean;
- publicationDate: string;
-}
+const styles = (theme: Theme) =>
+ createStyles({
+ date: {
+ "& svg": {
+ fill: theme.palette.primary.main
+ },
+ marginTop: theme.spacing.unit * 4
+ },
+ expandedSwitchContainer: {
+ marginBottom: 0
+ },
+ switchContainer: {
+ marginBottom: -theme.spacing.unit
+ }
+ });
-export interface VisibilityCardProps {
- data: FormData;
- disabled: boolean;
- errors: Partial<Record<"publicationDate", string>>;
- onChange: (event: React.ChangeEvent<any>, cb?: () => void) => void;
+interface VisibilityCardProps extends WithStyles<typeof styles> {
+ children?: React.ReactNode;
+ data: {
+ isPublished: boolean;
+ publicationDate: string;
+ };
+ errors: { [key: string]: string };
+ loading?: boolean;
+ onChange(event: any);
}
-const VisibilityCard: React.StatelessComponent<VisibilityCardProps> = ({
- data,
- disabled,
- errors,
- onChange
-}) => (
- <LocaleConsumer>
- {locale => (
+export const VisibilityCard = withStyles(styles, {
+ name: "PVisibilityCard"
+})(
+ ({
+ children,
+ classes,
+ data: { isPublished, publicationDate },
+ errors,
+ loading,
+ onChange
+ }: VisibilityCardProps) => {
+ return (
<Card>
<CardTitle title={i18n.t("Visibility")} />
<CardContent>
- <ControlledSwitch
- checked={
- (data.publicationDate === "" || data.publicationDate === null) &&
- data.isPublished
- }
- disabled={disabled}
- label={
- data.isPublished && !data.publicationDate ? (
- i18n.t("Visible")
- ) : (
- <>
- {i18n.t("Hidden")}
- {data.publicationDate && (
- <Typography variant="caption">
- {i18n.t("Will become visible on {{ date }}", {
- context: "page",
- date: moment(data.publicationDate)
- .locale(locale)
- .format("ll")
- })}
- </Typography>
- )}
- </>
- )
- }
- name={"isPublished" as keyof FormData}
- onChange={event =>
- onChange(
- event,
- () =>
- event.target.value &&
- onChange({
- target: {
- name: "publicationDate",
- value: ""
- }
- } as any)
- )
+ <div
+ className={
+ isPublished
+ ? classes.expandedSwitchContainer
+ : classes.switchContainer
}
- />
- {!(data.publicationDate === "" || data.publicationDate === null) &&
- data.isPublished && (
- <>
- <FormSpacer />
- <TextField
- disabled={disabled}
- error={!!errors.publicationDate}
- fullWidth
- helperText={errors.publicationDate}
- label={i18n.t("Publish on")}
- name={"publicationDate" as keyof FormData}
- type="date"
- value={data.publicationDate}
- onChange={onChange}
- />
- </>
- )}
+ >
+ <ControlledSwitch
+ name="isPublished"
+ label={i18n.t("Visible")}
+ uncheckedLabel={i18n.t("Hidden")}
+ secondLabel={
+ publicationDate
+ ? isPublished
+ ? i18n.t("since ") + publicationDate
+ : i18n.t("will be visible on ") + publicationDate
+ : null
+ }
+ checked={isPublished}
+ onChange={onChange}
+ disabled={loading}
+ />
+ </div>
+ {!isPublished && (
+ <>
+ <TextField
+ error={!!errors.publicationDate}
+ disabled={loading}
+ label={i18n.t("Publish on")}
+ name="publicationDate"
+ type="date"
+ fullWidth={true}
+ helperText={errors.publicationDate}
+ value={publicationDate ? publicationDate : ""}
+ onChange={onChange}
+ className={classes.date}
+ InputLabelProps={{
+ shrink: true
+ }}
+ />
+ </>
+ )}
+ <FormSpacer />
+ {children}
</CardContent>
</Card>
- )}
- </LocaleConsumer>
+ );
+ }
);
VisibilityCard.displayName = "VisibilityCard";
export default VisibilityCard;
diff --git a/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx b/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx
index c2d4dca4a1..b0946ca04d 100644
--- a/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx
+++ b/saleor/static/dashboard-next/pages/components/PageDetailsPage/PageDetailsPage.tsx
@@ -114,7 +114,7 @@ const PageDetailsPage: React.StatelessComponent<PageDetailsPageProps> = ({
<CardSpacer />
<VisibilityCard
data={data}
- disabled={disabled}
+ loading={disabled}
errors={formErrors}
onChange={change}
/>
diff --git a/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx b/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
index 75a78bdac1..c035b22cde 100644
--- a/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductCreatePage/ProductCreatePage.tsx
@@ -10,11 +10,11 @@ import Grid from "../../../components/Grid";
import PageHeader from "../../../components/PageHeader";
import SaveButtonBar from "../../../components/SaveButtonBar/SaveButtonBar";
import SeoForm from "../../../components/SeoForm";
+import VisibilityCard from "../../../components/VisibilityCard";
import i18n from "../../../i18n";
import { maybe } from "../../../misc";
import { UserError } from "../../../types";
import { ProductCreateData_productTypes_edges_node_productAttributes } from "../../types/ProductCreateData";
-import ProductAvailabilityForm from "../ProductAvailabilityForm";
import ProductDetailsForm from "../ProductDetailsForm";
import ProductOrganization from "../ProductOrganization";
import ProductPricing from "../ProductPricing";
@@ -29,13 +29,13 @@ export interface FormData {
slug: string;
value: string;
}>;
- available: boolean;
basePrice: number;
publicationDate: string;
category: ChoiceType;
chargeTaxes: boolean;
collections: ChoiceType[];
description: RawDraftContentState;
+ isPublished: boolean;
name: string;
productType: {
label: string;
@@ -97,7 +97,6 @@ export const ProductCreatePage: React.StatelessComponent<
}: ProductCreatePageProps) => {
const initialData: FormData = {
attributes: [],
- available: false,
basePrice: 0,
category: {
label: "",
@@ -106,6 +105,7 @@ export const ProductCreatePage: React.StatelessComponent<
chargeTaxes: false,
collections: [],
description: {} as any,
+ isPublished: false,
name: "",
productType: {
label: "",
@@ -205,7 +205,7 @@ export const ProductCreatePage: React.StatelessComponent<
onChange={change}
/>
<CardSpacer />
- <ProductAvailabilityForm
+ <VisibilityCard
data={data}
errors={errors}
loading={disabled}
diff --git a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
index cf19c4025e..630a210a4e 100644
--- a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
@@ -10,6 +10,7 @@ import Grid from "../../../components/Grid";
import PageHeader from "../../../components/PageHeader";
import SaveButtonBar from "../../../components/SaveButtonBar/SaveButtonBar";
import SeoForm from "../../../components/SeoForm";
+import VisibilityCard from "../../../components/VisibilityCard";
import i18n from "../../../i18n";
import { maybe } from "../../../misc";
import { ListActions, UserError } from "../../../types";
@@ -19,7 +20,6 @@ import {
ProductDetails_product_images,
ProductDetails_product_variants
} from "../../types/ProductDetails";
-import ProductAvailabilityForm from "../ProductAvailabilityForm";
import ProductDetailsForm from "../ProductDetailsForm";
import ProductImages from "../ProductImages";
import ProductOrganization from "../ProductOrganization";
@@ -73,12 +73,12 @@ export interface FormData {
slug: string;
value: string;
}>;
- available: boolean;
basePrice: number;
category: ChoiceType | null;
chargeTaxes: boolean;
collections: ChoiceType[];
description: RawDraftContentState;
+ isPublished: boolean;
name: string;
productType: {
label: string;
@@ -138,7 +138,6 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
})),
[]
),
- available: maybe(() => product.isPublished, false),
basePrice: maybe(() => product.basePrice.amount),
category: maybe(() => ({
label: product.category.name,
@@ -152,6 +151,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
}))
: [],
description: maybe(() => JSON.parse(product.descriptionJson)),
+ isPublished: maybe(() => product.isPublished, false),
name: maybe(() => product.name),
productType: maybe(() => ({
label: product.productType.name,
@@ -289,7 +289,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
onChange={change}
/>
<CardSpacer />
- <ProductAvailabilityForm
+ <VisibilityCard
data={data}
errors={errors}
loading={disabled}
diff --git a/saleor/static/dashboard-next/products/views/ProductCreate.tsx b/saleor/static/dashboard-next/products/views/ProductCreate.tsx
index be64632c98..64ebb6abcb 100644
--- a/saleor/static/dashboard-next/products/views/ProductCreate.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductCreate.tsx
@@ -67,7 +67,7 @@ export const ProductUpdate: React.StatelessComponent<
descriptionJson: JSON.stringify(
formData.description
),
- isPublished: formData.available,
+ isPublished: formData.isPublished,
name: formData.name,
productType: formData.productType.value.id,
publicationDate:
diff --git a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
index 9a4afa934c..9d4d10311f 100644
--- a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
@@ -132,7 +132,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
),
descriptionJson: JSON.stringify(data.description),
id: product.id,
- isPublished: data.available,
+ isPublished: data.isPublished,
name: data.name,
publicationDate:
data.publicationDate !== ""
@@ -150,7 +150,7 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
),
descriptionJson: JSON.stringify(data.description),
id: product.id,
- isPublished: data.available,
+ isPublished: data.isPublished,
name: data.name,
productVariantId: product.variants[0].id,
productVariantInput: {