Files
web/apps/scandic-web/app/[lang]/(live)/(protected)/my-pages/[...path]/page.tsx
Erik Tiekstra 339e7195dc fix(BOOK-436): Added new section component and deprecated the other
Approved-by: Chuma Mcphoy (We Ahead)
2025-10-13 08:31:26 +00:00

76 lines
2.1 KiB
TypeScript

import Image from "@scandic-hotels/design-system/Image"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
import { serverClient } from "@/lib/trpc/server"
import Blocks from "@/components/Blocks"
import SectionHeader from "@/components/Section/Header/Deprecated"
import { getIntl } from "@/i18n"
import styles from "./page.module.css"
import type { LangParams, PageArgs } from "@/types/params"
export { generateMetadata } from "@/utils/metadata/generateMetadata"
export default async function MyPages({}: PageArgs<
LangParams & { path: string[] }
>) {
const caller = await serverClient()
const accountPageRes = await caller.contentstack.accountPage.get()
const intl = await getIntl()
if (!accountPageRes) {
return null
}
const { tracking, accountPage } = accountPageRes
const { heading, preamble, hero_image, hero_image_active, content } =
accountPage
return (
<>
<main className={styles.blocks}>
{hero_image_active ? (
<header className={styles.header}>
<Typography variant="Title/lg">
<h1 className={styles.heading}>{heading}</h1>
</Typography>
{hero_image ? (
<Image
className={styles.image}
alt={hero_image.meta.alt || hero_image.meta.caption || ""}
src={hero_image.url}
focalPoint={hero_image.focalPoint}
dimensions={hero_image.dimensions}
sizes="100vw"
fill
priority
/>
) : null}
</header>
) : (
<SectionHeader
title={heading}
preamble={preamble}
headingAs="h1"
headingLevel="h1"
/>
)}
{content?.length ? (
<Blocks blocks={content} />
) : (
<p>
{intl.formatMessage({
defaultMessage: "No content published",
})}
</p>
)}
</main>
<TrackingSDK pageData={tracking} />
</>
)
}