feat(post page): add view specific buttons

This commit is contained in:
plebeius.eth
2024-04-03 22:52:27 +02:00
parent b5fec98f9d
commit f5fefd51cf
6 changed files with 101 additions and 28 deletions
+6 -3
View File
@@ -1,6 +1,8 @@
import { useState } from 'react';
import styles from './post-form.module.css';
import { useTranslation } from 'react-i18next';
import styles from './post-form.module.css';
import { isPostPageView } from '../../lib/utils/view-utils';
import { useLocation, useParams } from 'react-router-dom';
export interface PostFormProps {
address: string | undefined;
@@ -9,19 +11,20 @@ export interface PostFormProps {
const PostForm = ({ address }: PostFormProps) => {
const { t } = useTranslation();
const [showForm, setShowForm] = useState(false);
const isInPostPage = isPostPageView(useLocation().pathname, useParams());
return (
<>
<div className={styles.postFormButtonDesktop}>
[
<button className='button' onClick={() => setShowForm(true)}>
{t('start_new_thread')}
{isInPostPage ? t('post_a_reply') : t('start_new_thread')}
</button>
]
</div>
<div className={styles.postFormButtonMobile}>
<button className='button' onClick={() => setShowForm(!showForm)}>
{showForm ? t('close_post_form') : t('start_new_thread')}
{showForm ? t('close_post_form') : isInPostPage ? t('post_a_reply') : t('start_new_thread')}
</button>
</div>
</>