'use client' import { useEffect, useState } from 'react' import { useSearchParams } from 'next/navigation' import ListingCard from '@/components/ListingCard' import { Heart, Share2, ClipboardCheck } from 'lucide-react' interface Props { allListings: any[] locale: string } export default function SavedClient({ allListings, locale }: Props) { const searchParams = useSearchParams() const [savedIds, setSavedIds] = useState([]) const [copied, setCopied] = useState(false) const [isClient, setIsClient] = useState(false) useEffect(() => { setIsClient(true) const paramIds = searchParams.get('ids') if (paramIds) { // Load shared favorites const ids = paramIds.split(',').filter(Boolean) setSavedIds(ids) // Save shared list to local storage as well localStorage.setItem('savedListingIds', JSON.stringify(ids)) } else { // Load personal favorites from localStorage try { const stored = localStorage.getItem('savedListingIds') if (stored) { setSavedIds(JSON.parse(stored)) } } catch (e) { console.error('Error reading localStorage:', e) } } }, [searchParams]) const handleShare = () => { if (savedIds.length === 0) return const shareUrl = `${window.location.origin}${window.location.pathname}?ids=${savedIds.join(',')}` navigator.clipboard.writeText(shareUrl).then(() => { setCopied(true) setTimeout(() => setCopied(false), 2000) }) } // Filter listings matching saved IDs const filteredListings = allListings.filter(l => savedIds.includes(l.id)) if (!isClient) { return (
liste yükleniyor...
) } return (
{/* Title / Action bar */}
kişisel rehberiniz

kaydedilen mekanlar

{savedIds.length > 0 && ( )}
{/* Grid List */} {filteredListings.length === 0 ? (

listeniz henüz boş

Mekan kartlarındaki kalp simgesine tıklayarak beğendiğiniz yerleri buraya ekleyebilir ve daha sonra hızlıca erişebilirsiniz.

) : (
{filteredListings.map((listing) => ( ))}
)}
) }