From 2dc6c6d44a4f59b285d70dddfd8e9fc3d79b864d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=9C=EC=A4=80?= Date: Mon, 25 Nov 2024 12:43:54 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=A0=80=EC=9E=A5=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/MainTimetable/index.tsx | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/pages/TimetablePage/components/MainTimetable/index.tsx b/src/pages/TimetablePage/components/MainTimetable/index.tsx index 47b51633..19fc2785 100644 --- a/src/pages/TimetablePage/components/MainTimetable/index.tsx +++ b/src/pages/TimetablePage/components/MainTimetable/index.tsx @@ -34,23 +34,37 @@ function MainTimetable({ frameId }: { frameId: number }) { const { data: deptList } = useDeptList(); const { data: mySemester } = useSemesterCheck(token); + const isSemesterAndTimetableExist = () => { + if (mySemester?.semesters.length === 0) { + toast.error('학기가 존재하지 않습니다. 학기를 추가해주세요.'); + return false; + } + + if (timeTableFrameList.length === 0) { + toast.error('시간표가 존재하지 않습니다. 시간표를 추가해주세요.'); + return false; + } + + return true; + }; + const onClickDownloadImage = (e: React.MouseEvent) => { e.stopPropagation(); - logger.actionEventClick({ - actionTitle: 'USER', - title: 'timetable', - value: '이미지저장', - duration_time: (new Date().getTime() - Number(sessionStorage.getItem('enterTimetablePage'))) / 1000, - }); - openModal(); + + if (isSemesterAndTimetableExist()) { + logger.actionEventClick({ + actionTitle: 'USER', + title: 'timetable', + value: '이미지저장', + duration_time: + (new Date().getTime() - Number(sessionStorage.getItem('enterTimetablePage'))) / 1000, + }); + openModal(); + } }; const onClickEdit = () => { - if (mySemester?.semesters.length === 0) { - toast('학기가 존재하지 않습니다. 학기를 추가해주세요.'); - } else if (timeTableFrameList.length === 0) { - toast('시간표가 존재하지 않습니다. 시간표를 추가해주세요.'); - } else { + if (isSemesterAndTimetableExist()) { navigate(`/timetable/modify/regular/${token ? frameId : semester}`); } };