import React, { Component } from 'react';
import { Immutable } from 'nuclear-js';
import { connect } from 'react-redux';
import Avatar from '@atlaskit/avatar';
import { getInviteURL } from '../../base/connection';
import { Dialog } from '../../base/dialog';
import { translate } from '../../base/i18n';
import MultiSelectAutocomplete
from '../../base/react/components/web/MultiSelectAutocomplete';
import { invitePeople, searchPeople } from '../functions';
/**
* The dialog that allows to invite people to the call.
*/
class AddPeopleDialog extends Component {
/**
* {@code AddPeopleDialog}'s property types.
*
* @static
*/
static propTypes = {
/**
* The URL pointing to the service allowing for people invite.
*/
_inviteServiceUrl: React.PropTypes.string,
/**
* The url of the conference to invite people to.
*/
_inviteUrl: React.PropTypes.string,
/**
* The JWT token.
*/
_jwt: React.PropTypes.string,
/**
* The URL pointing to the service allowing for people search.
*/
_peopleSearchUrl: React.PropTypes.string,
/**
* Invoked to obtain translated strings.
*/
t: React.PropTypes.func
};
/**
* Initializes a new {@code AddPeopleDialog} instance.
*
* @param {Object} props - The read-only properties with which the new
* instance is to be initialized.
*/
constructor(props) {
super(props);
this.state = {
/**
* Indicating that an error occurred when adding people to the call.
*/
addToCallError: false,
/**
* Indicating that we're currently adding the new people to the
* call.
*/
addToCallInProgress: false,
/**
* The list of invite items.
*/
inviteItems: new Immutable.List()
};
this._multiselect = null;
this._resourceClient = {
makeQuery: text => searchPeople(
this.props._peopleSearchUrl, this.props._jwt, text),
parseResults: response => response.map(user => {
const avatar = ( // eslint-disable-line no-extra-parens