From bc2dae703a4947f364438a416ba5a897fcba1cfb Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Fri, 3 Nov 2023 20:39:34 +0100 Subject: [PATCH] feat(account bar): change submit link depending on location --- src/components/header/account-bar/account-bar.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/header/account-bar/account-bar.tsx b/src/components/header/account-bar/account-bar.tsx index 0d94b860..99510bb9 100644 --- a/src/components/header/account-bar/account-bar.tsx +++ b/src/components/header/account-bar/account-bar.tsx @@ -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 (
@@ -15,7 +24,7 @@ const AccountBar = () => { | - + {t('account_bar_submit')} |