aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/UserInfo.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-07-26 13:22:00 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:55 +0300
commitf707d3d524d8d16e2bb780764f029d85fc57ecc0 (patch)
tree1580074a665bd16c9744b5749c2a777700c5ae73 /vnext/src/ui/UserInfo.js
parent6016b0888e77497e15384f1cd024eb42672129a4 (diff)
prop-types -> jsdoc
Diffstat (limited to 'vnext/src/ui/UserInfo.js')
-rw-r--r--vnext/src/ui/UserInfo.js40
1 files changed, 22 insertions, 18 deletions
diff --git a/vnext/src/ui/UserInfo.js b/vnext/src/ui/UserInfo.js
index 0d06d134..faa2ebd6 100644
--- a/vnext/src/ui/UserInfo.js
+++ b/vnext/src/ui/UserInfo.js
@@ -1,9 +1,6 @@
import React, { useState, useEffect } from 'react';
-import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
-import { UserType } from './Types';
-
import { info, fetchUserUri } from '../api';
import Avatar from './Avatar';
@@ -14,8 +11,20 @@ import './UserInfo.css';
let isMounted;
+/**
+ * Wrapper for dumb VSCode
+ * @param {import('../api').User} user
+ */
+function useUserState(user) {
+ return useState(user);
+}
+
+/**
+ * User info component
+ * @param {{user: string, onUpdate?: function, children?: Element}} props
+ */
export default function UserInfo(props) {
- const [user, setUser] = useState({ uname: props.user, uid: 0 });
+ const [user, setUser] = useUserState({ uname: props.user, uid: 0 });
const { onUpdate } = props;
useEffect(() => {
isMounted = true;
@@ -63,6 +72,10 @@ export default function UserInfo(props) {
);
}
+/**
+ * User summary component
+ * @param {{user: import('../api').User}} props
+ */
function Summary({ user }) {
const readUrl = `/${user.uname}/friends`;
const readersUrl = `/${user.uname}/readers`;
@@ -78,12 +91,13 @@ function Summary({ user }) {
);
}
-Summary.propTypes = {
- user: UserType.isRequired
-};
-
const UserSummary = React.memo(Summary);
+
+/**
+ * Link to user
+ * @param {{ user: import('../api').User}} props
+ */
export function UserLink(props) {
const [user, setUser] = useState(props.user);
useEffect(() => {
@@ -105,13 +119,3 @@ export function UserLink(props) {
: <a href={user.uri} className="info-avatar"><img src={user.avatar} />{user.uname}</a>
);
}
-
-UserInfo.propTypes = {
- user: PropTypes.string.isRequired,
- onUpdate: PropTypes.func,
- children: PropTypes.node
-};
-
-UserLink.propTypes = {
- user: UserType.isRequired
-};