Skip to content

Commit

Permalink
feat: add isLive check to menulinks
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzkirstein committed Mar 14, 2024
1 parent c8d1ad8 commit bcdc6ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/components/@shared/MenuDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ export default function MenuDropdown({
content={
<ul>
{items.map((item, i) => {
const { name, link, subItems } = item
const { name, subItems } = item
return (
<li key={`${name}-${i}`}>
{subItems && subItems.length > 0 ? (
<MenuDropdown label={name} items={subItems} />
) : (
<MenuLink
name={name}
link={link}
className={styles.subItem}
/>
<MenuLink {...item} className={styles.subItem} />
)}
</li>
)
Expand Down
7 changes: 5 additions & 2 deletions src/components/Header/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ declare type MenuItem = {
image?: string
category?: string
className?: string
isLive?: boolean
}

export function MenuLink({ name, link, className }: MenuItem) {
export function MenuLink({ name, link, className, isLive }: MenuItem) {
const router = useRouter()

const basePath = router?.pathname.split(/[/?]/)[1]
Expand All @@ -38,7 +39,9 @@ export function MenuLink({ name, link, className }: MenuItem) {
[className]: className
})

return (
return isLive === false ? (
<></>
) : (
<Button
className={classes}
{...(link.startsWith('/') ? { to: link } : { href: link })}
Expand Down

0 comments on commit bcdc6ec

Please sign in to comment.