From d37e4f1f4e7e6bb26ed83b81821b6a4df09a3b24 Mon Sep 17 00:00:00 2001 From: clarkohw Date: Tue, 20 Apr 2021 10:51:04 -0400 Subject: added link, gain --- react-frontend/src/components/InvestorInfo.js | 107 +++++++++++++++++--------- 1 file changed, 72 insertions(+), 35 deletions(-) (limited to 'react-frontend/src/components/InvestorInfo.js') diff --git a/react-frontend/src/components/InvestorInfo.js b/react-frontend/src/components/InvestorInfo.js index 3a3a11f..436fa17 100644 --- a/react-frontend/src/components/InvestorInfo.js +++ b/react-frontend/src/components/InvestorInfo.js @@ -14,8 +14,10 @@ import uuid from "react-uuid"; function InvestorInfo(props) { const [info, setInfo] = useState({ percentGain: 0, + moneyIn: 0, + moneyOut: 0, percentSP500: 0, - holdings: [] + holdings: [], }); const [showStocks, setShowStocks] = useState(false); @@ -26,7 +28,7 @@ function InvestorInfo(props) { return; } - const toEpochMilli = date => Date.parse(date); + const toEpochMilli = (date) => Date.parse(date); console.log({ selectedId: props.selectedId, @@ -46,37 +48,42 @@ function InvestorInfo(props) { }, credentials: "same-origin", }) - .then(res => res.json()) - .then(data => { - console.log(data); - setInfo(data); - props.setShowSelectedInfo(true); - }) - .catch(err => console.log(err)); + .then((res) => res.json()) + .then((data) => { + console.log(data); + setInfo(data); + props.setShowSelectedInfo(true); + }) + .catch((err) => console.log(err)); }; const stockTable = () => { return ( <> -
  • -
    -
    Symbol
    -
    Realized gain
    -
    Unrealized gain
    -
    -
  • - {info.holdings.map(holding => -
  • -
    {holding.ticker}
    -
    {holding.realizedGain.toFixed(3)}
    -
    {holding.unrealizedGain.toFixed(3)}
    -
  • )} +
  • +
    +
    Symbol
    +
    Realized gain
    +
    Unrealized gain
    +
    +
  • + {info.holdings.map((holding) => ( +
  • +
    {holding.ticker}
    +
    {holding.realizedGain.toFixed(3)}
    +
    {holding.unrealizedGain.toFixed(3)}
    +
  • + ))} ); }; - const followerList = () => - props.followers.map(follower =>
  • props.setSelectedId(follower.id)}>{follower.name}
  • ); + const followerList = () => + props.followers.map((follower) => ( +
  • props.setSelectedId(follower.id)}> + {follower.name} +
  • + )); // Hook that updates when selected has changed useEffect(() => getInfo(), [props.selectedId]); @@ -84,15 +91,20 @@ function InvestorInfo(props) { return (