@@ -2,36 +2,30 @@ import Heading from '@/components/heading';
22import { Button } from '@/components/ui/button' ;
33import { Separator } from '@/components/ui/separator' ;
44import { cn } from '@/lib/utils' ;
5- import { type NavItem } from '@/types' ;
65import { Link } from '@inertiajs/react' ;
76import { type PropsWithChildren } from 'react' ;
87
9- const sidebarNavItems : NavItem [ ] = [
8+ interface SettingsSidebarNavItem {
9+ title : string ;
10+ route : string ;
11+ }
12+
13+ const sidebarNavItems : SettingsSidebarNavItem [ ] = [
1014 {
1115 title : 'Profile' ,
12- href : '/settings/profile' ,
13- icon : null ,
16+ route : 'profile.edit' ,
1417 } ,
1518 {
1619 title : 'Password' ,
17- href : '/settings/password' ,
18- icon : null ,
20+ route : 'password.edit' ,
1921 } ,
2022 {
2123 title : 'Appearance' ,
22- href : '/settings/appearance' ,
23- icon : null ,
24+ route : 'appearance' ,
2425 } ,
2526] ;
2627
2728export default function SettingsLayout ( { children } : PropsWithChildren ) {
28- // When server-side rendering, we only render the layout on the client...
29- if ( typeof window === 'undefined' ) {
30- return null ;
31- }
32-
33- const currentPath = window . location . pathname ;
34-
3529 return (
3630 < div className = "px-4 py-6" >
3731 < Heading title = "Settings" description = "Manage your profile and account settings" />
@@ -41,15 +35,15 @@ export default function SettingsLayout({ children }: PropsWithChildren) {
4135 < nav className = "flex flex-col space-y-1 space-x-0" >
4236 { sidebarNavItems . map ( ( item ) => (
4337 < Button
44- key = { item . href }
38+ key = { item . route }
4539 size = "sm"
4640 variant = "ghost"
4741 asChild
4842 className = { cn ( 'w-full justify-start' , {
49- 'bg-muted' : currentPath === item . href ,
43+ 'bg-muted' : route ( ) . current ( item . route ) ,
5044 } ) }
5145 >
52- < Link href = { item . href } prefetch >
46+ < Link href = { route ( item . route ) } prefetch >
5347 { item . title }
5448 </ Link >
5549 </ Button >
0 commit comments