This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.

91 lines
4.5 KiB
TypeScript

'use client'
import Link from 'next/link'
import { useRouter } from 'next/navigation'
import { useAuthStore } from '@/store/authStore'
import { useToast } from './ui/toast'
import NotificationBell from './NotificationBell'
export default function Navbar() {
const router = useRouter()
const { user, isAuthenticated, logout } = useAuthStore()
const { showToast } = useToast()
const handleLogout = async () => {
try {
await logout()
showToast('Logged out successfully', 'success')
router.push('/login')
} catch (error) {
showToast('Failed to logout', 'error')
}
}
if (!isAuthenticated) return null
return (
<nav className="sticky top-0 z-50 bg-card border-b border-border">
<div className="max-w-7xl mx-auto px-4">
<div className="flex items-center justify-between h-16">
<Link href="/feed" className="text-2xl font-bold text-primary">
Gitgram
</Link>
<div className="flex items-center gap-6">
<Link href="/feed" className="hover:text-primary">
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
</svg>
</Link>
<Link href="/search" className="hover:text-primary">
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
</Link>
<Link href="/reels" className="hover:text-primary">
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" />
</svg>
</Link>
<Link href="/messages" className="hover:text-primary">
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" />
</svg>
</Link>
<Link
href="/collaborate"
className="border border-primary/50 px-3 py-1.5 font-mono text-[10px] font-semibold uppercase tracking-[0.12em] text-primary hover:bg-primary hover:text-background"
>
Talent graph
</Link>
<NotificationBell />
<Link href="/camera" className="hover:text-primary">
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" />
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
</Link>
<Link href="/create" className="hover:text-primary">
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
</svg>
</Link>
<Link href={`/profile/${user?.username}`} className="hover:text-primary">
<div className="w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center">
{user?.avatar ? (
<img src={user.avatar} alt={user.username} className="w-full h-full rounded-full object-cover" />
) : (
<span className="text-sm font-semibold">{user?.username?.[0]?.toUpperCase()}</span>
)}
</div>
</Link>
<button onClick={handleLogout} className="text-sm hover:text-primary">
Logout
</button>
</div>
</div>
</div>
</nav>
)
}