|
|
@@ -5,17 +5,13 @@ import Link from 'next/link'
|
|
|
import { useAuth } from '@/hooks/useAuth'
|
|
|
import LoginModal from './LoginModal'
|
|
|
import RegisterModal from './RegisterModal'
|
|
|
-
|
|
|
-const roleLinks: Record<string, { href: string; label: string }> = {
|
|
|
- customer: { href: '/places/add', label: 'Мои места' },
|
|
|
- executor: { href: '/services/add', label: 'Мои услуги' },
|
|
|
- landlord: { href: '/studios/add', label: 'Мои студии' },
|
|
|
-}
|
|
|
+import AddLocationModal from './AddLocationModal'
|
|
|
|
|
|
export default function Header() {
|
|
|
const { user, isLoading, logout } = useAuth()
|
|
|
const [showLogin, setShowLogin] = useState(false)
|
|
|
const [showRegister, setShowRegister] = useState(false)
|
|
|
+ const [showAddLocation, setShowAddLocation] = useState(false)
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
@@ -27,23 +23,31 @@ export default function Header() {
|
|
|
|
|
|
{showLogin && <LoginModal onClose={() => setShowLogin(false)} />}
|
|
|
{showRegister && <RegisterModal onClose={() => setShowRegister(false)} />}
|
|
|
+ {showAddLocation && <AddLocationModal onClose={() => setShowAddLocation(false)} />}
|
|
|
|
|
|
<div className="absolute right-4 top-4 z-30 inline-flex items-center gap-3 rounded-lg bg-white/10 backdrop-blur-md px-4 py-2">
|
|
|
{isLoading ? null : user ? (
|
|
|
<>
|
|
|
+ <Link
|
|
|
+ href="/places/my"
|
|
|
+ className="text-sm text-white hover:text-green-400 transition"
|
|
|
+ >
|
|
|
+ Мои места
|
|
|
+ </Link>
|
|
|
<span className="text-sm text-white/60">{user.name || user.email}</span>
|
|
|
- {(user.role === 'moderator' || user.role === 'superadmin') ? (
|
|
|
- <Link href="/admin" className="text-sm text-white hover:text-green-400 transition">
|
|
|
- Админка
|
|
|
- </Link>
|
|
|
- ) : roleLinks[user.role] ? (
|
|
|
- <Link href={roleLinks[user.role].href} className="text-sm text-white hover:text-green-400 transition">
|
|
|
- {roleLinks[user.role].label}
|
|
|
- </Link>
|
|
|
- ) : null}
|
|
|
- <button onClick={logout} className="text-sm text-white/60 hover:text-white transition">
|
|
|
+ <button
|
|
|
+ onClick={logout}
|
|
|
+ className="rounded-md px-3 py-1 text-sm text-white/80 hover:bg-[#ff5656] hover:text-white transition-colors"
|
|
|
+ >
|
|
|
Выйти
|
|
|
</button>
|
|
|
+ <button
|
|
|
+ onClick={() => setShowAddLocation(true)}
|
|
|
+ className="flex h-7 w-7 items-center justify-center rounded-md bg-green-600 text-lg font-bold text-white hover:bg-green-500 transition"
|
|
|
+ title="Добавить локацию"
|
|
|
+ >
|
|
|
+ +
|
|
|
+ </button>
|
|
|
</>
|
|
|
) : (
|
|
|
<>
|