Using Suspense on CurrentHeader #SW-386

This commit is contained in:
Linus Flood
2024-09-20 15:07:42 +02:00
parent d1621f77ac
commit 3a6e2c6279
2 changed files with 61 additions and 1 deletions

View File

@@ -0,0 +1,53 @@
import { homeHrefs } from "@/constants/homeHrefs"
import { env } from "@/env/server"
import { serverClient } from "@/lib/trpc/server"
import { getLang } from "@/i18n/serverContext"
import { MainMenu } from "../MainMenu"
import OfflineBanner from "../OfflineBanner"
import TopMenu from "../TopMenu"
import styles from "../header.module.css"
export default async function HeaderFallback() {
const [data] = await Promise.all([
serverClient().contentstack.base.currentHeader({
lang: getLang(),
}),
])
if (!data) {
return null
}
const homeHref = homeHrefs[env.NODE_ENV][getLang()]
const { frontpage_link_text, logo, menu, top_menu } = data
const topMenuMobileLinks = top_menu.links
.filter((link) => link.show_on_mobile)
.sort((a, b) => (a.sort_order_mobile < b.sort_order_mobile ? 1 : -1))
return (
<header className={styles.header} role="banner">
<OfflineBanner />
<TopMenu
frontpageLinkText={frontpage_link_text}
homeHref={homeHref}
links={top_menu.links}
languageSwitcher={null}
/>
<MainMenu
frontpageLinkText={frontpage_link_text}
homeHref={homeHref}
links={menu.links}
logo={logo}
topMenuMobileLinks={topMenuMobileLinks}
languageSwitcher={null}
myPagesMobileDropdown={null}
bookingHref={homeHref}
user={null}
/>
</header>
)
}