import {
  faFilePdf,
  faFileExcel,
  faFileWord,
  faFilePowerpoint,
  faFileZipper,
  faFileCsv,
  faFileLines,
  faFileImage,
  faFile,
  IconDefinition
} from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'

export const getExtensionIconLabel = (extension: string) => {
  let icon: IconDefinition
  switch (extension.toLowerCase()) {
    case 'pdf':
      icon = faFilePdf
      break
    case 'json':
      icon = faFilePdf
      break

    case 'xslx':
    case 'xsl':
      icon = faFileExcel
      break

    case 'doc':
    case 'docx':
      icon = faFileWord
      break

    case 'ppt':
    case 'pptx':
      icon = faFilePowerpoint
      break

    case 'zip':
    case '7z':
    case 'rar':
    case 'tar':
    case 'gz':
      icon = faFileZipper
      break

    case 'csv':
      icon = faFileCsv
      break

    case 'txt':
      icon = faFileLines
      break

    case 'png':
    case 'jpg':
    case 'jpeg':
    case 'gif':
    case 'svg':
    case 'bmp':
    case 'ico':
      icon = faFileImage
      break

    default:
      icon = faFile
      return
  }

  return (
    <>
      <FontAwesomeIcon icon={icon} /> {extension.toUpperCase()}
    </>
  )
}
