diff --git a/pages/token/[token].tsx b/pages/token/[token].tsx index dfc04701..b3f4809a 100644 --- a/pages/token/[token].tsx +++ b/pages/token/[token].tsx @@ -21,9 +21,7 @@ import Link from 'next/link' import SheenLoader from '@components/shared/SheenLoader' import Tooltip from '@components/shared/Tooltip' import { COLORS } from 'styles/colors' -import DetailedAreaChart, { - formatDateAxis, -} from '@components/shared/DetailedAreaChart' +import { formatDateAxis } from '@components/shared/DetailedAreaChart' import { Area, AreaChart, ResponsiveContainer, XAxis, YAxis } from 'recharts' import { useTheme } from 'next-themes' import ChartRangeButtons from '@components/shared/ChartRangeButtons' @@ -74,7 +72,6 @@ const Token: NextPage = () => { const group = mangoStore((s) => s.group) const mangoAccount = mangoStore((s) => s.mangoAccount.current) const jupiterTokens = mangoStore((s) => s.jupiterTokens) - const { theme } = useTheme() const coingeckoPrices = mangoStore((s) => s.coingeckoPrices.data) const [chartData, setChartData] = useState<{ prices: any[] } | null>(null) const [loadChartData, setLoadChartData] = useState(true) @@ -178,15 +175,6 @@ const Token: NextPage = () => { return [] }, [coingeckoPrices, bank, daysToShow, chartData, loadingChart]) - const change = useMemo(() => { - return coingeckoTokenPrices.length - ? ((coingeckoTokenPrices[coingeckoTokenPrices.length - 1][1] - - coingeckoTokenPrices[0][1]) / - coingeckoTokenPrices[0][1]) * - 100 - : 0 - }, [coingeckoTokenPrices]) - const handleDaysToShow = async (days: number) => { if (days !== 1) { try { @@ -385,84 +373,10 @@ const Token: NextPage = () => { onChange={(v) => handleDaysToShow(v)} /> -
{t('unavailable')}
@@ -603,3 +517,84 @@ const Token: NextPage = () => { } export default Token + +const PriceChart = ({ + prices, + daysToShow, +}: { + prices: number[][] + daysToShow: number +}) => { + const { theme } = useTheme() + + const change = useMemo(() => { + return prices[prices.length - 1][1] - prices[0][1] + }, [prices]) + + return ( +