@@ -18,16 +18,15 @@ import {
18
18
import * as React from 'react' ;
19
19
import { Assignment } from '../../model/assignment' ;
20
20
import { Lecture } from '../../model/lecture' ;
21
- import { deleteAssignment , getAllAssignments } from '../../services/assignments.service' ;
21
+ import {
22
+ deleteAssignment ,
23
+ getAllAssignments
24
+ } from '../../services/assignments.service' ;
22
25
import { CreateDialog , EditLectureDialog } from '../util/dialog' ;
23
26
import { getLecture , updateLecture } from '../../services/lectures.service' ;
24
27
import { red , grey } from '@mui/material/colors' ;
25
28
import { enqueueSnackbar } from 'notistack' ;
26
- import {
27
- useNavigate ,
28
- useNavigation ,
29
- useRouteLoaderData
30
- } from 'react-router-dom' ;
29
+ import { useNavigate } from 'react-router-dom' ;
31
30
import { ButtonTr , GraderTable } from '../util/table' ;
32
31
import { DeadlineComponent } from '../util/deadline' ;
33
32
import CloseIcon from '@mui/icons-material/Close' ;
@@ -163,10 +162,14 @@ export const LectureComponent = () => {
163
162
enabled : ! ! lectureId
164
163
} ) ;
165
164
166
- const { data : assignments = [ ] , isLoading : isLoadingAssignments , refetch : refetchAssignments } = useQuery < AssignmentDetail [ ] > ( {
165
+ const {
166
+ data : assignments = [ ] ,
167
+ isLoading : isLoadingAssignments ,
168
+ refetch : refetchAssignments
169
+ } = useQuery < AssignmentDetail [ ] > ( {
167
170
queryKey : [ 'assignments' , lecture , lectureId ] ,
168
171
queryFn : ( ) => getAllAssignments ( lectureId ) ,
169
- enabled : ! ! lecture
172
+ enabled : ! ! lecture
170
173
} ) ;
171
174
172
175
React . useEffect ( ( ) => {
@@ -175,12 +178,10 @@ export const LectureComponent = () => {
175
178
}
176
179
} , [ assignments ] ) ;
177
180
178
-
179
181
const [ lectureState , setLecture ] = React . useState ( lecture ) ;
180
182
const [ assignmentsState , setAssignments ] = React . useState < Assignment [ ] > ( [ ] ) ;
181
183
const [ isEditDialogOpen , setEditDialogOpen ] = React . useState ( false ) ;
182
184
183
-
184
185
if ( isLoadingLecture || isLoadingAssignments ) {
185
186
return (
186
187
< div >
@@ -195,19 +196,20 @@ export const LectureComponent = () => {
195
196
setEditDialogOpen ( true ) ;
196
197
} ;
197
198
198
-
199
- const handleUpdateLecture = ( updatedLecture ) => {
199
+ const handleUpdateLecture = updatedLecture => {
200
200
updateLecture ( updatedLecture ) . then (
201
- async ( response ) => {
201
+ async response => {
202
202
await updateMenus ( true ) ;
203
203
setLecture ( response ) ;
204
204
// Invalidate query key "lectures" and "completedLectures", so that we trigger refetch on lectures table and correct lecture name is shown in the table!
205
- queryClient . invalidateQueries ( { queryKey : [ 'lectures' ] } ) ;
206
- queryClient . invalidateQueries ( { queryKey : [ 'completedLectures' ] } ) ;
205
+ await queryClient . invalidateQueries ( { queryKey : [ 'lectures' ] } ) ;
206
+ await queryClient . invalidateQueries ( {
207
+ queryKey : [ 'completedLectures' ]
208
+ } ) ;
207
209
} ,
208
- ( error ) => {
210
+ error => {
209
211
enqueueSnackbar ( error . message , {
210
- variant : 'error' ,
212
+ variant : 'error'
211
213
} ) ;
212
214
}
213
215
) ;
@@ -236,11 +238,7 @@ export const LectureComponent = () => {
236
238
alignItems = "center"
237
239
sx = { { mt : 2 , mb : 1 } }
238
240
>
239
- < Stack
240
- direction = "row"
241
- alignItems = "center"
242
- sx = { { mr : 2 } }
243
- >
241
+ < Stack direction = "row" alignItems = "center" sx = { { mr : 2 } } >
244
242
{ lecture . code === lecture . name ? (
245
243
< Alert severity = "info" >
246
244
The name of the lecture is identical to the lecture code. You
0 commit comments