import React from 'react';
import PropTypes from 'prop-types';
import parse from 'react-html-parser';
import DecorativeLink from '../../links/DecorativeLink';
import './style.css';

var Address = function Address(props) {
  var address = props.address,
      directionLink = props.directionLink,
      details = props.details;

  return React.createElement(
    'span',
    { className: 'ma__address' },
    address.streetAddress ? React.createElement(
      'div',
      { className: 'ma__address__address' },
      React.createElement(
        'div',
        { className: 'ma__address__part' },
        address.streetAddress
      ),
      React.createElement(
        'div',
        { className: 'ma__address__part' },
        address.muni + ', ' + address.state + ' ' + address.zip
      )
    ) : React.createElement(
      'div',
      { className: 'ma__address__address' },
      parse(address)
    ),
    details && React.createElement(
      'p',
      { className: 'ma__contact__details' },
      parse(details)
    ),
    directionLink && React.createElement(
      'div',
      { className: 'ma__address__directions' },
      React.createElement(DecorativeLink, { text: 'Directions', href: directionLink })
    )
  );
};

Address.propTypes = process.env.NODE_ENV !== "production" ? {
  /** An object or string representing the address.
      If parsed the object contains the following:
        streetAddress: street number, name, if applicable apt/unit number
        muni: municipality/city/town
        state: state
        zip: zipcode
        country: country
      If a simple string just passed as:
        address: full address. */
  address: PropTypes.oneOfType([PropTypes.shape({
    streetAddress: PropTypes.string,
    muni: PropTypes.string,
    state: PropTypes.string,
    zip: PropTypes.string,
    country: PropTypes.string
  }), PropTypes.string, PropTypes.object]).isRequired,
  /** A link to the directions of the address. */
  directionLink: PropTypes.string,
  /** Details around visiting the address. */
  details: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
} : {};

export default Address;