From b22831ba25f25cd061b8fc613b6387c3bf45d2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=C5=BBegle=C5=84?= Date: Mon, 5 Jul 2021 14:01:58 +0200 Subject: [PATCH] Fix skeletons (#1161) * Fix skeletons * Fix warehouse list displaying * Fix product filters * Fix crashing views * Fix crashes --- src/collections/views/CollectionDetails.tsx | 2 +- src/components/Navigator/modes/catalog.ts | 12 +- src/components/Navigator/useQuickSearch.ts | 2 +- .../views/SaleDetails/SaleDetails.tsx | 10 +- .../views/VoucherDetails/VoucherDetails.tsx | 10 +- src/home/views/index.tsx | 2 +- src/hooks/makeTopLevelSearch/utils.ts | 2 +- src/navigation/views/MenuDetails/index.tsx | 12 +- src/navigation/views/MenuList/MenuList.tsx | 2 +- .../components/OrderReturnPage/utils.tsx | 21 +- .../OrderDetails/OrderNormalDetails/index.tsx | 2 +- src/pageTypes/views/PageTypeDetails.tsx | 2 +- .../views/PageTypeList/PageTypeList.tsx | 20 +- .../views/ProductTypeList/ProductTypeList.tsx | 18 +- .../views/ProductTypeUpdate/index.tsx | 18 +- .../ProductVariantCreatorContent.tsx | 12 +- .../views/ProductCreate/ProductCreate.tsx | 13 +- .../views/ProductList/ProductList.tsx | 23 +- .../views/ProductUpdate/ProductUpdate.tsx | 12 +- src/products/views/ProductVariant.tsx | 7 +- src/products/views/ProductVariantCreate.tsx | 7 +- .../ProductVariantCreator.tsx | 7 +- .../PriceRatesUpdate/PriceRatesUpdate.tsx | 2 +- .../views/ShippingZoneDetails/index.tsx | 2 +- src/shipping/views/ShippingZonesList.tsx | 7 +- .../WeightRatesUpdate/WeightRatesUpdate.tsx | 2 +- .../__snapshots__/Stories.test.ts.snap | 570 +++++++++++++++++- src/utils/maps.ts | 17 +- .../views/WarehouseList/WarehouseList.tsx | 2 +- 29 files changed, 677 insertions(+), 141 deletions(-) diff --git a/src/collections/views/CollectionDetails.tsx b/src/collections/views/CollectionDetails.tsx index 36fe79b6d..b6e9b9d37 100644 --- a/src/collections/views/CollectionDetails.tsx +++ b/src/collections/views/CollectionDetails.tsx @@ -361,7 +361,7 @@ export const CollectionDetails: React.FC = ({ } }) } - products={mapEdgesToItems(result?.data?.search).filter( + products={mapEdgesToItems(result?.data?.search)?.filter( suggestedProduct => suggestedProduct.id )} /> diff --git a/src/components/Navigator/modes/catalog.ts b/src/components/Navigator/modes/catalog.ts index cc613b90d..1dca02b09 100644 --- a/src/components/Navigator/modes/catalog.ts +++ b/src/components/Navigator/modes/catalog.ts @@ -19,8 +19,8 @@ export function searchInCatalog( navigate: UseNavigatorResult, catalog: SearchCatalog ): QuickSearchAction[] { - const categories: QuickSearchActionInput[] = mapEdgesToItems( - catalog?.categories + const categories: QuickSearchActionInput[] = ( + mapEdgesToItems(catalog?.categories) || [] ) .map(category => ({ caption: intl.formatMessage(messages.category), @@ -35,8 +35,8 @@ export function searchInCatalog( })) .sort(sortScores); - const collections: QuickSearchActionInput[] = mapEdgesToItems( - catalog?.collections + const collections: QuickSearchActionInput[] = ( + mapEdgesToItems(catalog?.collections) || [] ) .map(collection => ({ caption: intl.formatMessage(messages.collection), @@ -51,7 +51,9 @@ export function searchInCatalog( })) .sort(sortScores); - const products: QuickSearchActionInput[] = mapEdgesToItems(catalog?.products) + const products: QuickSearchActionInput[] = ( + mapEdgesToItems(catalog?.products) || [] + ) .map(product => ({ caption: intl.formatMessage(messages.product), extraInfo: product.category.name, diff --git a/src/components/Navigator/useQuickSearch.ts b/src/components/Navigator/useQuickSearch.ts index e2be6de52..a5ecf5155 100644 --- a/src/components/Navigator/useQuickSearch.ts +++ b/src/components/Navigator/useQuickSearch.ts @@ -108,7 +108,7 @@ function useQuickSearch( intl, { catalog, - customers: mapEdgesToItems(customers?.data?.search), + customers: mapEdgesToItems(customers?.data?.search) || [], order: maybe(() => orderData.order) }, { diff --git a/src/discounts/views/SaleDetails/SaleDetails.tsx b/src/discounts/views/SaleDetails/SaleDetails.tsx index 81600f199..7ef9a6667 100644 --- a/src/discounts/views/SaleDetails/SaleDetails.tsx +++ b/src/discounts/views/SaleDetails/SaleDetails.tsx @@ -395,12 +395,14 @@ export const SaleDetails: React.FC = ({ id, params }) => { } products={mapEdgesToItems( searchProductsOpts?.data?.search - ).filter(suggestedProduct => suggestedProduct.id)} + )?.filter(suggestedProduct => suggestedProduct.id)} /> suggestedCategory.id)} + )?.filter( + suggestedCategory => suggestedCategory.id + )} confirmButtonState={saleCataloguesAddOpts.status} hasMore={ searchCategoriesOpts.data?.search.pageInfo @@ -426,7 +428,9 @@ export const SaleDetails: React.FC = ({ id, params }) => { suggestedCategory.id)} + )?.filter( + suggestedCategory => suggestedCategory.id + )} confirmButtonState={saleCataloguesAddOpts.status} hasMore={ searchCollectionsOpts.data?.search.pageInfo diff --git a/src/discounts/views/VoucherDetails/VoucherDetails.tsx b/src/discounts/views/VoucherDetails/VoucherDetails.tsx index 9db06115c..5e31131c7 100644 --- a/src/discounts/views/VoucherDetails/VoucherDetails.tsx +++ b/src/discounts/views/VoucherDetails/VoucherDetails.tsx @@ -426,7 +426,9 @@ export const VoucherDetails: React.FC = ({ suggestedCategory.id)} + )?.filter( + suggestedCategory => suggestedCategory.id + )} confirmButtonState={voucherCataloguesAddOpts.status} hasMore={ searchCategoriesOpts.data?.search.pageInfo @@ -452,7 +454,9 @@ export const VoucherDetails: React.FC = ({ suggestedCategory.id)} + )?.filter( + suggestedCategory => suggestedCategory.id + )} confirmButtonState={voucherCataloguesAddOpts.status} hasMore={ searchCollectionsOpts.data?.search.pageInfo @@ -524,7 +528,7 @@ export const VoucherDetails: React.FC = ({ } products={mapEdgesToItems( searchProductsOpts?.data?.search - ).filter(suggestedProduct => suggestedProduct.id)} + )?.filter(suggestedProduct => suggestedProduct.id)} /> { return ( - mapEdgesToItems(data?.search); + mapEdgesToItems(data?.search) || []; diff --git a/src/navigation/views/MenuDetails/index.tsx b/src/navigation/views/MenuDetails/index.tsx index ddc319d76..9343cd58d 100644 --- a/src/navigation/views/MenuDetails/index.tsx +++ b/src/navigation/views/MenuDetails/index.tsx @@ -113,15 +113,13 @@ const MenuDetails: React.FC = ({ id, params }) => { pageSearch.search(query); }; - const categories = mapEdgesToItems( - categorySearch?.result?.data?.search - ); + const categories = + mapEdgesToItems(categorySearch?.result?.data?.search) || []; - const collections = mapEdgesToItems( - collectionSearch?.result?.data?.search - ); + const collections = + mapEdgesToItems(collectionSearch?.result?.data?.search) || []; - const pages = mapEdgesToItems(pageSearch?.result?.data?.search); + const pages = mapEdgesToItems(pageSearch?.result?.data?.search) || []; return ( = ({ params }) => { id="menuListDeleteMenuContent" values={{ menuName: - mapEdgesToItems(data?.menus).find( + mapEdgesToItems(data?.menus)?.find( getById(params.id) )?.name || "..." }} diff --git a/src/orders/components/OrderReturnPage/utils.tsx b/src/orders/components/OrderReturnPage/utils.tsx index b57b2075e..cc8b074ac 100644 --- a/src/orders/components/OrderReturnPage/utils.tsx +++ b/src/orders/components/OrderReturnPage/utils.tsx @@ -3,6 +3,7 @@ import { OrderDetails_order, OrderDetails_order_fulfillments } from "@saleor/orders/types/OrderDetails"; +import { Node } from "@saleor/types"; import { FulfillmentStatus } from "@saleor/types/globalTypes"; import { LineItemOptions } from "./form"; @@ -31,7 +32,7 @@ export const getAllOrderFulfilledLines = (order?: OrderDetails_order) => ); export function getLineItem( - { id }: { id: string }, + { id }: Node, { initialValue, isFulfillment = false, @@ -51,7 +52,7 @@ export function getParsedLineData({ isFulfillment = false, isRefunded = false }: LineItemOptions) { - return (item: { id: string }) => + return (item: Node) => getLineItem(item, { initialValue, isFulfillment, isRefunded }); } @@ -89,16 +90,16 @@ export const getParsedFulfiledLines = ( quantity })); -export const getById = (idToCompare: string) => (obj: { id: string }) => +export const getById = (idToCompare: string) => (obj: Node) => obj.id === idToCompare; export const getByUnmatchingId = (idToCompare: string) => (obj: { id: string; }) => obj.id !== idToCompare; -const isIncludedInIds = function( +const isIncludedInIds = function( arrayToCompare: string[] | T[], - obj: { id: string } + obj: Node ) { const isSimpleIdsArray = (arrayToCompare as string[]).every( value => typeof value === "string" @@ -111,14 +112,12 @@ const isIncludedInIds = function( return idsToCompare.includes(obj.id); }; -export function getByIds( - arrayToCompare: string[] | T[] -) { - return (obj: { id: string }) => isIncludedInIds(arrayToCompare, obj); +export function getByIds(arrayToCompare: string[] | T[]) { + return (obj: Node) => isIncludedInIds(arrayToCompare, obj); } -export function getByUnmatchingIds( +export function getByUnmatchingIds( arrayToCompare: string[] | T[] ) { - return (obj: { id: string }) => !isIncludedInIds(arrayToCompare, obj); + return (obj: Node) => !isIncludedInIds(arrayToCompare, obj); } diff --git a/src/orders/views/OrderDetails/OrderNormalDetails/index.tsx b/src/orders/views/OrderDetails/OrderNormalDetails/index.tsx index 042bcd049..9dd082dae 100644 --- a/src/orders/views/OrderDetails/OrderNormalDetails/index.tsx +++ b/src/orders/views/OrderDetails/OrderNormalDetails/index.tsx @@ -225,7 +225,7 @@ export const OrderNormalDetails: React.FC = ({ orderFulfillmentCancel.opts.data?.orderFulfillmentCancel.errors || [] } open={params.action === "cancel-fulfillment"} - warehouses={mapEdgesToItems(warehouses?.data?.warehouses)} + warehouses={mapEdgesToItems(warehouses?.data?.warehouses) || []} onConfirm={variables => orderFulfillmentCancel.mutate({ id: params.id, diff --git a/src/pageTypes/views/PageTypeDetails.tsx b/src/pageTypes/views/PageTypeDetails.tsx index 53ed9928e..f75bd2893 100644 --- a/src/pageTypes/views/PageTypeDetails.tsx +++ b/src/pageTypes/views/PageTypeDetails.tsx @@ -253,7 +253,7 @@ export const PageTypeDetails: React.FC = ({ }} /> - {!dataLoading && ( + {pageType && ( <> = ({ params }) => { } /> - + {pageTypesData && ( + + )} = ({ params }) => { } /> - + {productTypesData && ( + + )} = ({ key={key} /> ))} - + {productType && ( + + )} )} diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx index 99144349c..60bf3b153 100644 --- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx +++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx @@ -8,9 +8,9 @@ import { isSelected } from "@saleor/utils/lists"; import React from "react"; import { ProductVariantCreateFormData } from "./form"; -import ProductVariantCreatePriceAndSku from "./ProductVariantCreatorPriceAndSku"; -import ProductVariantCreateSummary from "./ProductVariantCreatorSummary"; -import ProductVariantCreateValues from "./ProductVariantCreatorValues"; +import ProductVariantCreatorPriceAndSku from "./ProductVariantCreatorPriceAndSku"; +import ProductVariantCreatorSummary from "./ProductVariantCreatorSummary"; +import ProductVariantCreatorValues from "./ProductVariantCreatorValues"; import { ProductVariantCreateReducerAction, ProductVariantCreateReducerActionType @@ -55,7 +55,7 @@ const ProductVariantCreatorContent: React.FC return ( <> {step === ProductVariantCreatorStep.values && ( - /> )} {step === ProductVariantCreatorStep.prices && ( - /> )} {step === ProductVariantCreatorStep.summary && ( - = ({ params }) => { = ({ params }) => { fetchMoreCategories={fetchMoreCategories} fetchMoreCollections={fetchMoreCollections} fetchMoreProductTypes={fetchMoreProductTypes} - warehouses={mapEdgesToItems(warehouses?.data?.warehouses)} + warehouses={mapEdgesToItems(warehouses?.data?.warehouses) || []} taxTypes={taxTypes.data?.taxTypes || []} weightUnit={shop?.defaultWeightUnit} openChannelsModal={handleChannelsModalOpen} diff --git a/src/products/views/ProductList/ProductList.tsx b/src/products/views/ProductList/ProductList.tsx index b70a96bdf..e6d0f8e79 100644 --- a/src/products/views/ProductList/ProductList.tsx +++ b/src/products/views/ProductList/ProductList.tsx @@ -347,18 +347,18 @@ export const ProductList: React.FC = ({ params }) => { const filterOpts = getFilterOpts( params, - mapEdgesToItems(initialFilterAttributes?.attributes), + mapEdgesToItems(initialFilterAttributes?.attributes) || [], searchAttributeValues, { - initial: mapEdgesToItems(initialFilterCategories?.categories), + initial: mapEdgesToItems(initialFilterCategories?.categories) || [], search: searchCategories }, { - initial: mapEdgesToItems(initialFilterCollections?.collections), + initial: mapEdgesToItems(initialFilterCollections?.collections) || [], search: searchCollections }, { - initial: mapEdgesToItems(initialFilterProductTypes?.productTypes), + initial: mapEdgesToItems(initialFilterProductTypes?.productTypes) || [], search: searchProductTypes }, channelOpts @@ -379,14 +379,15 @@ export const ProductList: React.FC = ({ params }) => { sort: params.sort }} onSort={handleSort} - availableInGridAttributes={mapEdgesToItems( - availableInGridAttributes?.data?.availableInGrid - )} + availableInGridAttributes={ + mapEdgesToItems(availableInGridAttributes?.data?.availableInGrid) || + [] + } currencySymbol={selectedChannel?.currencyCode || ""} currentTab={currentTab} defaultSettings={defaultListSettings[ListViews.PRODUCT_LIST]} filterOpts={filterOpts} - gridAttributes={mapEdgesToItems(gridAttributes?.data?.grid)} + gridAttributes={mapEdgesToItems(gridAttributes?.data?.grid) || []} totalGridAttributes={maybe( () => availableInGridAttributes.data.availableInGrid.totalCount, 0 @@ -491,7 +492,9 @@ export const ProductList: React.FC = ({ params }) => { = ({ params }) => { filter: data?.products.totalCount }} selectedProducts={listElements.length} - warehouses={mapEdgesToItems(warehouses?.data?.warehouses)} + warehouses={mapEdgesToItems(warehouses?.data?.warehouses) || []} channels={availableChannels} onClose={closeModal} onSubmit={data => diff --git a/src/products/views/ProductUpdate/ProductUpdate.tsx b/src/products/views/ProductUpdate/ProductUpdate.tsx index 254e68f78..aaa87ddf8 100644 --- a/src/products/views/ProductUpdate/ProductUpdate.tsx +++ b/src/products/views/ProductUpdate/ProductUpdate.tsx @@ -439,13 +439,13 @@ export const ProductUpdate: React.FC = ({ id, params }) => { createProductMediaOpts.data?.productMediaCreate.errors ); - const categories = mapEdgesToItems(searchCategoriesOpts?.data?.search); + const categories = mapEdgesToItems(searchCategoriesOpts?.data?.search) || []; - const collections = mapEdgesToItems(searchCollectionsOpts?.data?.search); + const collections = + mapEdgesToItems(searchCollectionsOpts?.data?.search) || []; - const attributeValues = mapEdgesToItems( - searchAttributeValuesOpts?.data?.attribute.choices - ); + const attributeValues = + mapEdgesToItems(searchAttributeValuesOpts?.data?.attribute.choices) || []; const errors = [ ...(updateProductOpts.data?.productUpdate.errors || []), @@ -550,7 +550,7 @@ export const ProductUpdate: React.FC = ({ id, params }) => { header={product?.name} placeholderImage={placeholderImg} product={product} - warehouses={mapEdgesToItems(warehouses?.data?.warehouses)} + warehouses={mapEdgesToItems(warehouses?.data?.warehouses) || []} taxTypes={data?.taxTypes} variants={product?.variants} onBack={handleBack} diff --git a/src/products/views/ProductVariant.tsx b/src/products/views/ProductVariant.tsx index 713c0dfaf..8eb70d4b4 100644 --- a/src/products/views/ProductVariant.tsx +++ b/src/products/views/ProductVariant.tsx @@ -323,9 +323,8 @@ export const ProductVariant: React.FC = ({ onFetchMore: loadMoreAttributeValues }; - const attributeValues = mapEdgesToItems( - searchAttributeValuesOpts?.data?.attribute.choices - ); + const attributeValues = + mapEdgesToItems(searchAttributeValuesOpts?.data?.attribute.choices) || []; return ( <> @@ -346,7 +345,7 @@ export const ProductVariant: React.FC = ({ placeholderImage={placeholderImg} variant={variant} header={variant?.name || variant?.sku} - warehouses={mapEdgesToItems(warehouses?.data?.warehouses)} + warehouses={mapEdgesToItems(warehouses?.data?.warehouses) || []} onAdd={() => navigate(productVariantAddUrl(productId))} onBack={handleBack} onDelete={() => openModal("remove")} diff --git a/src/products/views/ProductVariantCreate.tsx b/src/products/views/ProductVariantCreate.tsx index 3dbb21671..def9471ae 100644 --- a/src/products/views/ProductVariantCreate.tsx +++ b/src/products/views/ProductVariantCreate.tsx @@ -191,9 +191,8 @@ export const ProductVariant: React.FC = ({ onFetchMore: loadMoreAttributeValues }; - const attributeValues = mapEdgesToItems( - searchAttributeValuesOpts?.data?.attribute.choices - ); + const attributeValues = + mapEdgesToItems(searchAttributeValuesOpts?.data?.attribute.choices) || []; const disableForm = productLoading || @@ -225,7 +224,7 @@ export const ProductVariant: React.FC = ({ onWarehouseConfigure={() => navigate(warehouseAddPath)} onVariantReorder={handleVariantReorder} saveButtonBarState={variantCreateResult.status} - warehouses={mapEdgesToItems(warehouses?.data?.warehouses)} + warehouses={mapEdgesToItems(warehouses?.data?.warehouses) || []} weightUnit={shop?.defaultWeightUnit} assignReferencesAttributeId={ params.action === "assign-attribute-value" && params.id diff --git a/src/products/views/ProductVariantCreator/ProductVariantCreator.tsx b/src/products/views/ProductVariantCreator/ProductVariantCreator.tsx index 6fa518998..4c5d54330 100644 --- a/src/products/views/ProductVariantCreator/ProductVariantCreator.tsx +++ b/src/products/views/ProductVariantCreator/ProductVariantCreator.tsx @@ -66,9 +66,8 @@ const ProductVariantCreator: React.FC = ({ onFetchMore: loadMoreAttributeValues }; - const attributeValues = mapEdgesToItems( - searchAttributeValuesOpts?.data?.attribute.choices - ); + const attributeValues = + mapEdgesToItems(searchAttributeValuesOpts?.data?.attribute.choices) || []; return ( <> @@ -99,7 +98,7 @@ const ProductVariantCreator: React.FC = ({ variables: { id, inputs } }) } - warehouses={mapEdgesToItems(data?.warehouses)} + warehouses={mapEdgesToItems(data?.warehouses) || []} /> ); diff --git a/src/shipping/views/PriceRatesUpdate/PriceRatesUpdate.tsx b/src/shipping/views/PriceRatesUpdate/PriceRatesUpdate.tsx index 2e0c4de25..50b65825c 100644 --- a/src/shipping/views/PriceRatesUpdate/PriceRatesUpdate.tsx +++ b/src/shipping/views/PriceRatesUpdate/PriceRatesUpdate.tsx @@ -342,7 +342,7 @@ export const PriceRatesUpdate: React.FC = ({ loading={productsSearchOpts.loading} open={params.action === "assign-product"} hasMore={productsSearchOpts.data?.search?.pageInfo.hasNextPage} - products={mapEdgesToItems(productsSearchOpts?.data?.search).filter( + products={mapEdgesToItems(productsSearchOpts?.data?.search)?.filter( suggestedProduct => suggestedProduct.id )} onClose={closeModal} diff --git a/src/shipping/views/ShippingZoneDetails/index.tsx b/src/shipping/views/ShippingZoneDetails/index.tsx index 3d8317aa3..a3f23da0d 100644 --- a/src/shipping/views/ShippingZoneDetails/index.tsx +++ b/src/shipping/views/ShippingZoneDetails/index.tsx @@ -202,7 +202,7 @@ const ShippingZoneDetails: React.FC = ({ } saveButtonBarState={updateShippingZoneOpts.status} shippingZone={data?.shippingZone} - warehouses={mapEdgesToItems(searchWarehousesOpts?.data?.search)} + warehouses={mapEdgesToItems(searchWarehousesOpts?.data?.search) || []} hasMore={searchWarehousesOpts.data?.search?.pageInfo?.hasNextPage} loading={searchWarehousesOpts.loading} onFetchMore={loadMore} diff --git a/src/shipping/views/ShippingZonesList.tsx b/src/shipping/views/ShippingZonesList.tsx index db0d4fc52..ae81a565f 100644 --- a/src/shipping/views/ShippingZonesList.tsx +++ b/src/shipping/views/ShippingZonesList.tsx @@ -184,8 +184,11 @@ export const ShippingZonesList: React.FC = ({ values={{ shippingZoneName: ( - {mapEdgesToItems(data?.shippingZones).find(getById(params.id)) - ?.name || "..."} + {getStringOrPlaceholder( + mapEdgesToItems(data?.shippingZones)?.find( + getById(params.id) + )?.name + )} ) }} diff --git a/src/shipping/views/WeightRatesUpdate/WeightRatesUpdate.tsx b/src/shipping/views/WeightRatesUpdate/WeightRatesUpdate.tsx index f678d2de4..5fd087ae9 100644 --- a/src/shipping/views/WeightRatesUpdate/WeightRatesUpdate.tsx +++ b/src/shipping/views/WeightRatesUpdate/WeightRatesUpdate.tsx @@ -343,7 +343,7 @@ export const WeightRatesUpdate: React.FC = ({ loading={productsSearchOpts.loading} open={params.action === "assign-product"} hasMore={productsSearchOpts.data?.search?.pageInfo.hasNextPage} - products={mapEdgesToItems(productsSearchOpts?.data?.search).filter( + products={mapEdgesToItems(productsSearchOpts?.data?.search)?.filter( suggestedProduct => suggestedProduct.id )} onClose={closeModal} diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index 86d40fb28..3b2b43abf 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -40231,10 +40231,85 @@ exports[`Storyshots Views / Attributes / Attribute details loading 1`] = ` class="MuiTableRow-root-id" > - No values found + + + + + ‌ + + + + + ‌ + + + + @@ -42166,10 +42241,84 @@ exports[`Storyshots Views / Attributes / Attribute details no values 1`] = ` class="MuiTableRow-root-id" > - No values found + + + + + ‌ + + + + + ‌ + + + + @@ -62117,6 +62266,42 @@ exports[`Storyshots Views / Collections / Collection detailsCollection details l + + + + + + + + - - No products found + + + + + + + + +
+
+ +
+
+ + ‌ + +
+
+ + + + ‌ + + + + + ‌ + + + + @@ -76771,9 +77059,43 @@ exports[`Storyshots Views / Customers / Customer details loading 1`] = ` > - No orders found + + ‌ + + + + + ‌ + + + + + ‌ + + + + + ‌ + @@ -90317,6 +90639,42 @@ exports[`Storyshots Views / Discounts / Sale details loading 1`] = ` + + + + + + + + - No categories found + + + + + + + + + + ‌ + + + + + ‌ + + + + @@ -230940,10 +231372,95 @@ exports[`Storyshots Views / Shipping / Shipping rate loading 1`] = ` class="MuiTableRow-root-id" > - No Products + + + + + + + + +
+
+ +
+
+ + ‌ + +
+
+ + + @@ -249109,11 +249626,12 @@ exports[`Storyshots Views / Warehouses / Warehouse details loading 1`] = `
-
- This warehouse has no shipping zones assigned. -
+ ‌ +
diff --git a/src/utils/maps.ts b/src/utils/maps.ts index 8b1183de2..85c2f4bc7 100644 --- a/src/utils/maps.ts +++ b/src/utils/maps.ts @@ -8,16 +8,17 @@ import { SearchPages_search_edges_node } from "@saleor/searches/types/SearchPage import { Node, SlugNode } from "@saleor/types"; import { MetadataInput } from "@saleor/types/globalTypes"; -interface EdgesType { - edges?: Array<{ node: T }>; +interface Edge { + node: T; +} +interface Connection { + edges: Array> | undefined; } -export function mapEdgesToItems(data?: EdgesType): T[] { - if (!data || !data?.edges) { - return []; - } - - return data.edges.map(({ node }) => node); +export function mapEdgesToItems( + data: Connection | undefined +): T[] | undefined { + return data?.edges?.map(({ node }) => node); } export function mapCountriesToChoices(countries: ShopInfo_shop_countries[]) { diff --git a/src/warehouses/views/WarehouseList/WarehouseList.tsx b/src/warehouses/views/WarehouseList/WarehouseList.tsx index c6243065d..e560482fb 100644 --- a/src/warehouses/views/WarehouseList/WarehouseList.tsx +++ b/src/warehouses/views/WarehouseList/WarehouseList.tsx @@ -167,7 +167,7 @@ const WarehouseList: React.FC = ({ params }) => { />