diff --git a/src/CAREUI/misc/PaginatedList.tsx b/src/CAREUI/misc/PaginatedList.tsx index 3521807154e..142af264a83 100644 --- a/src/CAREUI/misc/PaginatedList.tsx +++ b/src/CAREUI/misc/PaginatedList.tsx @@ -33,7 +33,10 @@ function useContextualized() { interface Props extends QueryOptions> { route: QueryRoute>; perPage?: number; - children: (ctx: PaginatedListContext) => JSX.Element | JSX.Element[]; + children: ( + ctx: PaginatedListContext, + refetch: () => void + ) => JSX.Element | JSX.Element[]; } export default function PaginatedList({ @@ -59,7 +62,7 @@ export default function PaginatedList({ value={{ ...query, items, perPage, currentPage, setPage }} > - {(ctx) => children(ctx as PaginatedListContext)} + {(ctx) => children(ctx as PaginatedListContext, query.refetch)} ); diff --git a/src/Components/Shifting/CommentsSection.tsx b/src/Components/Shifting/CommentsSection.tsx index 6bb6042ba72..0f96dcfdd63 100644 --- a/src/Components/Shifting/CommentsSection.tsx +++ b/src/Components/Shifting/CommentsSection.tsx @@ -4,7 +4,6 @@ import * as Notification from "../../Utils/Notifications.js"; import { formatDateTime } from "../../Utils/utils"; import { useTranslation } from "react-i18next"; import ButtonV2 from "../Common/components/ButtonV2"; -import useQuery from "../../Utils/request/useQuery"; import routes from "../../Redux/api"; import { IComment } from "../Resource/models"; import PaginatedList from "../../CAREUI/misc/PaginatedList"; @@ -17,10 +16,6 @@ const CommentSection = (props: CommentSectionProps) => { const [commentBox, setCommentBox] = useState(""); const { t } = useTranslation(); - const { loading, refetch: fetchData } = useQuery(routes.getShiftComments, { - pathParams: { id: props.id }, - }); - const onSubmitComment = async () => { const payload = { comment: commentBox, @@ -37,54 +32,55 @@ const CommentSection = (props: CommentSectionProps) => { }); if (res?.ok) { Notification.Success({ msg: t("comment_added_successfully") }); - fetchData(); + setCommentBox(""); } }; return ( -
-