From b3c5d731367367ebda7f607817cd512b43b4d4da Mon Sep 17 00:00:00 2001 From: Jakub Majorek Date: Wed, 7 Jul 2021 16:09:35 +0200 Subject: [PATCH] Array fallback fixes (#1219) * Array fallback fixes * Update snapshots & changelog --- CHANGELOG.md | 1 + src/attributes/utils/data.ts | 2 +- .../CustomerAddressListPage.tsx | 6 ++++-- src/customers/views/CustomerDetails.tsx | 17 +++++---------- src/discounts/views/SaleList/filters.ts | 12 ++++------- src/discounts/views/VoucherList/filters.ts | 21 +++++++------------ src/home/views/index.tsx | 9 +++++--- src/navigation/views/MenuList/MenuList.tsx | 7 ++++--- src/orders/urls.ts | 9 ++------ src/orders/views/OrderList/OrderList.tsx | 2 +- src/orders/views/OrderList/filters.ts | 7 +++---- src/pages/utils/data.ts | 2 +- src/pages/views/PageCreate.tsx | 19 ++++++++++------- src/pages/views/PageDetails.tsx | 7 +++---- src/plugins/views/PluginList/filters.ts | 5 +++-- src/products/utils/data.ts | 4 ++-- .../views/ProductCreate/ProductCreate.tsx | 9 +++++--- src/products/views/ProductList/filters.ts | 11 ++++------ .../views/ProductUpdate/ProductUpdate.tsx | 6 ++++-- src/products/views/ProductVariant.tsx | 6 ++++-- src/products/views/ProductVariantCreate.tsx | 6 ++++-- .../__snapshots__/Stories.test.ts.snap | 2 +- .../TranslationsCategoriesPage.tsx | 3 ++- .../TranslationsCollectionsPage.tsx | 3 ++- .../TranslationsPagesPage.tsx | 3 ++- .../TranslationsProductTypesPage.tsx | 3 ++- .../TranslationsProductsPage.tsx | 3 ++- .../TranslationsSalesPage.tsx | 3 ++- .../TranslationsShippingMethodPage.tsx | 3 ++- .../TranslationsVouchersPage.tsx | 3 ++- 30 files changed, 97 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 427e4c3cd..06b23397c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ All notable, unreleased changes to this project will be documented in this file. - Fix duplicated labels in column picker - #1197 by @orzechdev - Fix forbidden null sending as attribute value - #1201 by @orzechdev - Fix missing call for update metadata mutation - #1207 by @orzechdev +- Fix order links on home page - #1219 by @jwm0 # 2.11.1 diff --git a/src/attributes/utils/data.ts b/src/attributes/utils/data.ts index 277ad51bf..3a245a34f 100644 --- a/src/attributes/utils/data.ts +++ b/src/attributes/utils/data.ts @@ -154,7 +154,7 @@ export const mergeChoicesWithValues = ( | PageDetails_page_attributes | SelectedVariantAttributeFragment ) => { - const choices = mapEdgesToItems(attribute.attribute.choices); + const choices = mapEdgesToItems(attribute.attribute.choices) || []; const valuesToConcat = attribute.values.filter( value => !choices.some(choice => choice.id === value.id) ); diff --git a/src/customers/components/CustomerAddressListPage/CustomerAddressListPage.tsx b/src/customers/components/CustomerAddressListPage/CustomerAddressListPage.tsx index adb5ca936..6fecf97e6 100644 --- a/src/customers/components/CustomerAddressListPage/CustomerAddressListPage.tsx +++ b/src/customers/components/CustomerAddressListPage/CustomerAddressListPage.tsx @@ -2,7 +2,7 @@ import { Button, Typography } from "@material-ui/core"; import AppHeader from "@saleor/components/AppHeader"; import Container from "@saleor/components/Container"; import PageHeader from "@saleor/components/PageHeader"; -import { renderCollection } from "@saleor/misc"; +import { getStringOrPlaceholder, renderCollection } from "@saleor/misc"; import { makeStyles } from "@saleor/theme"; import React from "react"; import { defineMessages, useIntl } from "react-intl"; @@ -86,7 +86,9 @@ const CustomerAddressListPage: React.FC = props => const intl = useIntl(); const isEmpty = customer?.addresses?.length === 0; - const fullName = [customer?.firstName, customer?.lastName].join(" ") || "..."; + const fullName = getStringOrPlaceholder( + customer && [customer.firstName, customer.lastName].join(" ") + ); return ( diff --git a/src/customers/views/CustomerDetails.tsx b/src/customers/views/CustomerDetails.tsx index 4d631b484..8ea5080c7 100644 --- a/src/customers/views/CustomerDetails.tsx +++ b/src/customers/views/CustomerDetails.tsx @@ -5,6 +5,7 @@ import { WindowTitle } from "@saleor/components/WindowTitle"; import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; import { commonMessages } from "@saleor/intl"; +import { getStringOrPlaceholder } from "@saleor/misc"; import createMetadataUpdateHandler from "@saleor/utils/handlers/metadataUpdateHandler"; import { useMetadataUpdate, @@ -13,7 +14,6 @@ import { import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; -import { maybe } from "../../misc"; import { orderListUrl, orderUrl } from "../../orders/urls"; import CustomerDetailsPage, { CustomerDetailsPageFormData @@ -114,11 +114,9 @@ export const CustomerDetailsView: React.FC = ({ return ( <> - customerDetails.data.user.email)} - /> + customerDetails.data.user)} + customer={user} disabled={ customerDetails.loading || updateCustomerOpts.loading || @@ -144,9 +142,7 @@ export const CustomerDetailsView: React.FC = ({ onViewAllOrdersClick={() => navigate( orderListUrl({ - customer: maybe( - () => customerDetails.data.user.email - ) + customer: user?.email }) ) } @@ -169,10 +165,7 @@ export const CustomerDetailsView: React.FC = ({ values={{ email: ( - {maybe( - () => customerDetails.data.user.email, - "..." - )} + {getStringOrPlaceholder(user?.email)} ) }} diff --git a/src/discounts/views/SaleList/filters.ts b/src/discounts/views/SaleList/filters.ts index 6f9d6e0dc..ff2ea9007 100644 --- a/src/discounts/views/SaleList/filters.ts +++ b/src/discounts/views/SaleList/filters.ts @@ -59,14 +59,10 @@ export function getFilterOpts( }, status: { active: !!maybe(() => params.status), - value: maybe( - () => - dedupeFilter( - params.status.map(status => - findValueInEnum(status, DiscountStatusEnum) - ) - ), - [] + value: dedupeFilter( + params.status?.map(status => + findValueInEnum(status, DiscountStatusEnum) + ) || [] ) } }; diff --git a/src/discounts/views/VoucherList/filters.ts b/src/discounts/views/VoucherList/filters.ts index aab32f5aa..8f5a3a1b9 100644 --- a/src/discounts/views/VoucherList/filters.ts +++ b/src/discounts/views/VoucherList/filters.ts @@ -41,12 +41,9 @@ export function getFilterOpts( }, saleType: { active: !!maybe(() => params.type), - value: maybe( - () => - dedupeFilter( - params.type.map(type => findValueInEnum(type, VoucherDiscountType)) - ), - [] + value: dedupeFilter( + params.type?.map(type => findValueInEnum(type, VoucherDiscountType)) || + [] ) }, started: { @@ -64,14 +61,10 @@ export function getFilterOpts( }, status: { active: !!maybe(() => params.status), - value: maybe( - () => - dedupeFilter( - params.status.map(status => - findValueInEnum(status, DiscountStatusEnum) - ) - ), - [] + value: dedupeFilter( + params.status?.map(status => + findValueInEnum(status, DiscountStatusEnum) + ) || [] ) }, timesUsed: { diff --git a/src/home/views/index.tsx b/src/home/views/index.tsx index a557f9ae6..c264e436c 100644 --- a/src/home/views/index.tsx +++ b/src/home/views/index.tsx @@ -40,21 +40,24 @@ const HomeSection = () => { onOrdersToCaptureClick={() => navigate( orderListUrl({ - status: [OrderStatusFilter.READY_TO_CAPTURE] + status: [OrderStatusFilter.READY_TO_CAPTURE], + channel: [channel?.id] }) ) } onOrdersToFulfillClick={() => navigate( orderListUrl({ - status: [OrderStatusFilter.READY_TO_FULFILL] + status: [OrderStatusFilter.READY_TO_FULFILL], + channel: [channel?.id] }) ) } onProductsOutOfStockClick={() => navigate( productListUrl({ - stockStatus: StockAvailability.OUT_OF_STOCK + stockStatus: StockAvailability.OUT_OF_STOCK, + channel: channel?.slug }) ) } diff --git a/src/navigation/views/MenuList/MenuList.tsx b/src/navigation/views/MenuList/MenuList.tsx index a3e649117..61ba7e7fa 100644 --- a/src/navigation/views/MenuList/MenuList.tsx +++ b/src/navigation/views/MenuList/MenuList.tsx @@ -9,7 +9,7 @@ import usePaginator, { createPaginationState } from "@saleor/hooks/usePaginator"; import { buttonMessages, commonMessages } from "@saleor/intl"; -import { maybe } from "@saleor/misc"; +import { getStringOrPlaceholder, maybe } from "@saleor/misc"; import { getById } from "@saleor/orders/components/OrderReturnPage/utils"; import { ListViews } from "@saleor/types"; import createSortHandler from "@saleor/utils/handlers/sortHandler"; @@ -209,10 +209,11 @@ const MenuList: React.FC = ({ params }) => { defaultMessage="Are you sure you want to delete {menuName}?" id="menuListDeleteMenuContent" values={{ - menuName: + menuName: getStringOrPlaceholder( mapEdgesToItems(data?.menus)?.find( getById(params.id) - )?.name || "..." + )?.name + ) }} /> diff --git a/src/orders/urls.ts b/src/orders/urls.ts index f6c393903..cbab9a824 100644 --- a/src/orders/urls.ts +++ b/src/orders/urls.ts @@ -6,7 +6,6 @@ import { BulkAction, Dialog, Filters, - FiltersAsDictWithMultipleValues, FiltersWithMultipleValues, Pagination, SingleAction, @@ -27,16 +26,12 @@ export enum OrderListUrlFiltersEnum { query = "query" } export enum OrderListUrlFiltersWithMultipleValues { - status = "status" -} - -export enum OrderListUrlFiltersDictWithMultipleValues { + status = "status", channel = "channel" } export type OrderListUrlFilters = Filters & - FiltersWithMultipleValues & - FiltersAsDictWithMultipleValues; + FiltersWithMultipleValues; export type OrderListUrlDialog = "cancel" | CreateOrderDialog | TabActionDialog; export enum OrderListUrlSortField { number = "number", diff --git a/src/orders/views/OrderList/OrderList.tsx b/src/orders/views/OrderList/OrderList.tsx index e6a306b58..f2d24e907 100644 --- a/src/orders/views/OrderList/OrderList.tsx +++ b/src/orders/views/OrderList/OrderList.tsx @@ -71,7 +71,7 @@ export const OrderList: React.FC = ({ params }) => { onCompleted: handleCreateOrderCreateSuccess }); - const { channel, availableChannels } = useAppChannel(); + const { channel, availableChannels } = useAppChannel(false); const limitOpts = useShopLimitsQuery({ variables: { orders: true diff --git a/src/orders/views/OrderList/filters.ts b/src/orders/views/OrderList/filters.ts index 8f5c459ee..0324d0c35 100644 --- a/src/orders/views/OrderList/filters.ts +++ b/src/orders/views/OrderList/filters.ts @@ -22,7 +22,6 @@ import { } from "../../../utils/filters"; import { OrderListUrlFilters, - OrderListUrlFiltersDictWithMultipleValues, OrderListUrlFiltersEnum, OrderListUrlFiltersWithMultipleValues, OrderListUrlQueryParams @@ -57,9 +56,9 @@ export function getFilterOpts( status: { active: params?.status !== undefined, value: dedupeFilter( - params?.status?.map(status => + params.status?.map(status => findValueInEnum(status, OrderStatusFilter) - ) + ) || [] ) } }; @@ -103,7 +102,7 @@ export function getFilterQueryParam( case OrderFilterKeys.channel: return getMultipleValueQueryParam( filter, - OrderListUrlFiltersDictWithMultipleValues.channel + OrderListUrlFiltersWithMultipleValues.channel ); case OrderFilterKeys.customer: diff --git a/src/pages/utils/data.ts b/src/pages/utils/data.ts index 659aa72e3..366c5d5d0 100644 --- a/src/pages/utils/data.ts +++ b/src/pages/utils/data.ts @@ -36,7 +36,7 @@ export function getAttributeInputFromPageType( entityType: attribute.entityType, inputType: attribute.inputType, isRequired: attribute.valueRequired, - values: mapEdgesToItems(attribute.choices) + values: mapEdgesToItems(attribute.choices) || [] }, id: attribute.id, label: attribute.name, diff --git a/src/pages/views/PageCreate.tsx b/src/pages/views/PageCreate.tsx index 096359aac..530eb1811 100644 --- a/src/pages/views/PageCreate.tsx +++ b/src/pages/views/PageCreate.tsx @@ -87,9 +87,8 @@ export const PageCreate: React.FC = ({ params }) => { skip: !selectedPageTypeId }); - const attributeValues = mapEdgesToItems( - searchAttributeValuesOpts?.data?.attribute.choices - ); + const attributeValues = + mapEdgesToItems(searchAttributeValuesOpts?.data?.attribute.choices) || []; const [uploadFile, uploadFileOpts] = useFileUploadMutation({}); @@ -192,7 +191,9 @@ export const PageCreate: React.FC = ({ params }) => { saveButtonBarState={pageCreateOpts.status} page={null} attributeValues={attributeValues} - pageTypes={mapEdgesToItems(searchPageTypesOpts?.data?.search)} + pageTypes={ + mapEdgesToItems(searchPageTypesOpts?.data?.search) || [] + } onBack={() => navigate(pageListUrl())} onRemove={() => undefined} onSubmit={handleSubmit} @@ -202,10 +203,12 @@ export const PageCreate: React.FC = ({ params }) => { params.action === "assign-attribute-value" && params.id } onAssignReferencesClick={handleAssignAttributeReferenceClick} - referencePages={mapEdgesToItems(searchPagesOpts?.data?.search)} - referenceProducts={mapEdgesToItems( - searchProductsOpts?.data?.search - )} + referencePages={ + mapEdgesToItems(searchPagesOpts?.data?.search) || [] + } + referenceProducts={ + mapEdgesToItems(searchProductsOpts?.data?.search) || [] + } fetchReferencePages={searchPages} fetchMoreReferencePages={fetchMoreReferencePages} fetchReferenceProducts={searchProducts} diff --git a/src/pages/views/PageDetails.tsx b/src/pages/views/PageDetails.tsx index f3789f82a..ff57b9c35 100644 --- a/src/pages/views/PageDetails.tsx +++ b/src/pages/views/PageDetails.tsx @@ -179,9 +179,8 @@ export const PageDetails: React.FC = ({ id, params }) => { result: searchAttributeValuesOpts } = createAttributeValueSearchHandler(DEFAULT_INITIAL_SEARCH_DATA); - const attributeValues = mapEdgesToItems( - searchAttributeValuesOpts?.data?.attribute.choices - ); + const attributeValues = + mapEdgesToItems(searchAttributeValuesOpts?.data?.attribute.choices) || []; const fetchMoreReferencePages = { hasMore: searchPagesOpts.data?.search?.pageInfo?.hasNextPage, @@ -213,7 +212,7 @@ export const PageDetails: React.FC = ({ id, params }) => { errors={pageUpdateOpts.data?.pageUpdate.errors || []} saveButtonBarState={pageUpdateOpts.status} page={pageDetails.data?.page} - attributeValues={attributeValues || []} + attributeValues={attributeValues} onBack={() => navigate(pageListUrl())} onRemove={() => navigate( diff --git a/src/plugins/views/PluginList/filters.ts b/src/plugins/views/PluginList/filters.ts index f776a54a5..4724a14dc 100644 --- a/src/plugins/views/PluginList/filters.ts +++ b/src/plugins/views/PluginList/filters.ts @@ -54,7 +54,7 @@ export function getFilterOpts( loading, onFetchMore, onSearchChange, - value: maybe(() => dedupeFilter(params.channels), []) + value: dedupeFilter(params.channels || []) }, type: { active: !!params.type, @@ -63,7 +63,8 @@ export function getFilterOpts( status: { active: !!params.channels?.length && params.active !== undefined, value: - !!dedupeFilter(params.channels)?.length && params.active !== undefined + !!dedupeFilter(params.channels || [])?.length && + params.active !== undefined } }; } diff --git a/src/products/utils/data.ts b/src/products/utils/data.ts index 7c7c0ec50..87aead510 100644 --- a/src/products/utils/data.ts +++ b/src/products/utils/data.ts @@ -74,7 +74,7 @@ export function getAttributeInputFromProductType( entityType: attribute.entityType, inputType: attribute.inputType, isRequired: attribute.valueRequired, - values: mapEdgesToItems(attribute.choices), + values: mapEdgesToItems(attribute.choices) || [], unit: attribute.unit }, id: attribute.id, @@ -92,7 +92,7 @@ export function getAttributeInputFromAttributes( entityType: attribute.entityType, inputType: attribute.inputType, isRequired: attribute.valueRequired, - values: mapEdgesToItems(attribute.choices), + values: mapEdgesToItems(attribute.choices) || [], unit: attribute.unit, variantAttributeScope }, diff --git a/src/products/views/ProductCreate/ProductCreate.tsx b/src/products/views/ProductCreate/ProductCreate.tsx index 2b657da6a..15a623b9d 100644 --- a/src/products/views/ProductCreate/ProductCreate.tsx +++ b/src/products/views/ProductCreate/ProductCreate.tsx @@ -128,7 +128,8 @@ export const ProductCreateView: React.FC = ({ params }) => { skip: !selectedProductTypeId }); - const productTypes = mapEdgesToItems(searchProductTypesOpts?.data?.search); + const productTypes = + mapEdgesToItems(searchProductTypesOpts?.data?.search) || []; const { availableChannels } = useAppChannel(false); const allChannels: ChannelData[] = createSortedChannelsData( @@ -335,8 +336,10 @@ export const ProductCreateView: React.FC = ({ params }) => { params.action === "assign-attribute-value" && params.id } onAssignReferencesClick={handleAssignAttributeReferenceClick} - referencePages={mapEdgesToItems(searchPagesOpts?.data?.search)} - referenceProducts={mapEdgesToItems(searchProductsOpts?.data?.search)} + referencePages={mapEdgesToItems(searchPagesOpts?.data?.search) || []} + referenceProducts={ + mapEdgesToItems(searchProductsOpts?.data?.search) || [] + } fetchReferencePages={searchPages} fetchMoreReferencePages={fetchMoreReferencePages} fetchReferenceProducts={searchProducts} diff --git a/src/products/views/ProductList/filters.ts b/src/products/views/ProductList/filters.ts index 091adb089..f64ef34d9 100644 --- a/src/products/views/ProductList/filters.ts +++ b/src/products/views/ProductList/filters.ts @@ -87,10 +87,7 @@ export function getFilterOpts( name: attr.name, slug: attr.slug, inputType: attr.inputType, - value: - !!params.attributes && params.attributes[attr.slug] - ? dedupeFilter(params.attributes[attr.slug]) - : [] + value: dedupeFilter(params.attributes?.[attr.slug] || []) })), attributeChoices: { active: true, @@ -132,7 +129,7 @@ export function getFilterOpts( loading: categories.search.result.loading, onFetchMore: categories.search.loadMore, onSearchChange: categories.search.search, - value: maybe(() => dedupeFilter(params.categories), []) + value: dedupeFilter(params.categories || []) }, channel: { active: params?.channel !== undefined, @@ -162,7 +159,7 @@ export function getFilterOpts( loading: collections.search.result.loading, onFetchMore: collections.search.loadMore, onSearchChange: collections.search.search, - value: maybe(() => dedupeFilter(params.collections), []) + value: dedupeFilter(params.collections || []) }, price: { active: maybe( @@ -198,7 +195,7 @@ export function getFilterOpts( loading: productTypes.search.result.loading, onFetchMore: productTypes.search.loadMore, onSearchChange: productTypes.search.search, - value: maybe(() => dedupeFilter(params.productTypes), []) + value: dedupeFilter(params.productTypes || []) }, stockStatus: { active: maybe(() => params.stockStatus !== undefined, false), diff --git a/src/products/views/ProductUpdate/ProductUpdate.tsx b/src/products/views/ProductUpdate/ProductUpdate.tsx index aaa87ddf8..6486f0d06 100644 --- a/src/products/views/ProductUpdate/ProductUpdate.tsx +++ b/src/products/views/ProductUpdate/ProductUpdate.tsx @@ -593,8 +593,10 @@ export const ProductUpdate: React.FC = ({ id, params }) => { params.action === "assign-attribute-value" && params.id } onAssignReferencesClick={handleAssignAttributeReferenceClick} - referencePages={mapEdgesToItems(searchPagesOpts?.data?.search)} - referenceProducts={mapEdgesToItems(searchProductsOpts?.data?.search)} + referencePages={mapEdgesToItems(searchPagesOpts?.data?.search) || []} + referenceProducts={ + mapEdgesToItems(searchProductsOpts?.data?.search) || [] + } fetchReferencePages={searchPages} fetchMoreReferencePages={fetchMoreReferencePages} fetchReferenceProducts={searchProducts} diff --git a/src/products/views/ProductVariant.tsx b/src/products/views/ProductVariant.tsx index 8eb70d4b4..97cd8d5de 100644 --- a/src/products/views/ProductVariant.tsx +++ b/src/products/views/ProductVariant.tsx @@ -363,8 +363,10 @@ export const ProductVariant: React.FC = ({ params.action === "assign-attribute-value" && params.id } onAssignReferencesClick={handleAssignAttributeReferenceClick} - referencePages={mapEdgesToItems(searchPagesOpts?.data?.search)} - referenceProducts={mapEdgesToItems(searchProductsOpts?.data?.search)} + referencePages={mapEdgesToItems(searchPagesOpts?.data?.search) || []} + referenceProducts={ + mapEdgesToItems(searchProductsOpts?.data?.search) || [] + } fetchReferencePages={searchPages} fetchMoreReferencePages={fetchMoreReferencePages} fetchReferenceProducts={searchProducts} diff --git a/src/products/views/ProductVariantCreate.tsx b/src/products/views/ProductVariantCreate.tsx index def9471ae..30fb36d31 100644 --- a/src/products/views/ProductVariantCreate.tsx +++ b/src/products/views/ProductVariantCreate.tsx @@ -230,8 +230,10 @@ export const ProductVariant: React.FC = ({ params.action === "assign-attribute-value" && params.id } onAssignReferencesClick={handleAssignAttributeReferenceClick} - referencePages={mapEdgesToItems(searchPagesOpts?.data?.search)} - referenceProducts={mapEdgesToItems(searchProductsOpts?.data?.search)} + referencePages={mapEdgesToItems(searchPagesOpts?.data?.search) || []} + referenceProducts={ + mapEdgesToItems(searchProductsOpts?.data?.search) || [] + } fetchReferencePages={searchPages} fetchMoreReferencePages={fetchMoreReferencePages} fetchReferenceProducts={searchProducts} diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index eb937606c..ea3148068 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -72324,7 +72324,7 @@ exports[`Storyshots Views / Customers / Address Book loading 1`] = `
- 's Address Book + ...'s Address Book
= ({ 'Translation Category "{categoryName}" - {languageCode}' }, { - categoryName: data?.category?.name || "...", + categoryName: getStringOrPlaceholder(data?.category?.name), languageCode } )} diff --git a/src/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx b/src/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx index 371db37b3..1e8f90515 100644 --- a/src/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx +++ b/src/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx @@ -5,6 +5,7 @@ import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; import { CollectionTranslationFragment } from "@saleor/fragments/types/CollectionTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { getStringOrPlaceholder } from "@saleor/misc"; import { TranslationInputFieldName, TranslationsEntitiesPageProps @@ -48,7 +49,7 @@ const TranslationsCollectionsPage: React.FC = description: "header" }, { - collectionName: data?.collection?.name || "...", + collectionName: getStringOrPlaceholder(data?.collection?.name), languageCode } )} diff --git a/src/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx b/src/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx index 01b79924e..742bceb6d 100644 --- a/src/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx +++ b/src/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx @@ -5,6 +5,7 @@ import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; import { PageTranslationFragment } from "@saleor/fragments/types/PageTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { getStringOrPlaceholder } from "@saleor/misc"; import { PageTranslationInputFieldName, TranslationsEntitiesPageProps @@ -48,7 +49,7 @@ const TranslationsPagesPage: React.FC = ({ }, { languageCode, - pageName: data?.page?.title || "..." + pageName: getStringOrPlaceholder(data?.page?.title) } )} > diff --git a/src/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx b/src/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx index 843c2876f..063fd5c6e 100644 --- a/src/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx +++ b/src/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx @@ -6,6 +6,7 @@ import PageHeader from "@saleor/components/PageHeader"; import { ListSettingsUpdate } from "@saleor/components/TablePagination"; import { AttributeTranslationDetailsFragment } from "@saleor/fragments/types/AttributeTranslationDetailsFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { getStringOrPlaceholder } from "@saleor/misc"; import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import { ListSettings } from "@saleor/types"; import React from "react"; @@ -76,7 +77,7 @@ const TranslationsProductTypesPage: React.FC description: "header" }, { - attribute: data?.attribute?.name || "...", + attribute: getStringOrPlaceholder(data?.attribute?.name), languageCode } )} diff --git a/src/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx b/src/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx index b0b9c039a..d14840af6 100644 --- a/src/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx +++ b/src/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx @@ -5,6 +5,7 @@ import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; import { ProductTranslationFragment } from "@saleor/fragments/types/ProductTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { getStringOrPlaceholder } from "@saleor/misc"; import { TranslationInputFieldName, TranslationsEntitiesPageProps @@ -49,7 +50,7 @@ const TranslationsProductsPage: React.FC = ({ }, { languageCode, - productName: data?.product?.name || "..." + productName: getStringOrPlaceholder(data?.product?.name) } )} > diff --git a/src/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx b/src/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx index 7457a8211..24433b024 100644 --- a/src/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx +++ b/src/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx @@ -4,6 +4,7 @@ import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; import { SaleTranslationFragment } from "@saleor/fragments/types/SaleTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { getStringOrPlaceholder } from "@saleor/misc"; import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import React from "react"; import { useIntl } from "react-intl"; @@ -48,7 +49,7 @@ const TranslationsSalesPage: React.FC = ({ }, { languageCode, - saleName: data?.sale?.name || "..." + saleName: getStringOrPlaceholder(data?.sale?.name) } )} > diff --git a/src/translations/components/TranslationsShippingMethodPage/TranslationsShippingMethodPage.tsx b/src/translations/components/TranslationsShippingMethodPage/TranslationsShippingMethodPage.tsx index 8b8496c7e..578743ee9 100644 --- a/src/translations/components/TranslationsShippingMethodPage/TranslationsShippingMethodPage.tsx +++ b/src/translations/components/TranslationsShippingMethodPage/TranslationsShippingMethodPage.tsx @@ -4,6 +4,7 @@ import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; import { ShippingMethodTranslationFragment } from "@saleor/fragments/types/ShippingMethodTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { getStringOrPlaceholder } from "@saleor/misc"; import { TranslationInputFieldName, TranslationsEntitiesPageProps @@ -48,7 +49,7 @@ const TranslationsShippingMethodPage: React.FC diff --git a/src/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx b/src/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx index 30be7089e..f752ec28b 100644 --- a/src/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx +++ b/src/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx @@ -4,6 +4,7 @@ import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; import { VoucherTranslationFragment } from "@saleor/fragments/types/VoucherTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { getStringOrPlaceholder } from "@saleor/misc"; import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import React from "react"; import { useIntl } from "react-intl"; @@ -49,7 +50,7 @@ const TranslationsVouchersPage: React.FC = ({ }, { languageCode, - voucherName: data?.voucher?.name || "..." + voucherName: getStringOrPlaceholder(data?.voucher?.name) } )} >