'use client'; import { Building2, CheckCircle2, Home, MapPin, Users, type LucideIcon } from 'lucide-react'; import { useTranslations } from 'next-intl'; import * as React from 'react'; import { PropertyCard } from '@/components/search/property-card'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Select } from '@/components/ui/select'; import { Link, useRouter } from '@/i18n/navigation'; import { listingsApi, type ListingDetail } from '@/lib/listings-api'; const DISTRICTS = [ { name: 'Quận 1', city: 'Hồ Chí Minh', img: null }, { name: 'Quận 2', city: 'Hồ Chí Minh', img: null }, { name: 'Quận 7', city: 'Hồ Chí Minh', img: null }, { name: 'Bình Thạnh', city: 'Hồ Chí Minh', img: null }, { name: 'Thủ Đức', city: 'Hồ Chí Minh', img: null }, { name: 'Ba Đình', city: 'Hà Nội', img: null }, { name: 'Hoàn Kiếm', city: 'Hà Nội', img: null }, { name: 'Hải Châu', city: 'Đà Nẵng', img: null }, ]; type StatKey = 'listings' | 'users' | 'transactions' | 'provinces'; const STATS: { key: StatKey; value: string; icon: LucideIcon }[] = [ { key: 'listings', value: '10,000+', icon: Home }, { key: 'users', value: '50,000+', icon: Users }, { key: 'transactions', value: '2,000+', icon: CheckCircle2 }, { key: 'provinces', value: '63', icon: MapPin }, ]; const PROPERTY_TYPE_KEYS = ['APARTMENT', 'HOUSE', 'VILLA', 'LAND', 'OFFICE', 'SHOPHOUSE'] as const; const TRANSACTION_TYPE_KEYS = ['SALE', 'RENT'] as const; export default function LandingPage() { const router = useRouter(); const t = useTranslations(); const [searchQuery, setSearchQuery] = React.useState(''); const [transactionType, setTransactionType] = React.useState(''); const [propertyType, _setPropertyType] = React.useState(''); const [featuredListings, setFeaturedListings] = React.useState([]); const [loadingFeatured, setLoadingFeatured] = React.useState(true); const [featuredError, setFeaturedError] = React.useState(false); const fetchFeatured = React.useCallback(() => { setLoadingFeatured(true); setFeaturedError(false); listingsApi .search({ status: 'ACTIVE', limit: 6 }) .then((res) => setFeaturedListings(res.data)) .catch(() => setFeaturedError(true)) .finally(() => setLoadingFeatured(false)); }, []); React.useEffect(() => { fetchFeatured(); }, [fetchFeatured]); const handleSearch = (e: React.FormEvent) => { e.preventDefault(); const params = new URLSearchParams(); if (searchQuery) params.set('q', searchQuery); if (transactionType) params.set('transactionType', transactionType); if (propertyType) params.set('propertyType', propertyType); router.push(`/search?${params.toString()}`); }; return (
{/* Hero Section */}

{t('landing.heroTitle')} {t('landing.heroTitleHighlight')}

{t('landing.heroSubtitle')}

{/* Search Bar */}
setSearchQuery(e.target.value)} className="border-0 shadow-none focus-visible:ring-0" aria-label={t('landing.searchPlaceholder')} />
{/* Quick property type links */}
{PROPERTY_TYPE_KEYS.map((key) => ( {t(`propertyTypes.${key}`)} ))}
{/* Featured Listings */}

{t('landing.featuredSubtitle')}

{loadingFeatured ? (
) : featuredError ? (

{t('landing.loadError')}

) : featuredListings.length > 0 ? (
{featuredListings.map((listing) => ( ))}
) : (

{t('landing.noFeatured')}

)}
{/* Districts / Quick Links */}

{t('landing.districtsTitle')}

{t('landing.districtsSubtitle')}

{DISTRICTS.map((district) => (

{district.name}

{district.city}

))}
{/* Market Stats */}

{t('landing.statsTitle')}

{t('landing.statsSubtitle')}

{STATS.map((stat) => (
))}
{/* CTA Section */}

{t('landing.ctaTitle')}

{t('landing.ctaSubtitle')}

); }