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, { useState } from 'react';
import { connect, PromiseState } from 'react-refetch';
import '../../assets/styles/widgets/pmr/pmr.scss';
import { Popover, Button, Icon, MenuOverlay, Menu, MenuItem, ListItemSection, Avatar } from '@momentum-ui/react';

// import pmrStyle from '../../assets/styles/widgets/pmr/pmr.module.scss';
import Loading from "../common/component/Loading";
import PmrDetail from "./PmrDetail";
import MeetingDetail from "../meetingCalenderViews/MeetingDetail";

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

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

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

    _this.state = {
      topic: "Dongdong Wang's Personal Room",
      hostPin: '683100',
      enabledAutoLock: false,
      autoLockMinutes: 0,
      enabledNotifyHost: true,
      supportCoHost: true,
      supportAnyoneAsCoHost: false,
      avatar: '',
      personalMeetingRoomLink: 'https://cisco.webex.com/meet/dongdwan'
    };
    return _this;
  }

  Pmr.prototype.render = function render() {
    var meFetch = this.props.meFetch;

    var myPMR = PromiseState.all([meFetch]);

    if (myPMR.pending) {
      return React.createElement(
        'div',
        { className: 'wg_pmr' },
        React.createElement(Loading, null)
      );
    } else if (myPMR.rejected) {
      return React.createElement(
        'div',
        { className: 'wg_pmr' },
        myPMR.reason
      );
    } else if (myPMR.fulfilled) {
      // decompose the PromiseState back into individual
      var _myPMR$value = myPMR.value,
          myInfo = _myPMR$value[0];

      // get pmr info

      return React.createElement(
        'div',
        { className: 'wg_pmr' },
        React.createElement(
          'div',
          { className: 'pmr_card_c' },
          React.createElement(
            'div',
            { id: 'avatar_div', className: 'pmr_avatar' },
            React.createElement(
              'div',
              { className: 'avatar_editor' },
              React.createElement(
                'div',
                {
                  role: 'application',
                  'aria-label': 'Press Enter to change your profile picture.',
                  tabIndex: '0',
                  className: 'user_avatar'
                },
                myInfo.avatar ? React.createElement(
                  'span',
                  { className: 'avatar_xlarge avatar_img' },
                  React.createElement('img', {
                    src: myInfo.avatar,
                    alt: myInfo.displayName
                  })
                ) : React.createElement(Avatar, { title: myInfo.displayName, size: '80' })
              )
            )
          ),
          React.createElement(PmrDetail, {
            token: this.props.token,
            userID: myInfo.id,
            endPoint: this.props.endPoint
          })
        )
      );
    }
  };

  return Pmr;
}(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
    meFetch: {
      url: props.endPoint + '/people/me',
      headers: {
        Authorization: 'Bearer ' + props.token
      }
    }
  };
})(Pmr);