show only the first item in appo list & update appo item text && change key in /doctors page URL && handle setting and updating data on first modal filter load
This commit is contained in:
@@ -12,21 +12,25 @@ import ModalSearchCity from "@/app/component/modalSearchCity";
|
||||
import specialties from "@/data/specialties.json";
|
||||
|
||||
function DoctorsPage({ params, matchedCity, matchedState, list }) {
|
||||
const fieldId = params.field;
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [selected, setSelected] = useState({
|
||||
province: matchedState?.name || params?.province,
|
||||
city: matchedCity?.name || params?.city,
|
||||
});
|
||||
console.log(specialties);
|
||||
// console.log(fieldId);
|
||||
|
||||
const findItem = (id) => specialties.find((item) => item.id === id);
|
||||
const isParent = findItem(fieldId) && findItem(fieldId).parent;
|
||||
console.log(isParent);
|
||||
|
||||
const findSpecial = (id) => specialties.find((item) => item.id === id);
|
||||
|
||||
const [data, setData] = useState({
|
||||
category: findSpecial(params.specialties)?.parent
|
||||
? findSpecial(findSpecial(params.specialties)?.parent)
|
||||
: findSpecial(params.specialties) || "",
|
||||
specialties: findSpecial(params.specialties)?.parent
|
||||
? findSpecial(params.specialties)
|
||||
: "",
|
||||
category: isParent ? findItem(isParent) : findItem(fieldId),
|
||||
specialties: isParent && findItem(fieldId),
|
||||
turn: params && params.hasOwnProperty("turn") ? JSON.parse(params.turn) : 1,
|
||||
gender: params.gender || "هر دو",
|
||||
degree: params.degree || "همه موارد",
|
||||
|
||||
Reference in New Issue
Block a user