"use client"; import { useState } from "react"; import SearchBar from "./search"; import SortList from "./sortlist"; import { Button } from "@mui/material"; import ListDoctors from "./listDoctors"; import LocationD from "../icons/LocationD"; import ModalSearchCity from "@/app/component/modalSearchCity"; // Data import specialties from "@/data/specialties.json"; function DoctorsPage({ params, matchedCity, matchedState, list }) { const fieldName = params.field; const [doctors, setDoctors] = useState(list); const [open, setOpen] = useState(false); const [fields, setFields] = useState({ search: "", stars: "", }); const [selected, setSelected] = useState({ province: matchedState?.name || params?.province, city: matchedCity?.name || params?.city, }); const findItem = (key, name) => specialties.find((item) => item[key] === name); const isParent = findItem("name", fieldName) && findItem("name", fieldName).parent; const dataParent = findItem("name", fieldName) && isParent && findItem("id", isParent); const defaultData = { category: isParent ? findItem("id", isParent) : findItem("name", fieldName), specialties: isParent && findItem("name", fieldName), turn: params && params.hasOwnProperty("turn") ? JSON.parse(params.turn) : 1, gender: params.gender || "هر دو", degree: params.degree || "همه موارد", }; const [data, setData] = useState(defaultData); const [confirmedData, setConfirmedData] = useState(defaultData); return (