import { type StatusTone } from '@ema-platform/shared';
import type { AdvancedColumn } from '@ema-platform/ui';
import { StatusBadge } from '@ema-platform/ui';
import type { Item } from '../../api/item-api';

const STATUS_TONES: Record<Item['status'], StatusTone> = {
  DRAFT: 'neutral',
  ACTIVE: 'success',
  ARCHIVED: 'pending',
};

export function itemColumns(showDate: (date: string) => string): AdvancedColumn<Item>[] {
  return [
    { header: 'Name', accessorKey: 'name' },
    {
      header: 'Status',
      cell: ({ row }) => (
        <StatusBadge tone={STATUS_TONES[row.original.status]} label={row.original.status} />
      ),
    },
    {
      header: 'Created',
      cell: ({ row }) => showDate(row.original.createdAt),
    },
  ];
}
