Files
5chan/src/components/post-form/post-form.tsx
T

35 lines
1.1 KiB
TypeScript
Raw Normal View History

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
export interface PostFormProps {
address: string | undefined;
}
const PostForm = ({ address }: PostFormProps) => {
2024-03-20 13:08:08 +01:00
const { t } = useTranslation();
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}>
[
<button className='button' onClick={() => setShowForm(true)}>
2024-04-03 22:52:27 +02:00
{isInPostPage ? t('post_a_reply') : t('start_new_thread')}
</button>
]
2024-03-21 15:21:33 +01:00
</div>
<div className={styles.postFormButtonMobile}>
<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')}
</button>
2024-03-21 15:21:33 +01:00
</div>
</>
2024-03-20 13:00:11 +01:00
);
};
export default PostForm;