import React from 'react'
import { StudyProgram } from '@/src/interfaces/users/studyPrograms'

import { ColumnDef } from '@tanstack/react-table'
import { ActionButtons } from './ActionButtons'

interface Props {
  onOpenEditModal: (studyProgramId: string) => void
  onOpenDeleteModal: (studyProgramId: string) => void
}

export const useColumns = ({ onOpenEditModal, onOpenDeleteModal }: Props) =>
  React.useMemo<ColumnDef<StudyProgram>[]>(
    () => [
      { header: 'Nombre', accessorKey: 'name' },
      // {
      //   header: 'Plan de Estudios',
      //   accessorKey: 'studyPlan',
      //   enableSorting: false,
      // },
      {
        header: 'Creado por',
        accessorKey: 'creatorName',
        enableSorting: false,
      },
      {
        header: 'Acciones',
        enableSorting: false,
        cell: ({ row }) => (
          <ActionButtons
            studyProgramId={row.original.id}
            onEdit={onOpenEditModal}
            onDelete={onOpenDeleteModal}
          />
        ),
      },
    ],
    [],
  )
