Skip to content

Commit c9f6023

Browse files
fixing linting errors which failed the build
1 parent b393942 commit c9f6023

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

dotcom-rendering/src/components/ProductCardButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const ProductCardButtons = ({
1515
}) => (
1616
<>
1717
{productCtas.map((productCta, index) => {
18-
const label = buttonLabelOverride || getLabel(productCta);
18+
const label = buttonLabelOverride ?? getLabel(productCta);
1919
return (
2020
<ProductLinkButton
2121
key={label}

dotcom-rendering/src/components/ProductCarouselCard.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Meta, StoryObj } from '@storybook/react-webpack5';
2-
import { ArticleDesign, ArticleDisplay, Pillar } from '../lib/articleFormat';
3-
import { ProductCarouselCard } from './ProductCarouselCard';
42
import { productImage } from '../../fixtures/manual/productImage';
3+
import { ArticleDesign, ArticleDisplay, Pillar } from '../lib/articleFormat';
54
import type { ProductBlockElement } from '../types/content';
5+
import { ProductCarouselCard } from './ProductCarouselCard';
66

77
const product = {
88
_type: 'model.dotcomrendering.pageElements.ProductBlockElement',

dotcom-rendering/src/components/ProductCarouselCard.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {
88
textSansBold15,
99
textSansBold17,
1010
} from '@guardian/source/foundations';
11+
import type { ArticleFormat } from '../lib/articleFormat';
12+
import type { ProductBlockElement } from '../types/content';
1113
import { ProductCardButtons } from './ProductCardButtons';
12-
import { ProductBlockElement } from '../types/content';
13-
import { ArticleFormat } from '../lib/articleFormat';
1414
import { ProductCardImage } from './ProductCardImage';
1515

1616
export type ProductCarouselCardProps = {
@@ -96,6 +96,9 @@ export const ProductCarouselCard = ({
9696
showReadMore,
9797
}: ProductCarouselCardProps) => {
9898
const hasHeading = !!product.primaryHeadingHtml;
99+
100+
const firstCta = product.productCtas[0];
101+
99102
return (
100103
<div css={baseCard}>
101104
{hasHeading && (
@@ -127,21 +130,13 @@ export const ProductCarouselCard = ({
127130
<div css={productNameStyle}>{product.productName}</div>
128131
</div>
129132
)}
130-
<div css={priceStyle}>
131-
{product.productCtas && product.productCtas.length > 0
132-
? product.productCtas[0]?.price ?? 'Price unavailable'
133-
: 'Price unavailable'}
134-
</div>
133+
<div css={priceStyle}>{firstCta?.price ?? 'Price unavailable'}</div>
134+
135135
<div css={buttonWrapper}>
136136
<ProductCardButtons
137-
productCtas={product.productCtas?.slice(0, 1) ?? []}
137+
productCtas={firstCta ? [firstCta] : []}
138138
buttonLabelOverride={
139-
product.productCtas && product.productCtas.length > 0
140-
? `Buy at ${
141-
product.productCtas[0]?.retailer ??
142-
'retailer'
143-
}`
144-
: 'Buy' //TODO better fallback?
139+
firstCta ? `Buy at ${firstCta.retailer}` : 'Buy'
145140
}
146141
/>
147142
</div>

0 commit comments

Comments
 (0)