Skip to content

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

wip

dominik-zeglen555defbe5882
diff --git a/saleor/static/dashboard-next/gql-types.ts b/saleor/static/dashboard-next/gql-types.ts
index b55a5dff3f..ca280c8855 100644
--- a/saleor/static/dashboard-next/gql-types.ts
+++ b/saleor/static/dashboard-next/gql-types.ts
@@ -479,6 +479,8 @@ export interface ProductUpdateMutation {
} | null,
} | null,
isPublished: boolean,
+ isFeatured: boolean,
+ chargeTaxes: boolean,
availableOn: string | null,
// List of product attributes assigned to this product.
attributes: Array< {
@@ -832,6 +834,8 @@ export interface ProductDetailsQuery {
} | null,
} | null,
isPublished: boolean,
+ isFeatured: boolean,
+ chargeTaxes: boolean,
availableOn: string | null,
// List of product attributes assigned to this product.
attributes: Array< {
@@ -1140,6 +1144,8 @@ export interface ProductFragment {
} | null,
} | null,
isPublished: boolean,
+ isFeatured: boolean,
+ chargeTaxes: boolean,
availableOn: string | null,
// List of product attributes assigned to this product.
attributes: Array< {
diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsx
index bc0b0a7cd3..7848bca428 100644
--- a/saleor/static/dashboard-next/index.tsx
+++ b/saleor/static/dashboard-next/index.tsx
@@ -1,10 +1,10 @@
import CssBaseline from "@material-ui/core/CssBaseline";
import MuiThemeProvider from "@material-ui/core/styles/MuiThemeProvider";
import { InMemoryCache } from "apollo-cache-inmemory";
-import { ApolloClient } from "apollo-client";
+import { ApolloClient, ApolloError } from "apollo-client";
import { createUploadLink } from "apollo-upload-client";
import * as React from "react";
-import { ApolloProvider } from "react-apollo";
+import { ApolloProvider, MutationFn } from "react-apollo";
import { render } from "react-dom";
import { Provider } from "react-redux";
import { BrowserRouter, Route, Switch } from "react-router-dom";
@@ -65,3 +65,13 @@ export interface ListProps {
export interface PageListProps extends ListProps {
onAdd: () => void;
}
+
+export interface MutationProviderChildrenRenderProps<
+ TData extends {} = {},
+ TVariables extends {} = {}
+> {
+ loading: boolean;
+ called: boolean;
+ error?: ApolloError;
+ mutate: MutationFn<TData, TVariables>;
+}
diff --git a/saleor/static/dashboard-next/products/components/ProductAvailabilityForm/ProductAvailabilityForm.tsx b/saleor/static/dashboard-next/products/components/ProductAvailabilityForm/ProductAvailabilityForm.tsx
index 56eddfc0f9..ecc57926df 100644
--- a/saleor/static/dashboard-next/products/components/ProductAvailabilityForm/ProductAvailabilityForm.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductAvailabilityForm/ProductAvailabilityForm.tsx
@@ -9,8 +9,12 @@ import PageHeader from "../../../components/PageHeader";
import i18n from "../../../i18n";
interface ProductAvailabilityFormProps {
- available?: boolean;
- availableOn?: string;
+ data: {
+ available: boolean;
+ availableOn: string;
+ chargeTaxes: boolean;
+ featured: boolean;
+ };
loading?: boolean;
onChange(event: any);
}
@@ -21,29 +25,56 @@ const decorate = withStyles(theme => ({
}
}));
export const ProductAvailabilityForm = decorate<ProductAvailabilityFormProps>(
- ({ classes, available, availableOn, loading, onChange }) => (
+ ({
+ classes,
+ data: { available, availableOn, chargeTaxes, featured },
+ loading,
+ onChange
+ }) => (
<Card>
<PageHeader title={i18n.t("Status")} />
<CardContent>
- <ControlledCheckbox
- name="available"
- label={i18n.t("Published in storefront")}
- checked={available}
- onChange={onChange}
- disabled={loading}
- />
- <TextField
- disabled={loading}
- label={i18n.t("Publish product on")}
- name="availableOn"
- type="date"
- value={availableOn ? availableOn : ""}
- onChange={onChange}
- className={classes.date}
- InputLabelProps={{
- shrink: true
- }}
- />
+ <div>
+ <ControlledCheckbox
+ name="available"
+ label={i18n.t("Published in storefront")}
+ checked={available}
+ onChange={onChange}
+ disabled={loading}
+ />
+ </div>
+ {available && (
+ <TextField
+ disabled={loading}
+ label={i18n.t("Publish product on")}
+ name="availableOn"
+ type="date"
+ value={availableOn ? availableOn : ""}
+ onChange={onChange}
+ className={classes.date}
+ InputLabelProps={{
+ shrink: true
+ }}
+ />
+ )}
+ <div>
+ <ControlledCheckbox
+ name="featured"
+ label={i18n.t("Feature this product on homepage")}
+ checked={featured}
+ onChange={onChange}
+ disabled={loading}
+ />
+ </div>
+ <div>
+ <ControlledCheckbox
+ name="chargeTaxes"
+ label={i18n.t("Charge taxes")}
+ checked={chargeTaxes}
+ onChange={onChange}
+ disabled={loading}
+ />
+ </div>
</CardContent>
</Card>
)
diff --git a/saleor/static/dashboard-next/products/components/ProductDetailsForm/ProductDetailsForm.tsx b/saleor/static/dashboard-next/products/components/ProductDetailsForm/ProductDetailsForm.tsx
index 7584c5b35c..8b86ff357e 100644
--- a/saleor/static/dashboard-next/products/components/ProductDetailsForm/ProductDetailsForm.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductDetailsForm/ProductDetailsForm.tsx
@@ -41,6 +41,7 @@ export const ProductDetailsForm = decorate<ProductDetailsFormProps>(
<TextField
disabled={disabled}
fullWidth
+ key="nameInput"
label={i18n.t("Name")}
name="name"
rows={5}
@@ -51,6 +52,7 @@ export const ProductDetailsForm = decorate<ProductDetailsFormProps>(
<PriceField
currencySymbol={currencySymbol}
disabled={disabled}
+ key="priceInput"
label={i18n.t("Price")}
onChange={onChange}
value={price}
@@ -61,6 +63,7 @@ export const ProductDetailsForm = decorate<ProductDetailsFormProps>(
disabled={disabled}
fullWidth
helperText={i18n.t("Select text to enable text-formatting tools.")}
+ key="descriptionInput"
label={i18n.t("Description")}
name="description"
value={description}
diff --git a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx
index b30afb930b..c1e3b427c8 100644
--- a/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductImages/ProductImages.tsx
@@ -33,7 +33,7 @@ interface ImageListElementProps {
alt?: string;
sortOrder: number;
url: string;
- }
+ };
onImageEdit(event: React.ChangeEvent<any>);
}
@@ -62,8 +62,9 @@ const decorate = withStyles(theme => ({
cursor: "move",
userSelect: "none" as "none",
"& img": {
+ height: 20 * theme.spacing.unit,
pointerEvents: "none" as "none",
- width: "100%"
+ width: 20 * theme.spacing.unit
}
},
icon: {
diff --git a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
index ec3f219d66..ca0c24ef33 100644
--- a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
@@ -3,7 +3,6 @@ import IconButton from "@material-ui/core/IconButton";
import { withStyles } from "@material-ui/core/styles";
import DeleteIcon from "@material-ui/icons/Delete";
import VisibilityIcon from "@material-ui/icons/Visibility";
-import * as CRC from 'crc-32'
import * as React from "react";
import { AttributeType, AttributeValueType, MoneyType } from "../../";
@@ -60,6 +59,8 @@ interface ProductUpdateProps {
description: string;
seoTitle?: string;
seoDescription?: string;
+ isFeatured?: boolean;
+ chargeTaxes?: boolean;
productType: {
id: string;
name: string;
@@ -101,16 +102,6 @@ interface ProductUpdateProps {
onVariantShow?(id: string);
}
-const shallowCompare = (a, b) => {
- let ret = true;
- Object.keys(a).forEach(k => {
- if (a[k] !== b[k]) {
- ret = false;
- }
- });
- return ret;
-};
-
const decorate = withStyles(theme => ({
cardContainer: {
marginTop: theme.spacing.unit * 2,
@@ -158,11 +149,13 @@ export const ProductUpdate = decorate<ProductUpdateProps>(
available: product ? product.isPublished : undefined,
availableOn: product ? product.availableOn : "",
category: product && product.category ? product.category.id : undefined,
+ chargeTaxes: product && product.chargeTaxes ? product.chargeTaxes : false,
collections:
product && productCollections
? productCollections.map(node => node.id)
: [],
description: product ? product.description : "",
+ featured: product && product.isFeatured ? product.isFeatured : false,
name: product ? product.name : "",
price: product && product.price ? product.price.amount : undefined,
seoDescription: product ? product.seoDescription : "",
@@ -177,9 +170,9 @@ export const ProductUpdate = decorate<ProductUpdateProps>(
<Form
onSubmit={onSubmit}
initial={initialData}
- key={product ? CRC.str(JSON.stringify(product)) : 'loading'}
+ key={product ? JSON.stringify(product) : "loading"}
>
- {({ change, data, submit }) => (
+ {({ change, data, hasChanged, submit }) => (
<Container width="md">
<Toggle>
{(openedDeleteDialog, { toggle: toggleDeleteDialog }) => (
@@ -202,7 +195,8 @@ export const ProductUpdate = decorate<ProductUpdateProps>(
</IconButton>
)}
</PageHeader>
- {product && onDelete &&
+ {product &&
+ onDelete &&
product.name && (
<ActionDialog
open={openedDeleteDialog}
@@ -262,7 +256,7 @@ export const ProductUpdate = decorate<ProductUpdateProps>(
titlePlaceholder={data.name}
description={data.seoDescription}
descriptionPlaceholder={data.description}
- storefrontUrl={ product ? product.url : undefined }
+ storefrontUrl={product ? product.url : undefined}
loading={disabled}
onClick={onSeoClick}
onChange={change}
@@ -271,15 +265,14 @@ export const ProductUpdate = decorate<ProductUpdateProps>(
</div>
<div>
<ProductAvailabilityForm
- available={data.available}
- availableOn={data.availableOn}
+ data={data}
loading={disabled}
onChange={change}
/>
<div className={classes.cardContainer}>
<ProductPrice
- margin={ product ? product.margin : undefined }
- purchaseCost={ product ? product.purchaseCost : undefined }
+ margin={product ? product.margin : undefined}
+ purchaseCost={product ? product.purchaseCost : undefined}
/>
</div>
<div className={classes.cardContainer}>
@@ -319,9 +312,7 @@ export const ProductUpdate = decorate<ProductUpdateProps>(
<SaveButtonBar
onSave={submit}
state={saveButtonBarState}
- disabled={
- disabled || !onSubmit || shallowCompare(initialData, data)
- }
+ disabled={disabled || !onSubmit || !hasChanged}
/>
</Container>
)}
diff --git a/saleor/static/dashboard-next/products/containers/ProductImagesReorder.tsx b/saleor/static/dashboard-next/products/containers/ProductImagesReorder.tsx
index 68c06384bb..5d1ca16bca 100644
--- a/saleor/static/dashboard-next/products/containers/ProductImagesReorder.tsx
+++ b/saleor/static/dashboard-next/products/containers/ProductImagesReorder.tsx
@@ -1,14 +1,24 @@
import * as React from "react";
import ErrorMessageCard from "../../components/ErrorMessageCard";
-import { ProductDetailsQuery } from "../../gql-types";
+import {
+ ProductDetailsQuery,
+ ProductImageReorderMutation,
+ ProductImageReorderMutationVariables
+} from "../../gql-types";
import { productImagesReorder, TypedProductImagesReorder } from "../mutations";
+import { MutationProviderChildrenRenderProps } from "../..";
import { productDetailsQuery } from "../queries";
interface ProductImagesReorderProviderProps {
productId: string;
- children: any;
+ children: ((
+ props: MutationProviderChildrenRenderProps<
+ ProductImageReorderMutation,
+ ProductImageReorderMutationVariables
+ >
+ ) => React.ReactElement<any>);
}
const ProductImagesReorderProvider: React.StatelessComponent<
@@ -27,11 +37,16 @@ const ProductImagesReorderProvider: React.StatelessComponent<
cache.writeQuery({ query: productDetailsQuery, data });
}}
>
- {(reorderProductImages, { error }) => {
+ {(mutate, { called, error, loading }) => {
if (error) {
return <ErrorMessageCard message={error.message} />;
}
- return children(reorderProductImages);
+ return children({
+ called,
+ error,
+ loading,
+ mutate
+ });
}}
</TypedProductImagesReorder>
);
diff --git a/saleor/static/dashboard-next/products/containers/ProductUpdate.tsx b/saleor/static/dashboard-next/products/containers/ProductUpdate.tsx
index 7b799d669f..38eeef9266 100644
--- a/saleor/static/dashboard-next/products/containers/ProductUpdate.tsx
+++ b/saleor/static/dashboard-next/products/containers/ProductUpdate.tsx
@@ -1,16 +1,26 @@
import * as React from "react";
+import { MutationProviderChildrenRenderProps } from "../..";
import ErrorMessageCard from "../../components/ErrorMessageCard";
-import { ProductDetailsQuery } from "../../gql-types";
+import {
+ ProductDetailsQuery,
+ ProductUpdateMutation,
+ ProductUpdateMutationVariables
+} from "../../gql-types";
import {
productUpdateMutation,
- TypedProductUpdateMutation,
+ TypedProductUpdateMutation
} from "../mutations";
import { productDetailsQuery } from "../queries";
interface ProductUpdateProviderProps {
productId: string;
- children: any;
+ children: ((
+ props: MutationProviderChildrenRenderProps<
+ ProductUpdateMutation,
+ ProductUpdateMutationVariables
+ >
+ ) => React.ReactElement<any>);
}
const ProductUpdateProvider: React.StatelessComponent<
@@ -27,11 +37,16 @@ const ProductUpdateProvider: React.StatelessComponent<
cache.writeQuery({ query: productDetailsQuery, data });
}}
>
- {(updateProduct, { error }) => {
+ {(mutate, { called, error, loading }) => {
if (error) {
return <ErrorMessageCard message={error.message} />;
}
- return children(updateProduct);
+ return children({
+ called,
+ error,
+ loading,
+ mutate
+ });
}}
</TypedProductUpdateMutation>
);
diff --git a/saleor/static/dashboard-next/products/containers/ProductUpdateOperations.tsx b/saleor/static/dashboard-next/products/containers/ProductUpdateOperations.tsx
index c068cecfca..c6541b3a3d 100644
--- a/saleor/static/dashboard-next/products/containers/ProductUpdateOperations.tsx
+++ b/saleor/static/dashboard-next/products/containers/ProductUpdateOperations.tsx
@@ -1,9 +1,14 @@
import * as React from "react";
import { Redirect } from "react-router-dom";
+import { ApolloError } from "apollo-client";
+import { MutationProviderChildrenRenderProps } from "../..";
import ErrorMessageCard from "../../components/ErrorMessageCard";
import {
+ ProductDeleteMutation,
+ ProductDeleteMutationVariables,
ProductDetailsQuery,
+ ProductImageCreateMutation,
ProductImageCreateMutationVariables,
ProductImageReorderMutationVariables,
ProductUpdateMutationVariables
@@ -21,7 +26,12 @@ import ProductUpdateProvider from "./ProductUpdate";
interface ProductDeleteProviderProps {
productId: string;
- children: ((deleteProduct: () => void) => React.ReactElement<any>);
+ children: ((
+ props: MutationProviderChildrenRenderProps<
+ ProductDeleteMutation,
+ ProductDeleteMutationVariables
+ >
+ ) => React.ReactElement<any>);
}
const ProductDeleteProvider: React.StatelessComponent<
@@ -31,21 +41,31 @@ const ProductDeleteProvider: React.StatelessComponent<
mutation={productDeleteMutation}
variables={{ id: productId }}
>
- {(deleteProduct, { called, loading, error }) => {
- if (called && !loading) {
- return <Redirect to={productListUrl} push={false} />;
- }
+ {(mutate, { called, error, loading }) => {
if (error) {
return <ErrorMessageCard message={error.message} />;
}
- return children(() => deleteProduct());
+ if (called && !loading) {
+ return <Redirect to={productListUrl} push={false} />;
+ }
+ return children({
+ called,
+ error,
+ loading,
+ mutate
+ });
}}
</TypedProductDeleteMutation>
);
interface ProductImageCreateProviderProps {
productId: string;
- children: any;
+ children: ((
+ props: MutationProviderChildrenRenderProps<
+ ProductImageCreateMutation,
+ ProductImageCreateMutationVariables
+ >
+ ) => React.ReactElement<any>);
}
const ProductImageCreateProvider: React.StatelessComponent<
@@ -66,11 +86,16 @@ const ProductImageCreateProvider: React.StatelessComponent<
cache.writeQuery({ query: productDetailsQuery, data });
}}
>
- {(createProductImage, { error }) => {
+ {(mutate, { called, error, loading }) => {
if (error) {
return <ErrorMessageCard message={error.message} />;
}
- return children(createProductImage);
+ return children({
+ called,
+ error,
+ loading,
+ mutate
+ });
}}
</TypedProductImageCreateMutation>
);
@@ -78,7 +103,9 @@ const ProductImageCreateProvider: React.StatelessComponent<
interface ProductUpdateOperationsProps {
product?: ProductDetailsQuery["product"];
children: (
- mutations: {
+ props: {
+ error: ApolloError;
+ loading: boolean;
createProductImage(variables: ProductImageCreateMutationVariables): void;
deleteProduct(): void;
reorderProductImages(
@@ -104,19 +131,31 @@ const ProductUpdateOperations: React.StatelessComponent<
{deleteProduct =>
children({
createProductImage: variables =>
- createProductImage({ variables }),
- deleteProduct,
+ createProductImage.mutate({ variables }),
+ deleteProduct: deleteProduct.mutate,
+ error:
+ updateProduct.error ||
+ reorderProductImages.error ||
+ createProductImage.error ||
+ deleteProduct.error,
+ loading:
+ updateProduct.loading ||
+ reorderProductImages.loading ||
+ createProductImage.loading ||
+ deleteProduct.loading,
reorderProductImages: variables => {
const imagesMap = {};
product.images.edges.forEach(edge => {
const image = edge.node;
imagesMap[image.id] = image;
- })
- const productImages = variables.imagesIds.map((id, index) => ({
- __typename: "ProductImage",
- ...imagesMap[id],
- sortOrder: index,
- }));
+ });
+ const productImages = variables.imagesIds.map(
+ (id, index) => ({
+ __typename: "ProductImage",
+ ...imagesMap[id],
+ sortOrder: index
+ })
+ );
const optimisticResponse = {
productImageReorder: {
__typename: "ProductImageReorder",
@@ -124,9 +163,13 @@ const ProductUpdateOperations: React.StatelessComponent<
productImages
}
};
- reorderProductImages({ variables, optimisticResponse })
+ reorderProductImages.mutate({
+ optimisticResponse,
+ variables
+ });
},
- updateProduct: variables => updateProduct({ variables })
+ updateProduct: variables =>
+ updateProduct.mutate({ variables })
})
}
</ProductDeleteProvider>
diff --git a/saleor/static/dashboard-next/products/queries.ts b/saleor/static/dashboard-next/products/queries.ts
index a6173970ec..fc70fd4dfd 100644
--- a/saleor/static/dashboard-next/products/queries.ts
+++ b/saleor/static/dashboard-next/products/queries.ts
@@ -62,6 +62,8 @@ export const fragmentProduct = gql`
}
}
isPublished
+ isFeatured
+ chargeTaxes
availableOn
attributes {
attribute {
diff --git a/saleor/static/dashboard-next/products/views/ProductList.tsx b/saleor/static/dashboard-next/products/views/ProductList.tsx
index 5572f642bb..3ff590f49c 100644
--- a/saleor/static/dashboard-next/products/views/ProductList.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductList.tsx
@@ -4,7 +4,6 @@ import * as React from "react";
import { productAddUrl, productUrl } from "..";
import ErrorMessageCard from "../../components/ErrorMessageCard";
import Navigator from "../../components/Navigator";
-import Toggle from "../../components/Toggle";
import ProductListCard from "../components/ProductListCard";
import { productListQuery, TypedProductListQuery } from "../queries";
@@ -19,7 +18,6 @@ const decorate = withStyles(theme => ({
gridTemplateColumns: "100%",
[theme.breakpoints.up("md")]: {
gridGap: theme.spacing.unit * 2 + "px",
- // TODO: Check on firefox
gridTemplateColumns: "3fr 1fr"
}
}
@@ -31,102 +29,92 @@ export const ProductList = decorate<ProductListProps>(
<Navigator>
{navigate => {
return (
- <Toggle>
- {(
- filtersVisible,
- { disable: hideFilters, enable: showFilters }
- ) => (
- <TypedProductListQuery
- query={productListQuery}
- variables={{ first: 12 }}
- fetchPolicy="network-only"
- >
- {({ data, loading, error, fetchMore }) => {
- if (error) {
- return (
- <ErrorMessageCard message="Something went wrong" />
- );
+ <TypedProductListQuery
+ query={productListQuery}
+ variables={{ first: 12 }}
+ fetchPolicy="network-only"
+ >
+ {({ data, loading, error, fetchMore }) => {
+ if (error) {
+ return <ErrorMessageCard message="Something went wrong" />;
+ }
+ const loadNextPage = () => {
+ if (loading) {
+ return;
+ }
+ return fetchMore({
+ updateQuery: (previousResult, { fetchMoreResult }) => {
+ return {
+ ...fetchMoreResult,
+ products: {
+ ...fetchMoreResult.products,
+ pageInfo: {
+ ...fetchMoreResult.products.pageInfo,
+ hasPreviousPage: true
+ }
+ }
+ };
+ },
+ variables: {
+ after: data.products.pageInfo.endCursor,
+ first: 12
+ }
+ });
+ };
+ const loadPreviousPage = () => {
+ if (loading) {
+ return;
+ }
+ return fetchMore({
+ updateQuery: (
+ previousResult,
+ { fetchMoreResult, variables }
+ ) => {
+ return {
+ ...fetchMoreResult,
+ products: {
+ ...fetchMoreResult.products,
+ pageInfo: {
+ ...fetchMoreResult.products.pageInfo,
+ hasNextPage: true
+ }
+ }
+ };
+ },
+ variables: {
+ before: data.products.pageInfo.startCursor,
+ first: undefined,
+ last: 12
}
- const loadNextPage = () => {
- if (loading) {
- return;
- }
- return fetchMore({
- updateQuery: (previousResult, { fetchMoreResult }) => {
- return {
- ...fetchMoreResult,
- products: {
- ...fetchMoreResult.products,
- pageInfo: {
- ...fetchMoreResult.products.pageInfo,
- hasPreviousPage: true
- }
- }
- };
- },
- variables: {
- after: data.products.pageInfo.endCursor,
- first: 12
+ });
+ };
+ return (
+ <>
+ <div>
+ <ProductListCard
+ onAdd={() => navigate(productAddUrl)}
+ disabled={loading}
+ products={
+ data &&
+ data.products !== undefined &&
+ data.products !== null
+ ? data.products.edges.map(p => p.node)
+ : undefined
}
- });
- };
- const loadPreviousPage = () => {
- if (loading) {
- return;
- }
- return fetchMore({
- updateQuery: (
- previousResult,
- { fetchMoreResult, variables }
- ) => {
- return {
- ...fetchMoreResult,
- products: {
- ...fetchMoreResult.products,
- pageInfo: {
- ...fetchMoreResult.products.pageInfo,
- hasNextPage: true
- }
- }
- };
- },
- variables: {
- before: data.products.pageInfo.startCursor,
- first: undefined,
- last: 12
+ onNextPage={loadNextPage}
+ onPreviousPage={loadPreviousPage}
+ pageInfo={
+ data && data.products && data.products.pageInfo
+ ? data.products.pageInfo
+ : undefined
}
- });
- };
- return (
- <>
- <div>
- <ProductListCard
- onAdd={() => navigate(productAddUrl)}
- disabled={loading}
- products={
- data &&
- data.products !== undefined &&
- data.products !== null
- ? data.products.edges.map(p => p.node)
- : undefined
- }
- onNextPage={loadNextPage}
- onPreviousPage={loadPreviousPage}
- pageInfo={
- data && data.products && data.products.pageInfo
- ? data.products.pageInfo
- : undefined
- }
- onRowClick={id => () =>
- navigate(productUrl(id))}
- />
- </div>
- </>
- );
- }}
- </TypedProductListQuery>
- )}
- </Toggle>
+ onRowClick={id => () => navigate(productUrl(id))}
+ />
+ </div>
+ </>
+ );
+ }}
+ </TypedProductListQuery>
);
}}
</Navigator>
diff --git a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
index dfe4dd9912..f25560f5d6 100644
--- a/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
+++ b/saleor/static/dashboard-next/products/views/ProductUpdate.tsx
@@ -48,6 +48,8 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
{({
createProductImage,
deleteProduct,
+ error,
+ loading,
reorderProductImages,
updateProduct
}) => {
@@ -55,6 +57,8 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
<ProductUpdatePage
categories={allCategories}
collections={allCollections}
+ disabled={loading}
+ saveButtonBarState={loading ? "loading" : "idle"}
images={images}
placeholderImage={placeholderImg}
product={product}
@@ -107,13 +111,14 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
updateProduct({
attributes,
- availableOn: data.availableOn !== "" ? data.availableOn : null,
+ availableOn:
+ data.availableOn !== "" ? data.availableOn : null,
category: data.category,
- chargeTaxes: false, // FIXME: missing in UI
+ chargeTaxes: data.chargeTaxes,
collections: data.collections,
description: data.description,
id: product.id,
- isFeatured: false, // FIXME: missing in UI
+ isFeatured: data.featured,
isPublished: data.available,
name: data.name,
price: data.price