Change more usages to map edges to items
This commit is contained in:
parent
e373ce3eaa
commit
b731e7cf89
3 changed files with 23 additions and 42 deletions
|
@ -23,6 +23,7 @@ import { commonMessages } from "@saleor/intl";
|
|||
import useProductSearch from "@saleor/searches/useProductSearch";
|
||||
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
|
||||
import createMetadataUpdateHandler from "@saleor/utils/handlers/metadataUpdateHandler";
|
||||
import { mapEdgesToItems } from "@saleor/utils/maps";
|
||||
import {
|
||||
useMetadataUpdate,
|
||||
usePrivateMetadataUpdate
|
||||
|
@ -361,10 +362,8 @@ export const CollectionDetails: React.FC<CollectionDetailsProps> = ({
|
|||
}
|
||||
})
|
||||
}
|
||||
products={maybe(() =>
|
||||
result.data.search.edges
|
||||
.map(edge => edge.node)
|
||||
.filter(suggestedProduct => suggestedProduct.id)
|
||||
products={mapEdgesToItems(result?.data?.search).filter(
|
||||
suggestedProduct => suggestedProduct.id
|
||||
)}
|
||||
/>
|
||||
<ActionDialog
|
||||
|
|
|
@ -51,6 +51,7 @@ import useCategorySearch from "@saleor/searches/useCategorySearch";
|
|||
import useCollectionSearch from "@saleor/searches/useCollectionSearch";
|
||||
import useProductSearch from "@saleor/searches/useProductSearch";
|
||||
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
|
||||
import { mapEdgesToItems } from "@saleor/utils/maps";
|
||||
import React from "react";
|
||||
import { FormattedMessage, useIntl } from "react-intl";
|
||||
|
||||
|
@ -393,20 +394,14 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
|
|||
}
|
||||
})
|
||||
}
|
||||
products={maybe(() =>
|
||||
searchProductsOpts.data.search.edges
|
||||
.map(edge => edge.node)
|
||||
.filter(suggestedProduct => suggestedProduct.id)
|
||||
)}
|
||||
products={mapEdgesToItems(
|
||||
searchProductsOpts?.data?.search
|
||||
).filter(suggestedProduct => suggestedProduct.id)}
|
||||
/>
|
||||
<AssignCategoriesDialog
|
||||
categories={maybe(() =>
|
||||
searchCategoriesOpts.data.search.edges
|
||||
.map(edge => edge.node)
|
||||
.filter(
|
||||
suggestedCategory => suggestedCategory.id
|
||||
)
|
||||
)}
|
||||
categories={mapEdgesToItems(
|
||||
searchCategoriesOpts?.data?.search
|
||||
).filter(suggestedCategory => suggestedCategory.id)}
|
||||
confirmButtonState={saleCataloguesAddOpts.status}
|
||||
hasMore={
|
||||
searchCategoriesOpts.data?.search.pageInfo
|
||||
|
@ -430,13 +425,9 @@ export const SaleDetails: React.FC<SaleDetailsProps> = ({ id, params }) => {
|
|||
}
|
||||
/>
|
||||
<AssignCollectionDialog
|
||||
collections={maybe(() =>
|
||||
searchCollectionsOpts.data.search.edges
|
||||
.map(edge => edge.node)
|
||||
.filter(
|
||||
suggestedCategory => suggestedCategory.id
|
||||
)
|
||||
)}
|
||||
collections={mapEdgesToItems(
|
||||
searchCollectionsOpts?.data?.search
|
||||
).filter(suggestedCategory => suggestedCategory.id)}
|
||||
confirmButtonState={saleCataloguesAddOpts.status}
|
||||
hasMore={
|
||||
searchCollectionsOpts.data?.search.pageInfo
|
||||
|
|
|
@ -49,6 +49,7 @@ import useCategorySearch from "@saleor/searches/useCategorySearch";
|
|||
import useCollectionSearch from "@saleor/searches/useCollectionSearch";
|
||||
import useProductSearch from "@saleor/searches/useProductSearch";
|
||||
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
|
||||
import { mapEdgesToItems } from "@saleor/utils/maps";
|
||||
import React from "react";
|
||||
import { FormattedMessage, useIntl } from "react-intl";
|
||||
|
||||
|
@ -426,13 +427,9 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
|
|||
toggleAll={toggleAll}
|
||||
/>
|
||||
<AssignCategoriesDialog
|
||||
categories={maybe(() =>
|
||||
searchCategoriesOpts.data.search.edges
|
||||
.map(edge => edge.node)
|
||||
.filter(
|
||||
suggestedCategory => suggestedCategory.id
|
||||
)
|
||||
)}
|
||||
categories={mapEdgesToItems(
|
||||
searchCategoriesOpts?.data?.search
|
||||
).filter(suggestedCategory => suggestedCategory.id)}
|
||||
confirmButtonState={voucherCataloguesAddOpts.status}
|
||||
hasMore={
|
||||
searchCategoriesOpts.data?.search.pageInfo
|
||||
|
@ -456,13 +453,9 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
|
|||
}
|
||||
/>
|
||||
<AssignCollectionDialog
|
||||
collections={maybe(() =>
|
||||
searchCollectionsOpts.data.search.edges
|
||||
.map(edge => edge.node)
|
||||
.filter(
|
||||
suggestedCategory => suggestedCategory.id
|
||||
)
|
||||
)}
|
||||
collections={mapEdgesToItems(
|
||||
searchCollectionsOpts?.data?.search
|
||||
).filter(suggestedCategory => suggestedCategory.id)}
|
||||
confirmButtonState={voucherCataloguesAddOpts.status}
|
||||
hasMore={
|
||||
searchCollectionsOpts.data?.search.pageInfo
|
||||
|
@ -532,11 +525,9 @@ export const VoucherDetails: React.FC<VoucherDetailsProps> = ({
|
|||
}
|
||||
})
|
||||
}
|
||||
products={maybe(() =>
|
||||
searchProductsOpts.data.search.edges
|
||||
.map(edge => edge.node)
|
||||
.filter(suggestedProduct => suggestedProduct.id)
|
||||
)}
|
||||
products={mapEdgesToItems(
|
||||
searchProductsOpts?.data?.search
|
||||
).filter(suggestedProduct => suggestedProduct.id)}
|
||||
/>
|
||||
<ActionDialog
|
||||
open={
|
||||
|
|
Loading…
Reference in a new issue