mirror of
https://github.com/plebbit/seedit.git
synced 2026-05-19 14:19:24 -04:00
feat(pending post): add pending post component and route
This commit is contained in:
@@ -8,6 +8,7 @@ import TopBar from './components/topbar/topbar';
|
||||
import Header from './components/header/header';
|
||||
import Submit from './views/submit/submit';
|
||||
import Settings from './views/settings';
|
||||
import PendingPost from './views/pending-post';
|
||||
|
||||
function App() {
|
||||
const [theme] = useTheme();
|
||||
@@ -34,6 +35,7 @@ function App() {
|
||||
<Route path='p/:subplebbitAddress/c/:commentCid' element={<Post />} />
|
||||
<Route path='p/:subplebbitAddress/submit' element={<Submit />} />
|
||||
<Route path='/settings' element={<Settings />} />
|
||||
<Route path='/profile/:accountCommentIndex' element={<PendingPost />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</div>
|
||||
|
||||
@@ -41,7 +41,9 @@ const Header = () => {
|
||||
|
||||
const commentsButton = (
|
||||
<li>
|
||||
<Link to={`/p/${subplebbitAddress}/c/${commentCid}`} className={styles.selected}>{t('header_comments')}</Link>
|
||||
<Link to={`/p/${subplebbitAddress}/c/${commentCid}`} className={styles.selected}>
|
||||
{t('header_comments')}
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
let headerTabs;
|
||||
@@ -63,10 +65,14 @@ const Header = () => {
|
||||
</Link>
|
||||
);
|
||||
let headerTitle;
|
||||
const submitTitle = <span style={{textTransform: 'uppercase'}}>{t('submit')}</span>;
|
||||
const submitTitle = <span style={{ textTransform: 'uppercase' }}>{t('submit')}</span>;
|
||||
|
||||
if (isSubplebbitSubmitView) {
|
||||
headerTitle = <>{subplebbitTitle}: {submitTitle}</>;
|
||||
headerTitle = (
|
||||
<>
|
||||
{subplebbitTitle}: {submitTitle}
|
||||
</>
|
||||
);
|
||||
} else if (isPostView || isSubplebbitView) {
|
||||
headerTitle = subplebbitTitle;
|
||||
} else if (isSubmitView) {
|
||||
|
||||
1
src/views/pending-post/index.ts
Normal file
1
src/views/pending-post/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export {default} from './pending-post'
|
||||
0
src/views/pending-post/pending-post.module.css
Normal file
0
src/views/pending-post/pending-post.module.css
Normal file
27
src/views/pending-post/pending-post.tsx
Normal file
27
src/views/pending-post/pending-post.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useAccountComment } from '@plebbit/plebbit-react-hooks';
|
||||
import Post from '../../components/post';
|
||||
|
||||
const PendingPost = () => {
|
||||
const { accountCommentIndex } = useParams<{ accountCommentIndex?: string }>();
|
||||
const commentIndex = accountCommentIndex ? parseInt(accountCommentIndex) : undefined;
|
||||
const post = useAccountComment({ commentIndex });
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => window.scrollTo(0, 0), []);
|
||||
|
||||
useEffect(() => {
|
||||
if (post?.cid && post?.subplebbitAddress) {
|
||||
navigate(`/p/${post?.subplebbitAddress}/c/${post?.cid}`, { replace: true });
|
||||
}
|
||||
}, [post]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Post post={post} isPostView={true} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default PendingPost;
|
||||
Reference in New Issue
Block a user