import React, { Component, PropTypes } from 'react';
import { withRouter } from 'react-router';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import styles from './styles.scss';
import cx from 'classnames';
import { defineMessages, injectIntl } from 'react-intl';
import UserListItem from './user-list-item/component.jsx';
import ChatListItem from './chat-list-item/component.jsx';
const propTypes = {
openChats: PropTypes.array.isRequired,
users: PropTypes.array.isRequired,
};
const defaultProps = {
};
const listTransition = {
enter: styles.enter,
enterActive: styles.enterActive,
appear: styles.appear,
appearActive: styles.appearActive,
leave: styles.leave,
leaveActive: styles.leaveActive,
};
class UserList extends Component {
constructor(props) {
super(props);
this.state = {
compact: this.props.compact,
};
}
render() {
return (
{this.renderHeader()}
{this.renderContent()}
);
}
renderHeader() {
const { intl } = this.props;
return (
{
!this.state.compact ?
{intl.formatMessage(intlMessages.participantsTitle)}
: null
}
);
}
renderContent() {
return (
{this.renderMessages()}
{this.renderParticipants()}
);
}
renderMessages() {
const {
openChats,
openChat,
intl,
} = this.props;
return (
{
!this.state.compact ?
{intl.formatMessage(intlMessages.messagesTitle)}
:
}
{openChats.map(chat => (
))}
);
}
renderParticipants() {
const {
users,
currentUser,
userActions,
compact,
isBreakoutRoom,
intl,
} = this.props;
return (
{
!this.state.compact ?
{intl.formatMessage(intlMessages.usersTitle)}
({users.length})
:
}
{
users.map(user => (
))}
);
}
}
const intlMessages = defineMessages({
usersTitle: {
id: 'app.userlist.usersTitle',
description: 'Title for the Header',
},
messagesTitle: {
id: 'app.userlist.messagesTitle',
description: 'Title for the messages list',
},
participantsTitle: {
id: 'app.userlist.participantsTitle',
description: 'Title for the Users list',
},
});
UserList.propTypes = propTypes;
export default withRouter(injectIntl(UserList));