import { useParams } from 'react-router-dom'; import { Trans, useTranslation } from 'react-i18next'; import { useAccountComment, useSubplebbit, useSubplebbitStats } from '@plebbit/plebbit-react-hooks'; import useSubplebbitsPagesStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits-pages'; import useSubplebbitStatsVisibilityStore from '../../stores/use-subplebbit-stats-visibility-store'; import { useResolvedSubplebbitAddress } from '../../hooks/use-resolved-subplebbit-address'; import styles from './subplebbit-stats.module.css'; const SubplebbitStats = () => { const { t } = useTranslation(); const params = useParams(); const accountComment = useAccountComment({ commentIndex: params?.accountCommentIndex as any }); const resolvedAddress = useResolvedSubplebbitAddress(); const subplebbitAddress = resolvedAddress || accountComment?.subplebbitAddress; const subplebbit = useSubplebbit({ subplebbitAddress }); const { address, createdAt } = subplebbit || {}; const stats = useSubplebbitStats({ subplebbitAddress: address }); const { hiddenStats, toggleVisibility } = useSubplebbitStatsVisibilityStore(); const isHidden = hiddenStats[address]; const comment = useSubplebbitsPagesStore((state) => state.comments[params?.commentCid as string]); const { deleted, locked, removed } = comment || {}; const hideStats = deleted || locked || removed; const unixToMMDDYYYY = (timestamp: number) => { const date = new Date(timestamp * 1000); const month = ('0' + (date.getMonth() + 1)).slice(-2); const day = ('0' + date.getDate()).slice(-2); const year = date.getFullYear().toString().slice(-2); return month + '/' + day + '/' + year; }; return (
{!isHidden && ( )}

}} /> {' / '} }} />
}} /> {' / '} }} />
{createdAt && unixToMMDDYYYY(createdAt)} {t('board_created')} {' / '} }} />
[ toggleVisibility(address)}> {isHidden ? t('show_stats') : t('hide')} ]
); }; export default SubplebbitStats;