"use client"; import { type ColumnDef } from "@tanstack/react-table"; import { DataTableColumnHeader } from "@/components/shared/data-table-column-header"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { RotateCw } from "lucide-react"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; export interface SkippedRow { id: string; fileName: string; fileSize: string; reason: "SIZE_LIMIT" | "DOWNLOAD_FAILED" | "EXTRACT_FAILED" | "UPLOAD_FAILED"; errorMessage: string | null; sourceChannel: { id: string; title: string }; isMultipart: boolean; partCount: number; createdAt: string; } function formatBytes(bytesStr: string): string { const bytes = Number(bytesStr); if (bytes === 0) return "0 B"; const k = 1024; const sizes = ["B", "KB", "MB", "GB", "TB"]; const i = Math.floor(Math.log(bytes) / Math.log(k)); return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`; } const REASON_LABELS: Record = { SIZE_LIMIT: { label: "Size Limit", variant: "secondary" }, DOWNLOAD_FAILED: { label: "Download Failed", variant: "destructive" }, EXTRACT_FAILED: { label: "Extract Failed", variant: "destructive" }, UPLOAD_FAILED: { label: "Upload Failed", variant: "destructive" }, }; export function getSkippedColumns({ onRetry, }: { onRetry: (row: SkippedRow) => void; }): ColumnDef[] { return [ { accessorKey: "fileName", header: ({ column }) => , cell: ({ row }) => (
{row.original.fileName} {row.original.isMultipart && ( {row.original.partCount} parts )}
), enableHiding: false, }, { accessorKey: "fileSize", header: ({ column }) => , cell: ({ row }) => ( {formatBytes(row.original.fileSize)} ), }, { accessorKey: "reason", header: ({ column }) => , cell: ({ row }) => { const { label, variant } = REASON_LABELS[row.original.reason]; return {label}; }, }, { accessorKey: "errorMessage", header: "Error", cell: ({ row }) => { const msg = row.original.errorMessage; if (!msg) return {"\u2014"}; return ( {msg}

{msg}

); }, }, { id: "channel", header: ({ column }) => , cell: ({ row }) => ( {row.original.sourceChannel.title} ), accessorFn: (row) => row.sourceChannel.title, }, { accessorKey: "createdAt", header: ({ column }) => , cell: ({ row }) => ( {new Date(row.original.createdAt).toLocaleDateString()} ), }, { id: "actions", cell: ({ row }) => ( ), enableHiding: false, }, ]; }