import numeral from 'numeral' import Link from 'next/link' import { Address } from 'viem' import { useEffect, useState } from 'react' import { useAccount, useSwitchChain } from 'wagmi' import { ChevronLeftIcon } from '@heroicons/react/outline' import { useTranslations } from 'next-intl' import Card from '@tw/Card' import Grid from '@tw/Grid' import { zeroAddress } from 'viem' import { PoolActionOptions } from '@/components/Pools/PoolActionOptions' import { TransactionButton } from '@/components/buttons/TransactionButton' import { useConnectModal } from '@rainbow-me/rainbowkit' import { segmentAnalyticsEvent } from '@/contexts/SegmentAnalyticsProvider' import { DisplayBalances } from '../pools/PoolCard' import { usePoolDataState, usePoolUserDataState } from '@/slices/pools/hooks' import { POOLS_PATH } from '@urls' import PoolTitle from './components/PoolTitle' import PoolInfoSection from './PoolInfoSection' import PoolManagement from './poolManagement' const PoolBody = ({ address, connectedChainId, }: { address?: Address connectedChainId?: number }) => { const [isClient, setIsClient] = useState(false) const { chains, switchChain } = useSwitchChain() const { openConnectModal } = useConnectModal() const { isConnected } = useAccount() const { poolUserData } = usePoolUserDataState() const { pool, poolAPYData } = usePoolDataState() const t = useTranslations('Pools') useEffect(() => { setIsClient(true) }, []) useEffect(() => { if (pool && isClient) { segmentAnalyticsEvent(`[Pool] arrives`, { poolName: pool?.poolName, }) } }, [isClient, address, pool]) if (!pool) return null return ( <>