2024-11-05 06:15:40 +00:00
|
|
|
"use client";
|
|
|
|
|
import { Button, Card, CardFooter, ScrollShadow } from "@nextui-org/react";
|
|
|
|
|
import Image from "next/image";
|
|
|
|
|
import { EyeIcon } from "../icons";
|
|
|
|
|
import { Swiper, SwiperSlide } from "swiper/react";
|
|
|
|
|
import "swiper/css";
|
|
|
|
|
import "swiper/css/pagination";
|
|
|
|
|
import { Autoplay, Pagination, Navigation } from "swiper/modules";
|
|
|
|
|
import Link from "next/link";
|
|
|
|
|
import GPRKominfo from "../ui/social-media/gpr-kominfo";
|
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
import { getListArticle } from "@/service/article";
|
2024-11-06 08:44:56 +00:00
|
|
|
import { convertDateFormat } from "@/utils/global";
|
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-11-05 06:15:40 +00:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
async function getArticle() {
|
|
|
|
|
const response = await getListArticle();
|
|
|
|
|
console.log("res", response?.data?.data);
|
2024-11-06 08:44:56 +00:00
|
|
|
setArticle(response?.data?.data);
|
2024-11-05 06:15:40 +00:00
|
|
|
}
|
|
|
|
|
getArticle();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return (
|
2024-11-06 08:44:56 +00:00
|
|
|
<div className=" bg-[#1F1A17] gap-3 md:py-6 md:px-12 md:h-[700px]">
|
|
|
|
|
<div className="lg:flex items-center justify-center bg-white p-1 md:p-4 rounded-lg gap-3 md:h-[654px] md:w-fit md:mx-auto">
|
|
|
|
|
<div className="w-auto lg:w-[25%] p-2 bg-[#020101] text-white rounded-md mb-2 md:mb-0 md:h-[636px]">
|
|
|
|
|
<p className="text-lg font-bold h-10 text-center">Berita Terkini</p>
|
|
|
|
|
<ScrollShadow hideScrollBar className="md:h-[530px] gap-3">
|
2024-11-07 06:45:09 +00:00
|
|
|
{article?.map((data: any) => (
|
2024-11-06 08:44:56 +00:00
|
|
|
<div
|
|
|
|
|
className="text-xs text-left m-2 p-2 bg-[#1E1616] rounded-md"
|
|
|
|
|
key={data.id}
|
|
|
|
|
>
|
|
|
|
|
<p>{data.title}</p>
|
|
|
|
|
<p className="py-[2px]">
|
|
|
|
|
{" "}
|
|
|
|
|
{convertDateFormat(data.createdAt)} WIB
|
|
|
|
|
</p>
|
|
|
|
|
<p className="flex items-center gap-1">
|
|
|
|
|
<EyeIcon />
|
|
|
|
|
{data.viewCount === null ? 0 : data.viewCount}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2024-11-05 06:15:40 +00:00
|
|
|
))}
|
2024-11-06 08:44:56 +00:00
|
|
|
</ScrollShadow>
|
|
|
|
|
<div className="m-2">
|
|
|
|
|
<Link href="/news/all">
|
|
|
|
|
<Button
|
|
|
|
|
className="w-full bg-[#DD8306] font-bold rounded-bl-md rounded-br-md focus:outline-none"
|
|
|
|
|
radius="none"
|
|
|
|
|
>
|
|
|
|
|
Lihat Semua
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
2024-11-05 06:15:40 +00:00
|
|
|
</div>
|
2024-11-06 08:44:56 +00:00
|
|
|
<div className="w-auto lg:w-[910px] md:h-[636px]">
|
|
|
|
|
<div className="md:h-[636px]">
|
|
|
|
|
<Swiper
|
|
|
|
|
centeredSlides={true}
|
|
|
|
|
autoplay={{
|
|
|
|
|
delay: 5000,
|
|
|
|
|
disableOnInteraction: false,
|
|
|
|
|
}}
|
|
|
|
|
pagination={{
|
|
|
|
|
clickable: true,
|
|
|
|
|
}}
|
|
|
|
|
navigation={true}
|
|
|
|
|
modules={[Autoplay, Pagination, Navigation]}
|
|
|
|
|
className="mySwiper"
|
|
|
|
|
height={636}
|
|
|
|
|
>
|
|
|
|
|
{article?.map((newsItem: any) => (
|
|
|
|
|
<SwiperSlide key={newsItem.id}>
|
|
|
|
|
<Card isFooterBlurred radius="lg" className="border-none">
|
2024-11-05 06:15:40 +00:00
|
|
|
<Image
|
2024-11-06 08:44:56 +00:00
|
|
|
alt="headernews"
|
|
|
|
|
height={400}
|
|
|
|
|
src="/headernews.png"
|
|
|
|
|
width={460}
|
|
|
|
|
layout="responsive"
|
2024-11-05 06:15:40 +00:00
|
|
|
/>
|
|
|
|
|
<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">
|
2024-11-06 08:44:56 +00:00
|
|
|
<div className="text-white">
|
|
|
|
|
<Link href={`news/detail/${newsItem.id}`}>
|
|
|
|
|
<p className="text-left font-semibold">
|
|
|
|
|
{newsItem.title}
|
|
|
|
|
</p>
|
|
|
|
|
</Link>
|
|
|
|
|
<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>
|
2024-11-05 06:15:40 +00:00
|
|
|
</CardFooter>
|
2024-11-06 08:44:56 +00:00
|
|
|
</Card>
|
|
|
|
|
</SwiperSlide>
|
|
|
|
|
))}
|
|
|
|
|
</Swiper>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="w-auto lg:w-[25%] p-2 rounded-md text-white dark:text-black ">
|
|
|
|
|
<GPRKominfo />
|
|
|
|
|
{/* <div className='text-lg font-bold border-5 border-blue-950 rounded-tr-lg rounded-tl-lg'>
|
2024-11-05 06:15:40 +00:00
|
|
|
<img src="/gprheader.png" alt="gpr" className='w-full' />
|
|
|
|
|
</div>
|
|
|
|
|
<div className='overflow-y-scroll h-[343px] border-5 border-blue-950 text-black'>
|
|
|
|
|
<div className='text-xs text-left m-2 p-2 bg-[#FFFFFF] rounded-md border-dashed border-2 border-sky-500'>
|
|
|
|
|
<p>Pelihara Kondusifitas Kamtibmas, Personel Polsek Sayan Sambangi Warganya yang Masih Beraktifitas Pada Malam Hari</p>
|
|
|
|
|
<p className='py-[2px]'>21-07-2023 13:50</p>
|
|
|
|
|
<p className='flex items-center gap-1'><EyeIcon />82</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className='text-xs text-left m-2 p-2 bg-[#FFFFFF] rounded-md border-dashed border-2 border-sky-500'>
|
|
|
|
|
<p>Pelihara Kondusifitas Kamtibmas, Personel Polsek Sayan Sambangi Warganya yang Masih Beraktifitas Pada Malam Hari</p>
|
|
|
|
|
<p className='py-[2px]'>21-07-2023 13:50</p>
|
|
|
|
|
<p className='flex items-center gap-1'><EyeIcon />82</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className='text-xs text-left m-2 p-2 bg-[#FFFFFF] rounded-md border-dashed border-2 border-sky-500'>
|
|
|
|
|
<p>Pelihara Kondusifitas Kamtibmas, Personel Polsek Sayan Sambangi Warganya yang Masih Beraktifitas Pada Malam Hari</p>
|
|
|
|
|
<p className='py-[2px]'>21-07-2023 13:50</p>
|
|
|
|
|
<p className='flex items-center gap-1'><EyeIcon />82</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className='text-xs text-left m-2 p-2 bg-[#FFFFFF] rounded-md border-dashed border-2 border-sky-500'>
|
|
|
|
|
<p>Pelihara Kondusifitas Kamtibmas, Personel Polsek Sayan Sambangi Warganya yang Masih Beraktifitas Pada Malam Hari</p>
|
|
|
|
|
<p className='py-[2px]'>21-07-2023 13:50</p>
|
|
|
|
|
<p className='flex items-center gap-1'><EyeIcon />82</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className=' border-5 border-blue-950 rounded-bl-lg rounded-br-lg'>
|
|
|
|
|
<img src="/gprfooter.png" alt="gpr" className='w-full' />
|
|
|
|
|
</div> */}
|
2024-11-06 08:44:56 +00:00
|
|
|
</div>
|
2024-11-05 06:15:40 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|