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 #2230 from iFixit/add-app-router-store-page-sections
Browse files Browse the repository at this point in the history
Add app router store pages sections
  • Loading branch information
masonmcelvain authored Feb 6, 2024
2 parents 79e75d2 + b79fdb2 commit dad3de2
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 4 deletions.
110 changes: 106 additions & 4 deletions frontend/app/(defaultLayout)/app-router/Store/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { BannersSection } from '@components/sections/BannersSection';
import { FeaturedProductsSection } from '@components/sections/FeaturedProductsSection';
import { IFixitStatsSection } from '@components/sections/IFixitStatsSection';
import { LifetimeWarrantySection } from '@components/sections/LifetimeWarrantySection';
import { QuoteGallerySection } from '@components/sections/QuoteGallerySection';
import { SocialGallerySection } from '@components/sections/SocialGallerySection';
import { SplitWithImageContentSection } from '@components/sections/SplitWithImageSection';
import { IFIXIT_ORIGIN } from '@config/env';
import { flags } from '@config/flags';
import { ensureIFixitSuffix } from '@helpers/metadata-helpers';
import { joinPaths } from '@helpers/path-helpers';
import { assertNever, invariant } from '@ifixit/helpers';
import { BrowseSection } from '@templates/page/sections/BrowseSection';
import { HeroSection } from '@templates/page/sections/HeroSection';
import { PressQuotesSection } from '@templates/page/sections/PressQuotesSection';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { findPageByPath } from './data';
import { joinPaths } from '@helpers/path-helpers';
import { IFIXIT_ORIGIN } from '@config/env';
import { invariant } from '@ifixit/helpers';

export const fetchCache = 'default-no-store';

export interface StorePageProps {
params: {
Expand All @@ -22,7 +34,97 @@ export default async function StorePage({ params }: StorePageProps) {

return (
<div>
<h1>Store Page: {page.title}</h1>
{page.sections.map((section) => {
switch (section.type) {
case 'Hero': {
return <HeroSection key={section.id} data={section} />;
}
case 'Browse': {
return <BrowseSection key={section.id} data={section} />;
}
case 'IFixitStats': {
return <IFixitStatsSection key={section.id} data={section} />;
}
case 'SplitWithImage': {
return (
<SplitWithImageContentSection
key={section.id}
id={section.id}
title={section.title}
description={section.description}
image={section.image}
imagePosition={section.imagePosition}
callToAction={section.callToAction}
/>
);
}
case 'PressQuotes': {
return (
<PressQuotesSection
key={section.id}
title={section.title}
description={section.description}
callToAction={section.callToAction}
quotes={section.quotes}
/>
);
}
case 'FeaturedProducts': {
return (
<FeaturedProductsSection
key={section.id}
id={section.id}
title={section.title}
description={section.description}
background={section.background}
products={section.products}
/>
);
}
case 'SocialGallery': {
return (
<SocialGallerySection
key={section.id}
title={section.title}
description={section.description}
posts={section.posts}
/>
);
}
case 'LifetimeWarranty': {
return (
<LifetimeWarrantySection
key={section.id}
title={section.title}
description={section.description}
/>
);
}
case 'Banners': {
return (
<BannersSection
key={section.id}
id={section.id}
banners={section.banners}
/>
);
}
case 'QuoteGallery': {
return (
<QuoteGallerySection
key={section.id}
id={section.id}
title={section.title}
description={section.description}
quotes={section.quotes}
/>
);
}

default:
return assertNever(section);
}
})}
</div>
);
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/sections/BannersSection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import type { Banner as SingleBannerSection } from '@models/components/banner';
import { MultipleBanners } from './MultipleBanners';
import { SingleBanner } from './SingleBanner';
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/sections/FeaturedProductsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { Box, Flex } from '@chakra-ui/react';
import { ProductGrid } from '@components/common/ProductGrid';
import { ProductGridItem } from '@components/common/ProductGridItem';
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/sections/IFixitStatsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import {
Box,
SimpleGrid,
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/sections/LifetimeWarrantySection.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { QualityGuarantee } from '@assets/svg/files';
import { Box, Button, Flex, Heading, Icon } from '@chakra-ui/react';
import { PrerenderedHTML } from '@components/common';
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/sections/QuoteGallerySection.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import {
Avatar,
Box,
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/sections/SocialGallerySection.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { AspectRatio, Box, Flex, Grid, GridItem, Text } from '@chakra-ui/react';
import { ResponsiveImage, Wrapper } from '@ifixit/ui';
import type { SocialPost } from '@models/components/social-post';
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/sections/SplitWithImageSection.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { Box, Flex, Text } from '@chakra-ui/react';
import { LinkButton } from '@components/ui/LinkButton';
import { SmartLink } from '@components/ui/SmartLink';
Expand Down
7 changes: 7 additions & 0 deletions frontend/lib/shopify-storefront-sdk/generated/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4796,6 +4796,7 @@ export type MenuItemResource =
| Article
| Blog
| Collection
| Metaobject
| Page
| Product
| ShopPolicy;
Expand All @@ -4816,6 +4817,8 @@ export enum MenuItemType {
Frontpage = 'FRONTPAGE',
/** An http link. */
Http = 'HTTP',
/** A metaobject page link. */
Metaobject = 'METAOBJECT',
/** A page link. */
Page = 'PAGE',
/** A product link. */
Expand Down Expand Up @@ -6333,6 +6336,8 @@ export type ProductSellingPlanGroupsArgs = {
*
*/
export type ProductVariantBySelectedOptionsArgs = {
caseInsensitiveMatch?: InputMaybe<Scalars['Boolean']>;
ignoreUnknownOptions?: InputMaybe<Scalars['Boolean']>;
selectedOptions: Array<SelectedOptionInput>;
};

Expand Down Expand Up @@ -6571,6 +6576,8 @@ export type ProductVariant = HasMetafields &
sku?: Maybe<Scalars['String']>;
/** The in-store pickup availability of this variant by location. */
storeAvailability: StoreAvailabilityConnection;
/** Whether tax is charged when the product variant is sold. */
taxable: Scalars['Boolean'];
/** The product variant’s title. */
title: Scalars['String'];
/** The unit price value for the variant based on the variant's measurement. */
Expand Down
2 changes: 2 additions & 0 deletions frontend/templates/page/sections/BrowseSection.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import {
Box,
Flex,
Expand Down
2 changes: 2 additions & 0 deletions frontend/templates/page/sections/HeroSection.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { Box } from '@chakra-ui/react';
import { SectionDescription } from '@components/sections/SectionDescription';
import { SectionHeading } from '@components/sections/SectionHeading';
Expand Down
2 changes: 2 additions & 0 deletions frontend/templates/page/sections/PressQuotesSection.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { Box, Flex, Link } from '@chakra-ui/react';
import { PrerenderedHTML } from '@components/common';
import { SectionDescription } from '@components/sections/SectionDescription';
Expand Down

0 comments on commit dad3de2

Please sign in to comment.