'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

require('../../assets/styles/widgets/meetingCalenderViews/meetingCalenderViews.scss');

var _reactRefetch = require('react-refetch');

var _moment = require('moment');

var _moment2 = _interopRequireDefault(_moment);

var _react3 = require('@momentum-ui/react');

var _Loading = require('../common/component/Loading');

var _Loading2 = _interopRequireDefault(_Loading);

var _PmrMoreInfo = require('./PmrMoreInfo');

var _PmrMoreInfo2 = _interopRequireDefault(_PmrMoreInfo);

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var PmrDetail = function (_React$Component) {
  _inherits(PmrDetail, _React$Component);

  function PmrDetail(props) {
    _classCallCheck(this, PmrDetail);

    var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));

    _this.state = {
      items: []
    };
    return _this;
  }

  PmrDetail.prototype.render = function render() {
    function handleClick(e) {
      e.preventDefault();
      e.stopPropagation();
      console.log('The link was clicked.');
    }
    var pmrFetch = this.props.pmrFetch;

    var myPMRInfo = _reactRefetch.PromiseState.all([pmrFetch]);

    if (myPMRInfo.pending) {
      return _react2.default.createElement(
        'div',
        { className: 'wg_pmr_detail' },
        _react2.default.createElement(_Loading2.default, null)
      );
    } else if (myPMRInfo.rejected) {
      return _react2.default.createElement(
        'div',
        { className: 'wg_pmr_detail' },
        myPMRInfo.reason
      );
    } else if (myPMRInfo.fulfilled) {
      // decompose the PromiseState back into individual
      var _myPMRInfo$value = myPMRInfo.value,
          pmrInfo = _myPMRInfo$value[0];
      // this.setState(state => ({ items: myMeetingInfo.items}));
      // + {item.meetingNumber}

      console.log(this.state);
      console.log(pmrInfo.items);

      return _react2.default.createElement(
        'div',
        { className: 'wg_pmr_detail pmr_card_c_wrapper' },
        _react2.default.createElement(
          'div',
          { className: 'pmr_card_c_name' },
          _react2.default.createElement(
            'div',
            { className: 'pmr_card_c_title' },
            _react2.default.createElement(
              'span',
              null,
              pmrInfo.personalMeetingRoom.topic
            )
          ),
          _react2.default.createElement(
            'div',
            { className: 'pmr_slide_f' },
            _react2.default.createElement('span', null),
            _react2.default.createElement(
              'a',
              {
                plain: 'true',
                role: 'button',
                tabIndex: '0',
                title: 'Copy',
                'aria-label': 'Press Enter to copy the information about ways to join your Personal Room meeting',
                'aria-describedby': 'popover-content-0'
              },
              _react2.default.createElement('i', { className: 'icon icon-copy_20' })
            )
          )
        ),
        _react2.default.createElement(
          'span',
          null,
          _react2.default.createElement(
            'span',
            {
              tabIndex: '0',
              'aria-label': 'Using command C or Ctrl C to copy the information',
              role: 'Note',
              title: pmrInfo.personalMeetingRoom.personalMeetingRoomLink,
              className: 'auto_select pmr_url_autoselect',
              id: 'pm_url'
            },
            pmrInfo.personalMeetingRoom.personalMeetingRoomLink
          )
        ),
        _react2.default.createElement(
          'div',
          { className: 'pmr_card_c_more pmr_more' },
          _react2.default.createElement(
            _react3.Popover,
            {
              isContained: true,
              content: _react2.default.createElement(_PmrMoreInfo2.default, {
                token: this.props.token,
                meetingNumber: '201 105 545',
                endPoint: this.props.endPoint
              }),
              direction: 'bottom-center',
              popoverTrigger: 'Click'
            },
            _react2.default.createElement(
              'a',
              {
                href: '#',
                role: 'button',
                'aria-label': 'Press Enter to show more ways to join your Personal Room meeting.',
                className: 'pmr_card_c_more_text',
                'aria-describedby': 'popover-content-1'
              },
              _react2.default.createElement(
                'span',
                { className: 'pmr_more_icon' },
                _react2.default.createElement('i', { className: 'icon icon-more-circle_16' })
              ),
              _react2.default.createElement(
                'span',
                null,
                'More ways to join'
              )
            )
          )
        ),
        _react2.default.createElement(
          'div',
          { className: 'pmr_card_btns' },
          _react2.default.createElement(
            _react3.Button,
            {
              children: 'Start a Meeting',
              onClick: handleClick,
              ariaLabel: 'Start a Meeting',
              color: 'green'
            },
            _react2.default.createElement(
              'span',
              null,
              'Start a Meeting'
            ),
            _react2.default.createElement(
              _react3.MenuOverlay,
              {
                menuTrigger: _react2.default.createElement(_react3.Icon, { name: 'icon-arrow-down_16' }),
                showArrow: false
              },
              _react2.default.createElement(
                _react3.Menu,
                null,
                _react2.default.createElement(
                  _react3.MenuItem,
                  null,
                  _react2.default.createElement(
                    _react3.ListItemSection,
                    { position: 'center' },
                    'Use desktop app'
                  ),
                  _react2.default.createElement(
                    _react3.ListItemSection,
                    { position: 'right' },
                    _react2.default.createElement(_react3.Icon, { name: 'icon-check_16' })
                  )
                ),
                _react2.default.createElement(
                  _react3.MenuItem,
                  null,
                  _react2.default.createElement(
                    _react3.ListItemSection,
                    { position: 'center' },
                    'Use web app'
                  ),
                  _react2.default.createElement(
                    _react3.ListItemSection,
                    { position: 'right' },
                    _react2.default.createElement(_react3.Icon, { name: 'icon-check_16', className: 'hide' })
                  )
                )
              )
            )
          ),
          _react2.default.createElement(_react3.Button, {
            children: 'Schedule',
            onClick: function onClick() {},
            ariaLabel: 'Schedule'
          })
        )
      );
    }
  };

  return PmrDetail;
}(_react2.default.Component);

exports.default = (0, _reactRefetch.connect)(function (props) {
  return {
    // simple GET from a URL injected as `userFetch` prop
    // if `userId` changes, data will be refetched

    // similar to `userFetch`, but using object syntax
    // specifies a refresh interval to poll for new data

    pmrFetch: {
      url: props.endPoint + '/meetingPreferences?userid=' + props.userID,
      headers: {
        Authorization: 'Bearer ' + props.token
      }
    }
  };
})(PmrDetail);
module.exports = exports['default'];