diff --git a/app/[locale]/(protected)/admin/broadcast/create/[id]/page.tsx b/app/[locale]/(protected)/admin/broadcast/create/[id]/page.tsx index 73256382..dd9732de 100644 --- a/app/[locale]/(protected)/admin/broadcast/create/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/broadcast/create/[id]/page.tsx @@ -5,7 +5,7 @@ export default function CreateEmailBlast() { return (
- +
); } diff --git a/app/[locale]/(protected)/admin/broadcast/whatsapp/[id]/page.tsx b/app/[locale]/(protected)/admin/broadcast/whatsapp/[id]/page.tsx index d1ddaa08..648b93d9 100644 --- a/app/[locale]/(protected)/admin/broadcast/whatsapp/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/broadcast/whatsapp/[id]/page.tsx @@ -5,7 +5,7 @@ export default function CreateWABlast() { return (
- + {/* */}
); } diff --git a/app/[locale]/(protected)/dashboard/executive/page.tsx b/app/[locale]/(protected)/dashboard/executive/page.tsx index c62d01f3..98a01de4 100644 --- a/app/[locale]/(protected)/dashboard/executive/page.tsx +++ b/app/[locale]/(protected)/dashboard/executive/page.tsx @@ -381,7 +381,7 @@ export default function ExecutiveDashboard() { -
+ {/*

Emergency Issue

@@ -407,7 +407,7 @@ export default function ExecutiveDashboard() {
-
+ */} ); } diff --git a/components/form/broadcast/content-blast-form.tsx b/components/form/broadcast/content-blast-form.tsx index d69f7607..e4deae1c 100644 --- a/components/form/broadcast/content-blast-form.tsx +++ b/components/form/broadcast/content-blast-form.tsx @@ -50,9 +50,6 @@ const CustomEditor = dynamic( const animatedComponent = makeAnimated(); -// ------------------------- -// ZOD SCHEMA (baru) -// ------------------------- const FormSchema = z.object({ selected: z .array( @@ -79,7 +76,7 @@ interface Campaign { name: string; } -export default function ContentBlast(props: { type: string }) { +export default function ContentBlast() { const editor = useRef(null); const id = useParams()?.id; const MySwal = withReactContent(Swal); @@ -93,7 +90,7 @@ export default function ContentBlast(props: { type: string }) { defaultValues: { selected: [], detail: "", - messageType: [], // checkbox + messageType: [], }, }); @@ -113,23 +110,43 @@ export default function ContentBlast(props: { type: string }) { }); }; - // ------------------------- - // SAVE LOGIC (baru) - // ------------------------- + function htmlToWaText(html: string) { + // Hilangkan link menjadi URL saja + html = html.replace(/]*href="([^"]+)"[^>]*>(.*?)<\/a>/gi, "$1"); + + // Ambil gambar sebagai URL + html = html.replace(/]*src="([^"]+)".*?>/gi, "$1"); + + // Hapus semua HTML tag + html = html.replace(/<\/?[^>]+>/gi, ""); + + // Decode HTML entities + html = html.replace(/&/g, "&"); + + // Rapikan spasi + return html.replace(/\s+/g, " ").trim(); + } + const save = async (data: z.infer) => { const selectedCampaign = data.selected; + const mediaRes = await detailMediaSummary(String(id)); + const details = mediaRes?.data?.data; for (let i = 0; i < selectedCampaign.length; i++) { const campaignId = selectedCampaign[i].id; - // Loop WA / Email for (let mt of data.messageType) { + let finalBody = data.detail; + if (mt === "wa") { + finalBody = textEllipsis(details?.description || "", 150); + } + const payload = { mediaUploadId: id, mediaBlastCampaignId: campaignId, subject: mt === "wa" ? `*${data.title}*` : data.title, - body: data.detail.replace(/\n/g, ""), - type: mt, // <-- WA / email + body: mt === "wa" ? htmlToWaText(finalBody) : finalBody, + type: mt, isScheduled: false, thumbnail: data.thumbnail, sendDate: getLocaleTimestamp(new Date()), @@ -145,6 +162,36 @@ export default function ContentBlast(props: { type: string }) { setOpenModal(true); }; + // const save = async (data: z.infer) => { + // const selectedCampaign = data.selected; + + // for (let i = 0; i < selectedCampaign.length; i++) { + // const campaignId = selectedCampaign[i].id; + + // // Loop WA / Email + // for (let mt of data.messageType) { + // const payload = { + // mediaUploadId: id, + // mediaBlastCampaignId: campaignId, + // subject: mt === "wa" ? `*${data.title}*` : data.title, + // // body: data.detail.replace(/\n/g, ""), + // body: mt === "wa" ? htmlToWaText(data.detail) : data.detail, + // type: mt, // <-- WA / email + // isScheduled: false, + // thumbnail: data.thumbnail, + // sendDate: getLocaleTimestamp(new Date()), + // sendTime: getLocaleTime(new Date()), + // contentUrl: data.url, + // }; + + // console.log("REQ =>", payload); + // await saveMediaBlastBroadcast(payload); + // } + // } + + // setOpenModal(true); + // }; + useEffect(() => { async function init() { const response = await detailMediaSummary(String(id)); diff --git a/components/main/audio-detail.tsx b/components/main/audio-detail.tsx index 7c45cd86..517a663a 100644 --- a/components/main/audio-detail.tsx +++ b/components/main/audio-detail.tsx @@ -253,11 +253,10 @@ const DetailAudio = () => { extension = "mp3"; } - if (selectedSize === "WAV") { + if (selectedSize === "WAV") { extension = "wav"; } - const filename = `${name}.${extension}`; const blob = new Blob([xhr.response], { diff --git a/components/main/document-detail.tsx b/components/main/document-detail.tsx index 96020b32..607dc2dd 100644 --- a/components/main/document-detail.tsx +++ b/components/main/document-detail.tsx @@ -247,7 +247,19 @@ const DetailDocument = () => { if (xhr.readyState === 4 && xhr.status === 200) { const contentType = xhr.getResponseHeader("content-type") || "application/octet-stream"; - const extension = contentType.split("/")[1]; + let extension = contentType.split("/")[1]; + + if (selectedSize === "DOC") { + extension = "doc"; + } + + if (selectedSize === "PPT") { + extension = "ppt"; + } + + if (selectedSize === "PDF") { + extension = "pdf"; + } const filename = `${name}.${extension}`; const blob = new Blob([xhr.response], { diff --git a/lib/menus.ts b/lib/menus.ts index 870ff19c..25b24f01 100644 --- a/lib/menus.ts +++ b/lib/menus.ts @@ -4190,20 +4190,20 @@ export function getMenuList(pathname: string, t: any): Group[] { }, ], }, - { - groupLabel: "", - id: "management-user", - menus: [ - { - id: "management-user-menu", - href: "/admin/management-user", - label: "Management User", - active: pathname.includes("/management-user"), - icon: "clarity:users-solid", - submenus: [], - }, - ], - }, + // { + // groupLabel: "", + // id: "management-user", + // menus: [ + // { + // id: "management-user-menu", + // href: "/admin/management-user", + // label: "Management User", + // active: pathname.includes("/management-user"), + // icon: "clarity:users-solid", + // submenus: [], + // }, + // ], + // }, { groupLabel: "", id: "content-production", @@ -4289,20 +4289,20 @@ export function getMenuList(pathname: string, t: any): Group[] { }, ], }, - { - groupLabel: "", - id: "experts", - menus: [ - { - id: "experts", - href: "/admin/add-experts", - label: t("add-experts"), - active: pathname.includes("/add-experts"), - icon: "majesticons:user", - submenus: [], - }, - ], - }, + // { + // groupLabel: "", + // id: "experts", + // menus: [ + // { + // id: "experts", + // href: "/admin/add-experts", + // label: t("add-experts"), + // active: pathname.includes("/add-experts"), + // icon: "majesticons:user", + // submenus: [], + // }, + // ], + // }, { groupLabel: "", id: "settings",