import { FaDownload, FaTrash, FaUpload } from 'react-icons/fa6'

interface Props {
  studyYearId: string
  gradeReport: string | null
  onUpload: (studyYearId: string) => void
  onDownload: (studyYearId: string) => void
  onDelete: (studyYearId: string) => void
}

export default function ActionButtons({
  studyYearId,
  gradeReport,
  onUpload,
  onDelete,
  onDownload,
}: Props) {
  const handleUploadGradeReport = () => onUpload(studyYearId)
  const handleDownloadGradeReport = () => onDownload(studyYearId)
  const handleDeleteGradeReport = () => onDelete(studyYearId)

  return (
    <div className="flex space-x-3 justify-center">
      {!gradeReport ? (
        <>
          <button
            className="text-green-700 hover:underline flex items-center space-x-1"
            onClick={handleUploadGradeReport}>
            <FaUpload />
            <span>Subir Reporte</span>
          </button>
        </>
      ) : (
        <>
          <button
            className="text-blue-500 hover:underline flex items-center space-x-1"
            onClick={handleDownloadGradeReport}>
            <FaDownload />
            <span className="text-nowrap">Descargar Reporte</span>
          </button>

          <button
            className="text-error hover:underline flex items-center space-x-1"
            onClick={handleDeleteGradeReport}>
            <FaTrash />
            <span className="text-nowrap">Eliminar Reporte</span>
          </button>
        </>
      )}
    </div>
  )
}
