import Navbar from 'react-bootstrap/Navbar' import Nav from 'react-bootstrap/Nav' import Link from 'next/link' import styles from './header.module.css' import { useRouter } from 'next/router' import { Button, Container, NavDropdown, SplitButton, Dropdown } from 'react-bootstrap' import Price from './price' import { useMe } from './me' import Head from 'next/head' import { signOut, signIn, useSession } from 'next-auth/client' import { useLightning } from './lightning' import { useEffect, useState } from 'react' import { randInRange } from '../lib/rand' function WalletSummary ({ me }) { return `${me?.sats} \\ ${me?.stacked}` } function RefreshableLink ({ href, children, ...props }) { const router = useRouter() const same = router.asPath === href return ( {children} ) } export default function Header () { const router = useRouter() const path = router.asPath.split('?')[0] const me = useMe() const [session, loading] = useSession() const [sort, setSort] = useState('recent') const [within, setWithin] = useState() useEffect(() => { setSort(localStorage.getItem('sort') || 'recent') setWithin(localStorage.getItem('topWithin')) }, []) const otherSort = sort === 'recent' ? 'top' : 'recent' const sortLink = `/${sort}${sort === 'top' && within ? `/${within}` : ''}` const otherSortLink = `/${otherSort}${otherSort === 'top' && within ? `/${within}` : ''}` const Corner = () => { if (me) { return (
profile {me && !me.bio &&
{' '}
}
notifications {me?.hasNewNotes &&
{' '}
}
wallet invites {me && !me.hasInvites &&
{' '}
}
recent top {me ? ( post ) : post} jobs
logout
{me?.hasNewNotes && {' '} } {me && !me.bio && {' '} }
{me && }
) } else { if (loading || session) { return null } const strike = useLightning() useEffect(() => { setTimeout(strike, randInRange(3000, 10000)) }, [router.asPath]) return path !== '/login' && !path.startsWith('/invites') && } } return ( <> ) } export function HeaderPreview () { return ( <> ) }