From 407566899f1a1789c8a70e143071871d331e12be Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Tue, 13 Jan 2026 16:35:54 +0700 Subject: [PATCH] feat:delete button on edit article --- components/form/article/edit-article-form.tsx | 40 +++++++++++++++++-- components/table/article-table.tsx | 2 +- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/components/form/article/edit-article-form.tsx b/components/form/article/edit-article-form.tsx index c3c49a8..9b57e3a 100644 --- a/components/form/article/edit-article-form.tsx +++ b/components/form/article/edit-article-form.tsx @@ -15,6 +15,7 @@ import Image from "next/image"; import { Switch } from "@heroui/switch"; import { createArticle, + deleteArticle, deleteArticleFiles, getArticleByCategory, getArticleById, @@ -573,6 +574,33 @@ export default function EditArticleForm(props: { isDetail: boolean }) { }); }; + const handleDelete = (id: any) => { + MySwal.fire({ + title: "Hapus Artikel", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#3085d6", + confirmButtonColor: "#d33", + confirmButtonText: "Hapus", + }).then((result) => { + if (result.isConfirmed) { + doDelete(id); + } + }); + }; + + async function doDelete(id: any) { + // loading(); + const resDelete = await deleteArticle(id); + + if (resDelete?.error) { + error(resDelete.message); + return false; + } + close(); + router.push("/admin/article"); + } + return (
)} - {/* {!isDetail && ( - - )} */} + )}