11import { AnimatePresence , motion } from "motion/react" ;
2- import { useState , useEffect } from "react" ;
2+ import { useState , useEffect , useMemo } from "react" ;
33import { SearchIcon , XIcon } from "lucide-react" ;
44import { cn } from "@/lib/utils" ;
55import { Button } from "../button" ;
@@ -22,15 +22,25 @@ import { useSearch } from "@/lib/hooks";
2222import type { GetApiV1SearchParams } from "@dester/api-client" ;
2323import SearchResults from "./search-results" ;
2424import { useLocation } from "@tanstack/react-router" ;
25+ import { useAuth } from "@/hooks/useAuth" ;
2526
26- const tabs = [
27+ const allTabs = [
2728 { id : "home" , label : "Home" , href : "/" } ,
2829 { id : "library" , label : "Library" , href : "/library" } ,
2930 { id : "settings" , label : "Settings" , href : "/settings" } ,
3031] ;
3132
3233const Header = ( ) => {
3334 const location = useLocation ( ) ;
35+ const { user } = useAuth ( ) ;
36+
37+ // Filter tabs based on user role - hide Settings for guests and unauthenticated users
38+ const tabs = useMemo ( ( ) => {
39+ if ( ! user || user . role === "GUEST" ) {
40+ return allTabs . filter ( ( tab ) => tab . id !== "settings" ) ;
41+ }
42+ return allTabs ;
43+ } , [ user ] ) ;
3444 const [ activeTab , setActiveTab ] = useState ( tabs [ 0 ] . id ) ;
3545 const [ isSearchOpen , setIsSearchOpen ] = useState ( false ) ;
3646 const [ isDialogOpen , setIsDialogOpen ] = useState ( false ) ;
@@ -52,7 +62,7 @@ const Header = () => {
5262 if ( currentTab ) {
5363 setActiveTab ( currentTab . id ) ;
5464 }
55- } , [ location . pathname ] ) ;
65+ } , [ location . pathname , tabs ] ) ;
5666
5767 // Check if current path matches any of the header tabs
5868 const isOnHeaderTab = tabs . some ( ( tab ) => {
0 commit comments