fix: validation for header
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
import { getHeader, getLanguageSwitcher } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import { GiftIcon, SearchIcon } from "@/components/Icons"
|
||||
import LanguageSwitcher from "@/components/LanguageSwitcher"
|
||||
@@ -9,23 +9,26 @@ import HeaderLink from "../HeaderLink"
|
||||
import styles from "./topMenu.module.css"
|
||||
|
||||
export default async function TopMenu() {
|
||||
const [intl, languages, headerData] = await Promise.all([
|
||||
getIntl(),
|
||||
serverClient().contentstack.languageSwitcher.get(),
|
||||
serverClient().contentstack.base.header(),
|
||||
])
|
||||
// cached
|
||||
const intl = await getIntl()
|
||||
// both preloaded
|
||||
const languages = await getLanguageSwitcher()
|
||||
const header = await getHeader()
|
||||
|
||||
if (!languages || !headerData) {
|
||||
if (!languages || !header) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.topMenu}>
|
||||
<div className={styles.content}>
|
||||
{headerData.topLink ? (
|
||||
<HeaderLink className={styles.topLink} href={headerData.topLink.href}>
|
||||
{header.data.topLink.link ? (
|
||||
<HeaderLink
|
||||
className={styles.topLink}
|
||||
href={header.data.topLink.link.url}
|
||||
>
|
||||
<GiftIcon width={20} height={20} color="burgundy" />
|
||||
{headerData.topLink.title}
|
||||
{header.data.topLink.title}
|
||||
</HeaderLink>
|
||||
) : null}
|
||||
<div className={styles.options}>
|
||||
|
||||
Reference in New Issue
Block a user