"use client"; import Image from "next/image"; import { Calendar, Clock, Eye } from "lucide-react"; import { Button } from "@/components/ui/button"; import Link from "next/link"; import { useState, useEffect } from "react"; import { FaFacebookF, FaTiktok, FaYoutube, FaWhatsapp, FaInstagram, FaTwitter, FaCheck, FaLink, FaShareAlt, } from "react-icons/fa"; import { getDetail } from "@/service/landing/landing"; import VideoPlayer from "@/utils/video-player"; import { toBase64, shimmer } from "@/utils/globals"; import { Skeleton } from "@/components/ui/skeleton"; export default function ImageDetail({ id }: { id: string }) { const [copied, setCopied] = useState(false); const [showShareMenu, setShowShareMenu] = useState(false); const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [selectedImage, setSelectedImage] = useState(0); const [isLoading, setIsLoading] = useState(true); useEffect(() => { const timer = setTimeout(() => { setIsLoading(false); }, 3000); return () => clearTimeout(timer); }, []); const handleCopyLink = async () => { try { await navigator.clipboard.writeText(window.location.href); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (err) { console.error("Failed to copy: ", err); } }; const SocialItem = ({ icon, label, }: { icon: React.ReactNode; label: string; }) => (
{icon}
{label}
); useEffect(() => { const fetchDetail = async () => { try { setLoading(true); const response = await getDetail(id); setData(response?.data?.data); } catch (error) { console.error("Error fetching detail:", error); } finally { setLoading(false); } }; if (id) fetchDetail(); }, [id]); if (loading) { return (

Loading...

); } if (!data) { return (

Data tidak ditemukan

); } return (
{isLoading ? (
) : (
Main
)} {/* Gambar bawah Kecil */} {isLoading ? (
) : ( //
// {detailDataImage?.files?.map((file: any, index: number) => ( // setSelectedImage(index)} key={file?.id}> // image-small // // ))} //
{data?.files?.map((file: any, index: number) => ( setSelectedImage(index)} key={file?.id}> image-small ))}
)}
by {data?.uploadedBy?.publisher || "MABES POLRI"} {new Date(data.createdAt) .toLocaleString("id-ID", { day: "2-digit", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit", hour12: false, timeZone: "Asia/Jakarta", }) .replace(".", ":")}{" "} WIB {/* {data.time || "-"} */} {data.clickCount || 0} {" "} Creator: {data.creatorGroupLevelName}
{/* Sidebar actions */}
COPY LINK
SHARE {showShareMenu && (
} label="Facebook" /> } label="TikTok" /> } label="YouTube" /> } label="WhatsApp" /> } label="Instagram" /> } label="Twitter" />
)}
COMMENT
{/* Content */}

{data.title}

{data.description}

{/* Actions bawah */}
COPY LINK
SHARE
COMMENT
); }