simplify logic determining if territory select is shown

This commit is contained in:
keyan 2024-03-27 16:29:04 -05:00
parent 2575a4a494
commit 6054afa10c
4 changed files with 13 additions and 27 deletions

View File

@ -33,25 +33,11 @@ export function Brand ({ className }) {
) )
} }
export function noNavSelect ({ path, pathname }) { export function hasNavSelect ({ path, pathname }) {
return ( return (
path.startsWith('/items') || pathname.startsWith('/~') &&
path.endsWith('/post') || !path.endsWith('/post') &&
path.endsWith('/edit') || !path.endsWith('/edit')
path.endsWith('/notifications') ||
path.endsWith('/search') ||
path.startsWith('/wallet') ||
path.startsWith('/rewards') ||
path.startsWith('/referrals') ||
path.startsWith('/live') ||
path.startsWith('/settings') ||
path.startsWith('/invites') ||
path.startsWith('/stackers') ||
path.startsWith('/satistics') ||
path.startsWith('/withdrawals') ||
path.startsWith('/invoices') ||
pathname.startsWith('/[name]') ||
path.startsWith('/territory')
) )
} }

View File

@ -1,10 +1,10 @@
import { Nav, Navbar } from 'react-bootstrap' import { Nav, Navbar } from 'react-bootstrap'
import { NavSelect, PostItem, Sorts, noNavSelect } from '../common' import { NavSelect, PostItem, Sorts, hasNavSelect } from '../common'
import styles from '../../header.module.css' import styles from '../../header.module.css'
export default function SecondBar (props) { export default function SecondBar (props) {
const { prefix, topNavKey, sub } = props const { prefix, topNavKey, sub } = props
if (noNavSelect(props)) return null if (!hasNavSelect(props)) return null
return ( return (
<Navbar className='pt-0 pb-3'> <Navbar className='pt-0 pb-3'>
<Nav <Nav

View File

@ -1,10 +1,10 @@
import { Nav, Navbar } from 'react-bootstrap' import { Nav, Navbar } from 'react-bootstrap'
import { NavPrice, Sorts, noNavSelect } from '../common' import { NavPrice, Sorts, hasNavSelect } from '../common'
import styles from '../../header.module.css' import styles from '../../header.module.css'
export default function SecondBar (props) { export default function SecondBar (props) {
const { topNavKey } = props const { topNavKey } = props
if (noNavSelect(props)) return null if (!hasNavSelect(props)) return null
return ( return (
<Navbar> <Navbar>
<Nav <Nav

View File

@ -1,6 +1,6 @@
import { Nav, Navbar } from 'react-bootstrap' import { Nav, Navbar } from 'react-bootstrap'
import styles from '../../header.module.css' import styles from '../../header.module.css'
import { Back, NavPrice, NavSelect, NavWalletSummary, SignUpButton, noNavSelect } from '../common' import { Back, NavPrice, NavSelect, NavWalletSummary, SignUpButton, hasNavSelect } from '../common'
import { useMe } from '@/components/me' import { useMe } from '@/components/me'
export default function TopBar ({ prefix, sub, path, pathname, topNavKey, dropNavKey }) { export default function TopBar ({ prefix, sub, path, pathname, topNavKey, dropNavKey }) {
@ -12,13 +12,13 @@ export default function TopBar ({ prefix, sub, path, pathname, topNavKey, dropNa
activeKey={topNavKey} activeKey={topNavKey}
> >
<Back className='d-flex d-md-none' /> <Back className='d-flex d-md-none' />
{noNavSelect({ path, pathname }) {hasNavSelect({ path, pathname })
? ( ? <NavSelect sub={sub} className='w-100' />
: (
<> <>
<NavPrice className='flex-shrink-1' /> <NavPrice className='flex-shrink-1' />
{me ? <NavWalletSummary /> : <SignUpButton />} {me ? <NavWalletSummary /> : <SignUpButton />}
</>) </>)}
: <NavSelect sub={sub} className='w-100' />}
</Nav> </Nav>
</Navbar> </Navbar>
) )