From fceeda6e35ca9e1ae1d58b6e25eb0f23828d1c92 Mon Sep 17 00:00:00 2001 From: Imggaggu Date: Sat, 14 Jun 2025 22:22:33 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20assignment=EC=83=81=ED=83=9C=20=20selec?= =?UTF-8?q?t=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/api/api.js | 2 +- .../pages/admin/AdminStudentAssignment.jsx | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/frontend/src/api/api.js b/frontend/src/api/api.js index 1950026..ae4217f 100644 --- a/frontend/src/api/api.js +++ b/frontend/src/api/api.js @@ -1,7 +1,7 @@ import axios from "axios"; const api = axios.create({ - baseURL: "http://api.pirocheck.org:8080/api", + baseURL: "https://api.pirocheck.org:8080/api", // 수정 필요한지 재검 필요함 // "http://api.pirocheck.org:8080/api" withCredentials: true, diff --git a/frontend/src/pages/admin/AdminStudentAssignment.jsx b/frontend/src/pages/admin/AdminStudentAssignment.jsx index c29c35e..7b76b46 100644 --- a/frontend/src/pages/admin/AdminStudentAssignment.jsx +++ b/frontend/src/pages/admin/AdminStudentAssignment.jsx @@ -42,7 +42,7 @@ const AdminStudentAssignment = () => { id: task.id, label: task.assignmentName, status: task.status, - //modified: false, + modified: false, })), })), })); @@ -64,12 +64,20 @@ const AdminStudentAssignment = () => { }); }, [studentId, week]); - const handleStatusChange = (weekIdx, dayIdx, taskIdx, newStatus) => { - const updated = [...weeks]; - const task = updated[weekIdx].days[dayIdx].tasks[taskIdx]; - task.status = newStatus; - task.modified = true; - setWeeks(updated); + const handleStatusChange = (taskId, newStatus) => { + const updatedWeeks = weeks.map((weekItem) => ({ + ...weekItem, + days: weekItem.days.map((dayItem) => ({ + ...dayItem, + tasks: dayItem.tasks.map((task) => + task.id === taskId + ? { ...task, status: newStatus, modified: true } + : task + ), + })), + })); + + setWeeks(updatedWeeks); }; /* const handleSave = async (taskId, status) => { @@ -134,8 +142,6 @@ const AdminStudentAssignment = () => { value={task.status} onChange={(e) => handleStatusChange( - weekIdx, - dayIdx, taskIdx, e.target.value )