+
{
+ const { value: message } = await MySwal.fire({
+ title: "Komen Banner",
+ input: "textarea",
+ inputLabel: "Komentar (opsional)",
+ inputPlaceholder: "Masukkan komentar...",
+ inputAttributes: {
+ "aria-label": "Masukkan komentar",
+ },
+ showCancelButton: true,
+ confirmButtonText: "Komentar",
+ cancelButtonText: "Batal",
+ confirmButtonColor: "#dc2626",
+ });
+
+ if (message === undefined) {
+ return; // User cancelled
+ }
+
+ loading();
+ const res = await commentBanner(id, message || undefined);
+
+ if (res?.error) {
+ error(res.message || "Gagal menolak banner");
+ close();
+ return;
+ }
+
+ close();
+ success("Banner berhasil ditolak");
+ initState(); // refresh table
+ };
+
const handleReject = async () => {
if (!viewBanner) return;
@@ -866,7 +900,7 @@ export default function ArticleTable() {
className="bg-blue-200 hover:bg-blue-400"
onClick={(e) => {
e.stopPropagation();
- setOpenCommentModal(true);
+ handleCommentBanner(viewBanner.id);
}}
>
Beri Tanggapan
diff --git a/service/banner.ts b/service/banner.ts
index 900f3f0..835523f 100644
--- a/service/banner.ts
+++ b/service/banner.ts
@@ -68,6 +68,17 @@ export async function rejectBanner(id: string | number, message?: string) {
);
}
+export async function commentBanner(id: string | number, message?: string) {
+ const headers = {
+ "content-type": "application/json",
+ };
+ return await httpPutInterceptor(
+ `/banners/${id}/comment`,
+ { message },
+ headers,
+ );
+}
+
export async function getApprovalHistory(
moduleType: string,
moduleId: string | number,