From 194088239ba853a7f5c7b9df22ed3fd81598e53b Mon Sep 17 00:00:00 2001 From: NamKyeongMin Date: Mon, 2 Jun 2025 07:51:39 +0900 Subject: [PATCH] =?UTF-8?q?[add]:=20=EB=B3=B4=EC=A6=9D=EA=B8=88=20?= =?UTF-8?q?=EB=B0=A9=EC=96=B4=EA=B6=8C=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/students.js | 8 +++++ .../src/pages/admin/DetailManageStudent.jsx | 34 +++++++++++++++++-- .../admin/DetailManageStudent.module.css | 33 ++++++++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/frontend/src/api/students.js b/frontend/src/api/students.js index 3239a66..03e7f98 100644 --- a/frontend/src/api/students.js +++ b/frontend/src/api/students.js @@ -17,3 +17,11 @@ export const getStudentDetail = async (studentId) => { throw error; } }; + +// 보증금 방어권 수정 +export const updateStudentDefence = async (studentId, defenceValue) => { + const res = await api.patch(`/admin/managestudent/${studentId}/defence`, { + defence: defenceValue, + }); + return res.data; +}; diff --git a/frontend/src/pages/admin/DetailManageStudent.jsx b/frontend/src/pages/admin/DetailManageStudent.jsx index 36cfbb1..1dd5798 100644 --- a/frontend/src/pages/admin/DetailManageStudent.jsx +++ b/frontend/src/pages/admin/DetailManageStudent.jsx @@ -4,6 +4,7 @@ import { useEffect, useState } from "react"; import Header from "../../components/Header"; import style from "./DetailManageStudent.module.css"; import { getStudentDetail } from "../../api/students"; +import { updateStudentDefence } from "../../api/students"; // 보증금 방어권 수정 api const weekData = [ { week: "1주차", title: "Git/HTML/CSS" }, @@ -17,6 +18,7 @@ const DetailManageStudent = () => { const { studentId } = useParams(); const numericId = Number(studentId); const [student, setStudent] = useState(null); + const [defenceInput, setDefenceInput] = useState(""); // 보증금 방어권 input 값 const navigate = useNavigate(); useEffect(() => { @@ -38,8 +40,19 @@ const DetailManageStudent = () => { }; fetchStudent(); + setDefenceInput(data.defenece); // 보증금 업데이트 }, [studentId]); + const handleDefenceSave = async () => { + try { + await updateStudentDefence(student.id, defenceInput); + setStudent((prev) => ({ ...prev, defence: defenceInput })); + alert("보증금 방어권이 수정되었습니다."); + } catch (err) { + console.error("방어권 업데이트 실패:", err); + alert("방어권 업데이트 실패"); + } + }; if (!student) return
loading...
; @@ -56,7 +69,20 @@ const DetailManageStudent = () => { 잔여 보증금: {student.deposit}원
- 보증금 방어권: {student.defence} + 보증금 방어권 + setDefenceInput(e.target.value)} + className={style.defence_input} + /> +
{student && ( @@ -67,13 +93,15 @@ const DetailManageStudent = () => { 출석 관리 > )} - {student && ( + {student && (
{weekData.map((week, index) => ( diff --git a/frontend/src/pages/admin/DetailManageStudent.module.css b/frontend/src/pages/admin/DetailManageStudent.module.css index d69fe20..c06bcfd 100644 --- a/frontend/src/pages/admin/DetailManageStudent.module.css +++ b/frontend/src/pages/admin/DetailManageStudent.module.css @@ -66,3 +66,36 @@ .assignment_button:focus { border: 1px var(--main-green) solid; } + +/* 보증금 업데이트 버튼 css 추가 */ +.defence_container { + display: flex; + align-items: center; + gap: 10px; + margin-top: 10px; +} + +.defence_input { + width: 60px; + height: 28px; + border-radius: 10px; + border: 1px solid #333; + padding-left: 8px; + font-size: 14px; + background-color: white; +} + +.defence_save_btn { + background-color: #888; + color: white; + border: none; + border-radius: 12px; + padding: 4px 10px; + font-size: 13px; + cursor: pointer; +} + +.defence_save_btn:disabled { + opacity: 0.4; + cursor: not-allowed; +}