'use client'; import { useState } from 'react'; import Link from 'next/link'; import { motion } from 'framer-motion'; import { useTranslation } from 'react-i18next'; import { Search, MapPin, Home, DollarSign, ShieldCheck } from 'lucide-react'; export default function HeroSearch({ onSearch, isAuthenticated }) { const { t } = useTranslation(); const [activeTab, setActiveTab] = useState('buy'); const [filters, setFilters] = useState({ city: 'all', propertyType: 'all', priceRange: 'all', identityType: 'syrian', ownerSource: 'all', rentPeriod: 'all', availableToday: false }); const [showLoginDialog, setShowLoginDialog] = useState(false); const cities = [ { id: 'all', label: 'جميع المدن' }, { id: 'دمشق', label: 'دمشق' }, { id: 'حلب', label: 'حلب' }, { id: 'حمص', label: 'حمص' }, { id: 'اللاذقية', label: 'اللاذقية' }, { id: 'درعا', label: 'درعا' } ]; const propertyTypes = [ { id: 'all', label: 'الكل' }, { id: 'apartment', label: 'شقق سكنية' }, { id: 'studio', label: 'استوديو' }, { id: 'commercial', label: 'عقار تجاري' }, { id: 'villa', label: 'فيلا / مزرعة' } ]; const priceRanges = [ { id: 'all', label: 'جميع الأسعار' }, { id: '0-500', label: 'أقل من 50$' }, { id: '500-1000', label: '50$ - 100$' }, { id: '1000-2000', label: '100$ - 200$' }, { id: '2000-3000', label: '200$ - 300$' }, { id: '3000+', label: 'أكثر من 300$' } ]; const identityTypes = [ { id: 'syrian', label: 'هوية سورية' }, { id: 'passport', label: 'جواز سفر' } ]; const ownerSources = [ { id: 'all', label: 'الكل' }, { id: 'owner', label: 'من المالك' }, { id: 'agency', label: 'من مكتب عقاري' } ]; const rentPeriods = [ { id: 'all', label: 'الكل' }, { id: 'daily', label: 'إيجار يومي' }, { id: 'monthly', label: 'إيجار شهري' } ]; const handleTabClick = (tab) => { setActiveTab(tab); if ((tab === 'rent' || tab === 'sell') && !isAuthenticated) { setShowLoginDialog(true); } }; const handleSearch = () => { if ((activeTab === 'rent' || activeTab === 'sell') && !isAuthenticated) { setShowLoginDialog(true); return; } onSearch({ ...filters, mode: activeTab, city: filters.city || 'all', propertyType: filters.propertyType || 'all', priceRange: filters.priceRange || 'all', ownerSource: filters.ownerSource || 'all', rentPeriod: filters.rentPeriod || 'all' }); }; return ( <>
{['rent', 'buy', 'sell'].map((tab) => ( handleTabClick(tab)} className={`px-4 py-2 rounded-lg font-medium text-sm transition-all ${ activeTab === tab ? 'bg-amber-500 text-white' : 'bg-white/20 text-white hover:bg-white/30' }`} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} > {t(`${tab}Tab`)} ))}
{t("searchButton")}
{showLoginDialog && !isAuthenticated && (

يرجى تسجيل الدخول

للوصول إلى خيارات التأجير والبيع، يجب أن تكون مسجلاً.

اضغط على تسجيل الدخول لاستكمال البحث أو إدارة عقاراتك.

تسجيل الدخول
)} ); }