'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactRouter = require('react-router');

var _TimeString = require('../internal/TimeString');

var _TimeString2 = _interopRequireDefault(_TimeString);

var _Icon = require('../Icon');

var _Icon2 = _interopRequireDefault(_Icon);

var _style = require('./style.scss');

var _style2 = _interopRequireDefault(_style);

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

var ActivityFeedItem = function ActivityFeedItem(props) {

  var generateProfileName = function generateProfileName() {
    if (!props.profileUrl) {
      return props.name ? props.name : null;
    } else {
      return _react2.default.createElement(
        _reactRouter.Link,
        { to: props.profileUrl },
        props.name ? props.name : null
      );
    }
  };

  var generateActions = function generateActions() {
    var actions = props.actions.map(function (action, index) {
      return _react2.default.createElement(_Icon2.default, { name: action.icon, onClick: action.callback, fill: '#3c97d3', height: '16', width: '16', key: index });
    });
    return actions;
  };

  return _react2.default.createElement(
    'div',
    { className: _style2.default['item-wrapper'] },
    props.time ? _react2.default.createElement(
      'time',
      null,
      (0, _TimeString2.default)(props.time)
    ) : null,
    _react2.default.createElement(
      'div',
      { className: _style2.default['title-wrapper'] },
      _react2.default.createElement(
        'h3',
        null,
        generateProfileName(),
        ' ',
        props.title ? props.title : null
      ),
      props.actions ? _react2.default.createElement(
        'div',
        { className: _style2.default['action-wrapper'] },
        generateActions()
      ) : null
    ),
    props.text ? _react2.default.createElement(
      'p',
      null,
      props.text
    ) : null
  );
};

ActivityFeedItem.propTypes = {
  /**
   * The name that appears in the
   */
  name: _react2.default.PropTypes.string,
  /**
   * A URL that you want to use to redirect when the name is clicked.
   */
  profileUrl: _react2.default.PropTypes.string,
  /**
   * A title to display next to the name.
   */
  title: _react2.default.PropTypes.string,
  /**
   * An array of actions that allow you to present an icon (on hover),
   * and a callback function (when clicked)
   */
  actions: _react2.default.PropTypes.array,
  /**
   * The text that you want to display below the title.
   */
  text: _react2.default.PropTypes.string,
  /**
   * A timestamp that you want to provide to the feed item.
   */
  time: _react2.default.PropTypes.string
};

exports.default = ActivityFeedItem;