Skip to content

Commit

Permalink
Merge pull request #83 from kimyeonjinn/feature/#4
Browse files Browse the repository at this point in the history
✅ detailletter 초코 삭제 기능 및 부분 코드 수정
  • Loading branch information
kimyeonjinn authored Sep 24, 2024
2 parents 187283a + c5de541 commit 1673f57
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/pages/DetailLetter/DetailLetter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,21 @@ const DetailLetter = () => {
const { chocoType } = state || {}; // * chocoType

// * chocoType과 letter 이미지 매핑
const letterDesignId = chocoType ? chocoType : 1; // chocoType을 사용하여 letterDesignId 결정
const letterDesignId = chocoType ? chocoType : 1;

const selectedLetter = LETTERS.find((letter) => letter.id === letterDesignId);

// 아래로는 삭제 코드 수정
const handleDeleteClick = async () => {
try {
const response = await instance.delete(`/api/choco/${id}`);

// 204 응답
if (!response || response.status === 204) {
alert("삭제가 완료되었습니다.");
navigate(-1);
} else if (response.data && response.data.message === "SUCCESS") {
alert("삭제가 완료되었습니다.");
navigate(-1);
} else {
console.error("Unexpected response structure:", response.data);
console.error("Unexpected response structure:", response);
alert("삭제에 실패했습니다.");
}
} catch (error) {
Expand Down

0 comments on commit 1673f57

Please sign in to comment.