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 } from '@momentum-ui/react';
import Loading from "../common/component/Loading";

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

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

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

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

  MeetingHost.prototype.render = function render() {
    var userDetailFetch = this.props.userDetailFetch;

    var userDetail = PromiseState.all([userDetailFetch]);

    if (userDetail.pending) {
      return React.createElement(
        'div',
        { className: 'wg_m_avatar' },
        React.createElement(Loading, null)
      );
    } else if (userDetail.rejected) {
      return React.createElement(
        'div',
        { className: 'wg_m_avatar' },
        userDetail.reason
      );
    } else if (userDetail.fulfilled) {
      // decompose the PromiseState back into individual
      var _userDetail$value = userDetail.value,
          userDetailInfo = _userDetail$value[0];
      // this.setState(state => ({ items: myMeetingInfo.items}));
      // + {item.meetingNumber}

      console.log(this.state);
      console.log(userDetailInfo.items);
      console.log(userDetailInfo.items);
      var userDetailInfoItems = userDetailInfo.items[0];
      return React.createElement(
        'div',
        { className: 'wg_m_avatar' },
        userDetailInfoItems ? userDetailInfoItems.avatar ? React.createElement('img', { src: userDetailInfoItems.avatar, alt: userDetailInfoItems.displayName }) : React.createElement(Avatar, { size: 40, title: userDetailInfoItems.displayName }) : React.createElement(Avatar, { size: 40, title: this.props.userEmail })
      );
    }
  };

  return MeetingHost;
}(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
    userDetailFetch: {
      url: props.endPoint + '/people?email=' + props.userEmail,
      headers: {
        Authorization: 'Bearer ' + props.token
      }
    }
  };
})(MeetingHost);