import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';

import Icon from '../../base/Icon';

import './style.css';

var FooterSlim = function FooterSlim(props) {
  return React.createElement(
    'footer',
    { className: 'ma__footer_slim', id: 'footer' },
    React.createElement(
      'div',
      { className: 'ma__footer_slim--container ma__container' },
      props.siteLogo,
      React.createElement(
        'div',
        { className: 'ma__footer_slim--container-inner' },
        React.createElement(
          'section',
          { className: 'ma__footer_slim--info' },
          React.createElement(
            'h3',
            null,
            props.title
          ),
          React.createElement(
            'p',
            null,
            props.description
          ),
          React.createElement(
            'p',
            { className: 'ma__footer_slim--copyright' },
            '\xA9 ',
            moment().year(),
            ' Commonwealth of Massachusetts'
          )
        ),
        React.createElement(
          'section',
          { className: 'ma__footer_slim--details' },
          props.links && React.createElement(
            'div',
            { className: 'ma__footer_slim--links' },
            props.links.map(function (link, linkIndex) {
              return (
                /* eslint-disable-next-line react/no-array-index-key */
                React.createElement(
                  'a',
                  { href: link.href, key: 'footslimlinks-' + linkIndex },
                  link.title
                )
              );
            })
          ),
          props.contact && React.createElement(
            'div',
            { className: 'ma__footer_slim--contact' },
            props.contact.address && React.createElement(
              'p',
              null,
              React.createElement(Icon, { name: 'marker', svgWidth: 20, svgHeight: 20 }),
              React.createElement(
                'span',
                null,
                props.contact.address
              )
            ),
            props.contact.phone && React.createElement(
              'p',
              null,
              React.createElement(Icon, { name: 'phone', svgWidth: 20, svgHeight: 20 }),
              React.createElement(
                'span',
                null,
                props.contact.phone
              )
            ),
            props.contact.online && props.contact.online.href && props.contact.online.title && React.createElement(
              'p',
              null,
              React.createElement(Icon, { name: 'laptop', svgWidth: 20, svgHeight: 20 }),
              React.createElement(
                'a',
                { href: props.contact.online.href },
                props.contact.online.title
              )
            )
          )
        )
      )
    )
  );
};

FooterSlim.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The main title to be displayed in the footer */
  title: PropTypes.string.isRequired,
  /** A short description */
  description: PropTypes.string.isRequired,
  /** Additional links for key information */
  links: PropTypes.arrayOf(PropTypes.shape({
    href: PropTypes.string,
    title: PropTypes.string
  })),
  /** Contact details for the responsible authority */
  contact: PropTypes.shape({
    address: PropTypes.string,
    phone: PropTypes.string,
    online: PropTypes.shape({
      href: PropTypes.string,
      title: PropTypes.string
    })
  }),
  /** The domain you want to send users to from the site logo icon */
  // eslint-disable-next-line consistent-return
  siteLogo: function siteLogo(props, propName, componentName) {
    var component = props[propName];
    var isValid = function isValid(comp) {
      if (typeof comp.type === 'string') {
        return comp.type === 'SiteLogo';
      }
      return comp.type.name && comp.type.name === 'SiteLogo';
    };
    if (!component || component && !isValid(component)) {
      return new Error('Invalid prop ' + propName + ' supplied to ' + componentName + '. Got: ' + component.type.name + '. Validation failed.');
    }
  }
} : {};

export default FooterSlim;