import { Progress, Button } from "antd"
import { downloadFile } from "../../components/factory"

export const ReportCreationNotify = ({progressData}) => {
  progressData = progressData ?? {progress: 0.0, operation: 'Создание отчета'}

  let downloadButton = null
  if (progressData.file)
    downloadButton = <Button      
      type="link"
      onClick={_ => {downloadFile(progressData.file)}}
      download={progressData.file.name}>
        {progressData.file.name}
      </Button>
  
  const progressText = `${progressData.operation} стр ${progressData.currentPage} из ${progressData.totalPages}`
  return (
  <>
      <Progress percent={ progressData.progress } />
      <br/>
      <span>{progressText}</span>
      {downloadButton}
  </>
  )
}