"use client"; import { ColumnDef } from "@tanstack/react-table"; import { ArrowUpDown, MoreHorizontal, Eye, Pencil, Trash2 } from "lucide-react"; import Link from "next/link"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { ProjectStatusBadge } from "@/components/ui/project-status-badge"; import { Project, ProjectStatus } from "@/types/project"; // Componente para la barra de progreso function ProgressBar({ progress }: { progress: number }) { const getProgressColor = (value: number) => { if (value >= 75) return 'bg-green-500'; if (value >= 50) return 'bg-blue-500'; if (value >= 25) return 'bg-yellow-500'; return 'bg-gray-400'; }; return (
{progress.toFixed(0)}%
); } // Formateador de moneda function formatCurrency(amount: number): string { return new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR', minimumFractionDigits: 0, maximumFractionDigits: 0, }).format(amount); } // Formateador de fecha function formatDate(dateString: string): string { if (!dateString) return '-'; try { return new Date(dateString).toLocaleDateString('es-ES', { day: '2-digit', month: 'short', year: 'numeric', }); } catch { return '-'; } } export const projectColumns: ColumnDef[] = [ // Columna de selección { id: "select", header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Seleccionar todo" className="translate-y-[2px]" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="Seleccionar fila" className="translate-y-[2px]" /> ), enableSorting: false, enableHiding: false, }, // Referencia { accessorKey: "ref", header: ({ column }) => ( ), cell: ({ row }) => ( {row.getValue("ref")} ), }, // Nombre del proyecto { accessorKey: "name", header: ({ column }) => ( ), cell: ({ row }) => (
{row.getValue("name")}
), }, // Cliente { accessorKey: "client", header: "Cliente", cell: ({ row }) => ( {row.getValue("client")} ), }, // Estado { accessorKey: "status", header: "Estado", cell: ({ row }) => , filterFn: (row, id, value) => { return value.includes(row.getValue(id)); }, }, // Progreso { accessorKey: "progress", header: ({ column }) => ( ), cell: ({ row }) => , }, // Presupuesto { accessorKey: "budget", header: ({ column }) => ( ), cell: ({ row }) => ( {formatCurrency(row.getValue("budget"))} ), }, // Fecha inicio { accessorKey: "startDate", header: ({ column }) => ( ), cell: ({ row }) => ( {formatDate(row.getValue("startDate"))} ), }, // Fecha fin { accessorKey: "endDate", header: "Fin", cell: ({ row }) => ( {formatDate(row.getValue("endDate"))} ), }, // Acciones { id: "actions", enableHiding: false, cell: ({ row }) => { const project = row.original; return ( Acciones Ver detalles Editar Eliminar ); }, }, ];