diff --git a/app/component/modalSearchCity/Content.js b/app/component/modalSearchCity/Content.js
index 4551bdb..b94e43f 100644
--- a/app/component/modalSearchCity/Content.js
+++ b/app/component/modalSearchCity/Content.js
@@ -23,10 +23,26 @@ function Content({
};
const handleFilter = () => {
+ const city =
+ selected &&
+ citySelected &&
+ filteredCities.find((item) => item.name === citySelected);
+
+ const current = new URLSearchParams(window.location.search);
+ current.set("province", city.id);
+ const newUrl = `${window.location.pathname}?${current.toString()}`;
+ window.history.replaceState({}, "", newUrl);
+
handleSearch && handleSearch("");
handleClose();
};
+ const valState =
+ selected &&
+ citySelected &&
+ filteredCities.find((item) => item.name === citySelected) &&
+ citySelected;
+
return (
{list && list.length ? (
{list?.map((doctor) => (
-
+
))}
) : (
diff --git a/components/doctors/modal/ButtonApply.js b/components/doctors/modal/ButtonApply.js
index 758aa49..8e3d3b8 100644
--- a/components/doctors/modal/ButtonApply.js
+++ b/components/doctors/modal/ButtonApply.js
@@ -19,13 +19,13 @@ function ButtonApply({
setLoading(true);
const params = new URLSearchParams(window.location.search);
- const field = params.get("field");
+ const specialty = params.get("specialty");
const gender = params.get("gender");
const degree = params.get("degree");
const turn = params.get("turn");
const requestData = {
- field: field === "null" ? null : field,
+ specialty: specialty === "null" ? null : specialty,
gender,
degree,
turn,
@@ -38,7 +38,7 @@ function ButtonApply({
.then((res) => {
if (res && res.data) setDoctors(res.data);
})
- .catch((err) => {})
+ .catch(() => {})
.finally(() => {
setOpen(false);
setLoading(false);
@@ -50,7 +50,7 @@ function ButtonApply({
const mappings = [
{
- key: "field",
+ key: "specialty",
getValue: () => {
if (data.category) {
const children = specialties.filter(
diff --git a/components/doctors/modal/FilterModal.js b/components/doctors/modal/FilterModal.js
index e713595..648025a 100644
--- a/components/doctors/modal/FilterModal.js
+++ b/components/doctors/modal/FilterModal.js
@@ -31,7 +31,7 @@ function FilterModal({
const deleteData = () => {
clearFilterParams(router, [
"turn",
- "field",
+ "specialty",
"degree",
"category",
"gender",
diff --git a/components/doctors/modal/form/index.js b/components/doctors/modal/form/index.js
index 22c2616..6f3fe78 100644
--- a/components/doctors/modal/form/index.js
+++ b/components/doctors/modal/form/index.js
@@ -15,14 +15,14 @@ function Form({ data, changeData }) {
list={parentList}
label="دسته بندی"
value={data.category}
- updateData={(value) => changeData(value, "category", true, "field")}
+ updateData={(value) => changeData(value, "category", true, "specialty")}
/>
{!!childrenList.length && (
- changeData(value, "specialties", false, "field")
+ changeData(value, "specialties", false, "specialty")
}
value={data.specialties}
label="تخصص"
diff --git a/components/doctors/search/SearchField.js b/components/doctors/search/SearchField.js
new file mode 100644
index 0000000..eed9720
--- /dev/null
+++ b/components/doctors/search/SearchField.js
@@ -0,0 +1,34 @@
+import { TextField } from "@mui/material";
+import React from "react";
+
+function SearchField({ fields, setFields }) {
+ return (
+ setFields({ ...fields, search: e.target.value })}
+ InputProps={{
+ disableUnderline: true,
+ }}
+ sx={{
+ display: "flex",
+ flexDirection: "column",
+ justifyContent: "center",
+ width: "100% !important",
+ "& .MuiInput-root": {
+ padding: "0",
+ borderBottom: "none",
+ },
+ "& .MuiInputBase-input": {
+ color: "#6C757D",
+ padding: "0px",
+ },
+ }}
+ dir="rtl"
+ placeholder="جستجوی نام پزشک، تخصص، بیماری ..."
+ className={`!shadow-none !px-5 !h-full !w-[524px] bg-[#FAFAFA] !text-[14px] md:!text-[16px] !min-w-[50%] !rounded-0 !font-normal !text-[#6C757D]`}
+ />
+ );
+}
+
+export default SearchField;
diff --git a/components/doctors/search/SendReq.js b/components/doctors/search/SendReq.js
new file mode 100644
index 0000000..d720873
--- /dev/null
+++ b/components/doctors/search/SendReq.js
@@ -0,0 +1,53 @@
+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 (
+
+ );
+}
+
+export default SendReq;
diff --git a/components/doctors/search/index.js b/components/doctors/search/index.js
index 803ea01..336e44c 100644
--- a/components/doctors/search/index.js
+++ b/components/doctors/search/index.js
@@ -1,13 +1,16 @@
-import { Button, ButtonGroup, TextField } from "@mui/material";
+import { Button, ButtonGroup } from "@mui/material";
import SettingD from "@/components/icons/SettingD";
import ArrowBottomD from "@/components/icons/ArrowBottomD";
-import SearchD from "@/components/icons/SearchD";
import FilterModal from "../modal/FilterModal";
+import SendReq from "./SendReq";
+import { useState } from "react";
+import SearchField from "./SearchField";
function SearchBar({
data,
+ fields,
setData,
- params,
+ setFields,
setDoctors,
matchedCity,
matchedState,
@@ -18,8 +21,8 @@ function SearchBar({
-
+
-
);
}