import { Badge, Text } from '@mantine/core';
import type { TFunction } from 'i18next';
import type { AdvancedColumn } from '@ema-platform/ui';
import type { Certification } from '../../types/certification';

export function certificationColumns(
  t: TFunction,
  locale: 'en' | 'am',
): AdvancedColumn<Certification>[] {
  return [
    {
      header: t('certification.columns.name'),
      cell: ({ row }) => <Text fz="sm" fw={500}>{row.original.name[locale]}</Text>,
    },
    {
      header: t('certification.columns.description'),
      cell: ({ row }) => <Text fz="sm" lineClamp={2} maw={250}>{row.original.description[locale]}</Text>,
    },
    {
      header: t('certification.columns.rank', 'Rank'),
      cell: ({ row }) =>
        row.original.rankKey ? (
          <Badge size="sm" variant="outline" color="violet">{row.original.rankKey}</Badge>
        ) : (
          <Text fz="sm" c="dimmed">—</Text>
        ),
    },
    {
      header: t('certification.columns.status'),
      cell: ({ row }) => (
        <Badge size="sm" variant="light" color={row.original.isActive ? 'teal' : 'gray'}>
          {row.original.isActive ? t('certification.status.active') : t('certification.status.inactive')}
        </Badge>
      ),
    },
  ];
}
