diff --git a/src/components/Assignment/AssignmentCards.tsx b/src/components/Assignment/AssignmentCards.tsx index 5c71f629ea1214eb1c4029a73529e959d29e8ef4..5e0b63f3a7dac39fffd7b4bceaf6b4224ee91ae7 100644 --- a/src/components/Assignment/AssignmentCards.tsx +++ b/src/components/Assignment/AssignmentCards.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react-hooks/exhaustive-deps */ import { DeleteIcon, ViewIcon } from "@chakra-ui/icons" import { useColorModeValue, @@ -78,22 +79,22 @@ export const AssignmentCards = ({ assignment_id ) const { students, fetchStudent } = useFetchStudent(scholarship_id) - const [applicants, setApplicants] = useState(students.length) - const [submissions, setSubmissions] = useState(submissionFile.length) + const [applicants, setApplicants] = useState(students?.length || 0) + const [submissions, setSubmissions] = useState(submissionFile?.length || 0) useEffect(() => { const fetchData = async () => { await fetchFile() setSubmissions(submissionFile.length) } fetchData() - }, [submissionFile.length]) + }, [submissionFile?.length]) useEffect(() => { const fetchData = async () => { await fetchStudent() - setApplicants(students.length) + setApplicants(students?.length) } fetchData() - }, [students.length]) + }, [students?.length]) // TODO: SET THE APPLICANTS AND SUBMSISSIONS @MATTHEW MAHENDRA const [isOpenEditAssignment, setIsOpenEditAssignment] = useState(false) const [isOpenDeleteAssignment, setIsOpenDeleteAssignment] =