2021-04-06 15:11:42 -07:00
|
|
|
import useMarketList from '../hooks/useMarketList'
|
|
|
|
import useMangoStore from '../stores/useMangoStore'
|
|
|
|
|
|
|
|
const MarketSelect = () => {
|
|
|
|
const { spotMarkets } = useMarketList()
|
|
|
|
const selectedMarket = useMangoStore((s) => s.selectedMarket)
|
|
|
|
const setMangoStore = useMangoStore((s) => s.set)
|
|
|
|
|
|
|
|
const handleChange = (mktName) => {
|
|
|
|
setMangoStore((state) => {
|
|
|
|
state.selectedMarket = { name: mktName, address: spotMarkets[mktName] }
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-04-12 09:49:02 -07:00
|
|
|
<div className={`bg-th-bkg-3`}>
|
2021-04-19 06:45:59 -07:00
|
|
|
<div className={`flex items-center py-2 px-4 sm:px-10`}>
|
|
|
|
{/* <div className="text-xs text-th-fgd-4 font-semibold mr-2">MARKETS</div> */}
|
2021-04-12 09:20:17 -07:00
|
|
|
{Object.entries(spotMarkets).map(([name, address]) => (
|
|
|
|
<div
|
2021-04-19 06:45:59 -07:00
|
|
|
className={`px-2 py-1 mr-2 rounded-md cursor-pointer default-transition bg-th-bkg-2
|
2021-04-12 09:49:02 -07:00
|
|
|
${
|
|
|
|
selectedMarket.name === name
|
2021-04-12 13:01:55 -07:00
|
|
|
? `text-th-primary`
|
2021-04-19 06:45:59 -07:00
|
|
|
: `text-th-fgd-1 opacity-50 hover:opacity-100`
|
2021-04-12 09:49:02 -07:00
|
|
|
}
|
|
|
|
`}
|
2021-04-12 09:20:17 -07:00
|
|
|
onClick={() => handleChange(name)}
|
2021-04-19 09:15:49 -07:00
|
|
|
key={address as string}
|
2021-04-12 09:20:17 -07:00
|
|
|
>
|
2021-04-19 09:15:49 -07:00
|
|
|
{name}
|
2021-04-12 09:20:17 -07:00
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
2021-04-06 15:11:42 -07:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MarketSelect
|