import { PortfolioMetrics } from 'common/user' import { formatMoney } from 'common/util/format' import { last } from 'lodash' import { memo, useState } from 'react' import { Period } from 'web/lib/firebase/users' import { Col } from '../layout/col' import { Row } from '../layout/row' import { PortfolioValueGraph } from './portfolio-value-graph' export const PortfolioValueSection = memo( function PortfolioValueSection(props: { portfolioHistory: PortfolioMetrics[] }) { const { portfolioHistory } = props const lastPortfolioMetrics = last(portfolioHistory) const [portfolioPeriod, setPortfolioPeriod] = useState('allTime') if (portfolioHistory.length === 0 || !lastPortfolioMetrics) { return
No portfolio history data yet
} return (
Portfolio value
{formatMoney( lastPortfolioMetrics.balance + lastPortfolioMetrics.investmentValue )}
) } )