"use client"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, } from "@/components/ui/dialog"; import Image from "next/image"; import { Check, CheckCheck, CheckCircle, Clock, X } from "lucide-react"; import { useEffect, useState } from "react"; import { approveGalery, getGaleryFileData } from "@/service/galery"; import { convertDateFormat } from "@/utils/global"; import { Button } from "../ui/button"; import { useRouter } from "next/navigation"; import Cookies from "js-cookie"; import { error, loading, success } from "@/config/swal"; export function DialogDetailGaleri({ open, onClose, data }: any) { const [images, setImages] = useState([]); const [openApproverHistory, setOpenApproverHistory] = useState(false); const [userLevelId, setUserLevelId] = useState(null); const [openViewDialog, setOpenViewDialog] = useState(false); const router = useRouter(); // 🔹 Ambil userlevelId dari cookies useEffect(() => { const ulne = Cookies.get("ulne"); // contoh: "3" setUserLevelId(ulne ?? null); }, []); const [openCommentModal, setOpenCommentModal] = useState(false); const [commentValue, setCommentValue] = useState(""); const handleSubmitComment = async () => { // await api.post("/banner/comment", { // bannerId: viewBanner.id, // comment: commentValue, // }); setOpenCommentModal(false); }; const fetchImages = async () => { try { const res = await getGaleryFileData(data.id); const allImages = res?.data?.data ?? []; const filteredImages = allImages.filter( (img: any) => img.gallery_id === data.id, ); setImages(filteredImages); } catch (e) { console.error("Error fetch files:", e); } }; useEffect(() => { if (open && data?.id) { fetchImages(); } }, [open, data]); const openFile = (url: string) => { window.open(url, "_blank"); }; const handleOpenApproverHistory = () => { setOpenApproverHistory(true); }; const handleApproveGalery = async (id: number) => { loading(); const res = await approveGalery(id); if (res?.error) { error(res.message || "Gagal menyetujui galeri"); close(); return; } close(); success("Galeri berhasil disetujui"); fetchImages(); // refresh table }; return ( <> {/* Header */}
Detail Galeri
{/* Images List */}

{data.title}

Deskripsi

{data.description}

{images.length === 0 && (

Tidak ada gambar.

)} {images.map((img) => (
openFile(img.image_url)} > {img.title}
Lihat File
))}
{/* Title */} {/* Deskripsi */} {/* Tanggal Upload */}

Tanggal Upload

{new Date(data.created_at).toLocaleDateString("id-ID")}

{/* Timeline */}

Status Timeline

Diupload oleh Operator

{convertDateFormat(data?.created_at)} WIB

{data?.status_id === 1 ? ( ) : data?.status_id === 2 ? ( ) : ( )}

{data?.status_id === 1 ? "Menunggu disetujui oleh Approver" : data?.status_id === 2 ? "Disetujui oleh Approver" : "Ditolak oleh Approver"}

{convertDateFormat(data?.updated_at)} WIB

Comment :

Jaecoo - Approver | 10/11/2026

{openViewDialog && userLevelId !== "2" && (
{data.status_id === 1 ? ( <> {userLevelId === "1" && ( )} ) : ( )}
)}
{/* */}
{openApproverHistory && (
setOpenApproverHistory(false)} >
e.stopPropagation()} > {/* HEADER */}

Approver History

Menunggu Banner 1
{/* BODY */}
{/* LEFT TIMELINE */}
{/* Upload */}
Upload
{/* Diterima */}

Diterima

Direview oleh: approver-jaecoo1
{/* Pending */}

Pending

Direview oleh: approver-jaecoo1
{/* ARROW */}
> >
{/* RIGHT NOTES */}
Catatan:
Catatan:
{/* FOOTER */}
)} ); }