2026-02-28 16:21:17 +00:00
|
|
|
import { Bed, MapPin } from 'lucide-react';
|
2026-02-21 11:34:53 +00:00
|
|
|
import type { PropertyProperties } from '@/types';
|
|
|
|
|
|
|
|
|
|
interface PropertyCardCompactProps {
|
|
|
|
|
property: PropertyProperties;
|
|
|
|
|
isActive?: boolean;
|
|
|
|
|
isHighlighted?: boolean;
|
|
|
|
|
avgPricePerSqm?: number;
|
|
|
|
|
onClick?: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function PropertyCardCompact({
|
|
|
|
|
property,
|
|
|
|
|
isActive = false,
|
|
|
|
|
isHighlighted = false,
|
|
|
|
|
avgPricePerSqm,
|
|
|
|
|
onClick,
|
|
|
|
|
}: PropertyCardCompactProps) {
|
|
|
|
|
const isGoodDeal = avgPricePerSqm && property.qmprice > 0 && property.qmprice < avgPricePerSqm * 0.9;
|
|
|
|
|
const isExpensive = avgPricePerSqm && property.qmprice > avgPricePerSqm * 1.1;
|
|
|
|
|
|
|
|
|
|
const priceIndicator = isGoodDeal
|
2026-02-28 16:21:17 +00:00
|
|
|
? { dotColor: 'bg-[var(--deal-good)]', label: 'Good deal' }
|
2026-02-21 11:34:53 +00:00
|
|
|
: isExpensive
|
2026-02-28 16:21:17 +00:00
|
|
|
? { dotColor: 'bg-[var(--deal-above)]', label: 'Above avg' }
|
2026-02-21 11:34:53 +00:00
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
2026-02-28 16:21:17 +00:00
|
|
|
className={`w-[280px] shrink-0 snap-center rounded-lg border bg-card shadow-sm overflow-hidden cursor-pointer transition-shadow hover:shadow-md ${
|
2026-02-21 11:34:53 +00:00
|
|
|
isActive ? 'ring-2 ring-primary scale-[1.02]' : ''
|
|
|
|
|
} ${isHighlighted ? 'ring-2 ring-primary' : ''}`}
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
>
|
2026-02-28 16:21:17 +00:00
|
|
|
{/* Thumbnail with 4:3 aspect ratio */}
|
|
|
|
|
<div className="aspect-[4/3] w-full bg-muted">
|
2026-02-21 11:34:53 +00:00
|
|
|
{property.photo_thumbnail && (
|
|
|
|
|
<img
|
|
|
|
|
src={property.photo_thumbnail}
|
2026-02-22 18:47:09 +00:00
|
|
|
alt={`${property.rooms}-bed, £${property.total_price.toLocaleString()}`}
|
2026-02-21 11:34:53 +00:00
|
|
|
className="w-full h-full object-cover"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Details */}
|
2026-02-28 16:21:17 +00:00
|
|
|
<div className="p-3 space-y-1">
|
|
|
|
|
{/* Price bold */}
|
|
|
|
|
<div className="flex items-center gap-1.5">
|
|
|
|
|
<span className="font-bold text-base">
|
2026-02-21 11:34:53 +00:00
|
|
|
£{property.total_price.toLocaleString()}
|
|
|
|
|
{property.listing_type !== 'BUY' && (
|
|
|
|
|
<span className="text-muted-foreground font-normal text-sm">/mo</span>
|
|
|
|
|
)}
|
2026-02-28 16:21:17 +00:00
|
|
|
</span>
|
2026-02-21 11:34:53 +00:00
|
|
|
{priceIndicator && (
|
2026-02-28 16:21:17 +00:00
|
|
|
<span className={`w-2 h-2 rounded-full shrink-0 ${priceIndicator.dotColor}`} title={priceIndicator.label} />
|
2026-02-21 11:34:53 +00:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-02-28 16:21:17 +00:00
|
|
|
{/* Beds and size */}
|
|
|
|
|
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
2026-02-21 11:34:53 +00:00
|
|
|
<span className="flex items-center gap-1">
|
|
|
|
|
<Bed className="h-3.5 w-3.5" />
|
2026-02-28 16:21:17 +00:00
|
|
|
{property.rooms} bed
|
2026-02-21 11:34:53 +00:00
|
|
|
</span>
|
2026-02-28 16:21:17 +00:00
|
|
|
<span>·</span>
|
|
|
|
|
<span>{property.qm} m²</span>
|
2026-02-21 11:34:53 +00:00
|
|
|
</div>
|
2026-02-28 16:21:17 +00:00
|
|
|
|
|
|
|
|
{/* Location */}
|
|
|
|
|
{property.city && (
|
|
|
|
|
<div className="flex items-center gap-1 text-xs text-muted-foreground truncate">
|
|
|
|
|
<MapPin className="h-3 w-3 shrink-0" />
|
|
|
|
|
{property.city}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-02-21 11:34:53 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|