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:
@@ -0,0 +1,59 @@
|
||||
import { Button } from "@mui/material";
|
||||
import Field from "./Field";
|
||||
import { useState } from "react";
|
||||
import { request } from "@/services/response";
|
||||
|
||||
function SendAnswer({ data }) {
|
||||
const [comment, setComment] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const resetData = () => {
|
||||
setComment("");
|
||||
setLoading(false);
|
||||
data.is_open_answer = false;
|
||||
};
|
||||
|
||||
const sendReq = () => {
|
||||
setLoading(true);
|
||||
const body = {
|
||||
comment,
|
||||
doctor_id: data?.doctor?.id,
|
||||
parent: data?.parent,
|
||||
};
|
||||
|
||||
request
|
||||
.postDoctorComment(body)
|
||||
.then(() => {
|
||||
resetData();
|
||||
})
|
||||
.catch(() => {
|
||||
resetData();
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`flex flex-col mt-2 justify-center overflow-hidden transition duration-500 items-start gap-2 mb-2
|
||||
${data.is_open_answer ? "max-h-fit" : "max-h-0"}`}
|
||||
>
|
||||
<Field
|
||||
type="text"
|
||||
value={comment}
|
||||
title="پاسخ شما..."
|
||||
isPlaceHolder={true}
|
||||
updateValue={(val) => setComment(val)}
|
||||
/>
|
||||
<Button
|
||||
loading={loading}
|
||||
variant="contained"
|
||||
onClick={sendReq}
|
||||
className="!p-2 !h-10 !text-[12px] !font-medium sm:!py-[10px] md:!px-[12px] !rounded-[8px]
|
||||
!shadow-none sm:!shadow-[0px_4px_30px_0px_rgba(56,_160,_162,_0.30)]"
|
||||
>
|
||||
ارسال پاسخ
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default SendAnswer;
|
||||
Reference in New Issue
Block a user