Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

Commit

Permalink
Merge 947f642 into 5fec836
Browse files Browse the repository at this point in the history
  • Loading branch information
bmigirl authored Feb 23, 2021
2 parents 5fec836 + 947f642 commit a85f229
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/views/Article/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 7 additions & 9 deletions src/views/Product/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@ 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";
import { IProps } from "./types";

import "./scss/index.scss";

const canDisplay = (product: ProductDetails_product) =>
maybe(
() =>
!!product.description &&
!!product.name &&
!!product.# &&
!!product.variants
);
const canDisplay = (product?: ProductDetails_product) =>
!!product?.name && !!product?.# && !!product?.variants;

const extractMeta = (product: ProductDetails_product, url: string) => ({
custom: [
{
Expand Down Expand Up @@ -127,6 +122,7 @@ const View: NextPage<ViewProps> = ({ query: { id } }) => {
<NetworkStatus>
{isOnline => {
const { product } = data;

if (canDisplay(product)) {
return (
<MetaWrapper
Expand All @@ -152,6 +148,8 @@ const View: NextPage<ViewProps> = ({ query: { id } }) => {
if (!isOnline) {
return <OfflinePlaceholder />;
}

return <NotFound />;
}}
</NetworkStatus>
)}
Expand Down

0 comments on commit a85f229

Please # to comment.