-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c48af72
commit 710788b
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Edit button functionality | ||
const editButton = document.querySelector('.edit-button'); | ||
if (editButton) { | ||
editButton.addEventListener('click', function(event) { | ||
const cardId = this.getAttribute("data-id"); | ||
console.log(cardId) | ||
window.location.href = `/cards/${cardId}/edit`; // Redirect to edit page | ||
}); | ||
} | ||
|
||
// Delete button functionality | ||
const deleteButton = document.querySelector('.delete-button'); | ||
if (deleteButton) { | ||
deleteButton.addEventListener('click', function(event) { | ||
const cardId = this.getAttribute("data-id"); | ||
|
||
if (confirm("정말로 이 명함을 삭제하시겠습니까?")) { | ||
fetch(`/cards/${cardId}`, { | ||
method: "DELETE", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
}) | ||
.then(response => { | ||
if (response.ok) { | ||
handleSuccess("명함이 삭제되었습니다.", 400); | ||
window.location.href = `/cards/manage` | ||
} else { | ||
handleError("명함 삭제에 실패했습니다.", 300); | ||
} | ||
}) | ||
.catch(error => { | ||
console.error("명함 삭제 실패:", error); | ||
handleError("명함 삭제에 실패했습니다.", 300); | ||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters