File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -41,9 +41,17 @@ const ViewStudentPage = () => {
41
41
42
42
const { data : student , isLoading } = trpc . student . getStudentById . useQuery (
43
43
{ student_id : student_id as string } ,
44
- { enabled : Boolean ( student_id ) }
44
+ {
45
+ enabled : Boolean ( student_id ) ,
46
+ retry : false ,
47
+ onError : ( ) => returnToStudentList ( ) ,
48
+ }
45
49
) ;
46
50
51
+ const returnToStudentList = async ( ) => {
52
+ await router . push ( `/students` ) ;
53
+ } ;
54
+
47
55
const buttonSX = {
48
56
"&:hover" : {
49
57
background : "#3023B8" ,
@@ -83,7 +91,7 @@ const ViewStudentPage = () => {
83
91
return ;
84
92
}
85
93
await archiveMutation . mutateAsync ( { student_id : student . student_id } ) ;
86
- await router . push ( `/students` ) ;
94
+ await returnToStudentList ( ) ;
87
95
} ;
88
96
89
97
const iepMutation = trpc . student . addIep . useMutation ( {
@@ -120,6 +128,8 @@ const ViewStudentPage = () => {
120
128
return < div > Loading...</ div > ;
121
129
}
122
130
131
+ if ( ! student ) return ;
132
+
123
133
return (
124
134
< Stack
125
135
spacing = { 2 }
You can’t perform that action at this time.
0 commit comments