diff --git a/app/routes/_procted+/students+/$lectureId+/UserAddModal.tsx b/app/routes/_procted+/students+/$lectureId+/UserAddModal.tsx index 5cd172c..645d6a3 100644 --- a/app/routes/_procted+/students+/$lectureId+/UserAddModal.tsx +++ b/app/routes/_procted+/students+/$lectureId+/UserAddModal.tsx @@ -22,6 +22,7 @@ const UserAddModal = ({ isOpen, onClose }: Props) => { const params = useParams(); const lectureId = parseInt(params.lectureId!, 10); const [tabIndex, setTabIndex] = useState(0); + const [file, setFile] = useState(null); return ( { e.preventDefault(); const formData = new FormData(e.currentTarget); if (tabIndex === 0) { - const file = formData.get("file") as File; + const formFile = file ? file : (formData.get("file") as File); const response = await addUsersInLecture( lectureId, - await parseXlsx(file), + await parseXlsx(formFile), auth.token ); if (response.status === 201) { @@ -76,7 +77,7 @@ const UserAddModal = ({ isOpen, onClose }: Props) => { console.log(file.name)} + onFileUpload={(file) => setFile(file)} fileValidator={(file) => file.name.endsWith(".xlsx")} placeholder="xlsx 파일 업로드" />