Skip to content

Commit 94af6d3

Browse files
committed
fix: Only fetch cooperations for student screeners
1 parent e701915 commit 94af6d3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/pages/screening/useCooperations.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { gql } from '@/gql';
2+
import { useRoles } from '@/hooks/useApollo';
23
import { useQuery } from '@apollo/client';
34

45
const GET_COOPERATION_STUDENTS_QUERY = gql(`
@@ -37,9 +38,11 @@ const GET_COOPERATION_LIST = gql(`
3738
`);
3839

3940
export const useCooperations = () => {
40-
const { data: cooperationStudents, refetch: refetchCooperationStudents } = useQuery(GET_COOPERATION_STUDENTS_QUERY);
41-
const { data: pendingCooperationStudentsCountData } = useQuery(GET_PENDING_COOPERATION_STUDENTS_COUNT_QUERY);
42-
const { data: cooperationListData } = useQuery(GET_COOPERATION_LIST);
41+
const roles = useRoles();
42+
const isScreener = roles.includes('STUDENT_SCREENER');
43+
const { data: cooperationStudents, refetch: refetchCooperationStudents } = useQuery(GET_COOPERATION_STUDENTS_QUERY, { skip: !isScreener });
44+
const { data: pendingCooperationStudentsCountData } = useQuery(GET_PENDING_COOPERATION_STUDENTS_COUNT_QUERY, { skip: !isScreener });
45+
const { data: cooperationListData } = useQuery(GET_COOPERATION_LIST, { skip: !isScreener });
4346

4447
return {
4548
cooperationStudents:

0 commit comments

Comments
 (0)