'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _flexboxReact = require('flexbox-react');

var _flexboxReact2 = _interopRequireDefault(_flexboxReact);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _semanticUiReact = require('semantic-ui-react');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

/**
 * A context specific component, intended to display _states_ of items in a list.
 * Items shall have an iterface including keys { id, state }, where state is one
 * of `[critical, warning, normal]`
 */
var LargeCardRecentList = function LargeCardRecentList(props) {
  var items = props.items,
      rest = _objectWithoutProperties(props, ['items']);

  return _react2.default.createElement(
    _flexboxReact2.default,
    _extends({ flexDirection: 'column', flexGrow: 1 }, rest),
    _react2.default.createElement(
      'h4',
      { className: 'label' },
      'Recent'
    ),
    items.map(function (_ref) {
      var id = _ref.id,
          state = _ref.state,
          status = _ref.status,
          date = _ref.date;

      var icon = '';
      switch (state) {
        case 'warning':
          icon = 'icon_error-triangle_alt';
          break;
        case 'critical':
          icon = 'icon_error-circle_alt';
          break;
        default:
          icon = 'icon_check_alt2';
      }
      return _react2.default.createElement(
        _flexboxReact2.default,
        {
          key: id,
          flexDirection: 'row',
          className: 'recent_list-' + state + ' recent__activity__row'
        },
        _react2.default.createElement(
          _flexboxReact2.default,
          {
            className: 'recent_list-' + state,
            alignItems: 'center',
            marginRight: '20px'
          },
          _react2.default.createElement(_semanticUiReact.Icon, { className: 'ei ' + icon + ' text-large' })
        ),
        _react2.default.createElement(
          _flexboxReact2.default,
          {
            className: 'text-uppercase text-small recent_list-' + state,
            alignItems: 'center',
            marginRight: '20px'
          },
          status
        ),
        _react2.default.createElement(
          _flexboxReact2.default,
          {
            className: 'text-uppercase text-small recent_list-' + state,
            alignItems: 'center'
          },
          date
        )
      );
    })
  );
};
LargeCardRecentList.STATES = ['critical', 'normal', 'warning'];

LargeCardRecentList.defaultProps = {};

LargeCardRecentList.propTypes = {
  /**
   * Array of items to render into recent list
   */
  items: _propTypes2.default.arrayOf(_propTypes2.default.shape({
    id: _propTypes2.default.any.isRequired,
    state: _propTypes2.default.oneOf(LargeCardRecentList.STATES).isRequired,
    status: _propTypes2.default.string.isRequired,
    date: _propTypes2.default.string.isRequired
  }))
};

exports.default = LargeCardRecentList;
//# sourceMappingURL=LargeCardRecentList.js.map