Skip to content

Commit 3de7e51

Browse files
authored
Merge pull request #88 from INU-Software-Design/feature/student-parent-page
refactor : 오류 수정
2 parents 6a0a5fe + c64305c commit 3de7e51

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/pages/student/student-record.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const StudentRecord = () => {
2222
fatherContact: "",
2323
motherContact: "",
2424
});
25-
const [photo, setPhoto] = useState<string | null>(null);
25+
const [photo, setPhoto] = useState<string>("");
2626

2727
useEffect(() => {
2828
const token = localStorage.getItem("accessToken");
@@ -50,7 +50,6 @@ const StudentRecord = () => {
5050
});
5151
setPhoto(`${process.env.NEXT_PUBLIC_BACKEND_DOMAIN}/images/${data.image}`);
5252
} catch (err) {
53-
alert(`학생 정보 가져오기 실패 : ${err}`);
5453
console.error("학생 정보 가져오기 실패 :", err);
5554
}
5655
};
@@ -63,7 +62,14 @@ const StudentRecord = () => {
6362
<div className="flex flex-col sm:flex-row w-full gap-8 justify-start items-start">
6463
{/* 증명 사진 */}
6564
<div className="flex justify-center items-center w-full sm:w-[272px] h-[336px] flex-shrink-0 border border-gray-400 cursor-default">
66-
{photo ? <img src={photo} alt="증명사진" className="w-[250px] h-[250px] object-cover" /> : <p className="text-base text-center text-gray-800">증명 사진</p>}
65+
<img
66+
src={photo}
67+
alt="증명사진"
68+
className="w-[250px] h-[250px] object-cover"
69+
onError={(e) => {
70+
e.currentTarget.src = "/images/defaultImage.png";
71+
}}
72+
/>
6773
</div>
6874

6975
{/* 표 컨테이너 */}

0 commit comments

Comments
 (0)