From 74bb21180cdb8345988f6807424a5db368280165 Mon Sep 17 00:00:00 2001 From: ingawei Date: Mon, 26 Sep 2022 13:02:27 -0700 Subject: [PATCH] fixing props function things --- web/components/portfolio/portfolio-value-graph.tsx | 11 +++++------ web/components/portfolio/portfolio-value-section.tsx | 6 ++++-- web/components/user-page.tsx | 7 +++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/web/components/portfolio/portfolio-value-graph.tsx b/web/components/portfolio/portfolio-value-graph.tsx index 38a6dbf3..8ce9a8f0 100644 --- a/web/components/portfolio/portfolio-value-graph.tsx +++ b/web/components/portfolio/portfolio-value-graph.tsx @@ -63,16 +63,15 @@ export const PortfolioValueGraph = memo(function PortfolioValueGraph(props: { }, ] } - const firstPoints = data[0].data - // const numYTickValues = !width || width < 800 ? 2 : 4 + let firstPoints = data[0].data const numYTickValues = 2 - const endDate = last(firstPoints)?.x + const endDate = last(data[0].data)?.x const firstPointsY = firstPoints - .filter((p) => { - return p.y !== null - }) .map((p) => p.y) + .filter((y) => { + return y !== null + }) const yMin = mode === 'value' diff --git a/web/components/portfolio/portfolio-value-section.tsx b/web/components/portfolio/portfolio-value-section.tsx index 6f8f07f1..a23b3c83 100644 --- a/web/components/portfolio/portfolio-value-section.tsx +++ b/web/components/portfolio/portfolio-value-section.tsx @@ -7,7 +7,6 @@ import { Period } from 'web/lib/firebase/users' import { PillButton } from '../buttons/pill-button' 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( @@ -18,6 +17,9 @@ export const PortfolioValueSection = memo( const portfolioHistory = usePortfolioHistory(userId, portfolioPeriod) const [graphMode, setGraphMode] = useState<'profit' | 'value'>('value') const [graphDisplayNumber, setGraphDisplayNumber] = useState(null) + const handleGraphDisplayChange = (num) => { + setGraphDisplayNumber(num) + } // Remember the last defined portfolio history. const portfolioRef = useRef(portfolioHistory) @@ -94,7 +96,7 @@ export const PortfolioValueSection = memo( portfolioHistory={currPortfolioHistory} includeTime={true} mode={graphMode} - setGraphDisplayNumber={setGraphDisplayNumber} + setGraphDisplayNumber={handleGraphDisplayChange} /> } {!isMobile && ( - + )} @@ -132,7 +135,7 @@ export function UserPage(props: { user: User }) { {user.bio && ( <> -
+