Skip to content

Commit 0e3c962

Browse files
committed
adjust navitem to match link href type
1 parent 94e00f5 commit 0e3c962

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

resources/js/components/app-header.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import AppLogoIcon from './app-logo-icon';
1919
const mainNavItems: NavItem[] = [
2020
{
2121
title: 'Dashboard',
22-
href: dashboard().url,
22+
href: dashboard(),
2323
icon: LayoutGrid,
2424
},
2525
];
@@ -79,7 +79,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
7979
{rightNavItems.map((item) => (
8080
<a
8181
key={item.title}
82-
href={item.href}
82+
href={typeof item.href === 'string' ? item.href : item.href.url}
8383
target="_blank"
8484
rel="noopener noreferrer"
8585
className="flex items-center space-x-2 font-medium"
@@ -109,7 +109,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
109109
href={item.href}
110110
className={cn(
111111
navigationMenuTriggerStyle(),
112-
page.url === item.href && activeItemStyles,
112+
page.url === (typeof item.href === 'string' ? item.href : item.href.url) && activeItemStyles,
113113
'h-9 cursor-pointer px-3',
114114
)}
115115
>
@@ -136,7 +136,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
136136
<Tooltip>
137137
<TooltipTrigger>
138138
<a
139-
href={item.href}
139+
href={typeof item.href === 'string' ? item.href : item.href.url}
140140
target="_blank"
141141
rel="noopener noreferrer"
142142
className="group ml-1 inline-flex h-9 w-9 items-center justify-center rounded-md bg-transparent p-0 text-sm font-medium text-accent-foreground ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50"

resources/js/components/app-sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import AppLogo from './app-logo';
1111
const mainNavItems: NavItem[] = [
1212
{
1313
title: 'Dashboard',
14-
href: dashboard().url,
14+
href: dashboard(),
1515
icon: LayoutGrid,
1616
},
1717
];

resources/js/components/nav-footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function NavFooter({
2020
asChild
2121
className="text-neutral-600 hover:text-neutral-800 dark:text-neutral-300 dark:hover:text-neutral-100"
2222
>
23-
<a href={item.href} target="_blank" rel="noopener noreferrer">
23+
<a href={typeof item.href === 'string' ? item.href : item.href.url} target="_blank" rel="noopener noreferrer">
2424
{item.icon && <Icon iconNode={item.icon} className="h-5 w-5" />}
2525
<span>{item.title}</span>
2626
</a>

resources/js/layouts/settings/layout.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ import { type PropsWithChildren } from 'react';
1212
const sidebarNavItems: NavItem[] = [
1313
{
1414
title: 'Profile',
15-
href: edit().url,
15+
href: edit(),
1616
icon: null,
1717
},
1818
{
1919
title: 'Password',
20-
href: editPassword().url,
20+
href: editPassword(),
2121
icon: null,
2222
},
2323
{
2424
title: 'Appearance',
25-
href: appearance().url,
25+
href: appearance(),
2626
icon: null,
2727
},
2828
];
@@ -44,12 +44,12 @@ export default function SettingsLayout({ children }: PropsWithChildren) {
4444
<nav className="flex flex-col space-y-1 space-x-0">
4545
{sidebarNavItems.map((item, index) => (
4646
<Button
47-
key={`${item.href}-${index}`}
47+
key={`${typeof item.href === 'string' ? item.href : item.href.url}-${index}`}
4848
size="sm"
4949
variant="ghost"
5050
asChild
5151
className={cn('w-full justify-start', {
52-
'bg-muted': currentPath === item.href,
52+
'bg-muted': currentPath === (typeof item.href === 'string' ? item.href : item.href.url),
5353
})}
5454
>
5555
<Link href={item.href} prefetch>

resources/js/types/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { InertiaLinkProps } from '@inertiajs/react';
12
import { LucideIcon } from 'lucide-react';
23

34
export interface Auth {
@@ -16,7 +17,7 @@ export interface NavGroup {
1617

1718
export interface NavItem {
1819
title: string;
19-
href: string;
20+
href: NonNullable<InertiaLinkProps['href']>;
2021
icon?: LucideIcon | null;
2122
isActive?: boolean;
2223
}

0 commit comments

Comments
 (0)