diff --git a/src/app/(client-components)/(HeroSearchForm2Mobile)/(real-estate-search-form)/RealestateSearchForm.tsx b/src/app/(client-components)/(HeroSearchForm2Mobile)/(real-estate-search-form)/RealestateSearchForm.tsx new file mode 100644 index 0000000..4538cf4 --- /dev/null +++ b/src/app/(client-components)/(HeroSearchForm2Mobile)/(real-estate-search-form)/RealestateSearchForm.tsx @@ -0,0 +1,162 @@ +"use client"; + +import React, { useState } from "react"; +import convertNumbThousand from "@/utils/convertNumbThousand"; +import LocationInput from "../LocationInput"; +import PriceRangeInput from "./PriceRangeInput"; +import PropertyTypeSelect from "./PropertyTypeSelect"; +import { ClassOfProperties } from "../../type"; + +const RealestateSearchForm = () => { + // + const [fieldNameShow, setFieldNameShow] = useState< + "location" | "propertyType" | "price" + >("location"); + // + const [locationInputTo, setLocationInputTo] = useState(""); + const [rangePrices, setRangePrices] = useState([100000, 4000000]); + const [typeOfProperty, setTypeOfProperty] = useState([ + { + name: "Duplex House", + description: "Have a place to yourself", + checked: true, + }, + { + name: "Ferme House", + description: "Have your own room and share some common spaces", + checked: true, + }, + { + name: "Chalet House", + description: + "Have a private or shared room in a boutique hotel, hostel, and more", + checked: true, + }, + { + name: "Maison House", + description: "Stay in a shared space, like a common room", + checked: false, + }, + ]); + + const renderInputLocation = () => { + const isActive = fieldNameShow === "location"; + return ( +
+ {!isActive ? ( + + ) : ( + { + setLocationInputTo(value); + setFieldNameShow("propertyType"); + }} + /> + )} +
+ ); + }; + + const renderInputPropertyType = () => { + const isActive = fieldNameShow === "propertyType"; + + let typeOfPropertyText = ""; + if (typeOfProperty && typeOfProperty.length > 0) { + typeOfPropertyText = typeOfProperty + .filter((item) => item.checked) + .map((item) => { + return item.name; + }) + .join(", "); + } + + return ( +
+ {!isActive ? ( + + ) : ( + + )} +
+ ); + }; + + const renderInputPrice = () => { + const isActive = fieldNameShow === "price"; + + return ( +
+ {!isActive ? ( + + ) : ( + + )} +
+ ); + }; + + return ( +
+
+ {/* */} + {renderInputLocation()} + {/* */} + {renderInputPropertyType()} + {/* */} + {renderInputPrice()} +
+
+ ); +}; + +export default RealestateSearchForm;