fix: add keys on mapped components
This commit is contained in:
@@ -12,13 +12,13 @@ export default function Contact({ sections, system: { locale } }: ContactNode) {
|
|||||||
const visitingAddressMessage = getVisitingAddressMessage(locale)
|
const visitingAddressMessage = getVisitingAddressMessage(locale)
|
||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
{sections.map((section) => {
|
{sections.map((section, idx) => {
|
||||||
switch (section.__typename) {
|
switch (section.__typename) {
|
||||||
case Section.ContactBlockSectionsExtraInfo:
|
case Section.ContactBlockSectionsExtraInfo:
|
||||||
return <p>{section.extra_info.text}</p>
|
return <p>{section.extra_info.text}</p>
|
||||||
case Section.ContactBlockSectionsMailingAddress:
|
case Section.ContactBlockSectionsMailingAddress:
|
||||||
return (
|
return (
|
||||||
<p>
|
<p key={`section-mail-${idx}`}>
|
||||||
{section.mailing_address.name}
|
{section.mailing_address.name}
|
||||||
<br />
|
<br />
|
||||||
{section.mailing_address.street}
|
{section.mailing_address.street}
|
||||||
@@ -30,7 +30,10 @@ export default function Contact({ sections, system: { locale } }: ContactNode) {
|
|||||||
)
|
)
|
||||||
case Section.ContactBlockSectionsPhone:
|
case Section.ContactBlockSectionsPhone:
|
||||||
return (
|
return (
|
||||||
<div className={styles.highlightBlock}>
|
<div
|
||||||
|
className={styles.highlightBlock}
|
||||||
|
key={`section-phone-${idx}`}
|
||||||
|
>
|
||||||
<h3>{section.phone.title}</h3>
|
<h3>{section.phone.title}</h3>
|
||||||
<div className={styles.phoneContainer}>
|
<div className={styles.phoneContainer}>
|
||||||
<svg
|
<svg
|
||||||
@@ -55,10 +58,14 @@ export default function Contact({ sections, system: { locale } }: ContactNode) {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
case Section.ContactBlockSectionsTitle:
|
case Section.ContactBlockSectionsTitle:
|
||||||
return <h2 className={styles.heading}>{section.title.text}</h2>
|
return (
|
||||||
|
<h2 className={styles.heading} key={`section-heading-${idx}`}>
|
||||||
|
{section.title.text}
|
||||||
|
</h2>
|
||||||
|
)
|
||||||
case Section.ContactBlockSectionsVisitingAddress:
|
case Section.ContactBlockSectionsVisitingAddress:
|
||||||
return (
|
return (
|
||||||
<p>
|
<p key={`section-visiting-address-${idx}`}>
|
||||||
{visitingAddressMessage}: {section.visiting_address.street}{" "}
|
{visitingAddressMessage}: {section.visiting_address.street}{" "}
|
||||||
</p>
|
</p>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ export default function Blocks({ blocks }: BlocksProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={styles.wrapper}>
|
<section className={styles.wrapper}>
|
||||||
{blocks.map((block) => {
|
{blocks.map((block, idx) => {
|
||||||
const type = block.__typename
|
const type = block.__typename
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksList:
|
case BlocksTypenameEnum.CurrentBlocksPageBlocksList:
|
||||||
return <List key={block.__typename} {...block} />
|
return <List key={`${block.__typename}-${idx}`} {...block} />
|
||||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs:
|
case BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs:
|
||||||
return <Puffs key={block.__typename} {...block} />
|
return <Puffs key={`${block.__typename}-${idx}`} {...block} />
|
||||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksText:
|
case BlocksTypenameEnum.CurrentBlocksPageBlocksText:
|
||||||
return <Text key={block.__typename} {...block} />
|
return <Text key={`${block.__typename}-${idx}`} {...block} />
|
||||||
default:
|
default:
|
||||||
console.log(`Unknown type: (${type})`)
|
console.log(`Unknown type: (${type})`)
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ export default function BenefitCard({
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles.benefitComparison}>
|
<div className={styles.benefitComparison}>
|
||||||
{comparedValues.map((benefit, idx) => (
|
{comparedValues.map((benefit, idx) => (
|
||||||
<div key={idx} className={styles.comparisonItem}>
|
<div
|
||||||
|
key={`${benefit.valueDetails}-${idx}`}
|
||||||
|
className={styles.comparisonItem}
|
||||||
|
>
|
||||||
<BenefitValue benefit={benefit} />
|
<BenefitValue benefit={benefit} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ export default function BenefitList({ levels }: BenefitListProps) {
|
|||||||
<BenefitCard
|
<BenefitCard
|
||||||
title={benefit.name}
|
title={benefit.name}
|
||||||
description={benefit.description}
|
description={benefit.description}
|
||||||
comparedValues={levelBenefits.map((benefit) => {
|
comparedValues={levelBenefits.map((benefit, idx) => {
|
||||||
return {
|
return {
|
||||||
|
key: `${benefit.name}-${idx}`,
|
||||||
value: benefit.value,
|
value: benefit.value,
|
||||||
unlocked: benefit.unlocked,
|
unlocked: benefit.unlocked,
|
||||||
valueDetails: benefit.valueDetails,
|
valueDetails: benefit.valueDetails,
|
||||||
|
|||||||
@@ -14,10 +14,15 @@ export function Blocks({ lang, blocks }: BlocksProps & LangParams) {
|
|||||||
const firstItem = idx === 0
|
const firstItem = idx === 0
|
||||||
switch (block.__typename) {
|
switch (block.__typename) {
|
||||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksCardsGrid:
|
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksCardsGrid:
|
||||||
return <CardsGrid cards_grid={block.cards_grid} />
|
return (
|
||||||
|
<CardsGrid
|
||||||
|
key={`${block.cards_grid.title}-${idx}`}
|
||||||
|
cards_grid={block.cards_grid}
|
||||||
|
/>
|
||||||
|
)
|
||||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent:
|
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent:
|
||||||
return (
|
return (
|
||||||
<section>
|
<section key={`${block.__typename}-${idx}`}>
|
||||||
<JsonToHtml
|
<JsonToHtml
|
||||||
nodes={block.content.content.json.children}
|
nodes={block.content.content.json.children}
|
||||||
embeds={block.content.content.embedded_itemsConnection.edges}
|
embeds={block.content.content.embedded_itemsConnection.edges}
|
||||||
@@ -39,6 +44,7 @@ export function Blocks({ lang, blocks }: BlocksProps & LangParams) {
|
|||||||
<DynamicContentBlock
|
<DynamicContentBlock
|
||||||
dynamicContent={dynamicContent}
|
dynamicContent={dynamicContent}
|
||||||
firstItem={firstItem}
|
firstItem={firstItem}
|
||||||
|
key={`${block.dynamic_content.title}-${idx}`}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
||||||
@@ -49,6 +55,7 @@ export function Blocks({ lang, blocks }: BlocksProps & LangParams) {
|
|||||||
return (
|
return (
|
||||||
<Shortcuts
|
<Shortcuts
|
||||||
firstItem={firstItem}
|
firstItem={firstItem}
|
||||||
|
key={`${block.shortcuts.title}-${idx}`}
|
||||||
shortcuts={shortcuts}
|
shortcuts={shortcuts}
|
||||||
title={block.shortcuts.title}
|
title={block.shortcuts.title}
|
||||||
subtitle={block.shortcuts.preamble}
|
subtitle={block.shortcuts.preamble}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export function Blocks({ blocks }: BlocksProps) {
|
|||||||
switch (block.__typename) {
|
switch (block.__typename) {
|
||||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent:
|
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent:
|
||||||
return (
|
return (
|
||||||
<section>
|
<section key={`${block.__typename}-${idx}`}>
|
||||||
<JsonToHtml
|
<JsonToHtml
|
||||||
nodes={block.content.content.json.children}
|
nodes={block.content.content.json.children}
|
||||||
embeds={block.content.content.embedded_itemsConnection.edges}
|
embeds={block.content.content.embedded_itemsConnection.edges}
|
||||||
@@ -25,19 +25,26 @@ export function Blocks({ blocks }: BlocksProps) {
|
|||||||
<DynamicContentBlock
|
<DynamicContentBlock
|
||||||
dynamicContent={block.dynamic_content}
|
dynamicContent={block.dynamic_content}
|
||||||
firstItem={firstItem}
|
firstItem={firstItem}
|
||||||
|
key={`${block.dynamic_content.title}-${idx}`}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksShortcuts:
|
||||||
return (
|
return (
|
||||||
<Shortcuts
|
<Shortcuts
|
||||||
firstItem={firstItem}
|
firstItem={firstItem}
|
||||||
|
key={`${block.shortcuts.title}-${idx}`}
|
||||||
shortcuts={block.shortcuts.shortcuts}
|
shortcuts={block.shortcuts.shortcuts}
|
||||||
subtitle={block.shortcuts.preamble}
|
subtitle={block.shortcuts.preamble}
|
||||||
title={block.shortcuts.title}
|
title={block.shortcuts.title}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksCardsGrid:
|
case LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksCardsGrid:
|
||||||
return <CardsGrid cards_grid={block.cards_grid} />
|
return (
|
||||||
|
<CardsGrid
|
||||||
|
cards_grid={block.cards_grid}
|
||||||
|
key={`${block.cards_grid.title}-${idx}`}
|
||||||
|
/>
|
||||||
|
)
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,14 @@ import { SidebarProps } from "@/types/components/loyalty/sidebar"
|
|||||||
export default function SidebarLoyalty({ blocks, lang }: SidebarProps) {
|
export default function SidebarLoyalty({ blocks, lang }: SidebarProps) {
|
||||||
return (
|
return (
|
||||||
<aside className={styles.aside}>
|
<aside className={styles.aside}>
|
||||||
{blocks.map((block) => {
|
{blocks.map((block, idx) => {
|
||||||
switch (block.__typename) {
|
switch (block.__typename) {
|
||||||
case SidebarTypenameEnum.LoyaltyPageSidebarContent:
|
case SidebarTypenameEnum.LoyaltyPageSidebarContent:
|
||||||
return (
|
return (
|
||||||
<section className={styles.content}>
|
<section
|
||||||
|
className={styles.content}
|
||||||
|
key={`${block.__typename}-${idx}`}
|
||||||
|
>
|
||||||
<JsonToHtml
|
<JsonToHtml
|
||||||
embeds={block.content.content.embedded_itemsConnection.edges}
|
embeds={block.content.content.embedded_itemsConnection.edges}
|
||||||
nodes={block.content.content.json.children}
|
nodes={block.content.content.json.children}
|
||||||
@@ -26,6 +29,7 @@ export default function SidebarLoyalty({ blocks, lang }: SidebarProps) {
|
|||||||
<JoinLoyaltyContact
|
<JoinLoyaltyContact
|
||||||
block={block.join_loyalty_contact}
|
block={block.join_loyalty_contact}
|
||||||
lang={lang}
|
lang={lang}
|
||||||
|
key={`${block.join_loyalty_contact.title}-${idx}`}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ function DynamicComponent({ component, props }: AccountPageContentProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Content({ lang, content }: ContentProps) {
|
export default function Content({ lang, content }: ContentProps) {
|
||||||
return content.map((item) => {
|
return content.map((item, idx) => {
|
||||||
switch (item.__typename) {
|
switch (item.__typename) {
|
||||||
case ContentEntries.AccountPageContentDynamicContent:
|
case ContentEntries.AccountPageContentDynamicContent:
|
||||||
const link = item.dynamic_content.link.linkConnection.edges.length
|
const link = item.dynamic_content.link.linkConnection.edges.length
|
||||||
@@ -71,6 +71,7 @@ export default function Content({ lang, content }: ContentProps) {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<DynamicComponent
|
<DynamicComponent
|
||||||
|
key={`${item.dynamic_content.title}-${idx}`}
|
||||||
component={item.dynamic_content.component}
|
component={item.dynamic_content.component}
|
||||||
props={componentProps}
|
props={componentProps}
|
||||||
/>
|
/>
|
||||||
@@ -78,6 +79,7 @@ export default function Content({ lang, content }: ContentProps) {
|
|||||||
case ContentEntries.AccountPageContentShortcuts:
|
case ContentEntries.AccountPageContentShortcuts:
|
||||||
return (
|
return (
|
||||||
<Shortcuts
|
<Shortcuts
|
||||||
|
key={`${item.shortcuts.title}-${idx}`}
|
||||||
shortcuts={item.shortcuts.shortcuts}
|
shortcuts={item.shortcuts.shortcuts}
|
||||||
subtitle={item.shortcuts.preamble}
|
subtitle={item.shortcuts.preamble}
|
||||||
title={item.shortcuts.title}
|
title={item.shortcuts.title}
|
||||||
@@ -85,7 +87,7 @@ export default function Content({ lang, content }: ContentProps) {
|
|||||||
)
|
)
|
||||||
case ContentEntries.AccountPageContentTextContent:
|
case ContentEntries.AccountPageContentTextContent:
|
||||||
return (
|
return (
|
||||||
<section>
|
<section key={`${item.__typename}-${idx}`}>
|
||||||
<JsonToHtml
|
<JsonToHtml
|
||||||
embeds={item.text_content.content.embedded_itemsConnection.edges}
|
embeds={item.text_content.content.embedded_itemsConnection.edges}
|
||||||
nodes={item.text_content.content.json.children}
|
nodes={item.text_content.content.json.children}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ function DynamicComponent({ component, props }: AccountPageContentProps) {
|
|||||||
export default function Content({ lang, content }: ContentProps) {
|
export default function Content({ lang, content }: ContentProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{content.map((item) => {
|
{content.map((item, idx) => {
|
||||||
switch (item.__typename) {
|
switch (item.__typename) {
|
||||||
case ContentEntries.AccountPageContentDynamicContent:
|
case ContentEntries.AccountPageContentDynamicContent:
|
||||||
const link = item.dynamic_content.link.linkConnection.edges.length
|
const link = item.dynamic_content.link.linkConnection.edges.length
|
||||||
@@ -70,6 +70,7 @@ export default function Content({ lang, content }: ContentProps) {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<DynamicComponent
|
<DynamicComponent
|
||||||
|
key={`${item.dynamic_content.title}-${idx}`}
|
||||||
component={item.dynamic_content.component}
|
component={item.dynamic_content.component}
|
||||||
props={componentProps}
|
props={componentProps}
|
||||||
/>
|
/>
|
||||||
@@ -83,6 +84,7 @@ export default function Content({ lang, content }: ContentProps) {
|
|||||||
})
|
})
|
||||||
return (
|
return (
|
||||||
<Shortcuts
|
<Shortcuts
|
||||||
|
key={`${item.shortcuts.title}-${idx}`}
|
||||||
shortcuts={shortcuts}
|
shortcuts={shortcuts}
|
||||||
subtitle={item.shortcuts.preamble}
|
subtitle={item.shortcuts.preamble}
|
||||||
title={item.shortcuts.title}
|
title={item.shortcuts.title}
|
||||||
@@ -90,7 +92,7 @@ export default function Content({ lang, content }: ContentProps) {
|
|||||||
)
|
)
|
||||||
case ContentEntries.AccountPageContentTextContent:
|
case ContentEntries.AccountPageContentTextContent:
|
||||||
return (
|
return (
|
||||||
<section>
|
<section key={`${item.__typename}-${idx}`}>
|
||||||
<JsonToHtml
|
<JsonToHtml
|
||||||
embeds={
|
embeds={
|
||||||
item.text_content.content.embedded_itemsConnection.edges
|
item.text_content.content.embedded_itemsConnection.edges
|
||||||
|
|||||||
Reference in New Issue
Block a user