aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Users.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-12-12 15:47:28 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:54 +0300
commite7b32a80cdcf0fa9ca97c14cda33db6d81b451d6 (patch)
tree3d0e53fcf47757bb02e2b44a94679b4f74b3a867 /vnext/src/components/Users.js
parent0c31e9ae31403beb3c390e864f0aae653240868d (diff)
read/readers
Diffstat (limited to 'vnext/src/components/Users.js')
-rw-r--r--vnext/src/components/Users.js58
1 files changed, 37 insertions, 21 deletions
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 <Users data={visitor.read || []} />;
+export function Friends({ user, ...rest }) {
+ return <Users user={user} prop='read' />;
}
-export function Readers({ visitor, ...rest }) {
- return <Users data={ visitor.readers || [] } />;
+export function Readers({ user, ...rest }) {
+ return <Users user={user} prop='readers' />;
}
-function Users({data, ...rest}) {
- return (
- <div className="users">
- {
- data.map(user => <span key={user.uid}>
- <Link to={`/${user.uname}/`}>
- <img src={`//i.juick.com/as/${user.uid}.png`} />
- <span>{user.uname}</span>
- </Link>
- </span>)
- }
- </div>
- );
+class Users extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ user: {}
+ };
+ }
+ updateUser = (user) => {
+ this.setState({
+ user: user
+ });
+ }
+ render() {
+ return (
+ <UserInfo user={this.props.user} onUpdate={this.updateUser}>
+ <div style={{ display: 'flex', flexWrap: 'wrap', flexDirection: 'row'}}>
+ {
+ this.state.user[this.props.prop] &&
+ this.state.user[this.props.prop].map(user =>
+ <Avatar key={user.uid} user={user} />
+ )
+ }
+ </div>
+ </UserInfo>
+ );
+ }
}
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
};