Skip to content

Commit

Permalink
chore: add error message of delete ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
moolmin committed Oct 2, 2024
1 parent dd6cc91 commit 3e18dfa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
12 changes: 9 additions & 3 deletions src/app/(pages)/mypage/my-4q/_components/item-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ const ItemList = ({ item }) => {
};

const handleOk = async () => {
await deleteTicket(item.id);
message.success("티켓이 삭제되었습니다.");
setIsModalOpen(false);
try {
await deleteTicket(item.id);
message.success("티켓이 삭제되었습니다.");
setIsModalOpen(false);
} catch (error) {
message.error("티켓 삭제에 실패했습니다.");
console.error(error);
}
};


const handleCancel = () => {
setIsModalOpen(false);
Expand Down
8 changes: 8 additions & 0 deletions src/app/(pages)/mypage/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@
font-size: 20px;
}

.linkText {
display: flex;
flex-direction: row;
align-items: center;
/* flex-direction: column; */
}


.profileEditBtn {
background-color: #000;
margin-top: 12px;
Expand Down
23 changes: 14 additions & 9 deletions src/service/photo_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,22 @@ export const getLikedTicket = async() => {
}
};

export const deleteTicket = async(ticketId: number) => {
// 티켓 삭제
export const deleteTicket = async (ticketId: number) => {
const token = sessionStorage.getItem('AccessToken');
try {
const response = await fetch(`${BASE_URL}/ticket/${ticketId}`, {
method: "DELETE",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json",
},
method: "DELETE",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json",
},
});
} catch (error) {

if (!response.ok) {
throw new Error("Failed to delete ticket");
}
} catch (error) {
throw error;
}
};
}
};

0 comments on commit 3e18dfa

Please sign in to comment.