'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);

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 pmrMoreInfo = function (_React$Component) {
  _inherits(pmrMoreInfo, _React$Component);

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

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

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

  pmrMoreInfo.prototype.render = function render() {
    var _this2 = this;

    function handleClick(e) {
      e.preventDefault();
      e.stopPropagation();
      console.log('The link was clicked.');
    }

    var pmrMoreInfoFetch = this.props.pmrMoreInfoFetch;

    var myPmrMoreInfo = _reactRefetch.PromiseState.all([pmrMoreInfoFetch]);

    if (myPmrMoreInfo.pending) {
      return _react2.default.createElement(
        'div',
        { className: 'wg_pmr_more' },
        _react2.default.createElement(_Loading2.default, null)
      );
    } else if (myPmrMoreInfo.rejected) {
      return _react2.default.createElement(
        'div',
        { className: 'wg_pmr_more' },
        myPmrMoreInfo.reason
      );
    } else if (myPmrMoreInfo.fulfilled) {
      // decompose the PromiseState back into individual
      var _myPmrMoreInfo$value = myPmrMoreInfo.value,
          _pmrMoreInfo = _myPmrMoreInfo$value[0];

      var pmrMoreInfos = _pmrMoreInfo.items[0];
      // this.setState(state => ({ items: myMeetingInfo.items}));
      // + {item.meetingNumber}
      console.log(this.state);
      console.log(_pmrMoreInfo.items);

      return _react2.default.createElement(
        'span',
        { className: 'wg_pmr_more moreway', role: 'alert', id: 'popover-content-1' },
        _react2.default.createElement(
          'span',
          { id: 'pmr_advancedInfo' },
          _react2.default.createElement(
            'div',
            { className: 'pop' },
            _react2.default.createElement(
              'div',
              { className: 'pmr_adInfo_roomid' },
              _react2.default.createElement(
                'span',
                null,
                'Meeting Number:'
              ),
              _react2.default.createElement(
                'span',
                {
                  tabIndex: '0',
                  'aria-label': 'Using command C or Ctrl C to copy the information',
                  title: this.props.meetingNumber
                },
                this.props.meetingNumber
              )
            ),
            _react2.default.createElement(
              'div',
              { id: 'copiedArea', className: 'pmr_pop' },
              _react2.default.createElement(
                'div',
                { className: 'pmr_pop_c' },
                _react2.default.createElement(
                  'div',
                  { className: 'pmr_pop_items' },
                  _react2.default.createElement(
                    'div',
                    { className: 'pmr_pop_imoret' },
                    _react2.default.createElement(
                      'h5',
                      null,
                      'Join by video system'
                    )
                  ),
                  _react2.default.createElement(
                    'div',
                    { id: 'VideoPart', className: 'pmr_pop_imorei' },
                    _react2.default.createElement(
                      'div',
                      null,
                      _react2.default.createElement(
                        'i',
                        {
                          id: 'joinByVideoDial' },
                        'Dial ',
                        pmrMoreInfos.hostEmail,
                        ' and enter your host PIN ',
                        pmrMoreInfos.hostKey,
                        '.'
                      )
                    ),
                    _react2.default.createElement(
                      'div',
                      null,
                      _react2.default.createElement(
                        'i',
                        null,
                        'You can also dial ',
                        pmrMoreInfos.dialInIpAddress,
                        ' and enter your meeting number.'
                      )
                    )
                  )
                ),
                _react2.default.createElement(
                  'div',
                  { className: 'pmr_pop_items' },
                  _react2.default.createElement(
                    'div',
                    { className: 'pmr_pop_imoret' },
                    _react2.default.createElement(
                      'h5',
                      null,
                      'Join by phone'
                    )
                  ),
                  _react2.default.createElement(
                    'div',
                    { id: 'AudioPart', className: 'pmr_pop_imorei' },
                    pmrMoreInfos.telephony.callInNumbers.map(function (item, index) {
                      return _react2.default.createElement(
                        'div',
                        { className: 'audioPartRow' },
                        _react2.default.createElement(
                          'label',
                          null,
                          item.callInNumber
                        ),
                        _react2.default.createElement(
                          'span',
                          null,
                          item.label
                        )
                      );
                    }),
                    _react2.default.createElement(
                      'div',
                      { className: 'audioPartRow' },
                      _react2.default.createElement(
                        'label',
                        null,
                        'Access code:'
                      ),
                      _react2.default.createElement(
                        'span',
                        null,
                        this.props.meetingNumber
                      )
                    ),
                    _react2.default.createElement(
                      'div',
                      { id: 'pmr_hostPIN', className: 'audioPartRow' },
                      _react2.default.createElement(
                        'label',
                        null,
                        'Host PIN:'
                      ),
                      _react2.default.createElement(
                        'span',
                        null,
                        pmrMoreInfos.hostKey
                      )
                    )
                  )
                )
              )
            ),
            _react2.default.createElement(
              'div',
              { className: 'pmr_pop_items callinNumber' },
              _react2.default.createElement(
                'div',
                { className: 'wbxCallinNumber' },
                _react2.default.createElement(
                  'a',
                  { 'aria-label': 'Open Modal', onClick: function onClick() {
                      return _this2.setState({ showDialog: true });
                    }, href: '#' },
                  'Global call-in numbers'
                ),
                _react2.default.createElement(
                  _react3.Modal,
                  {
                    icon: _react2.default.createElement(_react3.Icon, { name: 'warning_72', color: '$md-yellow-50' }),
                    applicationId: 'app',
                    onHide: function onHide() {
                      return _this2.setState({ showDialog: false });
                    },
                    show: this.state.showDialog,
                    ref: function ref(modalDialog) {
                      return _this2.modalDialog = modalDialog;
                    },
                    size: 'dialog',
                    htmlId: 'modalDialog'
                  },
                  _react2.default.createElement(_react3.ModalHeader, {
                    headerLabel: 'Global call-in numbers'
                  }),
                  _react2.default.createElement(
                    _react3.ModalBody,
                    null,
                    _react2.default.createElement(
                      'div',
                      { className: 'md-data-table', style: { width: '100%' } },
                      _react2.default.createElement(
                        'div',
                        { className: 'md-data-table__wrapper' },
                        _react2.default.createElement(
                          'table',
                          { className: 'testTableClass' },
                          _react2.default.createElement(
                            'thead',
                            { className: 'md-data-table__thead' },
                            _react2.default.createElement(
                              'tr',
                              null,
                              _react2.default.createElement(
                                'th',
                                { style: { width: '8rem' } },
                                'Country'
                              ),
                              _react2.default.createElement(
                                'th',
                                { style: { width: '5rem' } },
                                'Toll Type'
                              ),
                              _react2.default.createElement(
                                'th',
                                { style: { width: '10rem' } },
                                'Call Number'
                              )
                            )
                          ),
                          _react2.default.createElement(
                            'tbody',
                            {
                              className: 'md-data-table__tbody' },
                            pmrMoreInfos.telephony.callInNumbers.map(function (item, index) {
                              return _react2.default.createElement(
                                'tr',
                                null,
                                _react2.default.createElement(
                                  'td',
                                  null,
                                  ' ',
                                  item.label,
                                  ' '
                                ),
                                _react2.default.createElement(
                                  'td',
                                  null,
                                  ' ',
                                  item.tollType,
                                  ' '
                                ),
                                _react2.default.createElement(
                                  'td',
                                  null,
                                  ' ',
                                  item.callInNumber,
                                  ' '
                                )
                              );
                            })
                          )
                        )
                      )
                    )
                  ),
                  _react2.default.createElement(
                    _react3.ModalFooter,
                    null,
                    _react2.default.createElement(_react3.Button, {
                      children: 'Cancel',
                      onClick: function onClick() {
                        return _this2.modalDialog.closeModal();
                      },
                      ariaLabel: 'Close Modal',
                      color: 'default'
                    }),
                    _react2.default.createElement(_react3.Button, {
                      children: 'OK',
                      onClick: function onClick() {
                        return _this2.modalDialog.closeModal();
                      },
                      ariaLabel: 'Submit Form',
                      color: 'blue'
                    })
                  )
                )
              )
            )
          )
        )
      );
    }
  };

  return pmrMoreInfo;
}(_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

    pmrMoreInfoFetch: {
      url: props.endPoint + '/meetings?meetingNumber=201105545',
      headers: {
        Authorization: 'Bearer ' + props.token
      }
    }
  };
})(pmrMoreInfo);
module.exports = exports['default'];