import Image from 'next/image'; import Link from 'next/link'; import { AddToCompareButton } from '@/components/comparison/add-to-compare-button'; import { Badge } from '@/components/ui/badge'; import { Card, CardContent } from '@/components/ui/card'; import { formatPrice } from '@/lib/currency'; import { shimmerBlurDataURL } from '@/lib/image-blur'; import type { ListingDetail } from '@/lib/listings-api'; const PROPERTY_TYPE_LABELS: Record = { APARTMENT: 'Căn hộ', HOUSE: 'Nhà riêng', VILLA: 'Biệt thự', LAND: 'Đất nền', OFFICE: 'Văn phòng', SHOPHOUSE: 'Shophouse', }; interface PropertyCardProps { listing: ListingDetail; compact?: boolean; /** 'card' (default, vertical) or 'list' (horizontal row) */ layout?: 'card' | 'list'; } export function PropertyCard({ listing, compact, layout = 'card' }: PropertyCardProps) { const transactionLabel = listing.transactionType === 'SALE' ? 'Bán' : 'Cho thuê'; const propertyTypeLabel = PROPERTY_TYPE_LABELS[listing.property.propertyType] || listing.property.propertyType; const mediaCount = listing.property.media?.length ?? 0; const firstImage = listing.property.media?.[0]?.url; const directionLabel = listing.property.direction === 'NORTH' ? 'Bắc' : listing.property.direction === 'SOUTH' ? 'Nam' : listing.property.direction === 'EAST' ? 'Đông' : listing.property.direction === 'WEST' ? 'Tây' : listing.property.direction; const ariaLabel = `${listing.property.title} — ${transactionLabel} ${propertyTypeLabel}, ${formatPrice(listing.priceVND)} VNĐ`; if (layout === 'list') { return (
{firstImage ? ( {`Ảnh ) : ( )}
{transactionLabel} {propertyTypeLabel}
{mediaCount > 1 && (
{mediaCount} ảnh
)}

{listing.property.title}

{listing.property.address}, {listing.property.district}, {listing.property.city}

{formatPrice(listing.priceVND)} VNĐ {listing.transactionType === 'RENT' && listing.rentPriceMonthly && ( /tháng )}

  • {listing.property.areaM2} m²
  • {listing.property.bedrooms != null && (
  • {listing.property.bedrooms} PN
  • )} {listing.property.bathrooms != null && listing.property.bathrooms > 0 && (
  • {listing.property.bathrooms} PT
  • )} {listing.property.direction && (
  • Hướng {directionLabel}
  • )}
); } return (
{firstImage ? ( {`Ảnh ) : ( )}
{transactionLabel} {propertyTypeLabel}
{mediaCount > 1 && (
{mediaCount} ảnh
)}

{formatPrice(listing.priceVND)} VNĐ {listing.transactionType === 'RENT' && listing.rentPriceMonthly && ( /tháng )}

{listing.property.title}

{listing.property.address}, {listing.property.district}, {listing.property.city}

  • {listing.property.areaM2} m²
  • {listing.property.bedrooms != null && (
  • {listing.property.bedrooms} PN
  • )} {listing.property.bathrooms != null && listing.property.bathrooms > 0 && (
  • {listing.property.bathrooms} PT
  • )} {listing.property.direction && (
  • Hướng {directionLabel}
  • )}
); }