import React, { memo, VFC } from "react"; import styles from "./styles.module.scss"; import { Icon } from "~/components/input/Icon"; import classNames from "classnames"; import { Placeholder } from "~/components/placeholders/Placeholder"; import { getPrettyDate } from "~/utils/dom"; import { URLS } from "~/constants/urls"; import { Link } from "react-router-dom"; interface IProps { id?: number; title: string; username?: string; createdAt: string; likeCount: number; isHeroic: boolean; isLocked: boolean; isLiked: boolean; canEdit: boolean; canLike: boolean; canStar: boolean; isLoading: boolean; onLike: () => void; onStar: () => void; onLock: () => void; } const NodeTitle: VFC = memo( ({ id, title, username, createdAt, likeCount, isHeroic, isLocked, isLiked, canStar, canEdit, canLike, isLoading, onStar, onLike, onLock, }) => { return (
{isLoading ? : title || '...'}
{!!username && (
{isLoading ? ( ) : ( `~${username.toLocaleLowerCase()}, ${getPrettyDate(createdAt)}` )}
)}
{canEdit && (
{canStar && (
{isHeroic ? ( ) : ( )}
)}
{!!id && ( )}
)}
{canLike && (
{isLiked ? ( ) : ( )} {!!likeCount && likeCount > 0 && (
{likeCount}
)}
)}
); } ); export { NodeTitle };