feat: Implement Phase 2 features including blog, collections, saved listings, manifest, and api cron sync
This commit is contained in:
@@ -47,6 +47,16 @@ export default function Footer() {
|
||||
{nav('businesses')}
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/seckiler" className="hover:text-turquoise transition-colors">
|
||||
{nav('collections')}
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/blog" className="hover:text-turquoise transition-colors">
|
||||
{nav('blog')}
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
import Image from 'next/image'
|
||||
import { Link } from '@/i18n/routing'
|
||||
import { useLocale } from 'next-intl'
|
||||
import { Star } from 'lucide-react'
|
||||
import { Star, Heart } from 'lucide-react'
|
||||
|
||||
export interface Gallery {
|
||||
id: string
|
||||
@@ -44,6 +47,39 @@ export interface Listing {
|
||||
|
||||
export default function ListingCard({ listing }: { listing: Listing }) {
|
||||
const locale = useLocale()
|
||||
const [isSaved, setIsSaved] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
const stored = localStorage.getItem('savedListingIds')
|
||||
if (stored) {
|
||||
const ids = JSON.parse(stored) as string[]
|
||||
setIsSaved(ids.includes(listing.id))
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error reading localStorage:', e)
|
||||
}
|
||||
}, [listing.id])
|
||||
|
||||
const toggleSave = (e: React.MouseEvent) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
try {
|
||||
const stored = localStorage.getItem('savedListingIds')
|
||||
let ids: string[] = stored ? JSON.parse(stored) : []
|
||||
if (ids.includes(listing.id)) {
|
||||
ids = ids.filter(id => id !== listing.id)
|
||||
setIsSaved(false)
|
||||
} else {
|
||||
ids.push(listing.id)
|
||||
setIsSaved(true)
|
||||
}
|
||||
localStorage.setItem('savedListingIds', JSON.stringify(ids))
|
||||
window.dispatchEvent(new Event('favorites-updated'))
|
||||
} catch (err) {
|
||||
console.error('Error writing localStorage:', err)
|
||||
}
|
||||
}
|
||||
|
||||
const name =
|
||||
locale === 'ru'
|
||||
@@ -52,13 +88,6 @@ export default function ListingCard({ listing }: { listing: Listing }) {
|
||||
? listing.nameEn
|
||||
: listing.nameTr
|
||||
|
||||
const description =
|
||||
locale === 'ru'
|
||||
? listing.descriptionRu
|
||||
: locale === 'en'
|
||||
? listing.descriptionEn
|
||||
: listing.descriptionTr
|
||||
|
||||
const categoryName = listing.category
|
||||
? locale === 'ru'
|
||||
? listing.category.nameRu
|
||||
@@ -88,6 +117,15 @@ export default function ListingCard({ listing }: { listing: Listing }) {
|
||||
href={`/${categorySlug}/${listing.slug}`}
|
||||
className="group bg-paper rounded-2xl border border-pine/8 overflow-hidden flex flex-col relative shadow-sm hover:shadow-md hover:border-turquoise/35 transition-all duration-300 transform hover:-translate-y-0.5"
|
||||
>
|
||||
{/* Heart Save Button */}
|
||||
<button
|
||||
onClick={toggleSave}
|
||||
className="absolute top-4 left-4 z-20 w-9 h-9 rounded-full bg-paper/95 border border-pine/8 flex items-center justify-center shadow-sm hover:bg-stone transition duration-150 text-pine"
|
||||
aria-label="Kaydet"
|
||||
>
|
||||
<Heart className={`w-4.5 h-4.5 transition duration-150 ${isSaved ? 'fill-bougainvillea text-bougainvillea' : 'text-pine/70 hover:text-pine'}`} />
|
||||
</button>
|
||||
|
||||
{/* Local Approved Seal */}
|
||||
{listing.isLocalApproved && (
|
||||
<div className="absolute top-4 right-4 z-10 w-[52px] h-[52px] rounded-full border-[1.5px] border-turquoise bg-paper flex items-center justify-center -rotate-12 shadow-sm shrink-0">
|
||||
|
||||
+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