@@ -6,43 +6,59 @@ import { usePathname } from "next/navigation";
66
77export type NavbarItemKey = keyof typeof navbarItems ;
88
9- interface NavbarIconProps {
9+ interface NavbarItemProps {
1010 name : NavbarItemKey ;
11+ user : User ;
1112}
1213
1314const navbarItems = {
1415 home : {
1516 title : "Home" ,
1617 icon : Home ,
1718 route : "/home" ,
19+ isSelected : ( currPath : string , _ : User ) => currPath === "/home" ,
1820 } ,
1921 schedule : {
2022 title : "Schedule" ,
2123 icon : Calendar ,
2224 route : "/schedule" ,
25+ isSelected : ( currPath : string , _ : User ) => currPath === "/schedule" ,
2326 } ,
2427 profile : {
2528 title : "Profile" ,
2629 icon : User ,
2730 route : "/profile" ,
31+ isSelected : ( currPath : string , _ : User ) => currPath === "/profile" ,
2832 } ,
2933 connections : {
3034 title : "Connections" ,
3135 icon : Users ,
3236 route : "/profile/connections" ,
37+ isSelected : ( currPath : string , _ : User ) =>
38+ currPath === "/profile/connections" ,
3339 } ,
3440 companies : {
3541 title : "Companies" ,
3642 icon : Building ,
3743 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+ } ,
3854 } ,
3955} ;
4056
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 ] ;
4359
4460 const currPath = usePathname ( ) ;
45- const selected = route === currPath ;
61+ const selected = isSelected ( currPath , user ) ;
4662
4763 return (
4864 < Link
0 commit comments