Skip to content

Commit

Permalink
add Related Products tab section
Browse files Browse the repository at this point in the history
  • Loading branch information
tvikito committed Oct 23, 2023
1 parent 4e3d3d3 commit 0b6f35c
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 14 deletions.
6 changes: 4 additions & 2 deletions UPGRADE-14.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Follow the instructions in relevant sections, e.g. `shopsys/coding-standards` or
- see #project-base-diff to update your project
-->

- update your project to fix problems with single domain ([#2875](https://github.com/shopsys/shopsys/pull/2875))
- see #project-base-diff to update your project
- update your project to fix problems with single domain ([#2875](https://github.com/shopsys/shopsys/pull/2875))
- see #project-base-diff to update your project

## [Upgrade from v13.0.0 to v14.0.0-dev](https://github.com/shopsys/shopsys/compare/v13.0.0...14.0)

Expand Down Expand Up @@ -99,3 +99,5 @@ Follow the instructions in relevant sections, e.g. `shopsys/coding-standards` or
- react/self-closing-comp
- react/jsx-sort-props
- no-relative-import-paths/no-relative-import-paths
- add Related Products tab on product detail page ([#2885](https://github.com/shopsys/shopsys/pull/2885))
- see #project-base-diff to update your project
2 changes: 1 addition & 1 deletion project-base/storefront/components/Basic/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const TabsContent: TabFC<TabsContentProps & Partial<PropsWithRef<TabPanel
{headingTextMobile}
<ArrowIcon className={twJoin('w-4 rotate-0 transition', isActiveOnMobile && '-rotate-180 ')} />
</h3>
<div className={twJoin('py-5 ', isActiveOnMobile ? 'block' : 'hidden lg:block')}>{children}</div>
<div className={twJoin('w-full py-5', isActiveOnMobile ? 'block' : 'hidden lg:block')}>{children}</div>
</TabPanel>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ export const ProductDetailContent: FC<ProductDetailContentProps> = ({ product, f
</div>
</div>

<ProductDetailTabs description={product.description} parameters={product.parameters} />
<ProductDetailTabs
description={product.description}
parameters={product.parameters}
relatedProducts={product.relatedProducts}
/>

<ProductDetailAvailabilityList ref={scrollTarget} storeAvailabilities={product.storeAvailabilities} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export const ProductDetailMainVariantContent: FC<ProductDetailMainVariantContent

<ProductVariantsTable isSellingDenied={product.isSellingDenied} variants={product.variants} />

<ProductDetailTabs description={product.description} parameters={product.parameters} />
<ProductDetailTabs
description={product.description}
parameters={product.parameters}
relatedProducts={product.relatedProducts}
/>

{!!product.accessories.length && <ProductDetailAccessories accessories={product.accessories} />}
</Webline>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Cell, Row, Table } from 'components/Basic/Table/Table';
import { Tabs, TabsContent, TabsList, TabsListItem } from 'components/Basic/Tabs/Tabs';
import { UserText } from 'components/Basic/UserText/UserText';
import { ParameterFragmentApi } from 'graphql/generated';
import { ProductsSlider } from 'components/Blocks/Product/ProductsSlider';
import { ListedProductFragmentApi, ParameterFragmentApi } from 'graphql/generated';
import { GtmProductListNameType } from 'gtm/types/enums';
import useTranslation from 'next-translate/useTranslation';

type ProductDetailTabsProps = {
description: string | null;
parameters: ParameterFragmentApi[];
relatedProducts: ListedProductFragmentApi[];
};

export const ProductDetailTabs: FC<ProductDetailTabsProps> = ({ description, parameters }) => {
export const ProductDetailTabs: FC<ProductDetailTabsProps> = ({ description, parameters, relatedProducts }) => {
const { t } = useTranslation();

const formatParameterValue = (valueText: string, index: number) => {
Expand All @@ -22,6 +25,8 @@ export const ProductDetailTabs: FC<ProductDetailTabsProps> = ({ description, par
<TabsListItem>{t('Overview')}</TabsListItem>

{!!parameters.length && <TabsListItem>{t('Parameters')}</TabsListItem>}

{!!relatedProducts.length && <TabsListItem>{t('Related Products')}</TabsListItem>}
</TabsList>

<TabsContent headingTextMobile={t('Overview')}>
Expand All @@ -45,6 +50,15 @@ export const ProductDetailTabs: FC<ProductDetailTabsProps> = ({ description, par
</Table>
</TabsContent>
)}

{!!relatedProducts.length && (
<TabsContent headingTextMobile={t('Related Products')}>
<ProductsSlider
products={relatedProducts}
gtmProductListName={GtmProductListNameType.product_detail_related_products}
/>
</TabsContent>
)}
</Tabs>
);
};
17 changes: 10 additions & 7 deletions project-base/storefront/graphql/generated/index.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ fragment ProductDetailInterfaceFragment on Product {
productVideos {
...VideoTokenFragment
}
relatedProducts {
...ListedProductFragment
}
}
1 change: 1 addition & 0 deletions project-base/storefront/gtm/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export enum GtmProductListNameType {
cart = 'cart',
product_comparison_page = 'product comparison page',
product_detail = 'product detail',
product_detail_related_products = 'product detail related products',
autocomplete_search_results = 'autocomplete_search_results',
wishlist = 'wishlist',
sharedWishlist = 'sharedWishlist',
Expand Down
1 change: 1 addition & 0 deletions project-base/storefront/public/locales/cs/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@
"Register": "Registrujte se",
"Registration": "Registrace",
"Reject all": "Odmítnout vše",
"Related Products": "Související produkty",
"relevance": "Relevance",
"Remove from cart": "Odstranit z košíku",
"Remove from comparison": "Obebrat z porovnání",
Expand Down
1 change: 1 addition & 0 deletions project-base/storefront/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
"Register": "Register",
"Registration": "Registration",
"Reject all": "Reject all",
"Related Products": "Related Products",
"relevance": "Relevance",
"Remove from cart": "Remove from cart",
"Remove from comparison": "Remove from comparison",
Expand Down
1 change: 1 addition & 0 deletions project-base/storefront/public/locales/sk/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@
"Register": "Registrujte sa",
"Registration": "Registrácia",
"Reject all": "Reject all",
"Related Products": "Súvisiace produkty",
"relevance": "Relevantnosť",
"Remove from cart": "Odstrániť z košíka",
"Remove from comparison": "",
Expand Down

0 comments on commit 0b6f35c

Please sign in to comment.