'use client';
import {
Eye,
Heart,
MapPin,
MessageCircle,
Phone,
User,
} from 'lucide-react';
import * as React from 'react';
import { TransferItemTable } from '@/components/chuyen-nhuong/transfer-item-table';
import { Badge } from '@/components/ui/badge';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import {
type TransferListingDetail,
CATEGORY_ICONS,
CATEGORY_LABELS,
STATUS_LABELS,
} from '@/lib/chuyen-nhuong-api';
import { cn } from '@/lib/utils';
interface ChuyenNhuongDetailClientProps {
listing: TransferListingDetail;
}
function formatVND(value: string): string {
return new Intl.NumberFormat('vi-VN').format(Number(value)) + ' \u20ab';
}
export function ChuyenNhuongDetailClient({ listing }: ChuyenNhuongDetailClientProps) {
const statusColor =
listing.status === 'ACTIVE' ? 'bg-green-100 text-green-800' :
listing.status === 'RESERVED' ? 'bg-amber-100 text-amber-800' :
listing.status === 'SOLD' ? 'bg-red-100 text-red-800' :
'bg-gray-100 text-gray-800';
return (
{/* Header */}
{STATUS_LABELS[listing.status]}
{(() => {
const Icon = CATEGORY_ICONS[listing.category];
return ;
})()}
{CATEGORY_LABELS[listing.category]}
{listing.isNegotiable && (
Thương lượng
)}
{listing.title}
{listing.address}, {listing.ward ? `${listing.ward}, ` : ''}{listing.district}, {listing.city}
{/* Quick stats */}
{listing.aiEstimatePriceVND && (
)}
{listing.areaM2 && (
)}
}
label="Lượt xem"
value={`${listing.viewCount}`}
/>
}
label="Lượt lưu"
value={`${listing.saveCount}`}
/>
}
label="Liên hệ"
value={`${listing.inquiryCount}`}
/>
{/* Main content */}
{/* Description */}
{listing.description && (
Mô tả
{listing.description}
)}
{/* Items table */}
Danh sách vật phẩm ({listing.items.length})
{/* Business info */}
{(listing.businessType || listing.monthlyRentVND || listing.remainingLeaseMo) && (
Thông tin kinh doanh
{listing.businessType && (
Loại hình kinh doanh
{listing.businessType}
)}
{listing.monthlyRentVND && (
Tiền thuê hàng tháng
{formatVND(listing.monthlyRentVND)}
)}
{listing.depositMonths != null && (
Cọc
{listing.depositMonths} tháng
)}
{listing.remainingLeaseMo != null && (
Hợp đồng còn lại
{listing.remainingLeaseMo} tháng
)}
{listing.footTraffic && (
Lưu lượng khách
{listing.footTraffic}
)}
)}
{/* Sidebar */}
{/* Price card */}
Giá chuyển nhượng
Giá yêu cầu
{formatVND(listing.askingPriceVND)}
{listing.aiEstimatePriceVND && (
Giá AI ước tính
{formatVND(listing.aiEstimatePriceVND)}
)}
{listing.aiConfidence != null && (
Độ tin cậy AI
{Math.round(listing.aiConfidence * 100)}%
)}
{listing.isNegotiable && (
Giá có thể thương lượng
)}
{/* Contact card */}
Thông tin liên hệ
{listing.contactName ? (
) : null}
{listing.contactPhone ? (
) : null}
{!listing.contactName && !listing.contactPhone && (
Liên hệ qua hệ thống
)}
);
}
// ─── Sub-components ────────────────────────────────────────
function QuickStat({
icon,
label,
value,
valueClassName,
}: {
icon?: React.ReactNode;
label: string;
value: string;
valueClassName?: string;
}) {
return (
);
}