aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/Users.js
blob: 32ff2d03865b5915976c984ed3be4f90a1777c66 (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
import { useState } from 'react';
import { useParams } from 'react-router-dom';

import UserInfo from './UserInfo';
import Avatar from './Avatar';
import { Helmet } from 'react-helmet';

/**
 * Friends feed
 */
export function Friends() {
    const params = useParams();
    return (
        <>
            <Helmet>
                <title>{params.user} subscriptions</title>
            </Helmet>
            <Users uname={params.user} prop='read' />
        </>
    );
}

/**
 * Readers feed
 */
export function Readers() {
    const params = useParams();
    return (
        <>
            <Helmet>
                <title>{params.user} readers</title>
            </Helmet>
            <Users uname={params.user} prop='readers' />
        </>
    );
}

/**
 * UserInfo list component
 * @param {{uname: string, prop: string}} props
 */
function Users({ uname, prop }) {
    const [user, setUser] = useState({ uid: 0, uname: uname });
    return (
        <UserInfo uname={uname} onUpdate={setUser}>
            <div style={{ display: 'flex', flexWrap: 'wrap', flexDirection: 'row' }}>
                {
                    user[prop] &&
                    user[prop].map(user =>
                        <Avatar key={user.uid} user={user} />
                    )
                }
            </div>
        </UserInfo>
    );
}