diff --git a/app/component/modalSearchCity/Content.js b/app/component/modalSearchCity/Content.js index fb223e6..985f740 100644 --- a/app/component/modalSearchCity/Content.js +++ b/app/component/modalSearchCity/Content.js @@ -18,7 +18,7 @@ function Content({ const { matchedState } = getStateInfoClient(); const handleClick = () => { handleClose(); - sendReq(); + sendReq(filter); }; const updateData = (name, value) => { diff --git a/components/doctors/head/index.js b/components/doctors/head/index.js index 4fcbe17..1a02045 100644 --- a/components/doctors/head/index.js +++ b/components/doctors/head/index.js @@ -7,7 +7,7 @@ import { QueryForDoctorsFilter, QueryForDoctorsReq } from "@/helper"; import { request } from "@/services/response"; import FilterLocate from "./FilterLocate"; -function Head({ filter, setFilter, setPage, setDoctors }) { +function Head({ filter, setFilter, setPage, setDoctors, setLoading }) { const router = useRouter(); const setDataInURL = (newFilter) => { @@ -38,6 +38,7 @@ function Head({ filter, setFilter, setPage, setDoctors }) { filteredName.page = 1; filteredName.limit = 12; setPage(1); + setLoading(true); return request .getDoctors(filteredName) @@ -47,6 +48,9 @@ function Head({ filter, setFilter, setPage, setDoctors }) { }) .catch((err) => { throw err; + }) + .finally(() => { + setLoading(false); }); }; diff --git a/components/doctors/index.js b/components/doctors/index.js index 3a3474a..77cdf1e 100644 --- a/components/doctors/index.js +++ b/components/doctors/index.js @@ -45,6 +45,7 @@ function DoctorsPage({ matchedCity, matchedState, list }) { }; const [filter, setFilter] = useState(defaultFilter); + const [loading, setLoading] = useState(false); return (
@@ -54,6 +55,7 @@ function DoctorsPage({ matchedCity, matchedState, list }) { setPage={setPage} setFilter={setFilter} setDoctors={setDoctors} + setLoading={setLoading} matchedCity={matchedCity} matchedState={matchedState} /> @@ -64,6 +66,8 @@ function DoctorsPage({ matchedCity, matchedState, list }) { filter={filter} setPage={setPage} doctors={doctors} + loading={loading} + setLoading={setLoading} setDoctors={setDoctors} />
diff --git a/components/doctors/listDoctors/index.js b/components/doctors/listDoctors/index.js index db0f913..5cb6974 100644 --- a/components/doctors/listDoctors/index.js +++ b/components/doctors/listDoctors/index.js @@ -13,8 +13,10 @@ function ListDoctors({ doctors, setPage, setDoctors, + loading: filterLoading, }) { const [loading, setLoading] = useState(false); + const isLoading = loading || filterLoading; const router = useRouter(); const changePage =async (_, num) => { @@ -54,14 +56,14 @@ function ListDoctors({ return ( <> -
+
{doctors && doctors.length ? (