import React, { useMemo } from 'react' import Link from 'next/link' import { useRouter } from 'next/router' import { Popover } from '@headlessui/react' import { ChevronDownIcon } from '@heroicons/react/24/solid' import SearchInput from 'components/SearchInput' import ProgressBar from 'components/ProgressBar' import Spinner from 'components/Spinner' import Wallet from 'components/Wallet' import { formatCurrency } from 'utils/formatters' import useCreditAccounts from 'hooks/useCreditAccounts' import useCreateCreditAccount from 'hooks/mutations/useCreateCreditAccount' import useDeleteCreditAccount from 'hooks/mutations/useDeleteCreditAccount' import useCreditManagerStore from 'stores/useCreditManagerStore' import useAccountStats from 'hooks/useAccountStats' import SemiCircleProgress from './SemiCircleProgress' import useWalletStore from 'stores/useWalletStore' import ArrowRightLine from 'components/Icons/arrow-right-line.svg' // TODO: will require some tweaks depending on how lower viewport mocks pans out const MAX_VISIBLE_CREDIT_ACCOUNTS = 5 const navItems = [ { href: '/trade', label: 'Trade' }, { href: '/earn', label: 'Earn' }, { href: '/borrow', label: 'Borrow' }, { href: '/portfolio', label: 'Portfolio' }, { href: '/council', label: 'Council' }, ] const NavLink = ({ href, children }: { href: string; children: string }) => { const router = useRouter() return ( {children} ) } const Navigation = () => { const address = useWalletStore((s) => s.address) const selectedAccount = useCreditManagerStore((s) => s.selectedAccount) const setSelectedAccount = useCreditManagerStore((s) => s.actions.setSelectedAccount) const toggleCreditManager = useCreditManagerStore((s) => s.actions.toggleCreditManager) const { data: creditAccountsList } = useCreditAccounts() const { mutate: createCreditAccount, isLoading: isLoadingCreate } = useCreateCreditAccount() const { mutate: deleteCreditAccount, isLoading: isLoadingDelete } = useDeleteCreditAccount( selectedAccount || '' ) const accountStats = useAccountStats() const { firstCreditAccounts, restCreditAccounts } = useMemo(() => { return { firstCreditAccounts: creditAccountsList?.slice(0, MAX_VISIBLE_CREDIT_ACCOUNTS) ?? [], restCreditAccounts: creditAccountsList?.slice(MAX_VISIBLE_CREDIT_ACCOUNTS) ?? [], } }, [creditAccountsList]) return (
{formatCurrency(accountStats.netWorth)}
{/* TOOLTIP */}