2024-03-22 12:22:20 +01:00
|
|
|
import { useState } from 'react';
|
2024-03-20 13:08:08 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2024-04-03 22:52:27 +02:00
|
|
|
import styles from './post-form.module.css';
|
|
|
|
|
import { isPostPageView } from '../../lib/utils/view-utils';
|
|
|
|
|
import { useLocation, useParams } from 'react-router-dom';
|
2024-03-20 13:00:11 +01:00
|
|
|
|
2024-03-20 14:31:31 +01:00
|
|
|
export interface PostFormProps {
|
|
|
|
|
address: string | undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const PostForm = ({ address }: PostFormProps) => {
|
2024-03-20 13:08:08 +01:00
|
|
|
const { t } = useTranslation();
|
2024-03-22 12:22:20 +01:00
|
|
|
const [showForm, setShowForm] = useState(false);
|
2024-04-03 22:52:27 +02:00
|
|
|
const isInPostPage = isPostPageView(useLocation().pathname, useParams());
|
2024-03-20 13:08:08 +01:00
|
|
|
|
2024-03-20 13:00:11 +01:00
|
|
|
return (
|
2024-03-21 15:21:33 +01:00
|
|
|
<>
|
|
|
|
|
<div className={styles.postFormButtonDesktop}>
|
2024-03-22 12:22:20 +01:00
|
|
|
[
|
|
|
|
|
<button className='button' onClick={() => setShowForm(true)}>
|
2024-04-03 22:52:27 +02:00
|
|
|
{isInPostPage ? t('post_a_reply') : t('start_new_thread')}
|
2024-03-22 12:22:20 +01:00
|
|
|
</button>
|
|
|
|
|
]
|
2024-03-21 15:21:33 +01:00
|
|
|
</div>
|
|
|
|
|
<div className={styles.postFormButtonMobile}>
|
2024-03-22 12:22:20 +01:00
|
|
|
<button className='button' onClick={() => setShowForm(!showForm)}>
|
2024-04-03 22:52:27 +02:00
|
|
|
{showForm ? t('close_post_form') : isInPostPage ? t('post_a_reply') : t('start_new_thread')}
|
2024-03-22 12:22:20 +01:00
|
|
|
</button>
|
2024-03-21 15:21:33 +01:00
|
|
|
</div>
|
|
|
|
|
</>
|
2024-03-20 13:00:11 +01:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default PostForm;
|