diff --git a/src/views/Article/View.tsx b/src/views/Article/View.tsx index 0c8dd5aa77..6d8db0b39a 100644 --- a/src/views/Article/View.tsx +++ b/src/views/Article/View.tsx @@ -13,8 +13,8 @@ import { TypedArticleQuery } from "./query"; import "./scss/index.scss"; -const canDisplay = page => - maybe(() => !!page && !!page.title && !!page.content); +const canDisplay = page => !!page?.title; + const getHeaderImage = (collection: Article_collection) => maybe(() => collection.backgroundImage.url); diff --git a/src/views/Product/View.tsx b/src/views/Product/View.tsx index 5771e6912e..ac049d7edd 100644 --- a/src/views/Product/View.tsx +++ b/src/views/Product/View.tsx @@ -10,7 +10,7 @@ import { channelSlug } from "@temp/constants"; import { MetaWrapper, NotFound } from "../../components"; import NetworkStatus from "../../components/NetworkStatus"; -import { getGraphqlIdFromDBId, maybe } from "../../core/utils"; +import { getGraphqlIdFromDBId } from "../../core/utils"; import { ProductDetails_product } from "./gqlTypes/ProductDetails"; import Page from "./Page"; import { TypedProductDetailsQuery } from "./queries"; @@ -18,14 +18,9 @@ import { IProps } from "./types"; import "./scss/index.scss"; -const canDisplay = (product: ProductDetails_product) => - maybe( - () => - !!product.description && - !!product.name && - !!product.pricing && - !!product.variants - ); +const canDisplay = (product?: ProductDetails_product) => + !!product?.name && !!product?.pricing && !!product?.variants; + const extractMeta = (product: ProductDetails_product, url: string) => ({ custom: [ { @@ -127,6 +122,7 @@ const View: NextPage = ({ query: { id } }) => { {isOnline => { const { product } = data; + if (canDisplay(product)) { return ( = ({ query: { id } }) => { if (!isOnline) { return ; } + + return ; }} )}