last update
This commit is contained in:
@@ -5,7 +5,7 @@ import ModalSearchCity from "@/app/component/modalSearchCity";
|
||||
import { useState } from "react";
|
||||
import ButtonFilter from "@/app/component/modalSearchCity/ButtonFilter";
|
||||
|
||||
function SearchBar({ selected, setSelected, state, handleSearch }) {
|
||||
function SearchBar({ selected, setSelected, state, handleSearch, changeSearch, search }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
@@ -26,8 +26,9 @@ function SearchBar({ selected, setSelected, state, handleSearch }) {
|
||||
<ButtonFilter setOpen={setOpen} selected={selected} />
|
||||
</ModalSearchCity>
|
||||
<TextField
|
||||
value={search}
|
||||
variant="standard"
|
||||
onChange={e => handleSearch(e.target.value)}
|
||||
onChange={e => changeSearch(e.target.value)}
|
||||
InputProps={{
|
||||
disableUnderline: true,
|
||||
}}
|
||||
@@ -42,11 +43,12 @@ function SearchBar({ selected, setSelected, state, handleSearch }) {
|
||||
className={`!shadow-none !w-full !min-w-3 !px-5 !h-full bg-[#FAFAFA] !text-[14px] md:!text-[16px] lg:!min-w-[50%] !rounded-0 !font-normal !text-[#6C757D]`}
|
||||
/>
|
||||
<Button
|
||||
onClick={handleSearch}
|
||||
className="
|
||||
!rounded-[4px] !gap-2.5 !p-2 md:!p-3 lg:!p-4 !min-w-fit
|
||||
!w-[38px] sm:!w-[44px] md:!w-[50px] lg:!w-[56px]
|
||||
!h-[38px] sm:!h-[44px] md:!h-[50px] lg:!h-[56px]
|
||||
"
|
||||
!rounded-[4px] !gap-2.5 !p-2 md:!p-3 lg:!p-4 !min-w-fit
|
||||
!w-[38px] sm:!w-[44px] md:!w-[50px] lg:!w-[56px]
|
||||
!h-[38px] sm:!h-[44px] md:!h-[50px] lg:!h-[56px]
|
||||
"
|
||||
>
|
||||
<SearchD />
|
||||
</Button>
|
||||
|
||||
@@ -10,6 +10,7 @@ import HeadPageList from "@/app/component/head";
|
||||
|
||||
function ClinicsPage({ matchedCity, matchedState }) {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [search, setSearch] = useState("");
|
||||
const [filteredClinics, setFilteredClinics] = useState(clinics)
|
||||
|
||||
const [selected, setSelected] = useState({
|
||||
@@ -23,11 +24,13 @@ function ClinicsPage({ matchedCity, matchedState }) {
|
||||
}, 2000);
|
||||
}, []);
|
||||
|
||||
const handleSearch = text => {
|
||||
setFilteredClinics(
|
||||
searchOnList(clinics, text, 'title')
|
||||
);
|
||||
}
|
||||
const changeSearch = text => setSearch(text);
|
||||
|
||||
const handleSearch = () => {
|
||||
const searchOnName = searchOnList(clinics, search, 'title')
|
||||
const searchOnLocation = searchOnList(searchOnName, selected.city, 'city')
|
||||
setFilteredClinics(searchOnLocation);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -36,9 +39,11 @@ function ClinicsPage({ matchedCity, matchedState }) {
|
||||
detail="در قسمت زیر می توانید کلینیک مورد نظر خود را جستجو نمایید"
|
||||
>
|
||||
<SearchBar
|
||||
search={search}
|
||||
selected={selected}
|
||||
setSelected={setSelected}
|
||||
state={matchedState?.name}
|
||||
changeSearch={changeSearch}
|
||||
handleSearch={handleSearch}
|
||||
/>
|
||||
</HeadPageList>
|
||||
|
||||
Reference in New Issue
Block a user