Skip to content

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

Add product unassigning

dominik-zeglen69e94fa73be0
diff --git a/saleor/static/dashboard-next/discounts/components/DiscountProducts/DiscountProducts.tsx b/saleor/static/dashboard-next/discounts/components/DiscountProducts/DiscountProducts.tsx
index 7f1dedcea8..dbc01ede1a 100644
--- a/saleor/static/dashboard-next/discounts/components/DiscountProducts/DiscountProducts.tsx
+++ b/saleor/static/dashboard-next/discounts/components/DiscountProducts/DiscountProducts.tsx
@@ -1,12 +1,19 @@
import Button from "@material-ui/core/Button";
import Card from "@material-ui/core/Card";
-import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
+import IconButton from "@material-ui/core/IconButton";
+import {
+ createStyles,
+ Theme,
+ 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 TableFooter from "@material-ui/core/TableFooter";
import TableHead from "@material-ui/core/TableHead";
import TableRow from "@material-ui/core/TableRow";
+import DeleteIcon from "@material-ui/icons/Delete";
import * as React from "react";
import CardTitle from "../../../components/CardTitle";
@@ -23,19 +30,27 @@ import { VoucherDetails_voucher } from "../../types/VoucherDetails";
export interface SaleProductsProps extends ListProps {
discount: SaleDetails_sale | VoucherDetails_voucher;
onProductAssign: () => void;
+ onProductUnassign: (id: string) => void;
}
-const styles = createStyles({
- tableRow: {
- cursor: "pointer"
- },
- textRight: {
- textAlign: "right"
- },
- wideColumn: {
- width: "40%"
- }
-});
+const styles = (theme: Theme) =>
+ createStyles({
+ iconCell: {
+ "&:last-child": {
+ paddingRight: 0
+ },
+ width: 48 + theme.spacing.unit / 2
+ },
+ tableRow: {
+ cursor: "pointer"
+ },
+ textRight: {
+ textAlign: "right"
+ },
+ wideColumn: {
+ width: "40%"
+ }
+ });
const DiscountProducts = withStyles(styles, {
name: "DiscountProducts"
})(
@@ -47,6 +62,7 @@ const DiscountProducts = withStyles(styles, {
onRowClick,
onPreviousPage,
onProductAssign,
+ onProductUnassign,
onNextPage
}: SaleProductsProps & WithStyles<typeof styles>) => (
<Card>
@@ -73,6 +89,7 @@ const DiscountProducts = withStyles(styles, {
<TableCell className={classes.textRight}>
{i18n.t("Published")}
</TableCell>
+ <TableCell />
</TableRow>
</TableHead>
<TableFooter>
@@ -126,6 +143,17 @@ const DiscountProducts = withStyles(styles, {
<Skeleton />
)}
</TableCell>
+ <TableCell className={classes.iconCell}>
+ <IconButton
+ disabled={!product || disabled}
+ onClick={event => {
+ event.stopPropagation();
+ onProductUnassign(product.id);
+ }}
+ >
+ <DeleteIcon color="secondary" />
+ </IconButton>
+ </TableCell>
</TableRow>
),
() => (
diff --git a/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx b/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx
index d11af87b2e..27368ea033 100644
--- a/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx
+++ b/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx
@@ -53,6 +53,7 @@ export interface SaleDetailsPageProps
onCategoryAssign: () => void;
onCategoryClick: (id: string) => () => void;
onCollectionAssign: () => void;
+ onProductUnassign: (id: string) => void;
onCollectionClick: (id: string) => () => void;
onProductAssign: () => void;
onProductClick: (id: string) => () => void;
@@ -84,6 +85,7 @@ const SaleDetailsPage: React.StatelessComponent<SaleDetailsPageProps> = ({
onNextPage,
onPreviousPage,
onProductAssign,
+ onProductUnassign,
onProductClick
}) => {
const initialForm: FormData = {
@@ -177,6 +179,7 @@ const SaleDetailsPage: React.StatelessComponent<SaleDetailsPageProps> = ({
onNextPage={onNextPage}
onPreviousPage={onPreviousPage}
onProductAssign={onProductAssign}
+ onProductUnassign={onProductUnassign}
onRowClick={onProductClick}
pageInfo={pageInfo}
discount={sale}
diff --git a/saleor/static/dashboard-next/discounts/mutations.ts b/saleor/static/dashboard-next/discounts/mutations.ts
index 94836b7f6e..1dea22fd00 100644
--- a/saleor/static/dashboard-next/discounts/mutations.ts
+++ b/saleor/static/dashboard-next/discounts/mutations.ts
@@ -6,6 +6,10 @@ import {
SaleCataloguesAdd,
SaleCataloguesAddVariables
} from "./types/SaleCataloguesAdd";
+import {
+ SaleCataloguesRemove,
+ SaleCataloguesRemoveVariables
+} from "./types/SaleCataloguesRemove";
import { SaleUpdate, SaleUpdateVariables } from "./types/SaleUpdate";
const saleUpdate = gql`
@@ -51,3 +55,29 @@ export const TypedSaleCataloguesAdd = TypedMutation<
SaleCataloguesAdd,
SaleCataloguesAddVariables
>(saleCataloguesAdd);
+
+const saleCataloguesRemove = gql`
+ ${saleDetailsFragment}
+ mutation SaleCataloguesRemove(
+ $input: CatalogueInput!
+ $id: ID!
+ $after: String
+ $before: String
+ $first: Int
+ $last: Int
+ ) {
+ saleCataloguesRemove(id: $id, input: $input) {
+ errors {
+ field
+ message
+ }
+ sale {
+ ...SaleDetailsFragment
+ }
+ }
+ }
+`;
+export const TypedSaleCataloguesRemove = TypedMutation<
+ SaleCataloguesRemove,
+ SaleCataloguesRemoveVariables
+>(saleCataloguesRemove);
diff --git a/saleor/static/dashboard-next/discounts/types/SaleCataloguesRemove.ts b/saleor/static/dashboard-next/discounts/types/SaleCataloguesRemove.ts
new file mode 100644
index 0000000000..210fbde0ce
--- /dev/null
+++ b/saleor/static/dashboard-next/discounts/types/SaleCataloguesRemove.ts
@@ -0,0 +1,150 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+import { CatalogueInput, SaleType } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL mutation operation: SaleCataloguesRemove
+// ====================================================
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_errors {
+ __typename: "Error";
+ field: string | null;
+ message: string | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_products_edges_node_productType {
+ __typename: "ProductType";
+ id: string;
+ name: string;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_products_edges_node_thumbnail {
+ __typename: "Image";
+ url: string;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_products_edges_node {
+ __typename: "Product";
+ id: string;
+ name: string;
+ isPublished: boolean;
+ productType: SaleCataloguesRemove_saleCataloguesRemove_sale_products_edges_node_productType;
+ thumbnail: SaleCataloguesRemove_saleCataloguesRemove_sale_products_edges_node_thumbnail | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_products_edges {
+ __typename: "ProductCountableEdge";
+ node: SaleCataloguesRemove_saleCataloguesRemove_sale_products_edges_node;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_products_pageInfo {
+ __typename: "PageInfo";
+ endCursor: string | null;
+ hasNextPage: boolean;
+ hasPreviousPage: boolean;
+ startCursor: string | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_products {
+ __typename: "ProductCountableConnection";
+ edges: SaleCataloguesRemove_saleCataloguesRemove_sale_products_edges[];
+ pageInfo: SaleCataloguesRemove_saleCataloguesRemove_sale_products_pageInfo;
+ totalCount: number | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_categories_edges_node_products {
+ __typename: "ProductCountableConnection";
+ totalCount: number | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_categories_edges_node {
+ __typename: "Category";
+ id: string;
+ name: string;
+ products: SaleCataloguesRemove_saleCataloguesRemove_sale_categories_edges_node_products | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_categories_edges {
+ __typename: "CategoryCountableEdge";
+ node: SaleCataloguesRemove_saleCataloguesRemove_sale_categories_edges_node;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_categories_pageInfo {
+ __typename: "PageInfo";
+ endCursor: string | null;
+ hasNextPage: boolean;
+ hasPreviousPage: boolean;
+ startCursor: string | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_categories {
+ __typename: "CategoryCountableConnection";
+ edges: SaleCataloguesRemove_saleCataloguesRemove_sale_categories_edges[];
+ pageInfo: SaleCataloguesRemove_saleCataloguesRemove_sale_categories_pageInfo;
+ totalCount: number | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_collections_edges_node_products {
+ __typename: "ProductCountableConnection";
+ totalCount: number | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_collections_edges_node {
+ __typename: "Collection";
+ id: string;
+ name: string;
+ products: SaleCataloguesRemove_saleCataloguesRemove_sale_collections_edges_node_products | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_collections_edges {
+ __typename: "CollectionCountableEdge";
+ node: SaleCataloguesRemove_saleCataloguesRemove_sale_collections_edges_node;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_collections_pageInfo {
+ __typename: "PageInfo";
+ endCursor: string | null;
+ hasNextPage: boolean;
+ hasPreviousPage: boolean;
+ startCursor: string | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale_collections {
+ __typename: "CollectionCountableConnection";
+ edges: SaleCataloguesRemove_saleCataloguesRemove_sale_collections_edges[];
+ pageInfo: SaleCataloguesRemove_saleCataloguesRemove_sale_collections_pageInfo;
+ totalCount: number | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove_sale {
+ __typename: "Sale";
+ id: string;
+ name: string;
+ type: SaleType;
+ startDate: any;
+ endDate: any | null;
+ value: number;
+ products: SaleCataloguesRemove_saleCataloguesRemove_sale_products | null;
+ categories: SaleCataloguesRemove_saleCataloguesRemove_sale_categories | null;
+ collections: SaleCataloguesRemove_saleCataloguesRemove_sale_collections | null;
+}
+
+export interface SaleCataloguesRemove_saleCataloguesRemove {
+ __typename: "SaleRemoveCatalogues";
+ errors: SaleCataloguesRemove_saleCataloguesRemove_errors[] | null;
+ sale: SaleCataloguesRemove_saleCataloguesRemove_sale | null;
+}
+
+export interface SaleCataloguesRemove {
+ saleCataloguesRemove: SaleCataloguesRemove_saleCataloguesRemove | null;
+}
+
+export interface SaleCataloguesRemoveVariables {
+ input: CatalogueInput;
+ id: string;
+ after?: string | null;
+ before?: string | null;
+ first?: number | null;
+ last?: number | null;
+}
diff --git a/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx b/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx
index 01d5f41cc1..805f03ec99 100644
--- a/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx
+++ b/saleor/static/dashboard-next/discounts/views/SaleDetails/index.tsx
@@ -25,7 +25,11 @@ import { DiscountValueTypeEnum, SaleType } from "../../../types/globalTypes";
import SaleDetailsPage, {
SaleDetailsPageTab
} from "../../components/SaleDetailsPage";
-import { TypedSaleCataloguesAdd, TypedSaleUpdate } from "../../mutations";
+import {
+ TypedSaleCataloguesAdd,
+ TypedSaleUpdate,
+ TypedSaleCataloguesRemove
+} from "../../mutations";
import { TypedSaleDetails } from "../../queries";
import { SaleCataloguesAdd } from "../../types/SaleCataloguesAdd";
import { saleListUrl, saleUrl } from "../../urls";
@@ -93,262 +97,304 @@ export const SaleDetails: React.StatelessComponent<SaleDetailsProps> = ({
};
return (
- <TypedSaleCataloguesAdd onCompleted={handleProductAssign}>
- {(saleCataloguesAdd, saleCataloguesAddOpts) => (
- <TypedSaleUpdate>
- {(saleUpdate, saleUpdateOpts) => (
- <TypedSaleDetails
- displayLoader
- variables={{ id, ...paginationState }}
- >
- {({ data, loading }) => {
- const pageInfo =
- params.tab === SaleDetailsPageTab.categories
- ? maybe(() => data.sale.categories.pageInfo)
- : params.tab ===
- SaleDetailsPageTab.collections
- ? maybe(() => data.sale.collections.pageInfo)
- : maybe(() => data.sale.products.pageInfo);
- const formTransitionState = getMutationState(
- saleUpdateOpts.called,
- saleUpdateOpts.loading,
- maybe(
- () => saleUpdateOpts.data.saleUpdate.errors
- )
- );
- const assignTransitionState = getMutationState(
- saleCataloguesAddOpts.called,
- saleCataloguesAddOpts.loading,
- maybe(
- () =>
- saleCataloguesAddOpts.data.saleCataloguesAdd
- .errors
- )
- );
+ <TypedSaleCataloguesRemove>
+ {(saleCataloguesRemove, saleCataloguesRemoveOpts) => (
+ <TypedSaleCataloguesAdd onCompleted={handleProductAssign}>
+ {(saleCataloguesAdd, saleCataloguesAddOpts) => (
+ <TypedSaleUpdate>
+ {(saleUpdate, saleUpdateOpts) => (
+ <TypedSaleDetails
+ displayLoader
+ variables={{ id, ...paginationState }}
+ >
+ {({ data, loading }) => {
+ const pageInfo =
+ params.tab === SaleDetailsPageTab.categories
+ ? maybe(
+ () => data.sale.categories.pageInfo
+ )
+ : params.tab ===
+ SaleDetailsPageTab.collections
+ ? maybe(
+ () => data.sale.collections.pageInfo
+ )
+ : maybe(
+ () => data.sale.products.pageInfo
+ );
+ const formTransitionState = getMutationState(
+ saleUpdateOpts.called,
+ saleUpdateOpts.loading,
+ maybe(
+ () =>
+ saleUpdateOpts.data.saleUpdate.errors
+ )
+ );
+ const assignTransitionState = getMutationState(
+ saleCataloguesAddOpts.called,
+ saleCataloguesAddOpts.loading,
+ maybe(
+ () =>
+ saleCataloguesAddOpts.data
+ .saleCataloguesAdd.errors
+ )
+ );
- return (
- <>
- <Paginator
- pageInfo={pageInfo}
- paginationState={paginationState}
- queryString={params}
- >
- {({
- loadNextPage,
- loadPreviousPage,
- pageInfo
- }) => (
- <SaleDetailsPage
- defaultCurrency={maybe(
- () => shop.defaultCurrency
- )}
- sale={maybe(() => data.sale)}
- disabled={loading}
- errors={maybe(
- () =>
- saleUpdateOpts.data.saleUpdate
- .errors
- )}
+ return (
+ <>
+ <Paginator
pageInfo={pageInfo}
- onNextPage={loadNextPage}
- onPreviousPage={loadPreviousPage}
- onCategoryAssign={() =>
- navigate(
- saleAssignCategoriesUrl(id),
- false,
- true
- )
- }
- onCategoryClick={id => () =>
- navigate(categoryUrl(id))}
- onCollectionAssign={() =>
- navigate(
- saleAssignCollectionsUrl(id),
- false,
- true
- )
- }
- onCollectionClick={id => () =>
- navigate(collectionUrl(id))}
- onProductAssign={() =>
- navigate(
- saleAssignProductsUrl(id),
- false,
- true
- )
- }
- onProductClick={id => () =>
- navigate(productUrl(id))}
- activeTab={params.tab}
- onBack={() => navigate(saleListUrl)}
- onTabClick={changeTab}
- onSubmit={formData =>
- saleUpdate({
- variables: {
- id,
- input: {
- endDate:
- formData.endDate === ""
- ? null
- : formData.endDate,
- name: formData.name,
- startDate: formData.startDate,
- type: discountValueTypeEnum(
- formData.type
- ),
- value: formData.value
- }
+ paginationState={paginationState}
+ queryString={params}
+ >
+ {({
+ loadNextPage,
+ loadPreviousPage,
+ pageInfo
+ }) => (
+ <SaleDetailsPage
+ defaultCurrency={maybe(
+ () => shop.defaultCurrency
+ )}
+ sale={maybe(() => data.sale)}
+ disabled={
+ loading ||
+ saleCataloguesRemoveOpts.loading
}
- })
- }
- saveButtonBarState={formTransitionState}
- />
- )}
- </Paginator>
- <Route
- path={saleAssignProductsPath(":id")}
- render={({ match }) => (
- <SearchProductsProvider>
- {(
- searchProducts,
- searchProductsOpts
- ) => (
- <AssignProductDialog
- confirmButtonState={
- assignTransitionState
+ errors={maybe(
+ () =>
+ saleUpdateOpts.data.saleUpdate
+ .errors
+ )}
+ pageInfo={pageInfo}
+ onNextPage={loadNextPage}
+ onPreviousPage={loadPreviousPage}
+ onCategoryAssign={() =>
+ navigate(
+ saleAssignCategoriesUrl(id),
+ false,
+ true
+ )
}
- open={!!match}
- onFetch={searchProducts}
- loading={searchProductsOpts.loading}
- onClose={() =>
- navigate(saleUrl(id), true, true)
+ onCategoryClick={id => () =>
+ navigate(categoryUrl(id))}
+ onCollectionAssign={() =>
+ navigate(
+ saleAssignCollectionsUrl(id),
+ false,
+ true
+ )
}
- onSubmit={formData =>
- saleCataloguesAdd({
+ onCollectionClick={id => () =>
+ navigate(collectionUrl(id))}
+ onProductAssign={() =>
+ navigate(
+ saleAssignProductsUrl(id),
+ false,
+ true
+ )
+ }
+ onProductUnassign={productId =>
+ saleCataloguesRemove({
variables: {
...paginationState,
id,
input: {
- products: formData.products.map(
- product => product.id
- )
+ products: [productId]
}
}
})
}
- products={maybe(() =>
- searchProductsOpts.data.products.edges
- .map(edge => edge.node)
- .filter(
- suggestedProduct =>
- suggestedProduct.id
- )
- )}
- />
- )}
- </SearchProductsProvider>
- )}
- />
- <Route
- path={saleAssignCategoriesPath(":id")}
- render={({ match }) => (
- <SearchCategoriesProvider>
- {(
- searchCategories,
- searchCategoriesOpts
- ) => (
- <AssignCategoriesDialog
- categories={maybe(() =>
- searchCategoriesOpts.data.categories.edges
- .map(edge => edge.node)
- .filter(
- suggestedCategory =>
- suggestedCategory.id
- )
- )}
- confirmButtonState={
- assignTransitionState
- }
- open={!!match}
- onFetch={searchCategories}
- loading={
- searchCategoriesOpts.loading
- }
- onClose={() =>
- navigate(saleUrl(id), true, true)
- }
+ onProductClick={id => () =>
+ navigate(productUrl(id))}
+ activeTab={params.tab}
+ onBack={() => navigate(saleListUrl)}
+ onTabClick={changeTab}
onSubmit={formData =>
- saleCataloguesAdd({
+ saleUpdate({
variables: {
- ...paginationState,
id,
input: {
- categories: formData.categories.map(
- product => product.id
- )
+ endDate:
+ formData.endDate === ""
+ ? null
+ : formData.endDate,
+ name: formData.name,
+ startDate:
+ formData.startDate,
+ type: discountValueTypeEnum(
+ formData.type
+ ),
+ value: formData.value
}
}
})
}
+ saveButtonBarState={
+ formTransitionState
+ }
/>
)}
- </SearchCategoriesProvider>
- )}
- />
- <Route
- path={saleAssignCollectionsPath(":id")}
- render={({ match }) => (
- <SearchCollectionsProvider>
- {(
- searchCollections,
- searchCollectionsOpts
- ) => (
- <AssignCollectionDialog
- collections={maybe(() =>
- searchCollectionsOpts.data.collections.edges
- .map(edge => edge.node)
- .filter(
- suggestedCategory =>
- suggestedCategory.id
- )
+ </Paginator>
+ <Route
+ path={saleAssignProductsPath(":id")}
+ render={({ match }) => (
+ <SearchProductsProvider>
+ {(
+ searchProducts,
+ searchProductsOpts
+ ) => (
+ <AssignProductDialog
+ confirmButtonState={
+ assignTransitionState
+ }
+ open={!!match}
+ onFetch={searchProducts}
+ loading={
+ searchProductsOpts.loading
+ }
+ onClose={() =>
+ navigate(
+ saleUrl(id),
+ true,
+ true
+ )
+ }
+ onSubmit={formData =>
+ saleCataloguesAdd({
+ variables: {
+ ...paginationState,
+ id,
+ input: {
+ products: formData.products.map(
+ product => product.id
+ )
+ }
+ }
+ })
+ }
+ products={maybe(() =>
+ searchProductsOpts.data.products.edges
+ .map(edge => edge.node)
+ .filter(
+ suggestedProduct =>
+ suggestedProduct.id
+ )
+ )}
+ />
)}
- confirmButtonState={
- assignTransitionState
- }
- open={!!match}
- onFetch={searchCollections}
- loading={
- searchCollectionsOpts.loading
- }
- onClose={() =>
- navigate(saleUrl(id), true, true)
- }
- onSubmit={formData =>
- saleCataloguesAdd({
- variables: {
- ...paginationState,
- id,
- input: {
- collections: formData.collections.map(
- product => product.id
+ </SearchProductsProvider>
+ )}
+ />
+ <Route
+ path={saleAssignCategoriesPath(":id")}
+ render={({ match }) => (
+ <SearchCategoriesProvider>
+ {(
+ searchCategories,
+ searchCategoriesOpts
+ ) => (
+ <AssignCategoriesDialog
+ categories={maybe(() =>
+ searchCategoriesOpts.data.categories.edges
+ .map(edge => edge.node)
+ .filter(
+ suggestedCategory =>
+ suggestedCategory.id
)
- }
+ )}
+ confirmButtonState={
+ assignTransitionState
}
- })
- }
- />
+ open={!!match}
+ onFetch={searchCategories}
+ loading={
+ searchCategoriesOpts.loading
+ }
+ onClose={() =>
+ navigate(
+ saleUrl(id),
+ true,
+ true
+ )
+ }
+ onSubmit={formData =>
+ saleCataloguesAdd({
+ variables: {
+ ...paginationState,
+ id,
+ input: {
+ categories: formData.categories.map(
+ product => product.id
+ )
+ }
+ }
+ })
+ }
+ />
+ )}
+ </SearchCategoriesProvider>
+ )}
+ />
+ <Route
+ path={saleAssignCollectionsPath(":id")}
+ render={({ match }) => (
+ <SearchCollectionsProvider>
+ {(
+ searchCollections,
+ searchCollectionsOpts
+ ) => (
+ <AssignCollectionDialog
+ collections={maybe(() =>
+ searchCollectionsOpts.data.collections.edges
+ .map(edge => edge.node)
+ .filter(
+ suggestedCategory =>
+ suggestedCategory.id
+ )
+ )}
+ confirmButtonState={
+ assignTransitionState
+ }
+ open={!!match}
+ onFetch={searchCollections}
+ loading={
+ searchCollectionsOpts.loading
+ }
+ onClose={() =>
+ navigate(
+ saleUrl(id),
+ true,
+ true
+ )
+ }
+ onSubmit={formData =>
+ saleCataloguesAdd({
+ variables: {
+ ...paginationState,
+ id,
+ input: {
+ collections: formData.collections.map(
+ product => product.id
+ )
+ }
+ }
+ })
+ }
+ />
+ )}
+ </SearchCollectionsProvider>
)}
- </SearchCollectionsProvider>
- )}
- />
- </>
- );
- }}
- </TypedSaleDetails>
+ />
+ </>
+ );
+ }}
+ </TypedSaleDetails>
+ )}
+ </TypedSaleUpdate>
)}
- </TypedSaleUpdate>
+ </TypedSaleCataloguesAdd>
)}
- </TypedSaleCataloguesAdd>
+ </TypedSaleCataloguesRemove>
);
}}
</Navigator>