feat: Implement Phase 2 features including blog, collections, saved listings, manifest, and api cron sync

This commit is contained in:
AyrisAI
2026-07-12 20:49:41 +03:00
parent 862544b5a1
commit f696d359b0
29 changed files with 3066 additions and 194 deletions
+46 -8
View File
@@ -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">