Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/school/src/lib/queries/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export const paymentsOptions = {
getNextPageParam: lastPage => lastPage.nextCursor ?? undefined,
staleTime: 2 * 60 * 1000,
gcTime: 10 * 60 * 1000,
maxPages: 5,
throwOnError: true,
}),

detail: (id: string) =>
Expand Down
10 changes: 10 additions & 0 deletions apps/teacher/src/hooks/useLocalNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,32 +73,37 @@ export function useLocalNotes(options: UseLocalNotesOptions = {}): UseLocalNotes
},
enabled: dbStatus.isInitialized,
refetchInterval: autoRefresh ? refreshInterval : false,
networkMode: 'always',
})

const saveNoteMutation = useMutation({
mutationKey: teacherMutationKeys.localNotes.save,
mutationFn: ({ note, details }: { note: NewNote, details?: NewNoteDetail[] }) =>
localNotesService.saveNoteLocally(note, details),
onSettled: () => queryClient.invalidateQueries({ queryKey: ['notes'] }),
networkMode: 'always',
})

const updateNoteMutation = useMutation({
mutationKey: teacherMutationKeys.localNotes.update,
mutationFn: ({ noteId, updates, details }: { noteId: string, updates: Partial<NewNote>, details?: NewNoteDetail[] }) =>
localNotesService.updateNoteLocally(noteId, updates, details),
onSettled: () => queryClient.invalidateQueries({ queryKey: ['notes'] }),
networkMode: 'always',
})

const deleteNoteMutation = useMutation({
mutationKey: teacherMutationKeys.localNotes.delete,
mutationFn: (noteId: string) => localNotesService.deleteNoteLocally(noteId),
onSettled: () => queryClient.invalidateQueries({ queryKey: ['notes'] }),
networkMode: 'always',
})

const publishNoteMutation = useMutation({
mutationKey: teacherMutationKeys.localNotes.publish,
mutationFn: (noteId: string) => localNotesService.publishNote(noteId),
onSettled: () => queryClient.invalidateQueries({ queryKey: ['notes'] }),
networkMode: 'always',
})

return {
Expand Down Expand Up @@ -148,6 +153,7 @@ export function useNoteGrades(options: UseNoteGradesOptions): UseNoteGradesRetur
return map
},
enabled: dbStatus.isInitialized && !!noteId,
networkMode: 'always',
})

const pendingGrades = useMutationState({
Expand All @@ -171,6 +177,7 @@ export function useNoteGrades(options: UseNoteGradesOptions): UseNoteGradesRetur
localNotesService.updateStudentGrade(noteId, studentId, value),

onSettled: () => queryClient.invalidateQueries({ queryKey: ['notes', noteId, 'grades'] }),
networkMode: 'always',
})

return {
Expand Down Expand Up @@ -206,6 +213,7 @@ export function useUnpublishedNotes(): UseUnpublishedNotesReturn {
queryKey: ['notes', 'unpublished'],
queryFn: () => localNotesService.getUnpublishedNotes(),
enabled: dbStatus.isInitialized,
networkMode: 'always',
})

const publishAllMutation = useMutation({
Expand All @@ -218,6 +226,7 @@ export function useUnpublishedNotes(): UseUnpublishedNotesReturn {
onSettled: () => {
queryClient.invalidateQueries({ queryKey: ['notes'] })
},
networkMode: 'always',
})

const clearAfterPublishMutation = useMutation({
Expand All @@ -226,6 +235,7 @@ export function useUnpublishedNotes(): UseUnpublishedNotesReturn {
onSettled: () => {
queryClient.invalidateQueries({ queryKey: ['notes'] })
},
networkMode: 'always',
})

return {
Expand Down
Loading