// This file is part of Coog. The COPYRIGHT file at the top level of
// this repository contains the full copyright notices and license terms.

import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
  faFilePdf,
  faFilePowerpoint,
  faFileWord,
  faFileExcel,
  faFile,
  faFileImage,
} from '@fortawesome/free-solid-svg-icons';

import { fileTypes } from './Card.types';

export interface iFileCard {
  fileCard?: boolean;
  fileType?: fileTypes;
}

const CardFile = ({ fileCard = false, fileType }: iFileCard): JSX.Element => {
  if (!fileCard) return <></>;
  switch (fileType) {
    case 'pdf':
      return (
        <div className={`type ${fileType}`}>
          <FontAwesomeIcon className="icon" icon={faFilePdf} />
          <div className="label">{fileType}</div>
        </div>
      );
    case 'doc':
    case 'docx':
    case 'world':
      return (
        <div className={`type ${fileType}`}>
          <FontAwesomeIcon className="icon" icon={faFileWord} />
          <div className="label">{fileType}</div>
        </div>
      );
    case 'xls':
    case 'xlsx':
    case 'excel':
      return (
        <div className={`type ${fileType}`}>
          <FontAwesomeIcon className="icon" icon={faFileExcel} />
          <div className="label">{fileType}</div>
        </div>
      );
    case 'ppt':
    case 'pptx':
    case 'powerpoint':
      return (
        <div className={`type ${fileType}`}>
          <FontAwesomeIcon className="icon" icon={faFilePowerpoint} />
          <div className="label">{fileType}</div>
        </div>
      );

    case 'jpg':
    case 'png':
    case 'bmp':
      return (
        <div className={`type ${fileType}`}>
          <FontAwesomeIcon className="icon" icon={faFileImage} />
          <div className="label">{fileType}</div>
        </div>
      );

    case 'txt':
    case 'odt':
      return (
        <div className={`type ${fileType}`}>
          <FontAwesomeIcon className="icon" icon={faFile} />
          <div className="label">{fileType}</div>
        </div>
      );

    default:
      return (
        <div className="type">
          <FontAwesomeIcon icon={faFile} />
        </div>
      );
  }
};

export default CardFile;
