Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions frontend/src/api/students.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
34 changes: 31 additions & 3 deletions frontend/src/pages/admin/DetailManageStudent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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(() => {
Expand All @@ -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 <div>loading...</div>;

Expand All @@ -56,7 +69,20 @@ const DetailManageStudent = () => {
잔여 보증금: <span>{student.deposit}원</span>
</div>
<div className={style.defence_container}>
보증금 방어권: <span>{student.defence}</span>
보증금 방어권
<input
type="text"
value={defenceInput}
onChange={(e) => setDefenceInput(e.target.value)}
className={style.defence_input}
/>
<button
className={style.defence_save_btn}
onClick={handleDefenceSave}
disabled={defenceInput === student.defence}
>
save
</button>
</div>
</div>
{student && (
Expand All @@ -67,13 +93,15 @@ const DetailManageStudent = () => {
출석 관리 <span>&gt;</span>
</button>
)}
{student && (
{student && (
<div className={style.assignment_list}>
{weekData.map((week, index) => (
<button
key={index}
className={style.assignment_button}
onClick={() => navigate(`/admin/assignment/${student.id}/${index + 1}`)}
onClick={() =>
navigate(`/admin/assignment/${student.id}/${index + 1}`)
}
>
{week.week} {week.title && ` ${week.title}`}
</button>
Expand Down
33 changes: 33 additions & 0 deletions frontend/src/pages/admin/DetailManageStudent.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}