feat(account bar): change submit link depending on location

This commit is contained in:
plebeius.eth
2023-11-03 20:39:34 +01:00
parent dd2ec3671a
commit bc2dae703a

View File

@@ -1,11 +1,20 @@
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { Link, useLocation, useParams } from 'react-router-dom';
import styles from './account-bar.module.css';
import { useAccount } from '@plebbit/plebbit-react-hooks';
const AccountBar = () => {
const account = useAccount();
const { t } = useTranslation();
const location = useLocation();
const { subplebbitAddress } = useParams();
let submitLink;
if (location.pathname.startsWith(`/p/${subplebbitAddress}/`)) {
submitLink = `/p/${subplebbitAddress}/submit`;
} else {
submitLink = '/submit';
}
return (
<div className={styles.header}>
@@ -15,7 +24,7 @@ const AccountBar = () => {
</Link>
</span>
<span className={styles.separator}>|</span>
<Link to='/submit' className={styles.preferences}>
<Link to={submitLink} className={styles.preferences}>
{t('account_bar_submit')}
</Link>
<span className={styles.separator}>|</span>