From 21870d7edb430c105ce3d971e77fd97fe9b7a60e Mon Sep 17 00:00:00 2001 From: James Grugett Date: Tue, 6 Sep 2022 23:24:56 -0500 Subject: [PATCH] User page: Move portfolio graph and social stats to new tab --- .../portfolio/portfolio-value-graph.tsx | 11 ++++++--- .../portfolio/portfolio-value-section.tsx | 19 ++++++++++++--- web/components/user-page.tsx | 23 ++++++++++++------- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/web/components/portfolio/portfolio-value-graph.tsx b/web/components/portfolio/portfolio-value-graph.tsx index 61a1ce8b..d8489b47 100644 --- a/web/components/portfolio/portfolio-value-graph.tsx +++ b/web/components/portfolio/portfolio-value-graph.tsx @@ -8,16 +8,21 @@ import { formatTime } from 'web/lib/util/time' export const PortfolioValueGraph = memo(function PortfolioValueGraph(props: { portfolioHistory: PortfolioMetrics[] + mode: 'value' | 'profit' height?: number includeTime?: boolean }) { - const { portfolioHistory, height, includeTime } = props + const { portfolioHistory, height, includeTime, mode } = props const { width } = useWindowSize() const points = portfolioHistory.map((p) => { + const { timestamp, balance, investmentValue, totalDeposits } = p + const value = balance + investmentValue + const profit = value - totalDeposits + return { - x: new Date(p.timestamp), - y: p.balance + p.investmentValue, + x: new Date(timestamp), + y: mode === 'value' ? value : profit, } }) const data = [{ id: 'Value', data: points, color: '#11b981' }] diff --git a/web/components/portfolio/portfolio-value-section.tsx b/web/components/portfolio/portfolio-value-section.tsx index ab4bef0c..a7bce6bf 100644 --- a/web/components/portfolio/portfolio-value-section.tsx +++ b/web/components/portfolio/portfolio-value-section.tsx @@ -5,6 +5,7 @@ import { usePortfolioHistory } from 'web/hooks/use-portfolio-history' import { Period } from 'web/lib/firebase/users' import { Col } from '../layout/col' import { Row } from '../layout/row' +import { Spacer } from '../layout/spacer' import { PortfolioValueGraph } from './portfolio-value-graph' export const PortfolioValueSection = memo( @@ -24,15 +25,16 @@ export const PortfolioValueSection = memo( return <> } - const { balance, investmentValue } = lastPortfolioMetrics + const { balance, investmentValue, totalDeposits } = lastPortfolioMetrics const totalValue = balance + investmentValue + const totalProfit = totalValue - totalDeposits return ( <> -
Portfolio value
-
{formatMoney(totalValue)}
+
Profit
+
{formatMoney(totalProfit)}