17 lines
481 B
React
17 lines
481 B
React
import { deletePost } from "../wordpress";
|
|
|
|
function DeletePost({ postId, onDelete }) {
|
|
const handleDelete = async () => {
|
|
if (window.confirm("Es-tu sûr de vouloir supprimer cet article ?")) {
|
|
const success = await deletePost(postId);
|
|
if (success) {
|
|
alert("Article supprimé avec succès !");
|
|
onDelete(); // Rafraîchir la liste
|
|
}
|
|
}
|
|
};
|
|
|
|
return <button onClick={handleDelete}>🗑️ Supprimer</button>;
|
|
}
|
|
|
|
export default DeletePost; |