handle like comments data, req for update comments and add loading for like comment && search specialty with searchbar in doctors page && set category and specialty data

This commit is contained in:
ehsan
2025-09-20 17:04:36 +03:30
parent 2f078eba3c
commit dfc8492afa
14 changed files with 366 additions and 121 deletions
+21 -21
View File
@@ -5,33 +5,33 @@ import specialties from "@/data/specialties.json";
function SendReq({ filter, setFilter, setDataInURL, sendReq }) {
const [loading, setLoading] = useState(false);
const checkName = () => {
let newFilter = filter;
const specialtyItem =
filter.name &&
specialties.find((item) => item.name.includes(filter.name));
// const checkName = () => {
// let newFilter = filter;
// const specialtyItem =
// filter.name &&
// specialties.find((item) => item.name.includes(filter.name));
if (specialtyItem) {
if (specialtyItem.parent) {
newFilter.specialty = specialtyItem;
newFilter.category = specialties.find(
(item) => item.id === specialtyItem.parent
);
} else {
newFilter.specialty = specialtyItem;
}
}
// if (specialtyItem) {
// if (specialtyItem.parent) {
// newFilter.specialty = specialtyItem;
// newFilter.category = specialties.find(
// (item) => item.id === specialtyItem.parent
// );
// } else {
// newFilter.specialty = specialtyItem;
// }
// }
return newFilter;
};
// return newFilter;
// };
const filterData = () => {
setLoading(true);
const newFilter = checkName();
setFilter(newFilter);
setDataInURL(newFilter);
// const newFilter = checkName();
setFilter(filter);
setDataInURL(filter);
sendReq(newFilter).finally(() => {
sendReq(filter).finally(() => {
setLoading(false);
});
};