department-of-veterans-affairs/vets-website

View on GitHub
src/applications/pre-need-integration/components/DownloadLink.jsx

Summary

Maintainability
C
7 hrs
Test Coverage
import React from 'react';
import PropTypes from 'prop-types';

import recordEvent from 'platform/monitoring/record-event';

const DownloadLink = ({
  content = 'Download VA Form 40-10007',
  subTaskEvent = false,
}) => {
  const handler = {
    onClick: () => {
      if (subTaskEvent) {
        recordEvent({
          event: 'howToWizard-alert-link-click',
          'howToWizard-alert-link-click-label': content,
        });
      }
    },
  };

  return (
    <a
      href="https://www.va.gov/vaforms/va/pdf/va40-10007.pdf"
      // download="va40-10007.pdf"
      type="application/pdf"
      onClick={handler.onClick}
    >
      <span className="vads-u-padding-right--1">
        <va-icon icon="file_download" size={3} />
      </span>
      {content}{' '}
      <dfn>
        (<abbr title="Portable Document Format">PDF</abbr>, 3 pages)
      </dfn>
    </a>
  );
};

DownloadLink.propTypes = {
  content: PropTypes.string,
  subTaskEvent: PropTypes.bool,
};

export default DownloadLink;