2022-12-06 09:20:22 +00:00
|
|
|
import Link from 'next/link'
|
|
|
|
|
2022-12-08 20:14:38 +00:00
|
|
|
import { AccountNavigation, AccountStatus } from 'components/Account'
|
2022-12-06 09:20:22 +00:00
|
|
|
import Logo from 'components/Icons/logo.svg'
|
|
|
|
import { menuTree, NavLink } from 'components/Navigation'
|
|
|
|
import SearchInput from 'components/Navigation/SearchInput'
|
2022-12-08 20:14:38 +00:00
|
|
|
import Wallet from 'components/Wallet/Wallet'
|
2022-12-06 09:20:22 +00:00
|
|
|
import useCreditAccounts from 'hooks/useCreditAccounts'
|
2022-12-08 20:14:38 +00:00
|
|
|
import { useAccountDetailsStore, useWalletStore } from 'stores'
|
2022-12-06 09:20:22 +00:00
|
|
|
|
|
|
|
const Navigation = () => {
|
|
|
|
const address = useWalletStore((s) => s.address)
|
2022-12-08 20:14:38 +00:00
|
|
|
const selectedAccount = useAccountDetailsStore((s) => s.selectedAccount)
|
2022-12-06 09:20:22 +00:00
|
|
|
|
2022-12-08 20:14:38 +00:00
|
|
|
const { data: creditAccountsList } = useCreditAccounts()
|
2022-12-06 09:20:22 +00:00
|
|
|
|
|
|
|
const isConnected = !!address
|
|
|
|
const hasCreditAccounts = creditAccountsList && creditAccountsList.length > 0
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='relative hidden bg-header lg:block'>
|
|
|
|
<div className='flex items-center justify-between border-b border-white/20 px-6 py-3'>
|
|
|
|
<div className='flex flex-grow items-center'>
|
|
|
|
<Link href='/trade' passHref>
|
|
|
|
<span className='h-10 w-10'>
|
|
|
|
<Logo />
|
|
|
|
</span>
|
|
|
|
</Link>
|
|
|
|
<div className='flex gap-8 px-6'>
|
|
|
|
{menuTree.map((item, index) => (
|
|
|
|
<NavLink key={index} href={item.href}>
|
|
|
|
{item.label}
|
|
|
|
</NavLink>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<Wallet />
|
|
|
|
</div>
|
|
|
|
{/* Sub navigation bar */}
|
|
|
|
<div className='flex items-center justify-between border-b border-white/20 pl-6 text-sm text-white/40'>
|
|
|
|
<div className='flex items-center'>
|
|
|
|
<SearchInput />
|
|
|
|
{isConnected && hasCreditAccounts && (
|
2022-12-08 20:14:38 +00:00
|
|
|
<AccountNavigation
|
2022-12-06 09:20:22 +00:00
|
|
|
selectedAccount={selectedAccount}
|
|
|
|
creditAccountsList={creditAccountsList}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
2022-12-08 20:14:38 +00:00
|
|
|
{isConnected && <AccountStatus />}
|
2022-12-06 09:20:22 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Navigation
|