import { Button } from "@mui/material"; import Field from "./Field"; import { useState } from "react"; import { request } from "@/services/response"; import { alert } from "@/helper"; 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(() => { alert( "success", "کامنت شما با موفقیت ثبت شد و پس از تأیید نمایش داده میشود." ); resetData(); }) .catch(() => { alert("error", "خطایی رخ داد! لطفاً دوباره تلاش کنید."); resetData(); }); }; return (