1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-26 13:26:40 +07:00
vault-frontend/src/components/node/NodeAuthorBlock/index.tsx
2022-01-09 19:03:01 +07:00

35 lines
992 B
TypeScript

import React, { FC, useCallback } from 'react';
import styles from './styles.module.scss';
import { Avatar } from '~/components/common/Avatar';
import { openUserProfile } from '~/utils/user';
import { useUserDescription } from '~/hooks/auth/useUserDescription';
import { INodeUser } from '~/types';
interface Props {
user?: INodeUser;
}
const NodeAuthorBlock: FC<Props> = ({ user }) => {
const onOpenProfile = useCallback(() => openUserProfile(user?.username), [user]);
const description = useUserDescription(user);
if (!user) {
return null;
}
const { fullname, username, photo } = user;
return (
<div className={styles.block} onClick={onOpenProfile}>
<Avatar username={username} url={photo?.url} className={styles.avatar} />
<div className={styles.info}>
<div className={styles.username}>{fullname || username}</div>
<div className={styles.description}>{description}</div>
</div>
</div>
);
};
export { NodeAuthorBlock };