mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-26 21:36:40 +07:00
refactored node comments to component
This commit is contained in:
parent
b44266437d
commit
ab15a10d01
13 changed files with 208 additions and 111 deletions
|
@ -1,26 +1,24 @@
|
|||
import React, { FC, useCallback } from 'react';
|
||||
import { INode } from '~/redux/types';
|
||||
import styles from './styles.module.scss';
|
||||
import { Avatar } from '~/components/common/Avatar';
|
||||
import { openUserProfile } from '~/utils/user';
|
||||
import { useUserDescription } from '~/utils/hooks/user/useUserDescription';
|
||||
import { INodeUser } from '~/redux/types';
|
||||
|
||||
interface Props {
|
||||
node?: INode;
|
||||
user?: INodeUser;
|
||||
}
|
||||
|
||||
const NodeAuthorBlock: FC<Props> = ({ node }) => {
|
||||
const onOpenProfile = useCallback(() => openUserProfile(node?.user?.username), [
|
||||
node?.user?.username,
|
||||
]);
|
||||
const NodeAuthorBlock: FC<Props> = ({ user }) => {
|
||||
const onOpenProfile = useCallback(() => openUserProfile(user?.username), [user?.username]);
|
||||
|
||||
const description = useUserDescription(node?.user);
|
||||
const description = useUserDescription(user);
|
||||
|
||||
if (!node?.user) {
|
||||
if (!user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { fullname, username, photo } = node.user;
|
||||
const { fullname, username, photo } = user;
|
||||
|
||||
return (
|
||||
<div className={styles.block} onClick={onOpenProfile}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue