save state selected in modal filter, filter list with location selected, save data sort, filter list with sort point, real all url from .env file, change name of value category and specialties to persian and change functional find data with field
This commit is contained in:
@@ -12,23 +12,28 @@ import ModalSearchCity from "@/app/component/modalSearchCity";
|
||||
import specialties from "@/data/specialties.json";
|
||||
|
||||
function DoctorsPage({ params, matchedCity, matchedState, list }) {
|
||||
const fieldId = params.field;
|
||||
const fieldName = params.field;
|
||||
const [doctors, setDoctors] = useState(list);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [fields, setFields] = useState({
|
||||
search: "",
|
||||
stars: null,
|
||||
stars: "",
|
||||
});
|
||||
const [selected, setSelected] = useState({
|
||||
province: matchedState?.name || params?.province,
|
||||
city: matchedCity?.name || params?.city,
|
||||
});
|
||||
|
||||
const findItem = (id) => specialties.find((item) => item.id === id);
|
||||
const isParent = findItem(fieldId) && findItem(fieldId).parent;
|
||||
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(isParent) : findItem(fieldId),
|
||||
specialties: isParent && findItem(fieldId),
|
||||
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 || "همه موارد",
|
||||
@@ -72,7 +77,12 @@ function DoctorsPage({ params, matchedCity, matchedState, list }) {
|
||||
confirmedData={confirmedData}
|
||||
setConfirmedData={setConfirmedData}
|
||||
/>
|
||||
<SortList data={data} setData={setData} />
|
||||
<SortList
|
||||
fields={fields}
|
||||
setFields={setFields}
|
||||
data={data}
|
||||
setData={setData}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<ListDoctors list={doctors} />
|
||||
|
||||
Reference in New Issue
Block a user