Skip to content

Commit

Permalink
Fix: Add invalidation to editMutation trpc query to refactor refetch …
Browse files Browse the repository at this point in the history
…on handleEditStudent function.
  • Loading branch information
BrettEastman committed Nov 2, 2023
1 parent ecc994b commit 06626d8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/pages/students/[student_id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -75,7 +77,7 @@ const ViewStudentPage = () => {
grade: grade,
});
handleMainState();
document.location.reload();
// document.location.reload();
};

const archiveMutation = trpc.case_manager.removeStudent.useMutation();
Expand Down Expand Up @@ -125,11 +127,12 @@ const ViewStudentPage = () => {
return (
<Stack
spacing={2}
sx={{
display: "flex",
flexDirection: "column",
alignItems: "center",
}}
// sx={{
// display: "flex",
// flexDirection: "column",
// alignItems: "center",
// width: "100vu",
// }}
>
<Container
className={$StudentPage.studentInfoContainer}
Expand Down

0 comments on commit 06626d8

Please sign in to comment.