From 721e8995573311583fc0014b2fd1435c37893cf5 Mon Sep 17 00:00:00 2001 From: NamKyeongMin Date: Mon, 2 Jun 2025 15:51:05 +0900 Subject: [PATCH] =?UTF-8?q?[fix]:=20=ED=8A=B9=EC=A0=95=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EC=B6=9C=EC=84=9D=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C-boomImg=20=EB=A1=9C=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 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/generation/Attendance.jsx b/frontend/src/pages/generation/Attendance.jsx index 6198705..8ef8334 100644 --- a/frontend/src/pages/generation/Attendance.jsx +++ b/frontend/src/pages/generation/Attendance.jsx @@ -113,7 +113,9 @@ const Attendance = () => { withCredentials: true, // 세션 기반 인증 요청처리 }); - const slots = res.data.data?.[0]?.slots || []; + // api 응답 수정에 따라 업데이트 + // 서버 응답이 순서대로 오지 않을 수 있으므로 order 기준으로 정렬 + const slots = (res.data.data || []).sort((a, b) => a.order - b.order); const statuses = slots.map((slot) => { if (slot.status === true) return "success"; @@ -134,6 +136,19 @@ const Attendance = () => { useEffect(() => { fetchAttendance(); fetchTodayAttendance(); + + // 10초마다 출석체크 활성화 여부 확인 및 UI 업데이트 + const interval = setInterval(() => { + // 출석 미진행 상태가 하나라도 있을 때만 호출 + setTodayStatuses((prev) => { + if (prev.includes("not_started")) { + fetchTodayAttendance(); + } + return prev; + }); + }, 10000); + + return () => clearInterval(interval); }, []); const handleChange = (index, value) => {