feat: Implement Phase 2 features including blog, collections, saved listings, manifest, and api cron sync
This commit is contained in:
+59
-2
@@ -1,9 +1,9 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Link, usePathname, useRouter } from '@/i18n/routing'
|
||||
import { useTranslations, useLocale } from 'next-intl'
|
||||
import { Menu, X, Globe, PlusCircle } from 'lucide-react'
|
||||
import { Menu, X, Globe, PlusCircle, Heart } from 'lucide-react'
|
||||
|
||||
export default function Navbar() {
|
||||
const t = useTranslations('nav')
|
||||
@@ -12,6 +12,33 @@ export default function Navbar() {
|
||||
const router = useRouter()
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)
|
||||
const [langMenuOpen, setLangMenuOpen] = useState(false)
|
||||
const [favoritesCount, setFavoritesCount] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
const updateCount = () => {
|
||||
try {
|
||||
const stored = localStorage.getItem('savedListingIds')
|
||||
if (stored) {
|
||||
const ids = JSON.parse(stored) as string[]
|
||||
setFavoritesCount(ids.length)
|
||||
} else {
|
||||
setFavoritesCount(0)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error reading localStorage:', e)
|
||||
}
|
||||
}
|
||||
|
||||
updateCount()
|
||||
|
||||
window.addEventListener('favorites-updated', updateCount)
|
||||
window.addEventListener('storage', updateCount)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('favorites-updated', updateCount)
|
||||
window.removeEventListener('storage', updateCount)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const languages = [
|
||||
{ code: 'tr', label: 'Türkçe' },
|
||||
@@ -24,6 +51,8 @@ export default function Navbar() {
|
||||
{ name: t('restaurants'), href: '/restoranlar' },
|
||||
{ name: t('aparts'), href: '/apartlar' },
|
||||
{ name: t('businesses'), href: '/isletmeler' },
|
||||
{ name: t('collections'), href: '/seckiler' },
|
||||
{ name: t('blog'), href: '/blog' },
|
||||
{ name: t('about'), href: '/hakkinda' },
|
||||
{ name: t('contact'), href: '/iletisim' }
|
||||
]
|
||||
@@ -74,6 +103,20 @@ export default function Navbar() {
|
||||
|
||||
{/* Action Items */}
|
||||
<div className="hidden lg:flex items-center gap-4">
|
||||
{/* Saved items trigger */}
|
||||
<Link
|
||||
href="/kaydedilenler"
|
||||
className="relative w-8 h-8 rounded-full border border-stone/20 hover:border-turquoise transition text-stone hover:text-turquoise flex items-center justify-center"
|
||||
title={t('saved')}
|
||||
>
|
||||
<Heart className="w-4 h-4" />
|
||||
{favoritesCount > 0 && (
|
||||
<span className="absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-bougainvillea text-stone text-[8px] font-mono font-bold flex items-center justify-center shadow-sm shrink-0">
|
||||
{favoritesCount}
|
||||
</span>
|
||||
)}
|
||||
</Link>
|
||||
|
||||
{/* Language Selector */}
|
||||
<div className="relative">
|
||||
<button
|
||||
@@ -117,6 +160,20 @@ export default function Navbar() {
|
||||
|
||||
{/* Mobile menu button */}
|
||||
<div className="flex items-center gap-3 lg:hidden">
|
||||
{/* Mobile Saved trigger */}
|
||||
<Link
|
||||
href="/kaydedilenler"
|
||||
className="relative w-8 h-8 rounded-full border border-stone/20 text-stone flex items-center justify-center"
|
||||
title={t('saved')}
|
||||
>
|
||||
<Heart className="w-4 h-4" />
|
||||
{favoritesCount > 0 && (
|
||||
<span className="absolute -top-1.5 -right-1.5 w-3.5 h-3.5 rounded-full bg-bougainvillea text-stone text-[8px] font-mono font-bold flex items-center justify-center shadow-sm shrink-0">
|
||||
{favoritesCount}
|
||||
</span>
|
||||
)}
|
||||
</Link>
|
||||
|
||||
{/* Lang menu for mobile */}
|
||||
<div className="relative">
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user