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
@@ -7,9 +7,6 @@ import TextLoading from "@/app/component/loading/Text";
import CustomLoading from "@/app/component/loading/Custom";
function Chart({ comments, doctor }) {
console.log(doctor);
console.log(comments);
return (
<div
className="
@@ -50,7 +50,7 @@ function ModalAnswer({ doctor }) {
setLoading(true);
request
.postDoctorComment(comment.detail)
.then((res) => {
.then(() => {
let newComment = comment.rate;
newComment = {
correct_diagnosis: newComment[1].progress,
@@ -105,6 +105,7 @@ function ModalAnswer({ doctor }) {
<Rating
className="!my-[24px]"
value={averageRate}
readOnly
dir="ltr"
sx={{
"& .MuiSvgIcon-root": {
+79
View File
@@ -0,0 +1,79 @@
import { Autocomplete, TextField } from "@mui/material";
function AutoComplete({
data,
noneBg,
clearText,
inputValue,
placeholder,
handleSearch,
setInputValue,
setSelectedOption,
}) {
const clearIndicatorProps = clearText
? {
clearIndicator: {
onClick: () => {
clearText();
},
},
}
: {};
console.log(inputValue);
return (
<Autocomplete
freeSolo
options={data}
getOptionLabel={(option) => option.name}
disableClearable
inputValue={inputValue || ""}
className="!w-full"
onInputChange={(_, newInputValue) => {
setInputValue && setInputValue(newInputValue);
handleSearch(newInputValue);
}}
onChange={(_, newValue) => {
setSelectedOption && setSelectedOption(newValue);
handleSearch(newValue ? newValue.name : "");
}}
// componentsProps={clearIndicatorProps}
renderOption={(props, option) => (
<li {...props} key={option.id}>
{option.name}
</li>
)}
sx={{
"& .MuiAutocomplete-input": {
background: noneBg ? "" : "#ffffff !important",
},
}}
renderInput={(params) => (
<TextField
{...params}
variant="standard"
placeholder={placeholder}
dir="rtl"
InputProps={{
...params.InputProps,
disableUnderline: true,
style: { height: "100%" },
}}
sx={{
background: "transparent !important",
"& .MuiInputBase-input": {
background: "#FAFAFA",
color: "#6C757D",
padding: "0 16px",
fontSize: "14px",
fontFamily: "inherit",
},
}}
className="!shadow-none !w-full !px-5 !h-full !text-[14px] md:!text-[16px] !min-w-[50%] !rounded-0 !font-normal"
/>
)}
/>
);
}
export default AutoComplete;
+34 -4
View File
@@ -1,7 +1,7 @@
import AutoCompleteSearch from "@/components/searchHead/smSearch/AutoCompleteSearch";
import specialties from "@/data/specialties.json";
import { clearFilterParams } from "@/helper";
import { useRouter } from "next/navigation";
import specialties from "@/data/specialties.json";
import AutoComplete from "./AutoComplete";
function SearchField({ filter, setFilter, updateData, setDataInURL }) {
const router = useRouter();
@@ -19,13 +19,43 @@ function SearchField({ filter, setFilter, updateData, setDataInURL }) {
setFilter(newFilter);
// setDataInURL(newFilter);
};
console.log(filter);
const handleSearch = (e) => {
const findName = specialties.find((item) => item.name === e);
console.log(findName);
if (findName) {
let newFilter = { ...filter };
if (findName.parent) {
const itemParent = specialties.find(
(item) => item.id === findName.parent
);
newFilter.category = itemParent;
newFilter.specialty = findName;
// updateData("name", e);
} else {
newFilter.category = findName;
newFilter.specialty = "";
}
newFilter.name = e
setFilter(newFilter);
// const newFilter = { ...filter, [name]: e };
// setFilter(newFilter);
} else {
updateData("name", e);
}
};
return (
<div className="!min-w-[50%] !w-[524px]">
<AutoCompleteSearch
<AutoComplete
data={specialties}
clearText={clearText}
inputValue={filter.name}
handleSearch={(e) => updateData("name", e)}
handleSearch={handleSearch}
// handleSearch={(e) => updateData("name", e)}
placeholder="جستجوی نام پزشک، تخصص، بیماری ..."
/>
</div>
+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);
});
};
@@ -10,7 +10,6 @@ function AutoCompleteSearch({
setInputValue,
setSelectedOption,
}) {
// ایجاد props شرطی برای clearIndicator
const clearIndicatorProps = clearText
? {
clearIndicator: {