import * as React from "react"; import { ColumnDef } from "@tanstack/react-table"; import { exportMediaTrackingToExcel } from "@/utils/export-media-tracking"; import { loading, close } from "@/config/swal"; import { error } from "@/lib/swal"; import { DownloadIcon, Eye, MoreVertical, SquarePen, Trash2, } from "lucide-react"; import { cn } from "@/lib/utils"; import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger, DropdownMenuItem, } from "@/components/ui/dropdown-menu"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { formatDateToIndonesian, getOnlyDate, htmlToString, } from "@/utils/globals"; import { Link, useRouter } from "@/i18n/routing"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Collapsible, CollapsibleContent } from "@/components/ui/collapsible"; const columns: ColumnDef[] = [ { accessorKey: "no", header: "No", cell: ({ row }) => {row.getValue("no")}, }, { accessorKey: "title", header: "Judul", cell: ({ row }) => {row.getValue("title")}, }, // { // accessorKey: "resultTotal", // header: () =>
Jumlah Amplifikasi
, // cell: ({ row }) => { // const value = row.getValue("resultTotal") as number | string | null; // const finalValue = // value === null || value === undefined || value === "" // ? 0 // : Number(value); // return
{finalValue}
; // }, // }, { accessorKey: "resultTotal", header: () =>
Jumlah Amplifikasi
, cell: ({ row }) => { const totalRaw = row.getValue("resultTotal") as number | string | null; const total = totalRaw === null || totalRaw === undefined || totalRaw === "" ? 0 : Number(totalRaw); const invalidTotal = 0; return (
{total} /{invalidTotal}
); }, }, // { // accessorKey: "status", // header: "Status", // cell: ({ row }) => {row.getValue("status")}, // }, // { // accessorKey: "isProcessing", // header: () =>
Status
, // cell: ({ row }) => { // const raw = row.getValue("isProcessing"); // var status = "Sedang Diproses" // if (Boolean(raw) == true) { // status = "Selesai Diproses"; // } // return
{status}
; // }, // }, { accessorKey: "isProcessing", header: () =>
Status
, cell: ({ row }) => { const raw = Boolean(row.getValue("isProcessing")); // KONDISI STATUS const statusText = raw ? "Sedang Diproses" : "Sudah Selesai"; // WARNA STATUS const colorClass = raw ? "bg-yellow-100 text-yellow-700 border border-yellow-300" : "bg-green-100 text-green-700 border border-green-300"; return (
{statusText}
); }, }, { accessorKey: "createdAt", header: () =>
Tanggal Penarikan
, cell: ({ row }) => { const raw = row.getValue("createdAt"); if (!raw || typeof raw !== "string") return
-
; const date = new Date(raw); if (isNaN(date.getTime())) return
-
; const formatted = date.toLocaleDateString("id-ID", { day: "2-digit", month: "short", year: "numeric", }); return
{formatted}
; }, }, { id: "actions", accessorKey: "action", header: "Action", enableHiding: false, cell: ({ row }) => { return ( View  {row.original.mediaUpload.fileType.secondaryName && row.original.mediaUpload.fileType.secondaryName.toLowerCase()} { try { loading(); await exportMediaTrackingToExcel({ mediaTrackingId: row.original.id, }); close(); } catch (e: any) { close(); error(e.message || "Gagal export data"); } }} >

Download

); }, }, ]; export default columns;