Skip to content

Commit eded778

Browse files
authored
Merge pull request #82 from aligent/feature/SL-443-update-route-resolver-cms-page
SL-443 CMS pages from BC were being returned even when they were set to hidden. This was likly missed due to the different behaviors of AC and BC APIs.
2 parents d85df57 + 2d24c7f commit eded778

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

packages/modules/bigcommerce/src/apis/graphql/route.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ContactPage,
77
NormalPage,
88
Product,
9+
RawHtmlPage,
910
SiteRouteArgs,
1011
} from '@aligent/bigcommerce-operations';
1112
import { logAndThrowError } from '@aligent/utils';
@@ -15,7 +16,9 @@ import { getRouteQuery } from './requests';
1516
export const getRoute = async (
1617
variables: SiteRouteArgs & { includeTax?: boolean },
1718
customerImpersonationToken: string
18-
): Promise<Blog | BlogPost | Brand | Category | ContactPage | NormalPage | Product> => {
19+
): Promise<
20+
Blog | BlogPost | Brand | Category | ContactPage | NormalPage | Product | RawHtmlPage
21+
> => {
1922
const headers = {
2023
Authorization: `Bearer ${customerImpersonationToken}`,
2124
};

packages/modules/bigcommerce/src/factories/__tests__/__data__/normal-page-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const bcHomePageContent = {
2222
entityId: 17,
2323
parentEntityId: null,
2424
name: 'Big Commerce Homepage',
25-
isVisibleInNavigation: false,
25+
isVisibleInNavigation: true,
2626
seo: {
2727
pageTitle: '',
2828
metaDescription: '',

packages/modules/bigcommerce/src/factories/get-transformed-page-data.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ type PageData = {
88
htmlBody: string;
99
name: string;
1010
seo: SeoDetailsFragment;
11+
isVisibleInNavigation: boolean;
1112
};
1213

1314
export const getTransformedPageData = (data: PageData, cdnUrl: string): CmsPage => {
1415
const { path, htmlBody, name, seo } = data;
16+
17+
if (data.isVisibleInNavigation === false) {
18+
return {
19+
redirect_code: 0,
20+
__typename: 'CmsPage',
21+
};
22+
}
23+
1524
return {
1625
url_key: path.replace(/\//g, ''),
1726
content: htmlBody.replace(CND_MASK, cdnUrl),

packages/modules/bigcommerce/src/resolvers/queries/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { getBundleItemProducts } from '../../apis/graphql/bundle-item-products';
2222
import { retrieveCustomerImpersonationTokenFromCache } from '../../apis/rest';
2323

2424
interface TransformedRouteData {
25-
data: Blog | BlogPost | Brand | Category | ContactPage | NormalPage | Product;
25+
data: Blog | BlogPost | Brand | Category | ContactPage | NormalPage | Product | RawHtmlPage;
2626
storeConfig: StoreConfig & Settings;
2727
customerImpersonationToken: string;
2828
taxSettings?: TaxDisplaySettings | null;
@@ -65,6 +65,7 @@ const getTransformedRouteData = async ({
6565

6666
if (__typename === 'NormalPage' || __typename === 'RawHtmlPage') {
6767
const cdnUrl = storeConfig.url.cdnUrl;
68+
6869
return {
6970
...getTransformedPageData(data as NormalPage | RawHtmlPage, cdnUrl),
7071
type: 'CMS_PAGE',

0 commit comments

Comments
 (0)