'use client'; import { ArrowLeft, Factory, Search, X } from 'lucide-react'; import * as React from 'react'; import { IndustrialListingCard } from '@/components/khu-cong-nghiep/listing-card'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Link } from '@/i18n/navigation'; import { useIndustrialListingsSearch } from '@/lib/hooks/use-khu-cong-nghiep'; import { type IndustrialLeaseType, type IndustrialPropertyType, type SearchIndustrialListingsParams, LEASE_TYPE_LABELS, PROPERTY_TYPE_LABELS, } from '@/lib/khu-cong-nghiep-api'; const PAGE_SIZE = 12; export function ListingSearchClient() { const [filters, setFilters] = React.useState({ page: 1, limit: PAGE_SIZE, }); const [searchInput, setSearchInput] = React.useState(''); const { data, isLoading, isError } = useIndustrialListingsSearch(filters); const handleSearch = (e: React.FormEvent) => { e.preventDefault(); setFilters((prev) => ({ ...prev, q: searchInput.trim() || undefined, page: 1 })); }; const updateFilter = (key: keyof SearchIndustrialListingsParams, value: string) => { setFilters((prev) => ({ ...prev, [key]: value || undefined, page: 1 })); }; const updateNumericFilter = (key: keyof SearchIndustrialListingsParams, value: string) => { const num = value ? Number(value) : undefined; setFilters((prev) => ({ ...prev, [key]: num, page: 1 })); }; const handlePageChange = (page: number) => { setFilters((prev) => ({ ...prev, page })); window.scrollTo({ top: 0, behavior: 'smooth' }); }; const handleClear = () => { setSearchInput(''); setFilters({ page: 1, limit: PAGE_SIZE }); }; const hasFilters = filters.q || filters.propertyType || filters.leaseType || filters.minAreaM2 || filters.maxAreaM2 || filters.minPriceUsdM2 || filters.maxPriceUsdM2; return (
{/* Header */}

Cho Thuê Bất Động Sản Công Nghiệp

Tìm nhà xưởng, kho bãi, đất công nghiệp cho thuê tại các KCN

{/* Search bar */}
setSearchInput(e.target.value)} className="pl-9" />
{/* Filters */}
updateNumericFilter('minAreaM2', e.target.value)} className="w-36 text-sm" aria-label="Diện tích tối thiểu" /> updateNumericFilter('maxAreaM2', e.target.value)} className="w-36 text-sm" aria-label="Diện tích tối đa" /> updateNumericFilter('minPriceUsdM2', e.target.value)} className="w-36 text-sm" aria-label="Giá tối thiểu" /> updateNumericFilter('maxPriceUsdM2', e.target.value)} className="w-36 text-sm" aria-label="Giá tối đa" /> {hasFilters && ( )}
{/* Results */}
{isLoading ? (
{Array.from({ length: 6 }).map((_, i) => (
))}
) : isError ? (

Không thể tải danh sách tin cho thuê. Vui lòng thử lại.

) : data && data.data.length > 0 ? ( <>

{data.total} tin cho thuê được tìm thấy

{data.data.map((listing) => ( ))}
{/* Pagination */} {data.totalPages > 1 && (
Trang {data.page} / {data.totalPages}
)} ) : (

Không tìm thấy tin cho thuê

Thử thay đổi bộ lọc để tìm kiếm nhiều hơn

)}
); }