1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-05-01 23:56:41 +07:00
vault-frontend/src/components/node/NodeAuthorBlock/index.tsx
2021-09-22 16:02:30 +07:00

38 lines
1 KiB
TypeScript

import React, { FC, useCallback } from 'react';
import { INode } from '~/redux/types';
import styles from './styles.module.scss';
import { CommentAvatar } from '~/components/comment/CommentAvatar';
import { openUserProfile } from '~/utils/user';
import { useRandomPhrase } from '~/constants/phrases';
interface Props {
node?: INode;
}
const NodeAuthorBlock: FC<Props> = ({ node }) => {
if (!node?.user) {
return null;
}
const { fullname, username, description, photo } = node.user;
const onOpenProfile = useCallback(() => openUserProfile(username), [username]);
return (
<div className={styles.block} onClick={onOpenProfile}>
<CommentAvatar username={username} url={photo?.url} className={styles.avatar} />
<div className={styles.info}>
<div className={styles.username}>{fullname || username}</div>
{description && (
<div className={styles.description}>
{description || useRandomPhrase('USER_DESCRIPTION')}
</div>
)}
</div>
</div>
);
};
export { NodeAuthorBlock };