'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: t('allCities') }, { id: 'دمشق', label: t('damascus') }, { id: 'حلب', label: t('aleppo') }, { id: 'حمص', label: t('homs') }, { id: 'اللاذقية', label: t('latakia') }, { id: 'درعا', label: t('daraa') } ]; const propertyTypes = [ { id: 'all', label: t('all') }, { id: 'apartment', label: t('residentialApartments') }, { id: 'studio', label: t('studio') }, { id: 'commercial', label: t('commercialProperty') }, { id: 'villa', label: t('villaFarm') } ]; const priceRanges = [ { id: 'all', label: t('allPrices') }, { id: '0-500', label: t('priceRange1') }, { id: '500-1000', label: t('priceRange2') }, { id: '1000-2000', label: t('priceRange3') }, { id: '2000-3000', label: t('priceRange4') }, { id: '3000+', label: t('priceRange5') } ]; const identityTypes = [ { id: 'syrian', label: t('syrianId') }, { id: 'passport', label: t('passport') } ]; const ownerSources = [ { id: 'all', label: t('all') }, { id: 'owner', label: t('fromOwner') }, { id: 'agency', label: t('fromAgency') } ]; const rentPeriods = [ { id: 'all', label: t('all') }, { id: 'daily', label: t('dailyRent') }, { id: 'monthly', label: t('monthlyRent') } ]; 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`)} ))}
{activeTab === 'rent' && (
)}
{activeTab === 'rent' && (
)}
{t("searchButton")}
{showLoginDialog && !isAuthenticated && (

{t("loginRequired")}

{t("loginRequiredDesc")}

{t("loginPrompt")}

{t("login")}
)} ); }