"use client";

import type { ColumnDef } from "@tanstack/react-table";

import { Badge } from "@/components/ui/badge";

import type { UserRow } from "./schema";

export const userColumns: ColumnDef<UserRow>[] = [
  {
    accessorKey: "fullName",
    header: "Name",
    cell: ({ row }) => <span className="font-medium">{row.original.fullName}</span>,
  },
  {
    accessorKey: "email",
    header: "Email",
    cell: ({ row }) => (
      <span className="text-muted-foreground text-sm">{row.original.email}</span>
    ),
  },
  {
    accessorKey: "groupName",
    header: "Group",
    cell: ({ row }) => (
      <span className="text-muted-foreground text-sm">{row.original.groupName ?? "—"}</span>
    ),
  },
  {
    accessorKey: "statusLabel",
    header: "Status",
    cell: ({ row }) => (
      <Badge variant={row.original.status === "active" ? "default" : "secondary"}>
        {row.original.statusLabel}
      </Badge>
    ),
  },
  {
    accessorKey: "dateAdded",
    header: "Date added",
    cell: ({ row }) => (
      <span className="text-muted-foreground text-sm whitespace-nowrap">
        {row.original.dateAdded}
      </span>
    ),
  },
];
