"use client"

import * as React from "react"
import { type ColumnDef } from "@tanstack/react-table"
import { type InferSelectModel } from "drizzle-orm"
import { emailLogs } from "@/db/schema/emailLogs"

export function getColumns<T extends InferSelectModel<typeof emailLogs>>(): ColumnDef<T>[] {
  return [
   {
      id: "subject",
      header: () => <div className="text-left">Subject</div>,
      accessorKey: "subject",
      cell: ({ row }) => (
        <div className="whitespace-pre-wrap break-all">{String(row.original.subject ?? "")}</div>
      ),
      size: 360,
    },
    {
      id: "from",
      header: () => <div className="text-left">From</div>,
      accessorKey: "from",
      cell: ({ row }) => (
        <div className="whitespace-pre-wrap break-all">{String(row.original.from ?? "")}</div>
      ),
      size: 220,
    },
    {
      id: "to",
      header: () => <div className="text-left">To</div>,
      accessorKey: "to",
      cell: ({ row }) => (
        <div className="whitespace-pre-wrap break-all">{String(row.original.to ?? "")}</div>
      ),
      size: 220,
    },
    {
      id: "cc",
      header: () => <div className="text-left">CC</div>,
      accessorKey: "cc",
      cell: ({ row }) => (
        <div className="whitespace-pre-wrap break-all">{String(row.original.cc ?? "")}</div>
      ),
      size: 220,
    },
     {
      id: "createdAt",
      header: () => <div className="text-left">Created At</div>,
      accessorKey: "createdAt",
      cell: ({ row }) => (
        <div className="whitespace-nowrap">
          {new Date(row.original.createdAt as unknown as string).toLocaleString()}
        </div>
      ),
      size: 180,
    },
   
  ]
}


