'use client' import React from 'react' import { AppBar, IconButton, Tab, Tabs, Box, useTheme, Menu, MenuItem, Typography, useColorScheme, <§auth§>Button, Tooltip, Avatar, } from '@mui/material' import { useRouter, usePathname } from 'next/navigation' import { Brightness4, Brightness7, Menu as MenuIcon } from '@mui/icons-material' <§auth§>import { authClient } from '@/app/api/auth/[...all]/authClient' import LanguageSelector from './LanguageSelector' interface LinkTabProps { value: string disabled?: boolean label: string href: string } function LinkTab(props: LinkTabProps) { return ( ) => { event.preventDefault() }} {...props} /> ) } const TABS = [ { label: 'Home', pathname: '/', }, <§mui§>{ label: 'Responsive Design', pathname: '/responsive', }, <§redux§>{ label: 'Redux', pathname: '/redux', }, <§sse§>{ label: 'Server-Sent-Events', pathname: '/sse', }, ] const validatePath = (path: string | null) => { const tabPaths = TABS.map((tab) => tab.pathname) const pathWithoutLocale = '/' + path?.split('/').slice(2).join('/') return pathWithoutLocale && tabPaths.includes(pathWithoutLocale) ? pathWithoutLocale : false } export default function NavBar() { <§auth§>const { data: session } = authClient.useSession() const { mode, setMode } = useColorScheme() const router = useRouter() const pathname = usePathname() const theme = useTheme() const activeTab = validatePath(pathname) const [anchorElNav, setAnchorElNav] = React.useState(null) <§auth§>const [anchorElUser, setAnchorElUser] = React.useState(null) const handleOpenNavMenu = (event: React.MouseEvent) => { setAnchorElNav(event.currentTarget) } <§auth§>const handleOpenUserMenu = (event: React.MouseEvent) => { setAnchorElUser(event.currentTarget) } const handleCloseNavMenu = () => { setAnchorElNav(null) } <§auth§>const handleCloseUserMenu = () => { setAnchorElUser(null) } const handleNavigateFromMenu = (path: string) => { router.push(path) handleCloseNavMenu() } const handleChange = async (event: React.SyntheticEvent, newValue: string) => { router.push(newValue) } const handleChangeTheme = () => { setMode(mode === 'dark' ? 'light' : 'dark') } const a11yProps = (pathname: string) => { return { id: `simple-tab-${pathname}`, 'aria-controls': `tab-to-${pathname}`, } } return ( <> {pathname !== '/_error' && ( {/* responsive menu for mobile devices or small windows */} {TABS.map((tab, index) => ( handleNavigateFromMenu(tab.pathname)}> {tab.label} ))} {/* standard tabs menu for larger screens */} {TABS.map((tab, index) => ( ))} {/* language selector and theme mode toggle */} {mode === 'dark' ? : } <§auth§>{/* next auth login and user menu */} {session && session.user && ( <> {session.user.name && session.user.image && ( )} {session.user.name && !session.user.image && } Logged in as: {session.user.name} { await authClient.signOut() setAnchorElUser(null) router.refresh() }} > Logout )} {!session && ( )} )} ) }