2024-11-05 06:15:40 +00:00
|
|
|
"use client";
|
2025-01-17 02:57:45 +00:00
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
Card,
|
|
|
|
|
CardFooter,
|
|
|
|
|
CircularProgress,
|
|
|
|
|
ScrollShadow,
|
2025-02-13 08:25:39 +00:00
|
|
|
} from "@heroui/react";
|
2024-11-05 06:15:40 +00:00
|
|
|
import Image from "next/image";
|
2025-01-17 02:57:45 +00:00
|
|
|
import { ChevronLeftIcon, ChevronRightIcon, EyeIcon } from "../icons";
|
|
|
|
|
import { Swiper, SwiperSlide, useSwiper } from "swiper/react";
|
2024-11-05 06:15:40 +00:00
|
|
|
import "swiper/css";
|
2025-01-14 15:30:13 +00:00
|
|
|
import "swiper/css/navigation";
|
2025-01-17 02:57:45 +00:00
|
|
|
|
|
|
|
|
import { Autoplay, Pagination, Navigation, Controller } from "swiper/modules";
|
2024-11-05 06:15:40 +00:00
|
|
|
import Link from "next/link";
|
|
|
|
|
import GPRKominfo from "../ui/social-media/gpr-kominfo";
|
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
import { getListArticle } from "@/service/article";
|
2025-01-14 15:30:13 +00:00
|
|
|
import { convertDateFormat, textEllipsis } from "@/utils/global";
|
2024-12-12 09:48:17 +00:00
|
|
|
import { useTranslations } from "next-intl";
|
2025-01-15 11:08:49 +00:00
|
|
|
import { data } from "autoprefixer";
|
2025-01-17 02:57:45 +00:00
|
|
|
import { Controller as FormController } from "react-hook-form";
|
|
|
|
|
import { Nabla } from "next/font/google";
|
2024-11-05 06:15:40 +00:00
|
|
|
|
|
|
|
|
export default function HeaderNews() {
|
2024-11-06 08:44:56 +00:00
|
|
|
const [article, setArticle] = useState<any>([]);
|
2024-12-12 09:48:17 +00:00
|
|
|
const t = useTranslations("Landing");
|
2025-02-10 09:16:52 +00:00
|
|
|
const [selectedTab, setSelectedTab] = useState("media");
|
2025-02-17 10:01:58 +00:00
|
|
|
const [hotNews, setHotNews] = useState<any>([]);
|
|
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
|
|
|
|
|
|
|
|
// }, []);
|
2024-11-05 06:15:40 +00:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
getArticle();
|
2025-02-17 10:01:58 +00:00
|
|
|
|
|
|
|
|
getHotNews();
|
2024-11-05 06:15:40 +00:00
|
|
|
}, []);
|
|
|
|
|
|
2025-02-17 10:01:58 +00:00
|
|
|
async function getArticle() {
|
|
|
|
|
const req = { page: 1, search: "", limit: "10", sort: "desc" };
|
|
|
|
|
const response = await getListArticle(req);
|
|
|
|
|
setArticle(response?.data?.data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getHotNews() {
|
|
|
|
|
const req = {
|
|
|
|
|
page: 1,
|
|
|
|
|
search: "",
|
|
|
|
|
limit: "10",
|
|
|
|
|
sortBy: "view_count",
|
|
|
|
|
sort: "desc",
|
|
|
|
|
};
|
|
|
|
|
const response = await getListArticle(req);
|
|
|
|
|
setHotNews(response?.data?.data);
|
|
|
|
|
console.log("sadadasdasd", response?.data?.data);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-05 06:15:40 +00:00
|
|
|
return (
|
2025-01-17 02:57:45 +00:00
|
|
|
<div className="flex flex-col lg:flex-row gap-3 lg:gap-8 bg-white p-1 lg:p-8 lg:h-[70vh]">
|
2025-01-15 11:08:49 +00:00
|
|
|
<div className="lg:hidden w-full h-full">
|
2025-01-17 02:57:45 +00:00
|
|
|
{article ? (
|
|
|
|
|
<Swiper
|
|
|
|
|
centeredSlides={true}
|
|
|
|
|
autoplay={{
|
|
|
|
|
delay: 5000,
|
|
|
|
|
disableOnInteraction: false,
|
|
|
|
|
}}
|
|
|
|
|
navigation={true}
|
|
|
|
|
className="mySwiper"
|
|
|
|
|
modules={[Autoplay, Controller, Navigation]}
|
|
|
|
|
onSwiper={(swiper) => {
|
|
|
|
|
swiper.navigation.nextEl?.classList.add(
|
|
|
|
|
"bg-white/70",
|
|
|
|
|
"!text-black",
|
|
|
|
|
"rounded-full",
|
|
|
|
|
"!w-[24px]",
|
|
|
|
|
"!h-[24px]"
|
|
|
|
|
);
|
|
|
|
|
swiper.navigation.prevEl?.classList.add(
|
|
|
|
|
"bg-white/70",
|
|
|
|
|
"!text-black",
|
|
|
|
|
"rounded-full",
|
|
|
|
|
"!w-[24px]",
|
|
|
|
|
"!h-[24px]"
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-02-12 08:20:38 +00:00
|
|
|
{article?.map((newsItem: any, index: number) => (
|
2025-02-12 10:52:27 +00:00
|
|
|
<SwiperSlide key={newsItem?.id}>
|
2025-01-17 02:57:45 +00:00
|
|
|
<Card isFooterBlurred radius="lg" className="border-none">
|
2025-02-07 07:05:52 +00:00
|
|
|
<Image
|
|
|
|
|
width={1920}
|
|
|
|
|
height={1080}
|
2025-01-17 02:57:45 +00:00
|
|
|
alt="headernews"
|
2025-01-30 11:34:29 +00:00
|
|
|
src={
|
|
|
|
|
newsItem?.thumbnailUrl == ""
|
2025-02-07 07:05:52 +00:00
|
|
|
? "/no-image.jpg"
|
2025-01-30 11:34:29 +00:00
|
|
|
: newsItem?.thumbnailUrl
|
|
|
|
|
}
|
2025-01-17 02:57:45 +00:00
|
|
|
className="h-[25vh] object-cover"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<CardFooter className="before:bg-white/10 border-white/20 border-1 overflow-hidden py-1 md:absolute before:rounded-xl rounded-large bottom-1 w-[calc(100%_-_8px)] shadow-small ml-1 z-10">
|
|
|
|
|
<div className="text-black dark:text-white">
|
|
|
|
|
<Link
|
|
|
|
|
href={`news/detail/${newsItem.id}-${newsItem?.slug}`}
|
|
|
|
|
>
|
|
|
|
|
<p className="text-left font-semibold">
|
|
|
|
|
{textEllipsis(newsItem.title, 40)}
|
|
|
|
|
</p>
|
|
|
|
|
</Link>
|
|
|
|
|
<p className="py-[2px] text-left text-sm">
|
|
|
|
|
{convertDateFormat(newsItem.createdAt)} WIB
|
2025-01-15 11:08:49 +00:00
|
|
|
</p>
|
2025-01-17 02:57:45 +00:00
|
|
|
<p className="flex items-center gap-1 text-sm">
|
|
|
|
|
<EyeIcon className="text-black dark:text-white" />
|
|
|
|
|
{newsItem.viewCount === null ? 0 : newsItem.viewCount}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</CardFooter>
|
|
|
|
|
</Card>
|
|
|
|
|
</SwiperSlide>
|
|
|
|
|
))}
|
|
|
|
|
</Swiper>
|
|
|
|
|
) : (
|
|
|
|
|
<CircularProgress aria-label="Loading..." size="lg" />
|
|
|
|
|
)}
|
2025-01-15 11:08:49 +00:00
|
|
|
</div>
|
|
|
|
|
<div className="w-auto lg:w-[25%] p-2 dark:bg-stone-800 bg-[#f0f0f0] shadow-lg dark:text-white text-black rounded-xl mb-2 md:mb-0 h-[50vh] lg:h-[67vh]">
|
|
|
|
|
<p className="text-lg font-bold h-10 text-center dark:text-white text-black">
|
|
|
|
|
{t("berita")}
|
|
|
|
|
</p>
|
|
|
|
|
<ScrollShadow hideScrollBar className="h-[34vh] lg:h-[53vh] ">
|
2025-02-17 10:01:58 +00:00
|
|
|
{hotNews?.map((data: any, index: number) => (
|
2025-01-15 11:08:49 +00:00
|
|
|
<div
|
|
|
|
|
className="text-xs text-left m-2 p-2 dark:bg-[#1E1616] bg-white rounded-md flex flex-row gap-2"
|
2025-02-12 10:52:27 +00:00
|
|
|
key={data?.id}
|
2025-01-15 11:08:49 +00:00
|
|
|
>
|
2025-02-04 08:31:04 +00:00
|
|
|
<Image
|
|
|
|
|
height={480}
|
|
|
|
|
width={480}
|
2025-01-15 11:08:49 +00:00
|
|
|
alt="headernews"
|
2025-01-30 11:34:29 +00:00
|
|
|
src={
|
2025-02-04 08:31:04 +00:00
|
|
|
data?.thumbnailUrl == ""
|
|
|
|
|
? "/no-image.jpg"
|
|
|
|
|
: data?.thumbnailUrl
|
2025-01-30 11:34:29 +00:00
|
|
|
}
|
2025-02-04 08:31:04 +00:00
|
|
|
className="object-cover w-[60px] h-[60px] rounded-md"
|
2025-01-15 11:08:49 +00:00
|
|
|
/>
|
|
|
|
|
<div>
|
|
|
|
|
<Link
|
|
|
|
|
href={`/news/detail/${data?.id}-${data?.slug}`}
|
|
|
|
|
className="lg:hidden"
|
|
|
|
|
>
|
|
|
|
|
{textEllipsis(data.title, 40)}
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
href={`/news/detail/${data?.id}-${data?.slug}`}
|
|
|
|
|
key={data?.id}
|
|
|
|
|
className="hidden lg:block"
|
|
|
|
|
>
|
2025-01-31 12:42:40 +00:00
|
|
|
{textEllipsis(data.title, 66)}
|
2025-01-15 11:08:49 +00:00
|
|
|
</Link>
|
2025-01-17 02:57:45 +00:00
|
|
|
<div className="flex flex-row gap-2 text-[10px]">
|
|
|
|
|
<p className="py-[2px]">
|
|
|
|
|
{convertDateFormat(data.createdAt)} WIB
|
|
|
|
|
</p>
|
|
|
|
|
<p className="flex items-center gap-1">
|
|
|
|
|
<EyeIcon size={14} />
|
|
|
|
|
{data.viewCount === null ? 0 : data.viewCount}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2024-11-06 08:44:56 +00:00
|
|
|
</div>
|
2025-01-15 11:08:49 +00:00
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</ScrollShadow>
|
|
|
|
|
<div className="m-2">
|
|
|
|
|
<Link href="/news/all">
|
|
|
|
|
<Button
|
2025-02-17 10:01:58 +00:00
|
|
|
className="w-full bg-gradient-to-r from-red-700 to-[#bb3523] text-white font-bold rounded-md focus:outline-none"
|
2025-01-15 11:08:49 +00:00
|
|
|
radius="none"
|
|
|
|
|
>
|
|
|
|
|
{t("semua")}
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
2024-11-05 06:15:40 +00:00
|
|
|
</div>
|
2025-01-15 11:08:49 +00:00
|
|
|
</div>
|
2025-01-14 15:30:13 +00:00
|
|
|
|
2025-01-15 11:08:49 +00:00
|
|
|
<div className="hidden lg:block w-full lg:w-[50%] h-[67vh]">
|
2025-01-17 02:57:45 +00:00
|
|
|
{article ? (
|
|
|
|
|
<Swiper
|
|
|
|
|
centeredSlides={true}
|
|
|
|
|
autoplay={{
|
|
|
|
|
delay: 5000,
|
|
|
|
|
disableOnInteraction: false,
|
|
|
|
|
}}
|
|
|
|
|
navigation={true}
|
|
|
|
|
modules={[Autoplay, Controller, Navigation]}
|
|
|
|
|
className="mySwiper"
|
|
|
|
|
onSwiper={(swiper) => {
|
|
|
|
|
swiper.navigation.nextEl?.classList.add(
|
|
|
|
|
"bg-white/70",
|
|
|
|
|
"!text-black",
|
|
|
|
|
"rounded-full",
|
|
|
|
|
"!w-[48px]",
|
|
|
|
|
"!h-[48px]"
|
|
|
|
|
);
|
|
|
|
|
swiper.navigation.prevEl?.classList.add(
|
|
|
|
|
"bg-white/70",
|
|
|
|
|
"!text-black",
|
|
|
|
|
"rounded-full",
|
|
|
|
|
"!w-[48px]",
|
|
|
|
|
"!h-[48px]"
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2025-02-12 08:20:38 +00:00
|
|
|
{article?.map((newsItem: any, index: number) => (
|
2025-02-12 10:52:27 +00:00
|
|
|
<SwiperSlide key={newsItem?.id} className="h-[67vh]">
|
2025-01-17 02:57:45 +00:00
|
|
|
<Card
|
|
|
|
|
isFooterBlurred
|
|
|
|
|
radius="lg"
|
|
|
|
|
className="border-none h-[67vh] shadow-none"
|
|
|
|
|
>
|
2025-02-06 09:49:20 +00:00
|
|
|
<Image
|
2025-01-17 02:57:45 +00:00
|
|
|
alt="headernews"
|
2025-02-06 09:49:20 +00:00
|
|
|
width={1440}
|
|
|
|
|
height={1080}
|
2025-01-30 11:34:29 +00:00
|
|
|
src={
|
|
|
|
|
newsItem?.thumbnailUrl == ""
|
2025-02-06 09:49:20 +00:00
|
|
|
? "/no-image.jpg"
|
2025-01-30 11:34:29 +00:00
|
|
|
: newsItem?.thumbnailUrl
|
|
|
|
|
}
|
2025-02-06 09:49:20 +00:00
|
|
|
className="w-full !h-[67vh] object-cover rounded-lg"
|
2025-01-17 02:57:45 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<CardFooter className="mb-1 max-h-[20vh] before:bg-white/10 border-white/20 border-1 overflow-hidden py-1 md:absolute before:rounded-xl rounded-large bottom-1 w-[calc(100%_-_8px)] shadow-small ml-1 z-10">
|
|
|
|
|
<div className="text-white">
|
|
|
|
|
<Link
|
|
|
|
|
href={`news/detail/${newsItem.id}-${newsItem?.slug}`}
|
|
|
|
|
>
|
2025-02-06 09:49:20 +00:00
|
|
|
<p className="text-left font-semibold text-lg lg:text-2xl">
|
2025-01-17 02:57:45 +00:00
|
|
|
{newsItem.title}
|
|
|
|
|
</p>
|
|
|
|
|
</Link>
|
|
|
|
|
<div className="flex flex-row gap-1">
|
|
|
|
|
<p className="py-[2px] text-left text-sm">
|
|
|
|
|
{convertDateFormat(newsItem.createdAt)} WIB
|
|
|
|
|
</p>
|
|
|
|
|
<p className="flex items-center gap-1 text-sm">
|
|
|
|
|
<EyeIcon />
|
|
|
|
|
{newsItem.viewCount === null ? 0 : newsItem.viewCount}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</CardFooter>
|
|
|
|
|
</Card>
|
|
|
|
|
</SwiperSlide>
|
|
|
|
|
))}
|
|
|
|
|
</Swiper>
|
|
|
|
|
) : (
|
|
|
|
|
<CircularProgress aria-label="Loading..." size="lg" />
|
|
|
|
|
)}
|
2025-01-15 11:08:49 +00:00
|
|
|
</div>
|
2025-02-10 09:16:52 +00:00
|
|
|
<div className="lg:w-[25%] h-[67vh] rounded-md text-white dark:text-black ">
|
|
|
|
|
{/* <GPRKominfo /> */}
|
|
|
|
|
<div className="text-[15px] flex flex-row gap-10">
|
|
|
|
|
<a
|
|
|
|
|
onClick={() => setSelectedTab("media")}
|
|
|
|
|
className={
|
|
|
|
|
selectedTab === "media"
|
|
|
|
|
? "text-black border-b-3 border-red-400 cursor-pointer py-2"
|
|
|
|
|
: "text-slate-300 cursor-pointer py-2"
|
|
|
|
|
}
|
|
|
|
|
>
|
2025-02-17 10:01:58 +00:00
|
|
|
{t("terkini")}
|
2025-02-10 09:16:52 +00:00
|
|
|
</a>
|
|
|
|
|
<a
|
|
|
|
|
onClick={() => setSelectedTab("video")}
|
|
|
|
|
className={
|
|
|
|
|
selectedTab === "video"
|
|
|
|
|
? "text-black border-b-3 border-red-400 cursor-pointer py-2"
|
|
|
|
|
: "text-slate-300 cursor-pointer py-2"
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
Video Virtual
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
{selectedTab === "media" ? (
|
|
|
|
|
<div className="lg:!h-[62vh] p-2 dark:bg-stone-800 bg-[#f0f0f0] dark:text-white text-black rounded-lg">
|
|
|
|
|
<ScrollShadow hideScrollBar className=" h-[54vh]">
|
2025-02-12 08:20:38 +00:00
|
|
|
{article?.map((list: any, index: number) => (
|
2025-02-10 09:16:52 +00:00
|
|
|
<div
|
2025-02-12 10:52:27 +00:00
|
|
|
key={list?.id}
|
2025-02-10 09:16:52 +00:00
|
|
|
className="text-xs text-left m-2 p-2 dark:bg-[#1E1616] bg-white rounded-md"
|
|
|
|
|
>
|
|
|
|
|
<Link href={`news/detail/${list?.id}`}>
|
|
|
|
|
<p className="text-left font-semibold">{list?.title}</p>
|
|
|
|
|
</Link>
|
|
|
|
|
<div className="flex flex-row gap-1">
|
|
|
|
|
<p className="py-[2px] text-left text-xs">
|
|
|
|
|
{convertDateFormat(list?.createdAt)} WIB
|
|
|
|
|
</p>
|
|
|
|
|
<p className="flex items-center gap-1 text-xs">
|
|
|
|
|
<EyeIcon />
|
|
|
|
|
{list?.viewCount === null ? 0 : list?.viewCount}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</ScrollShadow>
|
|
|
|
|
<Button
|
2025-02-17 10:01:58 +00:00
|
|
|
className="w-full bg-gradient-to-r from-red-700 to-[#bb3523] text-white font-bold rounded-md focus:outline-none"
|
2025-02-10 09:16:52 +00:00
|
|
|
radius="none"
|
|
|
|
|
>
|
|
|
|
|
Lihat Semua
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
2025-02-17 10:01:58 +00:00
|
|
|
<div className="lg:!h-[62vh] dark:bg-stone-800 bg-[#f0f0f0] dark:text-white text-black rounded-lg flex flex-col p-2 lg:p-8 gap-2 lg:gap-5">
|
|
|
|
|
<Link
|
|
|
|
|
target="_blank"
|
|
|
|
|
href="https://www.youtube.com/watch?v=6_g_PyiFcNo"
|
|
|
|
|
className="border-b-2 py-2 lg:py-4"
|
|
|
|
|
>
|
|
|
|
|
IKLAN LAYANAN MASYARAKAT DIVHUMAS POLRI - POLRI PRESISI UNTUK
|
|
|
|
|
INDONESIA
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
target="_blank"
|
|
|
|
|
href="https://www.youtube.com/watch?v=p0AJEwvJ7gU"
|
|
|
|
|
className="border-b-2 py-2 lg:py-4"
|
|
|
|
|
>
|
|
|
|
|
ILM DIVHUMAS POLRI - POLRI PRESISI MENGAWAL PROSES VAKSINASI UNTUK
|
|
|
|
|
MENGATASI PANDEMI COVID 19
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
target="_blank"
|
|
|
|
|
href="https://www.youtube.com/watch?v=jaihQPjxcy4"
|
|
|
|
|
className="border-b-2 py-2 lg:py-4"
|
|
|
|
|
>
|
|
|
|
|
IKLAN LAYANAN MASYARAKAT DIVHUMAS POLRI - INDONESIA MENOLAK
|
|
|
|
|
RADIKALISME
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
target="_blank"
|
|
|
|
|
href="https://www.youtube.com/watch?v=umPEo0FYTQk"
|
|
|
|
|
className="border-b-2 py-2 lg:py-4"
|
|
|
|
|
>
|
|
|
|
|
IKLAN LAYANAN MASYARAKAT DIVHUMAS POLRI - BHABINKAMTIBMAS SAHABAT
|
|
|
|
|
MASYARAKAT
|
|
|
|
|
</Link>
|
2025-02-10 09:16:52 +00:00
|
|
|
</div>
|
|
|
|
|
)}
|
2024-11-05 06:15:40 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|