feat(SW-186): Added refs and some extra querys

This commit is contained in:
Erik Tiekstra
2024-09-05 09:25:21 +02:00
parent 52fdc1daac
commit 55fdbc527b
11 changed files with 388 additions and 303 deletions

View File

@@ -13,16 +13,12 @@ import type { NavigationMenuItemProps } from "@/types/components/header/navigati
export default function MenuItem({ item, isMobile }: NavigationMenuItemProps) {
const { submenu, title, link, seeAllLink, card } = item
const [isExpanded, setIsExpanded] = useState(false)
const [isExpanded, setIsExpanded] = useState(false) // TODO: Use store to manage this state when adding the menu itself.
function handleButtonClick() {
setIsExpanded((prev) => !prev)
}
if (!submenu.length && !link) {
return null
}
return submenu.length ? (
<MainMenuButton
onClick={handleButtonClick}

View File

@@ -46,7 +46,7 @@ export default async function MainMenu({
/>
</NextLink>
<div className={styles.menus}>
{menuItems ? (
{menuItems?.length ? (
<NavigationMenu items={menuItems} isMobile={false} />
) : null}
{user ? (
@@ -74,7 +74,7 @@ export default async function MainMenu({
</span>
</Link>
)}
{menuItems ? (
{menuItems?.length ? (
<MobileMenu languageUrls={languageUrls} menuItems={menuItems} />
) : null}
</div>
@@ -82,26 +82,3 @@ export default async function MainMenu({
</div>
)
}
const error = {
query: { lang: "sv" },
error: {
issues: [
{
code: "invalid_type",
expected: "string",
received: "null",
path: ["all_header", "items", 0, "top_link", "title"],
message: "Expected string, received null",
},
{
code: "invalid_type",
expected: "array",
received: "null",
path: ["all_header", "items", 0, "menu_items"],
message: "Expected array, received null",
},
],
name: "ZodError",
},
}