From 8d3cdc5da1f9d6205e7276361e374e0f97f04528 Mon Sep 17 00:00:00 2001 From: NamKyeongMin Date: Sat, 21 Jun 2025 03:06:19 +0900 Subject: [PATCH] =?UTF-8?q?[fix]:=20=EB=82=A0=EC=A7=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EC=8B=9C=20=EB=A6=AC=EB=A1=9C=EB=94=A9=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/generation/Attendance.jsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/generation/Attendance.jsx b/frontend/src/pages/generation/Attendance.jsx index a096d19..8d6d1ac 100644 --- a/frontend/src/pages/generation/Attendance.jsx +++ b/frontend/src/pages/generation/Attendance.jsx @@ -14,6 +14,11 @@ const Attendance = () => { "not_started", ]); + // 오늘 날짜 비교용 state + const [currentDate, setCurrentDate] = useState( + new Date().toISOString().split("T")[0] + ); + const getSubImage = (count) => { switch (count) { case 3: @@ -148,7 +153,19 @@ const Attendance = () => { }); }, 10000); - return () => clearInterval(interval); + // 매 분마다 현재 날짜를 확인해서 달라졌으면 상태 업데이트 + const dateCheckInterval = setInterval(() => { + const todayStr = new Date().toISOString().split("T")[0]; + if (todayStr !== currentDate) { + setCurrentDate(todayStr); // 날짜 변경 감지 + fetchTodayAttendance(); // 새로운 날짜 기준으로 다시 가져오기 + } + }, 60000); // 60초마다 확인 + + return () => { + clearInterval(interval); + clearInterval(dateCheckInterval); + }; }, []); const handleChange = (index, value) => {