From 7e1ffe2d2f930f564751399bed7082c6b5797b17 Mon Sep 17 00:00:00 2001 From: Sabda Yagra Date: Thu, 14 Aug 2025 10:38:00 +0700 Subject: [PATCH 1/4] fixing --- .../form/broadcast/content-blast-form.tsx | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/components/form/broadcast/content-blast-form.tsx b/components/form/broadcast/content-blast-form.tsx index 5453ac62..d7cac489 100644 --- a/components/form/broadcast/content-blast-form.tsx +++ b/components/form/broadcast/content-blast-form.tsx @@ -144,17 +144,30 @@ export default function ContentBlast(props: { type: string }) { 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 (pageUrl.includes("mediahub.polri.go.id")) { + pageUrl = pageUrl.replace( + /(\.id)(\/|$)/, + (match: any, p1: any, p2: any) => { + return p2.startsWith("/in") ? match : `${p1}/in${p2}`; + } + ); } if (details != undefined) { form.setValue("thumbnail", details.smallThumbnailLink); - let body = `

Berita hari ini !!!

${pageUrl}

${ - details?.title - }

- ${textEllipsis(details?.description, 150)}

`; + let body = `

Berita hari ini !!!

+
+
+ +
+ ${pageUrl} +

${details?.title}

+

+ ${textEllipsis(details?.description, 150)} +

+
+
`; form.setValue("title", `${details?.title}`); form.setValue( "url", From fb976f01bb0997d8fba2f83ffa712857c361a909 Mon Sep 17 00:00:00 2001 From: Sabda Yagra Date: Thu, 14 Aug 2025 21:19:12 +0700 Subject: [PATCH 2/4] fix: styling in hero and add imageblurry --- components/form/content/image-update-form.tsx | 90 ++++++++++++++++- components/landing-page/content-category.tsx | 98 ++++++++++++++----- components/landing-page/hero-new.tsx | 41 ++++---- components/landing-page/new-content.tsx | 23 ++++- .../landing-page/search-section-new.tsx | 30 +++++- components/ui/image-blurry.tsx | 25 +++-- service/content/content.ts | 7 +- 7 files changed, 252 insertions(+), 62 deletions(-) diff --git a/components/form/content/image-update-form.tsx b/components/form/content/image-update-form.tsx index dd64038b..f4eba049 100644 --- a/components/form/content/image-update-form.tsx +++ b/components/form/content/image-update-form.tsx @@ -64,6 +64,17 @@ type Category = { name: string; }; +type PlacementType = "all" | "mabes" | "polda" | "international" | string; + +interface FilePlacement { + mediaFileId: number; + placements?: PlacementType[]; +} + +interface TempFileItem { + id: number | string; +} + type Detail = { id: string; title: string; @@ -255,6 +266,7 @@ export default function FormImageUpdate() { setDetail(details); setSelectedTarget(String(details.category.id)); + setTempFile(details?.files); setValue("title", details.title); setValue("description", details.htmlDescription); @@ -641,6 +653,77 @@ export default function FormImageUpdate() { )); + type PlacementType = "all" | "mabes" | "polda" | "international" | string; + + interface FilePlacement { + mediaFileId: number; + placements?: PlacementType[]; + } + + interface TempFileItem { + id: number | string; + // tambahkan properti lain kalau ada + } + + const [tempFile, setTempFile] = useState([]); + const [filePlacements, setFilePlacements] = useState([]); + + + const setupPlacement = (id: number | string, placement: PlacementType) => { + console.log(`FileDestination.leng:: ${id}_${placement}`); + const arrayFile: FilePlacement[] = []; + + for (let i = 0; i < tempFile?.length; i++) { + const element = tempFile[i]; + + if (element.id == id) { + const findPlacementIdx = filePlacements.findIndex( + (o) => Number(o.mediaFileId) === Number(id) + ); + + if (findPlacementIdx > -1) { + const findPlacement = filePlacements[findPlacementIdx]; + + if (findPlacement?.placements?.includes(placement)) { + if (placement === "all") { + findPlacement.placements = undefined; + } else { + findPlacement.placements = findPlacement.placements.filter( + (val) => val !== placement + ); + if (findPlacement.placements?.includes("all")) { + findPlacement.placements = findPlacement.placements.filter( + (val) => val !== "all" + ); + } + } + } else if (placement === "all") { + findPlacement.placements = [ + "all", + "mabes", + "polda", + "international", + ]; + } else if (findPlacement.placements) { + findPlacement.placements = [...findPlacement.placements, placement]; + } else { + findPlacement.placements = [placement]; + } + } else { + const file: FilePlacement = { + mediaFileId: Number(element.id), + placements: [placement], + }; + + arrayFile.push(file); + } + } + } + + const finalPlacements = [...filePlacements, ...arrayFile]; + setFilePlacements(finalPlacements); + console.log("FileDestination.leng::", finalPlacements); + }; const handleCheckboxChangeImage = (fileId: number, value: string) => { setSelectedOptions((prev: any) => { @@ -894,11 +977,8 @@ export default function FormImageUpdate() { checked={selectedOptions[ file.id ]?.includes("all")} - onChange={() => - handleCheckboxChangeImage( - file.id, - "all" - ) + onChange={(e) => + setupPlacement(file.id, e.target.value) } className="form-checkbox" /> diff --git a/components/landing-page/content-category.tsx b/components/landing-page/content-category.tsx index 23630d9e..1eea3a90 100644 --- a/components/landing-page/content-category.tsx +++ b/components/landing-page/content-category.tsx @@ -1,13 +1,23 @@ -import { getCategoryData, getPublicCategoryData } from "@/service/landing/landing"; +import { + getCategoryData, + getPublicCategoryData, +} from "@/service/landing/landing"; import React, { useEffect, useState } from "react"; import { Reveal } from "./Reveal"; import { useTranslations } from "next-intl"; import { usePathname } from "next/navigation"; import { useParams } from "next/navigation"; import Image from "next/image"; -import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "../ui/carousel"; +import { + Carousel, + CarouselContent, + CarouselItem, + CarouselNext, + CarouselPrevious, +} from "../ui/carousel"; import { useRouter } from "@/i18n/routing"; import { Button } from "../ui/button"; +import ImageBlurry from "../ui/image-blurry"; const ContentCategory = (props: { group?: string; type: string }) => { const [categories, setCategories] = useState(); @@ -19,14 +29,26 @@ const ContentCategory = (props: { group?: string; type: string }) => { const satkerName = params?.satker_name; const router = useRouter(); - let prefixPath = poldaName ? `/polda/${poldaName}` : satkerName ? `/satker/${satkerName}` : "/"; + let prefixPath = poldaName + ? `/polda/${poldaName}` + : satkerName + ? `/satker/${satkerName}` + : "/"; useEffect(() => { initFetch(); }, []); const initFetch = async () => { const response = await getPublicCategoryData( - props.group == "mabes" ? "" : props.group == "polda" && poldaName && String(poldaName)?.length > 1 ? poldaName : props.group == "satker" && satkerName && String(satkerName)?.length > 1 ? "satker-" + satkerName : "", + props.group == "mabes" + ? "" + : props.group == "polda" && poldaName && String(poldaName)?.length > 1 + ? poldaName + : props.group == "satker" && + satkerName && + String(satkerName)?.length > 1 + ? "satker-" + satkerName + : "", "", locale == "en" ? true : false ); @@ -52,7 +74,10 @@ const ContentCategory = (props: { group?: string; type: string }) => { `; - const toBase64 = (str: string) => (typeof window === "undefined" ? Buffer.from(str).toString("base64") : window.btoa(str)); + const toBase64 = (str: string) => + typeof window === "undefined" + ? Buffer.from(str).toString("base64") + : window.btoa(str); return (
@@ -61,22 +86,34 @@ const ContentCategory = (props: { group?: string; type: string }) => {

{pathname?.split("/")[1] == "in" ? ( <> - {t("category", { defaultValue: "Category" })}  + + {t("category", { defaultValue: "Category" })}  + {t("content", { defaultValue: "Content" })} ) : ( <> - {t("content", { defaultValue: "Content" })}  + + {t("content", { defaultValue: "Content" })}  + {t("category", { defaultValue: "Category" })} )}

- {(seeAllValue ? categories : categories?.slice(0, 4))?.map((category: any) => ( -
-
router.push(`${prefixPath}all/filter?category=${category?.id}`)} className="cursor-pointer relative group rounded-md overflow-hidden shadow-md hover:shadow-lg block"> - {/* Gambar */} - ( +
+
+ router.push( + `${prefixPath}all/filter?category=${category?.id}` + ) + } + className="cursor-pointer relative group rounded-md overflow-hidden shadow-md hover:shadow-lg block" + > + {/* Gambar */} + {/* category { height={1440} src={category?.smallThumbnailLink} className="w-full lg:h-[300px] h-40 object-cover group-hover:scale-110 transition-transform duration-300" - /> + /> */} + - {/* Overlay gelap */} -
+ {/* Overlay gelap */} +
- {/* Judul */} -
-

{category?.name}

+ {/* Judul */} +
+

+ {category?.name} +

+
-
- ))} + ) + )}
{/* Tombol See More / See Less */} {categories?.length > 4 && (
-
)} diff --git a/components/landing-page/hero-new.tsx b/components/landing-page/hero-new.tsx index 61e96084..7eda42a8 100644 --- a/components/landing-page/hero-new.tsx +++ b/components/landing-page/hero-new.tsx @@ -50,6 +50,7 @@ import { ChevronLeft, ChevronRight } from "lucide-react"; import { Link } from "@/i18n/routing"; import { listBannerHero } from "@/service/settings/settings"; import ImageBlurry from "../ui/image-blurry"; +import { Icon } from "@iconify/react/dist/iconify.js"; type HeroModalProps = { onClose: () => void; @@ -173,7 +174,7 @@ const HeroModal = ({ > ✕ - {/* gambar-utama */} - + {/* + className="w-full h-[310px] lg:h-[420px] rounded-lg object-contain" + /> */}
@@ -577,24 +575,29 @@ const HeroNew = (props: { group?: string }) => { ? `${prefixPath}/document/detail/${list?.slug}` : `${prefixPath}/audio/detail/${list?.slug}` } - className="absolute bottom-20 left-8 lg:left-32 z-20 text-white w-[85%] lg:w-[45%] cursor-pointer" + className="absolute bottom-10 lg:bottom-20 left-8 lg:left-32 z-20 text-white w-[85%] lg:w-[45%] cursor-pointer" > - + {list?.categoryName} -

{list?.title}

-

+

{list?.title}

+

{formatDateToIndonesian(new Date(list?.createdAt))}{" "} {list?.timezone || "WIB"} | 👁 {list?.clickCount}

- {/* Tombol navigasi */} -
- +
+ {" "}
-
- +
+ {" "}
diff --git a/components/landing-page/new-content.tsx b/components/landing-page/new-content.tsx index cfbe8fb7..11eb17eb 100644 --- a/components/landing-page/new-content.tsx +++ b/components/landing-page/new-content.tsx @@ -18,6 +18,7 @@ import { useTranslations } from "next-intl"; import { Skeleton } from "../ui/skeleton"; import Image from "next/image"; import { motion } from "framer-motion"; +import ImageBlurry from "../ui/image-blurry"; const NewContent = (props: { group: string; type: string }) => { const [newContent, setNewContent] = useState(); @@ -228,7 +229,7 @@ const NewContent = (props: { group: string; type: string }) => { } > {" "} - { alt="image" src={image?.smallThumbnailLink} className="w-full h-full object-cover" + /> */} + @@ -431,7 +441,7 @@ const NewContent = (props: { group: string; type: string }) => { prefixPath + `/video/detail/${video?.slug}` } > - { height={1440} src={video?.smallThumbnailLink} className="w-full h-full object-cover" + /> */} + diff --git a/components/landing-page/search-section-new.tsx b/components/landing-page/search-section-new.tsx index 76866422..e07ab037 100644 --- a/components/landing-page/search-section-new.tsx +++ b/components/landing-page/search-section-new.tsx @@ -15,6 +15,7 @@ import { getHeroData } from "@/service/landing/landing"; import { htmlToString } from "@/utils/globals"; import { Link, useRouter } from "@/i18n/routing"; import { Button } from "../ui/button"; +import ImageBlurry from "../ui/image-blurry"; const ScrollableContent = () => { const [contentType, setContentType] = useState("all"); @@ -161,7 +162,10 @@ const ScrollableContent = () => {
@@ -1203,7 +1213,7 @@ const EventModal = ({