2019-12-21 15:16:13 +01:00
|
|
|
import React from 'react';
|
2019-12-23 17:00:57 +01:00
|
|
|
import PropTypes from 'prop-types';
|
2020-01-06 20:50:36 +01:00
|
|
|
import accounts, { me } from '../../../../initial_state';
|
2019-12-18 16:16:08 +01:00
|
|
|
|
2019-12-21 17:03:26 +01:00
|
|
|
export default class ContactsList extends React.PureComponent {
|
2019-12-18 16:16:08 +01:00
|
|
|
|
2019-12-23 17:00:57 +01:00
|
|
|
static propTypes = {
|
2020-01-06 20:50:36 +01:00
|
|
|
// myAccount : PropTypes.any,
|
2019-12-23 17:00:57 +01:00
|
|
|
showList : PropTypes.bool,
|
|
|
|
contactList : PropTypes.array,
|
|
|
|
conversationList: PropTypes.array,
|
2020-01-06 20:50:36 +01:00
|
|
|
following_count : PropTypes.number,
|
2019-12-23 17:00:57 +01:00
|
|
|
};
|
|
|
|
static defaultProps = {
|
2020-01-06 20:50:36 +01:00
|
|
|
showList : true,
|
|
|
|
// myAccount : '',
|
|
|
|
userID : me,
|
|
|
|
following_count: 0,
|
|
|
|
contactList : ['machin', 'bidule', 'chuck norris'],
|
2019-12-23 17:00:57 +01:00
|
|
|
};
|
2019-12-18 16:16:08 +01:00
|
|
|
|
2019-12-23 17:00:57 +01:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2020-01-06 20:50:36 +01:00
|
|
|
console.log('me', me);
|
|
|
|
console.log('account', accounts.accounts[me]);
|
|
|
|
console.log('i follow accounts.accounts[me].followingCount', accounts.accounts[me].following_count);
|
|
|
|
// this.props.myAccount = accounts.accounts[me];
|
|
|
|
// this.props.following_count = accounts.accounts[me].following_count;
|
|
|
|
|
2019-12-23 17:00:57 +01:00
|
|
|
this.state = {
|
2020-01-06 20:50:36 +01:00
|
|
|
following_count : accounts.accounts[me].following_count,
|
|
|
|
showList : props.showList,
|
2019-12-23 17:00:57 +01:00
|
|
|
contactList : ['machin', 'bidule', 'chuck norris'],
|
|
|
|
conversationList: ['machin', 'bidule', 'chuck norris'],
|
|
|
|
};
|
2020-01-06 20:50:36 +01:00
|
|
|
// fetchFollowing(1);
|
2019-12-18 16:16:08 +01:00
|
|
|
}
|
|
|
|
|
2019-12-23 17:00:57 +01:00
|
|
|
submitCompose() {
|
|
|
|
console.log('submit message');
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleList = () => {
|
|
|
|
this.setState((state) => {
|
|
|
|
return {
|
|
|
|
showList: !state.showList,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-12-18 16:16:08 +01:00
|
|
|
render() {
|
2019-12-21 17:03:26 +01:00
|
|
|
|
2020-01-06 20:50:36 +01:00
|
|
|
// const renderedList = 'la liste';
|
|
|
|
console.log('this.state.contactList', this.state.contactList);
|
|
|
|
const renderedList = this.state.contactList.map(elem => {
|
|
|
|
console.log('elem', elem);
|
2019-12-23 17:00:57 +01:00
|
|
|
return (
|
2020-01-06 20:50:36 +01:00
|
|
|
<li className='contact-item'> {elem}
|
2019-12-23 17:00:57 +01:00
|
|
|
</li >
|
|
|
|
);
|
|
|
|
});
|
2020-01-06 20:50:36 +01:00
|
|
|
const classList = 'btn btn-primary toggle-list ' + (this.state.showList ? 'active' : 'inactive');
|
2019-12-21 15:16:13 +01:00
|
|
|
return (
|
|
|
|
<div className='messaging-container'>
|
|
|
|
<div className='messaging-box'>
|
2019-12-23 17:00:57 +01:00
|
|
|
<div className='title column-header'>
|
2019-12-21 15:16:13 +01:00
|
|
|
<i
|
|
|
|
role='img'
|
|
|
|
className='fa fa-envelope column-header__icon fa-fw'
|
|
|
|
/>
|
|
|
|
Messaging box
|
|
|
|
</div >
|
2020-01-06 20:50:36 +01:00
|
|
|
<div className='user-list'>
|
|
|
|
<h2 className='title'>
|
|
|
|
la liste de {this.state.following_count} contacts
|
2019-12-21 15:16:13 +01:00
|
|
|
|
2019-12-23 17:00:57 +01:00
|
|
|
<button
|
2020-01-06 20:50:36 +01:00
|
|
|
className={classList}
|
2019-12-23 17:00:57 +01:00
|
|
|
onClick={this.toggleList}
|
|
|
|
>
|
2020-01-06 20:50:36 +01:00
|
|
|
{this.state.showList && (
|
|
|
|
<i className='fa fa-caret-up' />
|
|
|
|
)}
|
|
|
|
{!this.state.showList && (
|
|
|
|
<i className='fa fa-caret-left' />
|
|
|
|
)}
|
2019-12-23 17:00:57 +01:00
|
|
|
</button >
|
|
|
|
</h2 >
|
|
|
|
{this.state.showList && (
|
|
|
|
<div className='contact-list-container'>
|
|
|
|
<h3 >show list</h3 >
|
|
|
|
<ul className='contact-list'>
|
|
|
|
{renderedList}
|
|
|
|
</ul >
|
|
|
|
</div >
|
|
|
|
)}
|
|
|
|
</div >
|
2019-12-21 15:16:13 +01:00
|
|
|
|
|
|
|
</div >
|
|
|
|
</div >
|
|
|
|
);
|
2019-12-18 16:16:08 +01:00
|
|
|
}
|
|
|
|
|
2019-12-21 17:03:26 +01:00
|
|
|
}
|