Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1488 from iFixit/remove-featured-product-list-fro…
Browse files Browse the repository at this point in the history
…ntend

Remove featured product list section from product list page - frontend changes
  • Loading branch information
deltuh-vee authored Mar 21, 2023
2 parents 5faa6c9 + ef2ba3d commit bd710d8
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 388 deletions.
4 changes: 2 additions & 2 deletions frontend/components/common/InstantSearchProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function InstantSearchProvider({
const routing: RouterProps<UiState, RouteState> = {
stateMapping: {
stateToRoute(uiState) {
const indexUiState = uiState['main-product-list-index'];
const indexUiState = uiState[indexName];
if (!indexUiState) {
return {};
}
Expand Down Expand Up @@ -117,7 +117,7 @@ export function InstantSearchProvider({
});
}
return {
['main-product-list-index']: stateObject,
[indexName]: stateObject,
};
},
},
Expand Down
56 changes: 1 addition & 55 deletions frontend/lib/strapi-sdk/generated/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3471,37 +3471,7 @@ export type GetProductListQuery = {
callToActionLabel: string;
url: string;
}
| {
__typename: 'ComponentProductListFeaturedProductList';
id: string;
productList?: {
__typename?: 'ProductListEntityResponse';
data?: {
__typename?: 'ProductListEntity';
attributes?: {
__typename?: 'ProductList';
handle: string;
type?: Enum_Productlist_Type | null;
title: string;
deviceTitle?: string | null;
description: string;
filters?: string | null;
image?: {
__typename?: 'UploadFileEntityResponse';
data?: {
__typename?: 'UploadFileEntity';
attributes?: {
__typename?: 'UploadFile';
alternativeText?: string | null;
url: string;
formats?: any | null;
} | null;
} | null;
} | null;
} | null;
} | null;
} | null;
}
| { __typename: 'ComponentProductListFeaturedProductList' }
| {
__typename: 'ComponentProductListLinkedProductListSet';
id: string;
Expand Down Expand Up @@ -4349,30 +4319,6 @@ export const GetProductListDocument = `
id
tags
}
... on ComponentProductListFeaturedProductList {
id
productList {
data {
attributes {
handle
type
title
deviceTitle
description
filters
image {
data {
attributes {
alternativeText
url
formats
}
}
}
}
}
}
}
... on ComponentProductListLinkedProductListSet {
id
title
Expand Down
24 changes: 0 additions & 24 deletions frontend/lib/strapi-sdk/operations/getProductList.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -144,30 +144,6 @@ query getProductList($filters: ProductListFiltersInput) {
id
tags
}
... on ComponentProductListFeaturedProductList {
id
productList {
data {
attributes {
handle
type
title
deviceTitle
description
filters
image {
data {
attributes {
alternativeText
url
formats
}
}
}
}
}
}
}
... on ComponentProductListLinkedProductListSet {
id
title
Expand Down
1 change: 0 additions & 1 deletion frontend/models/product-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export {
FacetWidgetType,
} from './types';
export type {
FeaturedProductList,
iFixitPage,
ProductList,
ProductListPreview,
Expand Down
33 changes: 0 additions & 33 deletions frontend/models/product-list/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,39 +393,6 @@ function createProductListSection(
tags: section.tags || null,
};
}
case 'ComponentProductListFeaturedProductList': {
const productList = section.productList?.data?.attributes;
if (productList == null) {
return null;
}
const image = productList.image?.data?.attributes;

const algoliaApiKey = createPublicAlgoliaKey(
ALGOLIA_APP_ID,
ALGOLIA_API_KEY
);

return {
type: ProductListSectionType.FeaturedProductList,
id: section.id,
productList: {
handle: productList.handle,
title: productList.title,
type: getProductListType(productList.type),
deviceTitle: productList.deviceTitle ?? null,
description: productList.description,
image:
image == null
? null
: getImageFromStrapiImage(image, 'thumbnail'),
filters: productList.filters ?? null,
algolia: {
indexName: ALGOLIA_PRODUCT_INDEX_NAME,
apiKey: algoliaApiKey,
},
},
};
}
case 'ComponentProductListLinkedProductListSet': {
return {
type: ProductListSectionType.ProductListSet,
Expand Down
22 changes: 0 additions & 22 deletions frontend/models/product-list/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,12 @@ export interface ProductListImage {
export enum ProductListSectionType {
Banner = 'banner',
RelatedPosts = 'related-posts',
FeaturedProductList = 'featured-product-list',
ProductListSet = 'product-list-set',
}

export type ProductListSection =
| ProductListBannerSection
| ProductListRelatedPostsSection
| ProductListFeaturedProductListSection
| ProductListProductListSetSection;

export interface ProductListBannerSection {
Expand All @@ -157,26 +155,6 @@ export interface ProductListRelatedPostsSection {
tags: string | null;
}

export interface ProductListFeaturedProductListSection {
type: ProductListSectionType.FeaturedProductList;
id: string;
productList: FeaturedProductList;
}

export interface FeaturedProductList {
algolia: {
apiKey: string;
indexName: string;
};
handle: string;
title: string;
type: ProductListType;
deviceTitle: string | null;
description: string;
image: ProductListImage | null;
filters: string | null;
}

export interface ProductListProductListSetSection {
type: ProductListSectionType.ProductListSet;
id: string;
Expand Down
40 changes: 12 additions & 28 deletions frontend/templates/product-list/ProductListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { VStack } from '@chakra-ui/react';
import { computeProductListAlgoliaFilterPreset } from '@helpers/product-list-helpers';
import { Wrapper } from '@ifixit/ui';
import { ProductList, ProductListSectionType } from '@models/product-list';
import { Configure, Index } from 'react-instantsearch-hooks-web';
import { Configure } from 'react-instantsearch-hooks-web';
import { MetaTags } from './MetaTags';
import { SecondaryNavigation } from './SecondaryNavigation';
import {
BannerSection,
FeaturedProductListSection,
FilterableProductsSection,
HeroSection,
ProductListChildrenSection,
Expand All @@ -32,19 +31,17 @@ export function ProductListView({
<SecondaryNavigation productList={productList} />
<Wrapper py={{ base: 4, md: 6 }}>
<VStack align="stretch" spacing={{ base: 4, md: 6 }}>
<Index indexName={indexName} indexId="main-product-list-index">
<Configure filters={filters} hitsPerPage={24} />
<MetaTags productList={productList} />
{productList.heroImage ? (
<HeroWithBackgroundSection productList={productList} />
) : (
<HeroSection productList={productList} />
)}
{productList.children.length > 0 && (
<ProductListChildrenSection productList={productList} />
)}
<FilterableProductsSection productList={productList} />
</Index>
<Configure filters={filters} hitsPerPage={24} />
<MetaTags productList={productList} />
{productList.heroImage ? (
<HeroWithBackgroundSection productList={productList} />
) : (
<HeroSection productList={productList} />
)}
{productList.children.length > 0 && (
<ProductListChildrenSection productList={productList} />
)}
<FilterableProductsSection productList={productList} />
{productList.sections.map((section, index) => {
switch (section.type) {
case ProductListSectionType.Banner: {
Expand All @@ -65,19 +62,6 @@ export function ProductListView({
);
return <RelatedPostsSection key={index} tags={tags} />;
}
case ProductListSectionType.FeaturedProductList: {
const { productList } = section;
if (productList) {
return (
<FeaturedProductListSection
key={index}
productList={productList}
index={index}
/>
);
}
return null;
}
case ProductListSectionType.ProductListSet: {
const { title, productLists } = section;
if (productLists.length > 0) {
Expand Down
Loading

2 comments on commit bd710d8

@vercel
Copy link

@vercel vercel bot commented on bd710d8 Mar 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react-commerce – ./frontend

react-commerce.vercel.app
react-commerce-ifixit.vercel.app
react-commerce-git-main-ifixit.vercel.app

@vercel
Copy link

@vercel vercel bot commented on bd710d8 Mar 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react-commerce-prod – ./frontend

react-commerce-prod-git-main-ifixit.vercel.app
react-commerce-prod-ifixit.vercel.app
react-commerce-prod.vercel.app

Please sign in to comment.