From e65a16776f052c26116d85042227bbc09b70a0bc Mon Sep 17 00:00:00 2001
From: Anang Yusman
Date: Sun, 26 Oct 2025 14:24:55 +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 }) {
)} */}
+
+
);
- case "isPublish":
+ case "publishStatus":
return (
//
//
- {article.isPublish ? "Publish" : "Draft"}
+ {article.publishStatus}
);
case "isBanner":
return {article.isBanner ? "Ya" : "Tidak"}
;
diff --git a/service/article.ts b/service/article.ts
index 5682e6f..569cef0 100644
--- a/service/article.ts
+++ b/service/article.ts
@@ -94,6 +94,11 @@ export async function updateArticle(id: string, data: any) {
return await httpPutInterceptor(pathUrl, data);
}
+export async function unPublishArticle(id: string, data: any) {
+ const pathUrl = `/articles/${id}/unpublish`;
+ return await httpPutInterceptor(pathUrl, data);
+}
+
export async function getArticleById(id: any) {
const headers = {
"content-type": "application/json",