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; }

import React from 'react';
import '../../assets/styles/widgets/meetingCalenderViews/meetingCalenderViews.scss';
import { connect, PromiseState } from "react-refetch";
import moment from 'moment';
import { Avatar, Button, Icon, ListItemSection, Menu, MenuItem, MenuOverlay, Popover } from '@momentum-ui/react';
import Loading from "../common/component/Loading";
import PmrMoreInfo from "./PmrMoreInfo";

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 = PromiseState.all([pmrFetch]);

    if (myPMRInfo.pending) {
      return React.createElement(
        'div',
        { className: 'wg_pmr_detail' },
        React.createElement(Loading, null)
      );
    } else if (myPMRInfo.rejected) {
      return React.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 React.createElement(
        'div',
        { className: 'wg_pmr_detail pmr_card_c_wrapper' },
        React.createElement(
          'div',
          { className: 'pmr_card_c_name' },
          React.createElement(
            'div',
            { className: 'pmr_card_c_title' },
            React.createElement(
              'span',
              null,
              pmrInfo.personalMeetingRoom.topic
            )
          ),
          React.createElement(
            'div',
            { className: 'pmr_slide_f' },
            React.createElement('span', null),
            React.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'
              },
              React.createElement('i', { className: 'icon icon-copy_20' })
            )
          )
        ),
        React.createElement(
          'span',
          null,
          React.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
          )
        ),
        React.createElement(
          'div',
          { className: 'pmr_card_c_more pmr_more' },
          React.createElement(
            Popover,
            {
              isContained: true,
              content: React.createElement(PmrMoreInfo, {
                token: this.props.token,
                meetingNumber: '201 105 545',
                endPoint: this.props.endPoint
              }),
              direction: 'bottom-center',
              popoverTrigger: 'Click'
            },
            React.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'
              },
              React.createElement(
                'span',
                { className: 'pmr_more_icon' },
                React.createElement('i', { className: 'icon icon-more-circle_16' })
              ),
              React.createElement(
                'span',
                null,
                'More ways to join'
              )
            )
          )
        ),
        React.createElement(
          'div',
          { className: 'pmr_card_btns' },
          React.createElement(
            Button,
            {
              children: 'Start a Meeting',
              onClick: handleClick,
              ariaLabel: 'Start a Meeting',
              color: 'green'
            },
            React.createElement(
              'span',
              null,
              'Start a Meeting'
            ),
            React.createElement(
              MenuOverlay,
              {
                menuTrigger: React.createElement(Icon, { name: 'icon-arrow-down_16' }),
                showArrow: false
              },
              React.createElement(
                Menu,
                null,
                React.createElement(
                  MenuItem,
                  null,
                  React.createElement(
                    ListItemSection,
                    { position: 'center' },
                    'Use desktop app'
                  ),
                  React.createElement(
                    ListItemSection,
                    { position: 'right' },
                    React.createElement(Icon, { name: 'icon-check_16' })
                  )
                ),
                React.createElement(
                  MenuItem,
                  null,
                  React.createElement(
                    ListItemSection,
                    { position: 'center' },
                    'Use web app'
                  ),
                  React.createElement(
                    ListItemSection,
                    { position: 'right' },
                    React.createElement(Icon, { name: 'icon-check_16', className: 'hide' })
                  )
                )
              )
            )
          ),
          React.createElement(Button, {
            children: 'Schedule',
            onClick: function onClick() {},
            ariaLabel: 'Schedule'
          })
        )
      );
    }
  };

  return PmrDetail;
}(React.Component);

export default 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);