Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/components/longevity/MobileNavigation/MobileNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ const MobileNavigation: FC = () => {
return next ? { name: next.name, path: next.path } : null;
};

const isHabitsItem = (item: { hasNoUrl?: boolean }) => Boolean(item.hasNoUrl);

const nextPathname = getNextNavItem(navItems, subNavItems);

return (
Expand Down Expand Up @@ -172,10 +174,10 @@ const MobileNavigation: FC = () => {
key={item.path}
className={cn(styles.li, {
[styles.active]: router.pathname === item.path,
[styles.habitsLi]: item.name === 'Habits',
[styles.habitsLi]: isHabitsItem(item),
})}
onClick={() => {
if (item.name === 'Habits') {
if (isHabitsItem(item)) {
setOpenSubNav(!openSubNav);
} else {
setOpenNav(!openNav);
Expand All @@ -184,7 +186,7 @@ const MobileNavigation: FC = () => {
>
<span
className={cn(styles.txtAndIcon, {
[styles.habitsTxtAndIcon]: item.name === 'Habits',
[styles.habitsTxtAndIcon]: isHabitsItem(item),
})}
>
{item.icon && <span className={styles.icon}>{item.icon}</span>}
Expand All @@ -195,12 +197,12 @@ const MobileNavigation: FC = () => {
href={item.path}
passHref
className={styles.link}
target={item.name === 'AI Assistant' ? '_blank' : '_self'}
target={isInternal(item.path) ? '_self' : '_blank'}
>
{item.name}
</Link>
)}
{item.name === 'Habits' && (
{isHabitsItem(item) && (
<NavigationIcon
className={cn(styles.habitsArrow, {
[styles.openHabitsArrow]: openSubNav,
Expand All @@ -211,7 +213,7 @@ const MobileNavigation: FC = () => {
{item.icon && <NewPageIcon />}

<Divider className={styles.divider} />
{item.name === 'Habits' && (
{isHabitsItem(item) && (
<ul
className={cn(styles.subNav, {
[styles.openSubNav]:
Expand Down