aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/UserInfo.js
blob: 249bcf95ff3fdae97c717de042ba973becf9f474 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import React from 'react';

import { Link } from 'react-router-dom';

import { info } from '../api';

import Avatar from './Avatar';
import Icon from './Icon';
import SearchBox from './SearchBox';

export default class UserInfo extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            user: { uname: props.user, uid: 0 }
        };
    }
    componentDidMount() {
        info(this.state.user.uname).then(response => {
            this.setState({
                user: response.data[0]
            });
        });
    }
    render() {
        const { user } = this.state;
        return (
            <div style={{ padding: '14px' }}>
                <Avatar user={user}>
                    <div className="msg-ts">Was online recently</div>
                </Avatar>
                <div>
                    {
                        user.uid > 0 &&
                        <>
                            <ul>
                                <li>
                                    <Link to="/pm">
                                        <Icon name="ei-envelope" size="s" />PM
                              </Link>
                                </li>
                                <li>
                                    <Link to={`/${user.uname}/?show=recomm`} rel="nofollow">
                                        <Icon name="ei-heart" size="s" />Recommendations
                              </Link>
                                </li>
                                <li>
                                    <Link to={`/${user.uname}/?media=1`} rel="nofollow">
                                        <Icon name="ei-camera" size="s" />Photos
                              </Link>
                                </li>
                            </ul>
                            <hr />
                            <SearchBox pathname={`/${user.uname}/`} onSearch={this.search} {...this.props} />
                            <hr />
                            <div id="ustats">
                                <ul>
                                    {
                                        user.read &&
                                        <li><Link to={`/${user.uname}/friends`}>I read: {user.read.length}</Link></li>
                                    }
                                    <li><Link to={`/${user.uname}/readers`}>My readers: {user.readers ? user.readers.length : 0}</Link></li>
                                    {
                                        user.statsMyBL &&
                                        <li><Link to={`/${user.uname}/bl`}>My blacklist: {user.statsMyBL}</Link></li>
                                    }
                                    <li>Messages: {user.statsMessages}</li>
                                    <li>Comments: {user.statsReplies}</li>
                                </ul>
                                {
                                    user.read &&
                                    <div className="iread">
                                        {
                                            user.read.map(u => <Avatar user={u} key={u.uid} />)
                                        }
                                    </div>
                                }
                            </div>
                        </>
                    }
                </div>
            </div>
        );
    }
}