"use client"; import { useState } from "react"; import { motion } from "framer-motion"; import { useTranslation } from "react-i18next"; import { Search, MapPin, Home, DollarSign } from "lucide-react"; import { useFilterOptions } from "@/app/hooks/UseFilterOfHeroSearch"; import ShowLoginDialog from "./showLoginDialog"; import FilterSelect from "./FilterSelect"; export default function HeroSearch({ onSearch }) { const { t } = useTranslation(); const { cities, identityTypes, ownerSources, priceRanges, propertyTypes, rentPeriods } = useFilterOptions(); 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 handleTabClick = (tab) => { setActiveTab(tab); }; const handleSearch = () => { 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) => { const isActive = activeTab === tab; return ( ); })}
{/* city */}
} value={filters.city} onChange={(e) => setFilters({ ...filters, city: e.target.value })} option={cities} label={t(t("cityStreetLabel"))} /> {activeTab === "rent" && ( } value={filters.propertyType} onChange={(e) => setFilters({ ...filters, city: e.target.value })} option={propertyTypes} label={t("rentTypeLabel")} /> )} {/* price */} } value={filters.priceRange} onChange={(e) => setFilters({ ...filters, priceRange: e.target.value })} option={priceRanges} label={t("priceLabel")} /> {/* type */} setFilters({ ...filters, identityType: e.target.value })} option={identityTypes} label={t("identityTypeLabel")} />
{/* owener */} setFilters({ ...filters, ownerSource: e.target.value })} option={ownerSources} label={t("ownerSourceLabel")} /> {activeTab === "rent" && setFilters({ ...filters, rentPeriod: e.target.value })} option={rentPeriods} label={t("rentTypeLabel")} />}
{/* checkbox */}
{t("searchButton")}
{showLoginDialog && !isAuthenticated && } ); }