import React from 'react'
import { StudentStudyYear } from '@/src/interfaces/users/studentStudyYear'
import { ColumnDef } from '@tanstack/react-table'

import ActionButtons from './ActionButtons'

interface Props {
  onUploadGradeReport: (studyYearId: string) => void
  onDownloadGradeReport: (studyYearId: string) => void
  onDeleteGradeReport: (studyYearId: string) => void
}

export const useColumns = ({
  onUploadGradeReport,
  onDownloadGradeReport,
  onDeleteGradeReport,
}: Props) =>
  React.useMemo<ColumnDef<StudentStudyYear>[]>(
    () => [
      { header: 'Ciclo Académico', accessorKey: 'year' },
      {
        header: '\n',
        cell: ({ row }) => (
          <ActionButtons
            studyYearId={row.original.id}
            gradeReport={row.original.yearReportCard}
            onUpload={onUploadGradeReport}
            onDownload={onDownloadGradeReport}
            onDelete={onDeleteGradeReport}
          />
        ),
      },
    ],
    [],
  )
