Skip to content

Commit

Permalink
Merge pull request #71 from kimyeonjinn/feature/#4
Browse files Browse the repository at this point in the history
✅ delete 응답 관련 코드 수정
  • Loading branch information
kimyeonjinn authored Sep 23, 2024
2 parents b5ba485 + b7799be commit 41572c4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/components/ChocoCheck/ChocoCheck22.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ const ChocoCheck22 = ({ currentPage, itemsPerPage, chocoData, error }) => {
const startIndex = (currentPage - 1) * itemsPerPage;
const currentItems = chocoData.slice(startIndex, startIndex + itemsPerPage);

// * handleChocoClick 함수가 수정되었습니다.
const handleChocoClick = (id, chocoType) => {
// chocoType 인자를 추가
// chocoType 인자
setSelectedChocoId(id);
console.log("Clicked Choco Id:", id, "Choco Type:", chocoType); // chocoType을 콘솔에 출력
navigate(`/detailletter/${id}`, { state: { chocoType } }); // * chocoType을 state로 함께 전달
console.log("Clicked Choco Id:", id, "Choco Type:", chocoType);
navigate(`/detailletter/${id}`, { state: { chocoType } }); // * chocoType을 state로
};

if (error) {
Expand All @@ -32,7 +31,6 @@ const ChocoCheck22 = ({ currentPage, itemsPerPage, chocoData, error }) => {
return (
<S.Card
key={item.id}
// * handleChocoClick 호출 시 chocoType을 인자로 추가
onClick={() => handleChocoClick(item.id, item.chocoType)}
selected={selectedChocoId === item.id}
>
Expand Down
5 changes: 2 additions & 3 deletions src/components/ChocoCheck/ChocoCheck33.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ const ChocoCheck33 = ({ currentPage, itemsPerPage, chocoData, error }) => {
const startIndex = (currentPage - 1) * itemsPerPage;
const currentItems = chocoData.slice(startIndex, startIndex + itemsPerPage);

// * handleChocoClick 함수가 수정되었습니다.
const handleChocoClick = (id, chocoType) => {
// chocoType 인자를 추가
// chocoType 추가
setSelectedChocoId(id);
console.log("Clicked Choco Id:", id, "Choco Type:", chocoType); // chocoType을 콘솔에 출력
console.log("Clicked Choco Id:", id, "Choco Type:", chocoType);
navigate(`/detailletter/${id}`, { state: { chocoType } }); // * chocoType을 state로 함께 전달
};

Expand Down
7 changes: 5 additions & 2 deletions src/pages/DetailLetter/DetailLetter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ const DetailLetter = () => {

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

// 아래로는 삭제 코드
// 아래로는 삭제 코드 수정
const handleDeleteClick = async () => {
try {
const response = await instance.delete(`/api/choco/${id}`);
if (response.data && response.data.message === "SUCCESS") {
if (!response || response.status === 204) {
alert("삭제가 완료되었습니다.");
navigate(-1);
} else if (response.data && response.data.message === "SUCCESS") {
alert("삭제가 완료되었습니다.");
navigate(-1);
} else {
Expand Down

0 comments on commit 41572c4

Please sign in to comment.