Skip to content

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

Restyle product assign dialog

dominik-zeglenc7d4932eac80
diff --git a/saleor/static/dashboard-next/collections/components/CollectionAssignProductDialog/CollectionAssignProductDialog.tsx b/saleor/static/dashboard-next/collections/components/CollectionAssignProductDialog/CollectionAssignProductDialog.tsx
index 5e6f26f664..8c7ad91f2c 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionAssignProductDialog/CollectionAssignProductDialog.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionAssignProductDialog/CollectionAssignProductDialog.tsx
@@ -1,49 +1,63 @@
import Button from "@material-ui/core/Button";
+import Checkbox from "@material-ui/core/Checkbox";
+import CircularProgress from "@material-ui/core/CircularProgress";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogTitle from "@material-ui/core/DialogTitle";
import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
+import Table from "@material-ui/core/Table";
+import TableBody from "@material-ui/core/TableBody";
+import TableCell from "@material-ui/core/TableCell";
+import TableRow from "@material-ui/core/TableRow";
+import TextField from "@material-ui/core/TextField";
import * as React from "react";
import ConfirmButton, {
ConfirmButtonTransitionState
} from "../../../components/ConfirmButton/ConfirmButton";
+import Debounce from "../../../components/Debounce";
import Form from "../../../components/Form";
-import { SingleAutocompleteSelectField } from "../../../components/SingleAutocompleteSelectField";
+import FormSpacer from "../../../components/FormSpacer";
+import TableCellAvatar from "../../../components/TableCellAvatar";
import i18n from "../../../i18n";
+import { SearchProducts_products_edges_node } from "../../types/SearchProducts";
export interface FormData {
- product: {
- label: string;
- value: string;
- };
+ products: SearchProducts_products_edges_node[];
+ query: string;
}
const styles = createStyles({
+ avatar: {
+ "&:first-child": {
+ paddingLeft: 0
+ }
+ },
+ checkboxCell: {
+ paddingLeft: 0
+ },
overflow: {
overflowY: "visible"
+ },
+ wideCell: {
+ width: "100%"
}
});
interface CollectionAssignProductDialogProps extends WithStyles<typeof styles> {
confirmButtonState: ConfirmButtonTransitionState;
open: boolean;
- products: Array<{
- id: string;
- name: string;
- }>;
+ products: SearchProducts_products_edges_node[];
loading: boolean;
- fetch: (value: string) => void;
onClose: () => void;
+ onFetch: (value: string) => void;
onSubmit: (data: FormData) => void;
}
const initialForm: FormData = {
- product: {
- label: "",
- value: ""
- }
+ products: [],
+ query: ""
};
const CollectionAssignProductDialog = withStyles(styles, {
name: "CollectionAssignProductDialog"
@@ -54,8 +68,8 @@ const CollectionAssignProductDialog = withStyles(styles, {
open,
loading,
products,
- fetch,
onClose,
+ onFetch,
onSubmit
}: CollectionAssignProductDialogProps) => (
<Dialog
@@ -66,25 +80,87 @@ const CollectionAssignProductDialog = withStyles(styles, {
>
<Form initial={initialForm} onSubmit={onSubmit}>
{({ data, change }) => {
- const choices =
- !loading && products
- ? products.map(product => ({
- label: product.name,
- value: product.id
- }))
- : [];
return (
<>
- <DialogTitle>{i18n.t("Add product")}</DialogTitle>
+ <DialogTitle>
+ {i18n.t("Assign Product to Collection")}
+ </DialogTitle>
<DialogContent className={classes.overflow}>
- <SingleAutocompleteSelectField
- name="product"
- value={data.product}
- choices={choices}
- onChange={change}
- fetchChoices={fetch}
- loading={loading}
- />
+ <Debounce debounceFn={onFetch}>
+ {fetch => (
+ <TextField
+ name="query"
+ value={data.query}
+ onChange={event => change(event, () => fetch(data.query))}
+ label={i18n.t("Search Products", {
+ context: "product search input label"
+ })}
+ placeholder={i18n.t(
+ "Search by product name, attribute, product type etc...",
+ {
+ context: "product search input placeholder"
+ }
+ )}
+ fullWidth
+ InputProps={{
+ autoComplete: "off",
+ endAdornment: loading && <CircularProgress size={16} />
+ }}
+ />
+ )}
+ </Debounce>
+ <FormSpacer />
+ <Table>
+ <TableBody>
+ {products &&
+ products.map(product => (
+ <TableRow key={product.id}>
+ <TableCellAvatar
+ className={classes.avatar}
+ thumbnail={product.thumbnail.url}
+ />
+ <TableCell className={classes.wideCell}>
+ {product.name}
+ </TableCell>
+ <TableCell
+ padding="checkbox"
+ className={classes.checkboxCell}
+ >
+ <Checkbox
+ className={classes.checkbox}
+ checked={
+ !!data.products.find(
+ selectedProduct =>
+ selectedProduct.id === product.id
+ )
+ }
+ onChange={() =>
+ data.products.find(
+ selectedProduct =>
+ selectedProduct.id === product.id
+ )
+ ? change({
+ target: {
+ name: "products",
+ value: data.products.filter(
+ selectedProduct =>
+ selectedProduct.id !== product.id
+ )
+ }
+ } as any)
+ : change({
+ target: {
+ name: "products",
+ value: [...data.products, product]
+ }
+ } as any)
+ }
+ />
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>
@@ -96,7 +172,7 @@ const CollectionAssignProductDialog = withStyles(styles, {
variant="contained"
type="submit"
>
- {i18n.t("Confirm", { context: "button" })}
+ {i18n.t("Assign products", { context: "button" })}
</ConfirmButton>
</DialogActions>
</>
diff --git a/saleor/static/dashboard-next/collections/components/CollectionProducts/CollectionProducts.tsx b/saleor/static/dashboard-next/collections/components/CollectionProducts/CollectionProducts.tsx
index e62f8f200b..50b311954f 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionProducts/CollectionProducts.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionProducts/CollectionProducts.tsx
@@ -102,7 +102,7 @@ const CollectionProducts = withStyles(styles, { name: "CollectionProducts" })(
<TableFooter>
<TableRow>
<TablePagination
- colSpan={4}
+ colSpan={5}
hasNextPage={maybe(() => pageInfo.hasNextPage)}
onNextPage={onNextPage}
hasPreviousPage={maybe(() => pageInfo.hasPreviousPage)}
@@ -149,6 +149,7 @@ const CollectionProducts = withStyles(styles, { name: "CollectionProducts" })(
</TableCell>
<TableCell className={classes.iconCell}>
<IconButton
+ disabled={!product}
onClick={event => onProductUnassign(product.id, event)}
>
<DeleteIcon color="secondary" />
@@ -159,7 +160,7 @@ const CollectionProducts = withStyles(styles, { name: "CollectionProducts" })(
() => (
<TableRow>
<TableCell />
- <TableCell colSpan={4}>{i18n.t("No products found")}</TableCell>
+ <TableCell colSpan={5}>{i18n.t("No products found")}</TableCell>
</TableRow>
)
)}
diff --git a/saleor/static/dashboard-next/collections/mutations.ts b/saleor/static/dashboard-next/collections/mutations.ts
index 89337f0f20..4caf528fd5 100644
--- a/saleor/static/dashboard-next/collections/mutations.ts
+++ b/saleor/static/dashboard-next/collections/mutations.ts
@@ -87,17 +87,20 @@ const assignCollectionProduct = gql`
${collectionProductFragment}
mutation CollectionAssignProduct(
$collectionId: ID!
- $productId: ID!
- $first: Int!
+ $productIds: [ID!]!
+ $first: Int
+ $after: String
+ $last: Int
+ $before: String
) {
- collectionAddProducts(collectionId: $collectionId, products: [$productId]) {
+ collectionAddProducts(collectionId: $collectionId, products: $productIds) {
errors {
field
message
}
collection {
id
- products(first: $first) {
+ products(first: $first, after: $after, before: $before, last: $last) {
edges {
node {
...CollectionProductFragment
diff --git a/saleor/static/dashboard-next/collections/queries.ts b/saleor/static/dashboard-next/collections/queries.ts
index de9c345707..54627f6650 100644
--- a/saleor/static/dashboard-next/collections/queries.ts
+++ b/saleor/static/dashboard-next/collections/queries.ts
@@ -33,7 +33,7 @@ export const collectionDetailsFragment = gql`
description
seoDescription
seoTitle
- isPublisheds
+ isPublished
}
`;
diff --git a/saleor/static/dashboard-next/collections/types/CollectionAssignProduct.ts b/saleor/static/dashboard-next/collections/types/CollectionAssignProduct.ts
index 1dd86d2747..2e1b247750 100644
--- a/saleor/static/dashboard-next/collections/types/CollectionAssignProduct.ts
+++ b/saleor/static/dashboard-next/collections/types/CollectionAssignProduct.ts
@@ -17,13 +17,18 @@ export interface CollectionAssignProduct_collectionAddProducts_collection_produc
name: string;
}
+export interface CollectionAssignProduct_collectionAddProducts_collection_products_edges_node_thumbnail {
+ __typename: "Image";
+ url: string;
+}
+
export interface CollectionAssignProduct_collectionAddProducts_collection_products_edges_node {
__typename: "Product";
id: string;
isPublished: boolean;
name: string;
productType: CollectionAssignProduct_collectionAddProducts_collection_products_edges_node_productType;
- thumbnailUrl: string | null;
+ thumbnail: CollectionAssignProduct_collectionAddProducts_collection_products_edges_node_thumbnail | null;
}
export interface CollectionAssignProduct_collectionAddProducts_collection_products_edges {
@@ -63,6 +68,9 @@ export interface CollectionAssignProduct {
export interface CollectionAssignProductVariables {
collectionId: string;
- productId: string;
- first: number;
+ productIds: string[];
+ first?: number | null;
+ after?: string | null;
+ last?: number | null;
+ before?: string | null;
}
diff --git a/saleor/static/dashboard-next/collections/types/CollectionProductFragment.ts b/saleor/static/dashboard-next/collections/types/CollectionProductFragment.ts
new file mode 100644
index 0000000000..4c7855af8e
--- /dev/null
+++ b/saleor/static/dashboard-next/collections/types/CollectionProductFragment.ts
@@ -0,0 +1,26 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+// ====================================================
+// GraphQL fragment: CollectionProductFragment
+// ====================================================
+
+export interface CollectionProductFragment_productType {
+ __typename: "ProductType";
+ id: string;
+ name: string;
+}
+
+export interface CollectionProductFragment_thumbnail {
+ __typename: "Image";
+ url: string;
+}
+
+export interface CollectionProductFragment {
+ __typename: "Product";
+ id: string;
+ isPublished: boolean;
+ name: string;
+ productType: CollectionProductFragment_productType;
+ thumbnail: CollectionProductFragment_thumbnail | null;
+}
diff --git a/saleor/static/dashboard-next/collections/types/SearchProducts.ts b/saleor/static/dashboard-next/collections/types/SearchProducts.ts
index 5c4ed5e18e..495338a8ed 100644
--- a/saleor/static/dashboard-next/collections/types/SearchProducts.ts
+++ b/saleor/static/dashboard-next/collections/types/SearchProducts.ts
@@ -5,10 +5,24 @@
// GraphQL query operation: SearchProducts
// ====================================================
+export interface SearchProducts_products_edges_node_productType {
+ __typename: "ProductType";
+ id: string;
+ name: string;
+}
+
+export interface SearchProducts_products_edges_node_thumbnail {
+ __typename: "Image";
+ url: string;
+}
+
export interface SearchProducts_products_edges_node {
__typename: "Product";
id: string;
+ isPublished: boolean;
name: string;
+ productType: SearchProducts_products_edges_node_productType;
+ thumbnail: SearchProducts_products_edges_node_thumbnail | null;
}
export interface SearchProducts_products_edges {
diff --git a/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx b/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx
index b5bcc29503..5940e5c4bd 100644
--- a/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx
+++ b/saleor/static/dashboard-next/collections/views/CollectionDetails.tsx
@@ -52,342 +52,332 @@ export const CollectionDetails: React.StatelessComponent<
<Navigator>
{navigate => {
const paginationState = createPaginationState(PAGINATE_BY, params);
+
return (
- <SearchProductsProvider>
- {(searchProducts, searchProductsOpts) => (
- <TypedCollectionDetailsQuery
- displayLoader
- variables={{ id, ...paginationState }}
- require={["collection"]}
- >
- {({ data, loading }) => {
- const handleCollectionUpdate = (data: CollectionUpdate) => {
- if (
- data.collectionUpdate.errors === null ||
- data.collectionUpdate.errors.length === 0
- ) {
- pushMessage({
- text: i18n.t("Updated collection", {
- context: "notification"
- })
- });
- navigate(collectionUrl(id));
- }
- };
+ <TypedCollectionDetailsQuery
+ displayLoader
+ variables={{ id, ...paginationState }}
+ require={["collection"]}
+ >
+ {({ data, loading }) => {
+ const handleCollectionUpdate = (data: CollectionUpdate) => {
+ if (
+ data.collectionUpdate.errors === null ||
+ data.collectionUpdate.errors.length === 0
+ ) {
+ pushMessage({
+ text: i18n.t("Updated collection", {
+ context: "notification"
+ })
+ });
+ navigate(collectionUrl(id));
+ }
+ };
- const handleProductAssign = (
- data: CollectionAssignProduct
- ) => {
- if (
- data.collectionAddProducts.errors === null ||
- data.collectionAddProducts.errors.length === 0
- ) {
- pushMessage({
- text: i18n.t("Added product to collection", {
- context: "notification"
- })
- });
- navigate(collectionUrl(id), true);
- }
- };
+ const handleProductAssign = (data: CollectionAssignProduct) => {
+ if (
+ data.collectionAddProducts.errors === null ||
+ data.collectionAddProducts.errors.length === 0
+ ) {
+ pushMessage({
+ text: i18n.t("Added product to collection", {
+ context: "notification"
+ })
+ });
+ navigate(collectionUrl(id), true);
+ }
+ };
- const handleProductUnassign = (
- data: UnassignCollectionProduct
- ) => {
- if (
- data.collectionRemoveProducts.errors === null ||
- data.collectionRemoveProducts.errors.length === 0
- ) {
- pushMessage({
- text: i18n.t("Removed product from collection", {
- context: "notification"
- })
- });
- }
- };
+ const handleProductUnassign = (
+ data: UnassignCollectionProduct
+ ) => {
+ if (
+ data.collectionRemoveProducts.errors === null ||
+ data.collectionRemoveProducts.errors.length === 0
+ ) {
+ pushMessage({
+ text: i18n.t("Removed product from collection", {
+ context: "notification"
+ })
+ });
+ }
+ };
- const handleCollectionRemove = (data: RemoveCollection) => {
- if (
- data.collectionDelete.errors === null ||
- data.collectionDelete.errors.length === 0
- ) {
- pushMessage({
- text: i18n.t("Removed collection", {
- context: "notification"
- })
- });
- navigate(collectionListUrl);
- }
- };
- return (
- <CollectionOperations
- onUpdate={handleCollectionUpdate}
- onProductAssign={handleProductAssign}
- onProductUnassign={handleProductUnassign}
- onRemove={handleCollectionRemove}
- >
- {({
- updateCollection,
- updateCollectionWithHomepage,
- assignProduct,
- unassignProduct,
- removeCollection
- }) => {
- const handleSubmit = (
- formData: CollectionDetailsPageFormData
- ) => {
- const input = {
- backgroundImageAlt: formData.backgroundImageAlt,
- description: formData.description,
- isPublished: formData.isPublished,
- name: formData.name,
- seo: {
- description: formData.seoDescription,
- title: formData.seoTitle
- }
- };
- const isFeatured = data.shop.homepageCollection
- ? data.shop.homepageCollection.id ===
- data.collection.id
- : false;
+ const handleCollectionRemove = (data: RemoveCollection) => {
+ if (
+ data.collectionDelete.errors === null ||
+ data.collectionDelete.errors.length === 0
+ ) {
+ pushMessage({
+ text: i18n.t("Removed collection", {
+ context: "notification"
+ })
+ });
+ navigate(collectionListUrl);
+ }
+ };
+ return (
+ <CollectionOperations
+ onUpdate={handleCollectionUpdate}
+ onProductAssign={handleProductAssign}
+ onProductUnassign={handleProductUnassign}
+ onRemove={handleCollectionRemove}
+ >
+ {({
+ updateCollection,
+ updateCollectionWithHomepage,
+ assignProduct,
+ unassignProduct,
+ removeCollection
+ }) => {
+ const handleSubmit = (
+ formData: CollectionDetailsPageFormData
+ ) => {
+ const input = {
+ backgroundImageAlt: formData.backgroundImageAlt,
+ description: formData.description,
+ isPublished: formData.isPublished,
+ name: formData.name,
+ seo: {
+ description: formData.seoDescription,
+ title: formData.seoTitle
+ }
+ };
+ const isFeatured = data.shop.homepageCollection
+ ? data.shop.homepageCollection.id ===
+ data.collection.id
+ : false;
- if (formData.isFeatured !== isFeatured) {
- updateCollectionWithHomepage.mutate({
- homepageId: formData.isFeatured ? id : null,
- id,
- input
- });
- } else {
- updateCollection.mutate({
- id,
- input
- });
- }
- };
+ if (formData.isFeatured !== isFeatured) {
+ updateCollectionWithHomepage.mutate({
+ homepageId: formData.isFeatured ? id : null,
+ id,
+ input
+ });
+ } else {
+ updateCollection.mutate({
+ id,
+ input
+ });
+ }
+ };
- const formTransitionState = getMutationState(
- updateCollection.opts.called ||
- updateCollectionWithHomepage.opts.called,
- updateCollection.opts.loading ||
- updateCollectionWithHomepage.opts.loading,
- maybe(
- () =>
- updateCollection.opts.data.collectionUpdate
- .errors
- ),
- maybe(
- () =>
- updateCollectionWithHomepage.opts.data
- .collectionUpdate.errors
- ),
- maybe(
- () =>
- updateCollectionWithHomepage.opts.data
- .homepageCollectionUpdate.errors
- )
- );
- const assignTransitionState = getMutationState(
- assignProduct.opts.called,
- assignProduct.opts.loading,
- maybe(
- () =>
- assignProduct.opts.data.collectionAddProducts
- .errors
- )
- );
- const removeTransitionState = getMutationState(
- removeCollection.opts.called,
- removeCollection.opts.loading,
- maybe(
- () =>
- removeCollection.opts.data.collectionDelete
- .errors
- )
- );
- const imageRemoveTransitionState = getMutationState(
- updateCollection.opts.called,
- updateCollection.opts.loading,
- maybe(
- () =>
- updateCollection.opts.data.collectionUpdate
- .errors
- )
- );
+ const formTransitionState = getMutationState(
+ updateCollection.opts.called ||
+ updateCollectionWithHomepage.opts.called,
+ updateCollection.opts.loading ||
+ updateCollectionWithHomepage.opts.loading,
+ maybe(
+ () =>
+ updateCollection.opts.data.collectionUpdate.errors
+ ),
+ maybe(
+ () =>
+ updateCollectionWithHomepage.opts.data
+ .collectionUpdate.errors
+ ),
+ maybe(
+ () =>
+ updateCollectionWithHomepage.opts.data
+ .homepageCollectionUpdate.errors
+ )
+ );
+ const assignTransitionState = getMutationState(
+ assignProduct.opts.called,
+ assignProduct.opts.loading,
+ maybe(
+ () =>
+ assignProduct.opts.data.collectionAddProducts.errors
+ )
+ );
+ const removeTransitionState = getMutationState(
+ removeCollection.opts.called,
+ removeCollection.opts.loading,
+ maybe(
+ () =>
+ removeCollection.opts.data.collectionDelete.errors
+ )
+ );
+ const imageRemoveTransitionState = getMutationState(
+ updateCollection.opts.called,
+ updateCollection.opts.loading,
+ maybe(
+ () =>
+ updateCollection.opts.data.collectionUpdate.errors
+ )
+ );
- return (
- <>
- <WindowTitle
- title={maybe(() => data.collection.name)}
- />
- <Paginator
- pageInfo={maybe(
- () => data.collection.products.pageInfo
+ return (
+ <>
+ <WindowTitle
+ title={maybe(() => data.collection.name)}
+ />
+ <Paginator
+ pageInfo={maybe(
+ () => data.collection.products.pageInfo
+ )}
+ paginationState={paginationState}
+ queryString={params}
+ >
+ {({ loadNextPage, loadPreviousPage, pageInfo }) => (
+ <CollectionDetailsPage
+ onAdd={() =>
+ navigate(
+ collectionAddProductUrl(id),
+ false,
+ true
+ )
+ }
+ onBack={() => navigate(collectionListUrl)}
+ disabled={loading}
+ collection={data.collection}
+ isFeatured={maybe(
+ () =>
+ data.shop.homepageCollection.id ===
+ data.collection.id,
+ false
)}
- paginationState={paginationState}
- queryString={params}
- >
- {({
- loadNextPage,
- loadPreviousPage,
- pageInfo
- }) => (
- <CollectionDetailsPage
- onAdd={() =>
- navigate(
- collectionAddProductUrl(id),
- false,
- true
- )
- }
- onBack={() => navigate(collectionListUrl)}
- disabled={loading}
- collection={maybe(() => data.collection)}
- isFeatured={maybe(
- () =>
- data.shop.homepageCollection.id ===
- data.collection.id,
- false
- )}
- onCollectionRemove={() =>
- navigate(
- collectionRemoveUrl(id),
- false,
- true
- )
+ onCollectionRemove={() =>
+ navigate(collectionRemoveUrl(id), false, true)
+ }
+ onImageDelete={() =>
+ navigate(
+ collectionImageRemoveUrl(id),
+ false,
+ true
+ )
+ }
+ onImageUpload={event =>
+ updateCollection.mutate({
+ id,
+ input: {
+ backgroundImage: event.target.files[0]
}
- onImageDelete={() =>
- navigate(
- collectionImageRemoveUrl(id),
- false,
- true
- )
- }
- onImageUpload={event =>
- updateCollection.mutate({
- id,
- input: {
- backgroundImage: event.target.files[0]
- }
- })
- }
- onSubmit={handleSubmit}
- onNextPage={loadNextPage}
- onPreviousPage={loadPreviousPage}
- pageInfo={pageInfo}
- onProductUnassign={(productId, event) => {
- event.stopPropagation();
- unassignProduct.mutate({
- collectionId: id,
- productId,
- ...paginationState
- });
- }}
- onRowClick={id => () =>
- navigate(productUrl(id))}
- saveButtonBarState={formTransitionState}
- />
- )}
- </Paginator>
- <Route
- path={collectionAddProductPath(":id")}
- render={({ match }) => (
+ })
+ }
+ onSubmit={handleSubmit}
+ onNextPage={loadNextPage}
+ onPreviousPage={loadPreviousPage}
+ pageInfo={pageInfo}
+ onProductUnassign={(productId, event) => {
+ event.stopPropagation();
+ unassignProduct.mutate({
+ collectionId: id,
+ productId,
+ ...paginationState
+ });
+ }}
+ onRowClick={id => () =>
+ navigate(productUrl(id))}
+ saveButtonBarState={formTransitionState}
+ />
+ )}
+ </Paginator>
+ <Route
+ path={collectionAddProductPath(":id")}
+ render={({ match }) => (
+ <SearchProductsProvider>
+ {(searchProducts, searchProductsOpts) => (
<CollectionAssignProductDialog
confirmButtonState={assignTransitionState}
open={!!match}
- fetch={searchProducts}
+ onFetch={searchProducts}
loading={searchProductsOpts.loading}
onClose={() =>
navigate(collectionUrl(id), true, true)
}
- onSubmit={product =>
+ onSubmit={formData =>
assignProduct.mutate({
+ ...paginationState,
collectionId: id,
- first: PAGINATE_BY,
- productId: product.product.value
+ productIds: formData.products.map(
+ product => product.id
+ )
})
}
products={maybe(() =>
- searchProductsOpts.data.products.edges.map(
- edge => edge.node
- )
+ searchProductsOpts.data.products.edges
+ .map(edge => edge.node)
+ .filter(
+ suggestedProduct =>
+ suggestedProduct.id
+ )
)}
/>
)}
- />
- <Route
- path={collectionRemovePath(":id")}
- render={({ match }) => (
- <ActionDialog
- confirmButtonState={removeTransitionState}
- onClose={() =>
- navigate(collectionUrl(id), true, true)
- }
- onConfirm={() =>
- removeCollection.mutate({ id })
- }
- open={!!match}
- title={i18n.t("Remove collection", {
- context: "modal title"
- })}
- variant="delete"
- >
- <DialogContentText
- dangerouslySetInnerHTML={{
- __html: i18n.t(
- "Are you sure you want to remove <strong>{{ collectionName }}</strong>?",
- {
- collectionName: maybe(
- () => data.collection.name
- ),
- context: "modal"
- }
- )
- }}
- />
- </ActionDialog>
- )}
- />
- <Route
- path={collectionImageRemovePath(":id")}
- render={({ match }) => (
- <ActionDialog
- confirmButtonState={
- imageRemoveTransitionState
- }
- onClose={() =>
- navigate(collectionUrl(id), true, true)
- }
- onConfirm={() =>
- updateCollection.mutate({
- id,
- input: {
- backgroundImage: null
- }
- })
+ </SearchProductsProvider>
+ )}
+ />
+ <Route
+ path={collectionRemovePath(":id")}
+ render={({ match }) => (
+ <ActionDialog
+ confirmButtonState={removeTransitionState}
+ onClose={() =>
+ navigate(collectionUrl(id), true, true)
+ }
+ onConfirm={() =>
+ removeCollection.mutate({ id })
+ }
+ open={!!match}
+ title={i18n.t("Remove collection", {
+ context: "modal title"
+ })}
+ variant="delete"
+ >
+ <DialogContentText
+ dangerouslySetInnerHTML={{
+ __html: i18n.t(
+ "Are you sure you want to remove <strong>{{ collectionName }}</strong>?",
+ {
+ collectionName: maybe(
+ () => data.collection.name
+ ),
+ context: "modal"
+ }
+ )
+ }}
+ />
+ </ActionDialog>
+ )}
+ />
+ <Route
+ path={collectionImageRemovePath(":id")}
+ render={({ match }) => (
+ <ActionDialog
+ confirmButtonState={imageRemoveTransitionState}
+ onClose={() =>
+ navigate(collectionUrl(id), true, true)
+ }
+ onConfirm={() =>
+ updateCollection.mutate({
+ id,
+ input: {
+ backgroundImage: null
}
- open={!!match}
- title={i18n.t("Remove collection", {
- context: "modal title"
- })}
- variant="delete"
- >
- <DialogContentText>
- {i18n.t(
- "Are you sure you want to remove collection's image?"
- )}
- </DialogContentText>
- </ActionDialog>
- )}
- />
- </>
- );
- }}
- </CollectionOperations>
- );
- }}
- </TypedCollectionDetailsQuery>
- )}
- </SearchProductsProvider>
+ })
+ }
+ open={!!match}
+ title={i18n.t("Remove collection", {
+ context: "modal title"
+ })}
+ variant="delete"
+ >
+ <DialogContentText>
+ {i18n.t(
+ "Are you sure you want to remove collection's image?"
+ )}
+ </DialogContentText>
+ </ActionDialog>
+ )}
+ />
+ </>
+ );
+ }}
+ </CollectionOperations>
+ );
+ }}
+ </TypedCollectionDetailsQuery>
);
}}
</Navigator>
diff --git a/saleor/static/dashboard-next/components/DebounceForm.tsx b/saleor/static/dashboard-next/components/DebounceForm.tsx
index fdf681c0d6..0742aa50b5 100644
--- a/saleor/static/dashboard-next/components/DebounceForm.tsx
+++ b/saleor/static/dashboard-next/components/DebounceForm.tsx
@@ -24,3 +24,4 @@ export const DebounceForm: React.StatelessComponent<DebounceFormProps> = ({
}
</Debounce>
);
+export default DebounceForm;