import React from 'react';
import { Col, Glyphicon, Panel, Row, Alert } from 'react-bootstrap';
import AddressPanel from '../Address/AddressPanel';

function ShipmentSummary(props) {
  const { shipment, defaultShippingAddress, defaultReturnAddress } = props;

  return (
    <Row>
      <Col md={4}>
        {defaultShippingAddress !== undefined ? (
          <AddressPanel
            header={<b>Default sender's address</b>}
            address={defaultShippingAddress}
          />
        ) : (
          <Alert bsStyle="danger">
            Default sender's address no longer exists.
          </Alert>
        )}
      </Col>
      <Col md={4}>
        {defaultReturnAddress !== undefined ? (
          <AddressPanel
            header={<b>Default return address</b>}
            address={defaultReturnAddress}
          />
        ) : (
          <Alert bsStyle="danger">
            Default return address no longer exists.
          </Alert>
        )}
      </Col>
      <Col md={4}>
        <Panel>
          <Panel.Heading>
            <Glyphicon glyph="comment" /> Comments
          </Panel.Heading>
          <Panel.Body>{shipment.comments || 'No comments provided'}</Panel.Body>
        </Panel>
      </Col>
    </Row>
  );
}

export default ShipmentSummary;
