import React from 'react';
import { Button, Glyphicon } from 'react-bootstrap';
import { isSendable } from '../../helpers/statusUtils';
import ParcelResource from '../../resources/parcel';

function DownloadLabelButton(props) {
  const { parcel } = props;
  const { investigationId, _id: parcelId } = parcel;

  return (
    <Button
      bsStyle="primary"
      href={ParcelResource.labelUrl({ investigationId, parcelId })}
      download
      target="_blank"
      rel="noopener noreferrer"
      disabled={!isSendable(parcel)}
    >
      <Glyphicon glyph="download" />
      <span style={{ margin: 10 }}>Download Labels</span>
    </Button>
  );
}

export default DownloadLabelButton;
