import Link from 'next/link' import { Button, Dropdown, Nav, Navbar } from 'react-bootstrap' import styles from '../header.module.css' import { useRouter } from 'next/router' import BackArrow from '../../svgs/arrow-left-line.svg' import { useCallback, useEffect, useState } from 'react' import Price from '../price' import SubSelect from '../sub-select' import { USER_ID, BALANCE_LIMIT_MSATS } from '../../lib/constants' import Head from 'next/head' import NoteIcon from '../../svgs/notification-4-fill.svg' import { useMe } from '../me' import HiddenWalletSummary from '../hidden-wallet-summary' import { abbrNum, msatsToSats } from '../../lib/format' import { useServiceWorker } from '../serviceworker' import { signOut } from 'next-auth/react' import Hat from '../hat' import { randInRange } from '../../lib/rand' import { useLightning } from '../lightning' import LightningIcon from '../../svgs/bolt.svg' import SearchIcon from '../../svgs/search-line.svg' import classNames from 'classnames' import SnIcon from '@/svgs/sn.svg' import { useHasNewNotes } from '../use-has-new-notes' import { useWallets } from 'wallets' import SwitchAccountList, { useAccounts } from '@/components/account' import { useShowModal } from '@/components/modal' export function Brand ({ className }) { return ( ) } export function hasNavSelect ({ path, pathname }) { return ( pathname.startsWith('/~') && !path.endsWith('/post') && !path.endsWith('/edit') ) } export function Back () { const router = useRouter() const [back, setBack] = useState(router.asPath !== '/') useEffect(() => { setBack(router.asPath !== '/' && (typeof window.navigation === 'undefined' || window.navigation.canGoBack === undefined || window?.navigation.canGoBack)) }, [router.asPath]) if (!back) return null return ( { if (back) { router.back() } else { router.push('/') } }} > ) } export function BackOrBrand ({ className }) { const router = useRouter() const [back, setBack] = useState(router.asPath !== '/') useEffect(() => { setBack(router.asPath !== '/' && (typeof window.navigation === 'undefined' || window.navigation.canGoBack === undefined || window?.navigation.canGoBack)) }, [router.asPath]) return (
{back ? : }
) } export function SearchItem ({ prefix, className }) { return ( ) } export function NavPrice ({ className }) { return ( ) } const PREPEND_SUBS = ['home'] const APPEND_SUBS = [{ label: '--------', items: ['create'] }] export function NavSelect ({ sub: subName, className, size }) { const sub = subName || 'home' return ( ) } export function NavNotifications ({ className }) { const hasNewNotes = useHasNewNotes() return ( <> {hasNewNotes && {' '} } ) } export function WalletSummary () { const { me } = useMe() if (!me) return null if (me.privates?.hideWalletBalance) { return } return `${abbrNum(me.privates?.sats)}` } export function NavWalletSummary ({ className }) { const { me } = useMe() const walletLimitReached = me?.privates?.sats >= msatsToSats(BALANCE_LIMIT_MSATS) return ( ) } export function MeDropdown ({ me, dropNavKey }) { if (!me) return null return (
{`@${me.name}`} profile {me && !me.bioId &&
{' '}
}
bookmarks wallet satistics referrals
settings
{!me.bioId && {' '} }
) } export function SignUpButton ({ className = 'py-0', width }) { const router = useRouter() const handleLogin = useCallback(async pathname => await router.push({ pathname, query: { callbackUrl: window.location.origin + router.asPath } }), [router]) return ( ) } export default function LoginButton () { const router = useRouter() const handleLogin = useCallback(async pathname => await router.push({ pathname, query: { callbackUrl: window.location.origin + router.asPath } }), [router]) return ( ) } function LogoutObstacle ({ onClose }) { const { registration: swRegistration, togglePushSubscription } = useServiceWorker() const wallets = useWallets() const { multiAuthSignout } = useAccounts() return (

I reckon you want to logout?

) } export function LogoutDropdownItem ({ handleClose }) { const showModal = useShowModal() return ( <> { handleClose?.() showModal(onClose => ) }} >switch account { showModal(onClose => ()) }} >logout ) } function SwitchAccountButton ({ handleClose }) { const showModal = useShowModal() const { accounts } = useAccounts() if (accounts.length === 0) return null return ( ) } export function LoginButtons ({ handleClose }) { return ( <> ) } export function AnonDropdown ({ path }) { const strike = useLightning() useEffect(() => { if (!window.localStorage.getItem('striked')) { const to = setTimeout(() => { strike() window.localStorage.setItem('striked', 'yep') }, randInRange(3000, 10000)) return () => clearTimeout(to) } }, []) return (
@anon
) } export function Sorts ({ sub, prefix, className }) { return ( <> hot recent {sub !== 'jobs' && <> random top } ) } export function PostItem ({ className, prefix }) { return ( post ) } export function MeCorner ({ dropNavKey, me, className }) { return (
) } export function AnonCorner ({ dropNavKey, className }) { return (
) }