From 6eb732c730055d836c271f3ed6ef6768a805c5da Mon Sep 17 00:00:00 2001 From: Anang Yusman Date: Sun, 26 Oct 2025 14:22:43 +0800 Subject: [PATCH] update --- components/form/article/edit-article-form.tsx | 57 ++++++++++++++++++- components/table/article-table.tsx | 6 +- service/article.ts | 5 ++ 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/components/form/article/edit-article-form.tsx b/components/form/article/edit-article-form.tsx index 927c880..09bc944 100644 --- a/components/form/article/edit-article-form.tsx +++ b/components/form/article/edit-article-form.tsx @@ -24,6 +24,7 @@ import { getArticleByCategory, getArticleById, submitApproval, + unPublishArticle, updateArticle, uploadArticleFile, uploadArticleThumbnail, @@ -443,7 +444,7 @@ export default function EditArticleForm(props: { isDetail: boolean }) { } close(); - successSubmit("/admin/article"); + successSubmitData(); }; function successSubmit(redirect: string) { @@ -459,6 +460,51 @@ export default function EditArticleForm(props: { isDetail: boolean }) { }); } + function successSubmitData() { + MySwal.fire({ + title: "Berhasil disimpan!", + icon: "success", + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + }); + } + + const doUnpublish = async () => { + MySwal.fire({ + title: "Unpublish Artikel?", + text: "Artikel akan dihapus dari publik dan tidak tampil lagi.", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#d33", + confirmButtonColor: "#3085d6", + confirmButtonText: "Ya, Unpublish", + }).then(async (result) => { + if (result.isConfirmed) { + loading(); + const response = await unPublishArticle(String(id), { + id: Number(id), + isPublish: false, + title: detailData?.title, + typeId: 1, + slug: detailData?.slug, + categoryIds: getValues("category") + .map((val) => val.id) + .join(","), + tags: getValues("tags").join(","), + description: htmlToString(getValues("description")), + htmlDescription: getValues("description"), + }); + + if (response?.error) { + error(response.message); + return; + } + + successSubmit("/admin/article"); + } + }); + }; + const watchTitle = watch("title"); const generateSlug = (title: string) => { return title @@ -1186,6 +1232,15 @@ export default function EditArticleForm(props: { isDetail: boolean }) { )} */} + +