refactor: make components for rules, description, rename stats

This commit is contained in:
plebeius.eth
2024-04-09 15:03:26 +02:00
parent 6c86cc0124
commit 9aab7624ec
11 changed files with 69 additions and 59 deletions
-1
View File
@@ -1 +0,0 @@
export { default } from './board-stats';
@@ -0,0 +1 @@
export { default } from './subplebbit-description';
@@ -0,0 +1,26 @@
import Post from '../post';
interface DescriptionPostProps {
subplebbitAddress: string | undefined;
createdAt: number;
description: string;
avatarUrl?: string;
title: string;
}
export const SubplebbitDescription = ({ subplebbitAddress, createdAt, description, avatarUrl, title }: DescriptionPostProps) => {
const post = {
isDescription: true,
subplebbitAddress,
timestamp: createdAt,
author: { displayName: '## Board Mods' },
content: description,
link: avatarUrl,
title: 'Welcome to ' + title,
pinned: true,
locked: true,
};
return <Post post={post} />;
};
export default SubplebbitDescription;
+1
View File
@@ -0,0 +1 @@
export { default } from './subplebbit-rules';
@@ -0,0 +1,25 @@
import Post from '../post';
interface RulesPostProps {
subplebbitAddress: string | undefined;
createdAt: number;
rules: string[];
}
export const SubplebbitRules = ({ subplebbitAddress, createdAt, rules }: RulesPostProps) => {
const content = rules.map((rule, index) => `${index + 1}. ${rule}`).join('\n');
const post = {
isRules: true,
subplebbitAddress,
timestamp: createdAt,
author: { displayName: '## Board Mods' },
content,
title: 'Rules',
pinned: true,
locked: true,
};
return <Post post={post} />;
};
export default SubplebbitRules;
+1
View File
@@ -0,0 +1 @@
export { default } from './subplebbit-stats';
@@ -1,11 +1,11 @@
import { useState } from 'react';
import { useLocation, useParams } from 'react-router-dom';
import { useComment, useSubplebbit, useSubplebbitStats } from '@plebbit/plebbit-react-hooks';
import styles from './board-stats.module.css';
import styles from './subplebbit-stats.module.css';
import { Trans, useTranslation } from 'react-i18next';
import { isDescriptionView, isRulesView } from '../../lib/utils/view-utils';
const BoardStats = () => {
const SubplebbitStats = () => {
const { t } = useTranslation();
const { commentCid, subplebbitAddress } = useParams<{ subplebbitAddress: string; commentCid: string }>();
@@ -103,4 +103,4 @@ const BoardStats = () => {
);
};
export default BoardStats;
export default SubplebbitStats;