"use client" import { useMemo } from "react" import Link from "next/link" import { ColumnDef } from "@tanstack/react-table" import { DataTable } from "@/components/shared/data-table" import { DataTableColumnHeader } from "@/components/shared/data-table-column-header" import { LeadStatusBadge } from "./lead-status-badge" import { LeadActionsDropdown } from "./lead-actions-dropdown" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Checkbox } from "@/components/ui/checkbox" import { Lead } from "@/types" interface LeadsTableProps { data: Lead[] loading?: boolean } export function LeadsTable({ data, loading }: LeadsTableProps) { const columns: ColumnDef[] = useMemo( () => [ { id: "select", header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="Select row" /> ), enableSorting: false, enableHiding: false, }, { accessorKey: "companyName", header: ({ column }) => ( ), cell: ({ row }) => ( {row.getValue("companyName")} ), }, { accessorKey: "contactName", header: ({ column }) => ( ), cell: ({ row }) => ( {row.getValue("contactName")} ), }, { accessorKey: "email", header: ({ column }) => ( ), cell: ({ row }) => ( {row.getValue("email")} ), }, { accessorKey: "phone", header: ({ column }) => ( ), cell: ({ row }) => ( {row.getValue("phone")} ), }, { accessorKey: "status", header: ({ column }) => ( ), cell: ({ row }) => , }, { accessorKey: "assignedUser", header: ({ column }) => ( ), cell: ({ row }) => { const user = row.original.assignedUser if (!user) return return (
{user.name[0]} {user.name}
) }, }, { accessorKey: "createdAt", header: ({ column }) => ( ), cell: ({ row }) => ( {new Date(row.getValue("createdAt")).toLocaleDateString()} ), }, { id: "actions", cell: ({ row }) => , }, ], [] ) return ( ) }