'use client'; import Link from 'next/link'; import { Card, CardContent } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import type { ListingDetail } from '@/lib/listings-api'; function formatPrice(priceVND: string): string { const num = Number(priceVND); if (num >= 1_000_000_000) return `${(num / 1_000_000_000).toFixed(1)} tỷ`; if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(0)} triệu`; return num.toLocaleString('vi-VN'); } 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; } export function PropertyCard({ listing, compact }: PropertyCardProps) { return (
{listing.property.media.length > 0 ? ( {listing.property.title} ) : (
Chưa có ảnh
)}
{listing.transactionType === 'SALE' ? 'Bán' : 'Cho thuê'} {PROPERTY_TYPE_LABELS[listing.property.propertyType] || listing.property.propertyType}
{listing.property.media.length > 1 && (
{listing.property.media.length} ả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 {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} )}
); }