import { useTranslation } from 'next-i18next' import { useEffect, useState } from 'react' import { ChevronRightIcon } from '@heroicons/react/solid' import useMangoGroupConfig from '../hooks/useMangoGroupConfig' import useMangoStore from '../stores/useMangoStore' import Link from 'next/link' import { formatUsdValue } from '../utils' import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import PageBodyContainer from '../components/PageBodyContainer' import TopBar from '../components/TopBar' export async function getStaticProps({ locale }) { return { props: { ...(await serverSideTranslations(locale, ['common', 'tv-chart'])), // Will be passed to the page component as props }, } } const SelectMarket = () => { const { t } = useTranslation('common') const groupConfig = useMangoGroupConfig() const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current) const mangoCache = useMangoStore((s) => s.selectedMangoGroup.cache) const [markets, setMarkets] = useState([]) useEffect(() => { const markets = [] const allMarkets = [...groupConfig.spotMarkets, ...groupConfig.perpMarkets] allMarkets.forEach((market) => { const base = market.name.slice(0, -5) const found = markets.find((b) => b.baseAsset === base) if (!found) { markets.push({ baseAsset: base, markets: [market] }) } else { found.markets.push(market) } }) setMarkets(markets) }, []) return (
{t('markets')}
{markets.map((mkt) => (
{mkt.baseAsset}
{mangoGroup ? mkt.markets.map((m) => ( )) : null}
))} {/* spacer so last market can be selected albeit bottom bar overlay */}

) } export default SelectMarket