Skip to content

Commit

Permalink
only load student points when viewing student table, not when switchi…
Browse files Browse the repository at this point in the history
…ng to students
  • Loading branch information
sealexan committed Dec 9, 2023
1 parent b596994 commit 23608f5
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 62 deletions.
120 changes: 60 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/components/Hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ export const useStudents = () => {
return useQuery<StudentProps[]>(['courses', courseSlug, 'students'], { enabled: !!courseSlug })
}

export const useStudentPoints = () => {
const { courseSlug } = useParams()
return useQuery<StudentProps[]>(['courses', courseSlug, 'studentPoints'], { enabled: !!courseSlug })
}


export const useImport = () => {
const { courseSlug } = useParams()
const { mutateAsync, isLoading } = useMutation<string, object, any[]>(['import', courseSlug])
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Students.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Center, Heading, Table, TableCaption, TableContainer, Tbody, Td, Th, Thead, Tr, VStack } from '@chakra-ui/react'
import React from 'react'
import { useStudents } from '../components/Hooks'
import { useStudentPoints } from '../components/Hooks'

export default function Students() {
const { data: students } = useStudents()
const { data: students } = useStudentPoints()
if (!students)
return <></>
return (
Expand Down

0 comments on commit 23608f5

Please sign in to comment.