From e7b32a80cdcf0fa9ca97c14cda33db6d81b451d6 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 12 Dec 2018 15:47:28 +0300 Subject: read/readers --- vnext/src/components/Users.js | 58 +++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'vnext/src/components/Users.js') diff --git a/vnext/src/components/Users.js b/vnext/src/components/Users.js index c0da3748..2bab6de1 100644 --- a/vnext/src/components/Users.js +++ b/vnext/src/components/Users.js @@ -1,41 +1,57 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Link } from 'react-router-dom'; + import { UserType } from './Types'; +import UserInfo from './UserInfo'; +import Avatar from './Avatar'; -export function Friends({ visitor, ...rest }) { - return ; +export function Friends({ user, ...rest }) { + return ; } -export function Readers({ visitor, ...rest }) { - return ; +export function Readers({ user, ...rest }) { + return ; } -function Users({data, ...rest}) { - return ( -
- { - data.map(user => - - - {user.uname} - - ) - } -
- ); +class Users extends React.Component { + constructor(props) { + super(props); + this.state = { + user: {} + }; + } + updateUser = (user) => { + this.setState({ + user: user + }); + } + render() { + return ( + +
+ { + this.state.user[this.props.prop] && + this.state.user[this.props.prop].map(user => + + ) + } +
+
+ ); + } } Friends.propTypes = { - visitor: UserType + user: PropTypes.string.isRequired }; Readers.propTypes = { - visitor: UserType + user: PropTypes.string.isRequired }; Users.propTypes = { - data: PropTypes.arrayOf(UserType).isRequired + user: PropTypes.string.isRequired, + prop: PropTypes.string.isRequired }; -- cgit v1.2.3