@@ -28,7 +28,7 @@ import {
2828} from '@/components/ui/tooltip' ;
2929import { UserMenuContent } from '@/components/user-menu-content' ;
3030import { useInitials } from '@/hooks/use-initials' ;
31- import { cn } from '@/lib/utils' ;
31+ import { cn , isSameUrl , resolveUrl } from '@/lib/utils' ;
3232import { dashboard } from '@/routes' ;
3333import { type BreadcrumbItem , type NavItem , type SharedData } from '@/types' ;
3434import { Link , usePage } from '@inertiajs/react' ;
@@ -118,12 +118,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
118118 { rightNavItems . map ( ( item ) => (
119119 < a
120120 key = { item . title }
121- href = {
122- typeof item . href ===
123- 'string'
124- ? item . href
125- : item . href . url
126- }
121+ href = { resolveUrl ( item . href ) }
127122 target = "_blank"
128123 rel = "noopener noreferrer"
129124 className = "flex items-center space-x-2 font-medium"
@@ -165,12 +160,10 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
165160 href = { item . href }
166161 className = { cn (
167162 navigationMenuTriggerStyle ( ) ,
168- page . url ===
169- ( typeof item . href ===
170- 'string'
171- ? item . href
172- : item . href . url ) &&
173- activeItemStyles ,
163+ isSameUrl (
164+ page . url ,
165+ item . href ,
166+ ) && activeItemStyles ,
174167 'h-9 cursor-pointer px-3' ,
175168 ) }
176169 >
@@ -182,7 +175,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
182175 ) }
183176 { item . title }
184177 </ Link >
185- { page . url === item . href && (
178+ { isSameUrl ( page . url , item . href ) && (
186179 < div className = "absolute bottom-0 left-0 h-0.5 w-full translate-y-px bg-black dark:bg-white" > </ div >
187180 ) }
188181 </ NavigationMenuItem >
@@ -209,12 +202,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
209202 < Tooltip >
210203 < TooltipTrigger >
211204 < a
212- href = {
213- typeof item . href ===
214- 'string'
215- ? item . href
216- : item . href . url
217- }
205+ href = { resolveUrl ( item . href ) }
218206 target = "_blank"
219207 rel = "noopener noreferrer"
220208 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"
0 commit comments