From 05df8c0e08958496f28436713463ef85b89ee05a Mon Sep 17 00:00:00 2001 From: konavivekramakrishna <101407963+konavivekramakrishna@users.noreply.github.com> Date: Wed, 8 Nov 2023 19:41:40 +0530 Subject: [PATCH] fix commentSection in resource (#6562) --- src/Components/Resource/CommentSection.tsx | 86 +++++++++++----------- 1 file changed, 41 insertions(+), 45 deletions(-) diff --git a/src/Components/Resource/CommentSection.tsx b/src/Components/Resource/CommentSection.tsx index 33ed68da45d..5b9929ed19f 100644 --- a/src/Components/Resource/CommentSection.tsx +++ b/src/Components/Resource/CommentSection.tsx @@ -4,7 +4,6 @@ import { formatDateTime } from "../../Utils/utils"; import CircularProgress from "../Common/components/CircularProgress"; import ButtonV2 from "../Common/components/ButtonV2"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; -import useQuery from "../../Utils/request/useQuery"; import routes from "../../Redux/api"; import PaginatedList from "../../CAREUI/misc/PaginatedList"; import { IComment } from "./models"; @@ -12,12 +11,6 @@ import request from "../../Utils/request/request"; const CommentSection = (props: { id: string }) => { const [commentBox, setCommentBox] = useState(""); - const { loading, refetch: resourceRefetch } = useQuery( - routes.getResourceComments, - { - pathParams: { id: props.id }, - } - ); const onSubmitComment = async () => { const payload = { @@ -35,49 +28,52 @@ const CommentSection = (props: { id: string }) => { }); if (res?.ok) { Notification.Success({ msg: "Comment added successfully" }); - resourceRefetch(); } setCommentBox(""); }; return ( -
- setCommentBox(e.value)} - /> -
- Post Your Comment -
-
- {loading ? ( - - ) : ( - - {() => ( -
- - No comments available - - - - - > - {(item) => } - -
- -
+ + {(_, query) => ( +
+ setCommentBox(e.value)} + /> + +
+ { + await onSubmitComment(); + query.refetch(); + }} + > + Post Your Comment + +
+
+
+ + No comments available + + + + + > + {(item) => } + +
+
- )} - - )} -
-
+
+
+
+ )} + ); };