This commit is contained in:
hanif salafi 2025-08-14 09:37:37 +07:00
commit a01d77c82a
1 changed files with 14 additions and 10 deletions

View File

@ -50,7 +50,6 @@ const CustomEditor = dynamic(
{ ssr: false } { ssr: false }
); );
const animatedComponent = makeAnimated(); const animatedComponent = makeAnimated();
const FormSchema = z.object({ const FormSchema = z.object({
@ -144,20 +143,22 @@ export default function ContentBlast(props: { type: string }) {
async function initState() { async function initState() {
const response = await detailMediaSummary(String(id)); const response = await detailMediaSummary(String(id));
const details = response?.data?.data; 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) { if (details != undefined) {
form.setValue("thumbnail", details.smallThumbnailLink); 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='${ 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 details?.smallThumbnailLink
}'></div><a style='padding:5px 20px;margin:0;text-decoration:none' href='${ }'></div> <a style='padding:5px 20px;margin:0;text-decoration:none' href='${pageUrl}'>${pageUrl}</a><h3 style='padding:5px 20px;margin:0'>${
details?.pageUrl
}'>${details?.pageUrl}</a><h3 style='padding:5px 20px;margin:0'>${
details?.title details?.title
}</h3><p style='padding:0 20px;margin:0;margin-bottom:10px'> }</h3><p style='padding:0 20px;margin:0;margin-bottom:10px'>
${textEllipsis(details?.description, 150)}</p></div></div>`; ${textEllipsis(details?.description, 150)}</p></div></div>`;
form.setValue("title", `${details?.title}`); form.setValue("title", `${details?.title}`);
form.setValue( form.setValue(
"url", "url",
details?.pageUrl || "https://mediahub.polri.go.id/in" details?.pageUrl || "https://mediahub.polri.go.id"
); );
if (type == "wa") { if (type == "wa") {
body = `${textEllipsis(details?.description, 150)}`; body = `${textEllipsis(details?.description, 150)}`;
@ -241,11 +242,14 @@ export default function ContentBlast(props: { type: string }) {
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel>Detail Perencanaan</FormLabel> <FormLabel>Detail Perencanaan</FormLabel>
{type === "wa" ? ( {type === "wa" ? (
<Textarea value={field.value} onChange={field.onChange} /> <Textarea value={field.value} onChange={field.onChange} />
) : ( ) : (
<CustomEditor onChange={field.onChange} initialData={field.value} /> <CustomEditor
)} onChange={field.onChange}
initialData={field.value}
/>
)}
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}