import { formatCurrencyValue } from '../../utils/numbers' import FlipNumbers from 'react-flip-numbers' import SimpleAreaChart from '@components/shared/SimpleAreaChart' import { COLORS } from '../../styles/colors' import { IconButton } from '../shared/Button' import { ArrowsPointingOutIcon } from '@heroicons/react/20/solid' import { Transition } from '@headlessui/react' import SheenLoader from '../shared/SheenLoader' import Change from '../shared/Change' import FormatNumericValue from '@components/shared/FormatNumericValue' import useLocalStorageState from 'hooks/useLocalStorageState' import { ANIMATION_SETTINGS_KEY } from 'utils/constants' import { INITIAL_ANIMATION_SETTINGS } from '@components/settings/AnimationSettings' import useMangoGroup from 'hooks/useMangoGroup' import useMangoAccount from 'hooks/useMangoAccount' import { PerformanceDataItem } from 'types' import { useMemo, useState } from 'react' import { useTranslation } from 'next-i18next' import { useViewport } from 'hooks/useViewport' import { breakpoints } from 'utils/theme' import { ViewToShow } from './AccountPage' import useAccountPerformanceData from 'hooks/useAccountPerformanceData' import useThemeWrapper from 'hooks/useThemeWrapper' const AccountValue = ({ accountValue, latestAccountData, rollingDailyData, handleViewChange, }: { accountValue: number latestAccountData: PerformanceDataItem[] rollingDailyData: PerformanceDataItem[] handleViewChange: (view: ViewToShow) => void }) => { const { t } = useTranslation('common') const { theme } = useThemeWrapper() const { group } = useMangoGroup() const { mangoAccount, mangoAccountAddress } = useMangoAccount() const [showExpandChart, setShowExpandChart] = useState(false) const [animationSettings] = useLocalStorageState( ANIMATION_SETTINGS_KEY, INITIAL_ANIMATION_SETTINGS, ) const { width } = useViewport() const { performanceLoading: loading } = useAccountPerformanceData() const isMobile = width ? width < breakpoints.md : false const accountValueChange = useMemo(() => { if (!accountValue || !rollingDailyData.length) return 0 const accountValueChange = accountValue - rollingDailyData[0].account_equity return accountValueChange }, [accountValue, rollingDailyData]) const onHoverMenu = (open: boolean, action: string) => { if ( (!open && action === 'onMouseEnter') || (open && action === 'onMouseLeave') ) { setShowExpandChart(!open) } } const handleShowAccountValueChart = () => { handleViewChange('account-value') setShowExpandChart(false) } return (
{animationSettings['number-scroll'] ? ( group && mangoAccount ? ( ) : ( ) ) : ( )}

{t('rolling-change')}

{!loading ? ( rollingDailyData.length ? (
onHoverMenu(showExpandChart, 'onMouseEnter')} onMouseLeave={() => onHoverMenu(showExpandChart, 'onMouseLeave')} > = 0 ? COLORS.UP[theme] : COLORS.DOWN[theme] } data={rollingDailyData.concat(latestAccountData)} name="accountValue" xKey="time" yKey="account_equity" /> handleShowAccountValueChart()} >
) : null ) : mangoAccountAddress ? (
) : null}
) } export default AccountValue