From 06626d898eb05e381cd042534eeb6a92522c177a Mon Sep 17 00:00:00 2001 From: Brett Austin Eastman <76603041+BrettEastman@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:58:31 -0700 Subject: [PATCH] Fix: Add invalidation to editMutation trpc query to refactor refetch on handleEditStudent function. --- src/pages/students/[student_id].tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/students/[student_id].tsx b/src/pages/students/[student_id].tsx index a6bffd54..330006b2 100644 --- a/src/pages/students/[student_id].tsx +++ b/src/pages/students/[student_id].tsx @@ -61,7 +61,9 @@ const ViewStudentPage = () => { { enabled: Boolean(student_id), retry: false } ); - const editMutation = trpc.case_manager.editStudent.useMutation(); + const editMutation = trpc.case_manager.editStudent.useMutation({ + onSuccess: () => utils.student.getStudentById.invalidate(), + }); const handleEditStudent = async () => { if (!student) { @@ -75,7 +77,7 @@ const ViewStudentPage = () => { grade: grade, }); handleMainState(); - document.location.reload(); + // document.location.reload(); }; const archiveMutation = trpc.case_manager.removeStudent.useMutation(); @@ -125,11 +127,12 @@ const ViewStudentPage = () => { return (