From 902b9952a9deabe25bc6033e61eb49dfecba7e5a Mon Sep 17 00:00:00 2001 From: Imggaggu Date: Sun, 25 May 2025 23:40:37 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20fetchData=20=EB=B0=96=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B9=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/admin/AdminStudentAttendance.jsx | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/frontend/src/pages/admin/AdminStudentAttendance.jsx b/frontend/src/pages/admin/AdminStudentAttendance.jsx index 8c05603..9a70692 100644 --- a/frontend/src/pages/admin/AdminStudentAttendance.jsx +++ b/frontend/src/pages/admin/AdminStudentAttendance.jsx @@ -12,7 +12,26 @@ const AdminStudentAttendance = () => { const [studentInfo, setStudentInfo] = useState(null); const [attendanceData, setAttendanceData] = useState([]); const [selectedDate, setSelectedDate] = useState(null); - + const fetchData = async () => { + try { + const studentRes = await getStudentBasicInfo(studentId); + setStudentInfo(studentRes); + + const attendanceRes = await getStudentAttendance(studentId); + /* + "attendanceId": 1, + "userId": 1, + "username": "홍길동", + "date": "2023-10-20", + "order": 1, + "status": true + */ + const processed = processWeeklyAttendance(attendanceRes); + setAttendanceData(processed); + } catch (err) { + console.error("데이터 불러오기 실패:", err); + } + }; useEffect(() => { const id = Number(studentId); @@ -21,27 +40,6 @@ const AdminStudentAttendance = () => { return; } - const fetchData = async () => { - try { - const studentRes = await getStudentBasicInfo(studentId); - setStudentInfo(studentRes); - - const attendanceRes = await getStudentAttendance(studentId); - /* - "attendanceId": 1, - "userId": 1, - "username": "홍길동", - "date": "2023-10-20", - "order": 1, - "status": true - */ - const processed = processWeeklyAttendance(attendanceRes); - setAttendanceData(processed); - } catch (err) { - console.error("데이터 불러오기 실패:", err); - } - }; - fetchData(); }, [studentId]);