change design dashboards all page and search clinics
This commit is contained in:
@@ -3,11 +3,13 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import List from "./list";
|
||||
import { searchOnList } from "@/helper";
|
||||
import SearchBar from "./head/SearchBar";
|
||||
import HeadPageList from "@/app/component/head";
|
||||
import { useRouter } from "next/navigation";
|
||||
import specialtiesData from "@/data/specialties.json";
|
||||
|
||||
function ClinicsPage({ clinics, matchedCity, matchedState }) {
|
||||
const router = useRouter();
|
||||
const [filteredClinics, setFilteredClinics] = useState(clinics);
|
||||
|
||||
const [selected, setSelected] = useState({
|
||||
@@ -16,9 +18,13 @@ function ClinicsPage({ clinics, matchedCity, matchedState }) {
|
||||
});
|
||||
|
||||
const handleSearch = (value) => {
|
||||
const searchOnName = searchOnList(clinics, value, "title");
|
||||
const searchOnLocation = searchOnList(searchOnName, selected.city, "city");
|
||||
setFilteredClinics(searchOnLocation);
|
||||
const current = new URLSearchParams(window.location.search);
|
||||
current.set("search", value);
|
||||
const queryString = current.toString();
|
||||
router.push(`/clinics?${queryString}`);
|
||||
// const searchOnName = searchOnList(clinics, value, "title");
|
||||
// const searchOnLocation = searchOnList(searchOnName, selected.city, "city");
|
||||
// setFilteredClinics(searchOnLocation);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -32,6 +38,7 @@ function ClinicsPage({ clinics, matchedCity, matchedState }) {
|
||||
setSelected={setSelected}
|
||||
state={matchedState?.name}
|
||||
handleSearch={handleSearch}
|
||||
specialties={specialtiesData}
|
||||
/>
|
||||
</HeadPageList>
|
||||
<List selected={selected} clinics={filteredClinics} />
|
||||
|
||||
Reference in New Issue
Block a user