import { useState } from 'react' import styled from '@emotion/styled' import { RadioGroup } from '@headlessui/react' import useLocalStorageState from '../hooks/useLocalStorageState' import useMangoGroupConfig from '../hooks/useMangoGroupConfig' import useMangoStore from '../stores/useMangoStore' import { getMarketByBaseSymbolAndKind } from '@blockworks-foundation/mango-client' const StyledMarketTypeToggleWrapper = styled.div` background: rgba(255, 255, 255, 0.12); ` const StyledArrow = styled.div` width: 0; height: 0; border-top: 20px solid transparent; border-bottom: 20px solid transparent; border-left: 20px solid rgba(255, 255, 255, 0.12); ` const MarketSelect = () => { // const [lastViewedMarket, setLastViewedMarket] = useLocalStorageState( // 'lastViewedMarket', // { baseSymbol: 'BTC', kind: 'spot' } // ) const [marketType, setMarketType] = useState('spot') const groupConfig = useMangoGroupConfig() const selectedMarket = useMangoStore((s) => s.selectedMarket.config) const setMangoStore = useMangoStore((s) => s.set) const handleChange = (symbol, kind) => { const newMarket = getMarketByBaseSymbolAndKind(groupConfig, symbol, kind) setMangoStore((state) => { state.selectedMarket.current = null state.selectedMarket.config = newMarket }) // setLastViewedMarket({ baseSymbol: symbol, kind: kind }) } const markets = marketType === 'perp' ? groupConfig.perpMarkets : groupConfig.spotMarkets return (