@@ -6,43 +6,59 @@ import { usePathname } from "next/navigation";
6
6
7
7
export type NavbarItemKey = keyof typeof navbarItems ;
8
8
9
- interface NavbarIconProps {
9
+ interface NavbarItemProps {
10
10
name : NavbarItemKey ;
11
+ user : User ;
11
12
}
12
13
13
14
const navbarItems = {
14
15
home : {
15
16
title : "Home" ,
16
17
icon : Home ,
17
18
route : "/home" ,
19
+ isSelected : ( currPath : string , _ : User ) => currPath === "/home" ,
18
20
} ,
19
21
schedule : {
20
22
title : "Schedule" ,
21
23
icon : Calendar ,
22
24
route : "/schedule" ,
25
+ isSelected : ( currPath : string , _ : User ) => currPath === "/schedule" ,
23
26
} ,
24
27
profile : {
25
28
title : "Profile" ,
26
29
icon : User ,
27
30
route : "/profile" ,
31
+ isSelected : ( currPath : string , _ : User ) => currPath === "/profile" ,
28
32
} ,
29
33
connections : {
30
34
title : "Connections" ,
31
35
icon : Users ,
32
36
route : "/profile/connections" ,
37
+ isSelected : ( currPath : string , _ : User ) =>
38
+ currPath === "/profile/connections" ,
33
39
} ,
34
40
companies : {
35
41
title : "Companies" ,
36
42
icon : Building ,
37
43
route : "/companies" ,
44
+ isSelected : ( currPath : string , _ : User ) => currPath === "/companies" ,
45
+ } ,
46
+ myCompany : {
47
+ title : "My Company" ,
48
+ icon : Building ,
49
+ route : "/my-company" ,
50
+ isSelected : ( currPath : string , user : User ) => {
51
+ if ( ! user . company || user . company . length <= 0 ) return false ;
52
+ return currPath === `/companies/${ user . company [ 0 ] . company } ` ;
53
+ } ,
38
54
} ,
39
55
} ;
40
56
41
- export default function NavbarItem ( { name } : NavbarIconProps ) {
42
- const { title, icon : Icon , route } = navbarItems [ name ] ;
57
+ export default function NavbarItem ( { name, user } : NavbarItemProps ) {
58
+ const { title, icon : Icon , route, isSelected } = navbarItems [ name ] ;
43
59
44
60
const currPath = usePathname ( ) ;
45
- const selected = route === currPath ;
61
+ const selected = isSelected ( currPath , user ) ;
46
62
47
63
return (
48
64
< Link
0 commit comments