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

import UserInfo from './UserInfo';
import Avatar from './Avatar';

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

/**
 * Readers feed
 */
export function Readers() {
    const params = useParams();
    return <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>
    );
}