fix: add /in in link broadcast

This commit is contained in:
Sabda Yagra 2025-08-14 09:35:01 +07:00
parent 8b77700af8
commit cd7f7aec86
1 changed files with 14 additions and 10 deletions

View File

@ -50,7 +50,6 @@ const CustomEditor = dynamic(
{ ssr: false }
);
const animatedComponent = makeAnimated();
const FormSchema = z.object({
@ -144,20 +143,22 @@ export default function ContentBlast(props: { type: string }) {
async function initState() {
const response = await detailMediaSummary(String(id));
const details = response?.data?.data;
let pageUrl = details?.pageUrl || "";
if (process.env.NODE_ENV === "production") {
pageUrl = pageUrl.replace(/(\.com|\.id)(\/|$)/, "$1/in$2");
}
if (details != undefined) {
form.setValue("thumbnail", details.smallThumbnailLink);
let body = `<div><p>Berita hari ini !!!</p><div style='margin-top:20px;border:1px solid;border-radius:10px;width:500px;background-color:#f7f7f7'><div><img style='width:500px;height:auto;border-radius:10px;object-fit:cover' src='${
details?.smallThumbnailLink
}'></div><a style='padding:5px 20px;margin:0;text-decoration:none' href='${
details?.pageUrl
}'>${details?.pageUrl}</a><h3 style='padding:5px 20px;margin:0'>${
}'></div> <a style='padding:5px 20px;margin:0;text-decoration:none' href='${pageUrl}'>${pageUrl}</a><h3 style='padding:5px 20px;margin:0'>${
details?.title
}</h3><p style='padding:0 20px;margin:0;margin-bottom:10px'>
${textEllipsis(details?.description, 150)}</p></div></div>`;
form.setValue("title", `${details?.title}`);
form.setValue(
"url",
details?.pageUrl || "https://mediahub.polri.go.id/in"
details?.pageUrl || "https://mediahub.polri.go.id"
);
if (type == "wa") {
body = `${textEllipsis(details?.description, 150)}`;
@ -241,11 +242,14 @@ export default function ContentBlast(props: { type: string }) {
render={({ field }) => (
<FormItem>
<FormLabel>Detail Perencanaan</FormLabel>
{type === "wa" ? (
<Textarea value={field.value} onChange={field.onChange} />
) : (
<CustomEditor onChange={field.onChange} initialData={field.value} />
)}
{type === "wa" ? (
<Textarea value={field.value} onChange={field.onChange} />
) : (
<CustomEditor
onChange={field.onChange}
initialData={field.value}
/>
)}
<FormMessage />
</FormItem>
)}