import { Badge } from '@mantine/core';
import type { AdvancedColumn } from '@ema-platform/ui';
import type { Item } from '../../api/item-api';

const STATUS_COLORS: Record<Item['status'], string> = {
  DRAFT: 'gray',
  ACTIVE: 'green',
  ARCHIVED: 'orange',
};

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