fix: add rendering logic for optional link and preamble

This commit is contained in:
Arvid Norlin
2024-04-18 15:44:53 +02:00
parent c8cb832350
commit b7782b61a7
5 changed files with 65 additions and 1 deletions

View File

@@ -19,14 +19,27 @@ function DynamicComponent({
lang: Lang
user: User
}) {
const componentProps = {
title: content.title,
preamble: content.preamble,
link: content.link.linkConnection.edges.length
? {
href: content.link.linkConnection.edges[0].node.url,
text: content.link.link_text,
}
: null,
}
switch (content.component) {
case DynamicContentComponents.membership_overview:
return <Overview user={user} />
case DynamicContentComponents.benefits:
return null
case DynamicContentComponents.previous_stays:
return null
case DynamicContentComponents.upcoming_stays:
return <UpcomingStays lang={lang} stays={user.stays} />
return (
<UpcomingStays lang={lang} stays={user.stays} {...componentProps} />
)
default:
return null
}