diff --git a/app/[locale]/(protected)/admin/broadcast/create/[id]/page.tsx b/app/[locale]/(protected)/admin/broadcast/create/[id]/page.tsx
index 73256382..7d45dc1d 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..d750dbad 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/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/lib/menus.ts b/lib/menus.ts
index 00088138..1fbb9424 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",