From 3237c0c02efc11755408073bd9ad5d8fcbeae3c8 Mon Sep 17 00:00:00 2001
From: IceTeaXXD <13521024@std.stei.itb.ac.id>
Date: Fri, 17 Nov 2023 14:07:15 +0700
Subject: [PATCH] feat: null validation

---
 src/components/Assignment/AssignmentCards.tsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/components/Assignment/AssignmentCards.tsx b/src/components/Assignment/AssignmentCards.tsx
index 5c71f62..5e0b63f 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] =
-- 
GitLab