From 26cfb89e33d08976f53ba3ee57f6564aa28c2015 Mon Sep 17 00:00:00 2001 From: Terence Ho <> Date: Sat, 8 Oct 2022 00:29:20 +0800 Subject: [PATCH] [resumes][fix] fix invalidateQuery --- .../resumes/comments/CommentsForm.tsx | 19 ++++++++++++------- .../resumes/comments/CommentsList.tsx | 1 - 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/portal/src/components/resumes/comments/CommentsForm.tsx b/apps/portal/src/components/resumes/comments/CommentsForm.tsx index f14ba03a..c7b7dc6a 100644 --- a/apps/portal/src/components/resumes/comments/CommentsForm.tsx +++ b/apps/portal/src/components/resumes/comments/CommentsForm.tsx @@ -50,13 +50,18 @@ export default function CommentsForm({ // TODO: Give a feedback to the user if the action succeeds/fails const onSubmit: SubmitHandler = async (data) => { - await reviewCreateMutation.mutate({ - resumeId, - ...data, - }); - - // Redirect back to comments section - setShowCommentsForm(false); + return await reviewCreateMutation.mutate( + { + resumeId, + ...data, + }, + { + onSuccess: () => { + // Redirect back to comments section + setShowCommentsForm(false); + }, + }, + ); }; const onCancel = () => { diff --git a/apps/portal/src/components/resumes/comments/CommentsList.tsx b/apps/portal/src/components/resumes/comments/CommentsList.tsx index cf6c1cc7..54843bca 100644 --- a/apps/portal/src/components/resumes/comments/CommentsList.tsx +++ b/apps/portal/src/components/resumes/comments/CommentsList.tsx @@ -27,7 +27,6 @@ export default function CommentsList({ ]); // TODO: Add loading prompt - console.log(commentsQuery.data); return (