54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
import { Button } from "@mui/material";
|
|
import SearchD from "@/components/icons/SearchD";
|
|
import { useState } from "react";
|
|
import { request } from "@/services/response";
|
|
|
|
function SendReq({ fields, setDoctors, matchedCity, matchedState }) {
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const filterData = () => {
|
|
setLoading(true);
|
|
|
|
const params = new URLSearchParams(window.location.search);
|
|
const specialty = params.get("specialty");
|
|
const gender = params.get("gender");
|
|
const degree = params.get("degree");
|
|
const turn = params.get("turn");
|
|
|
|
const requestData = {
|
|
specialty: specialty === "null" ? null : specialty,
|
|
gender,
|
|
degree,
|
|
turn,
|
|
city: matchedCity?.id || null,
|
|
state: matchedState?.id || null,
|
|
name: fields.search,
|
|
};
|
|
|
|
request
|
|
.getDoctors(requestData)
|
|
.then((res) => {
|
|
if (res && res.data) setDoctors(res.data);
|
|
})
|
|
.catch(() => {})
|
|
.finally(() => {
|
|
setLoading(false);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<Button
|
|
loading={loading}
|
|
onClick={filterData}
|
|
className="!flex !m-1 !rounded-[4px] !w-[36px] sm:!w-[42px] md:!w-[49px] lg:!w-[56px] !min-w-[36px] sm:!min-w-[42px] md:!min-w-[49px] lg:!min-w-[56px]
|
|
!gap-2.5 !p-2.5 md:!p-4 !h-[calc(100%_-_8px)]"
|
|
>
|
|
<div className="w-[24px] h-[24px] min-w-[24px] min-h-[24px]">
|
|
{!loading && <SearchD />}
|
|
</div>
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
export default SendReq;
|