40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { notFound } from "next/navigation"
|
|
|
|
import { serverClient } from "@/lib/trpc/server"
|
|
|
|
import { Blocks } from "@/components/Loyalty/Blocks"
|
|
import Sidebar from "@/components/Loyalty/Sidebar"
|
|
import MaxWidth from "@/components/MaxWidth"
|
|
|
|
import styles from "./page.module.css"
|
|
|
|
import type { LangParams, PageArgs, UriParams } from "@/types/params"
|
|
|
|
export default async function LoyaltyPage({
|
|
params,
|
|
searchParams,
|
|
}: PageArgs<LangParams, UriParams>) {
|
|
try {
|
|
if (!searchParams.uri) {
|
|
throw new Error("Bad URI")
|
|
}
|
|
|
|
const loyaltyPage = await serverClient().contentstack.loyaltyPage.get({
|
|
href: searchParams.uri,
|
|
locale: params.lang,
|
|
})
|
|
|
|
return (
|
|
<section className={styles.content}>
|
|
{loyaltyPage.sidebar ? <Sidebar blocks={loyaltyPage.sidebar} /> : null}
|
|
|
|
<MaxWidth className={styles.blocks} tag="main">
|
|
{loyaltyPage.blocks ? <Blocks blocks={loyaltyPage.blocks} /> : null}
|
|
</MaxWidth>
|
|
</section>
|
|
)
|
|
} catch (err) {
|
|
return notFound()
|
|
}
|
|
}
|