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:
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user