import React from 'react' import Link from 'next/link' import { EyeIcon, EyeOffIcon } from '@heroicons/react/outline' import { ChevronRightIcon } from '@heroicons/react/solid' import Modal from './Modal' import useLocalStorageState from '../hooks/useLocalStorageState' import useMangoStore from '../stores/useMangoStore' import { formatUsdValue } from '../utils' import { LinkButton } from './Button' const MarketsModal = ({ isOpen, markets, onClose, }: { isOpen: boolean markets: Array onClose?: (x?) => void }) => { const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current) const mangoCache = useMangoStore((s) => s.selectedMangoGroup.cache) const [hiddenMarkets, setHiddenMarkets] = useLocalStorageState( 'hiddenMarkets', [] ) const handleHideShowMarket = (asset) => { if (hiddenMarkets.includes(asset)) { setHiddenMarkets(hiddenMarkets.filter((m) => m !== asset)) } else { setHiddenMarkets(hiddenMarkets.concat(asset)) } } return (
Markets
{hiddenMarkets.length === 0 ? ( setHiddenMarkets(markets.map((mkt) => mkt.baseAsset)) } > Hide all from Nav ) : ( setHiddenMarkets([])} > Show all in Nav )}
{markets.map((mkt, index) => (
{mkt.baseAsset}
{hiddenMarkets.includes(mkt.baseAsset) ? ( handleHideShowMarket(mkt.baseAsset)} /> ) : ( handleHideShowMarket(mkt.baseAsset)} /> )}
{/*
Markets
Price 24h Change 24h Vol
*/}
{mkt.markets.map((m) => (
{m.name}
{formatUsdValue(mangoGroup.getPrice(index, mangoCache))} {/* +2.44% $233m */}
))}
))}
) } export default React.memo(MarketsModal)