import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React from 'react';
import { Button } from 'react-bootstrap';
import { getDownloadURL } from 'util/api';
import { FormattedMessage } from './localization';

export default function DownloadButton({
  icon = 'download',
  id,
  fileName,
}: {
  icon?: IconProp,
  id: string,
  fileName: string
}) {
  return (
    <Button variant="success" href={getDownloadURL(id, fileName)}>
      <FontAwesomeIcon icon={icon} className="mr-2" />
      <FormattedMessage
        id="DownloadButton.download"
        defaultMessage="Download"
        description="Text of the download button"
      />
    </Button>
  );
}
