From 79cf63694077d0835a62b9833d31f3c263cdccd9 Mon Sep 17 00:00:00 2001 From: Michael Foiani Date: Fri, 16 Apr 2021 18:55:40 -0400 Subject: Working version without the feature to see data on a certain ceo. --- maps-frontend/src/components/Hub.js | 2 +- maps-frontend/src/components/HubList.js | 13 ++++++++----- maps-frontend/src/components/InvestorInfo.js | 21 +++++++++++---------- maps-frontend/src/components/Visualization.js | 2 +- 4 files changed, 21 insertions(+), 17 deletions(-) (limited to 'maps-frontend/src') diff --git a/maps-frontend/src/components/Hub.js b/maps-frontend/src/components/Hub.js index b5b3f28..8a3ac1c 100644 --- a/maps-frontend/src/components/Hub.js +++ b/maps-frontend/src/components/Hub.js @@ -15,7 +15,7 @@ function Hub(props) { return (
  • - props.setSelected(props.id)}>{props.name} + console.log(props.id)}>{props.name} {props.value.toFixed(3)}
  • ); diff --git a/maps-frontend/src/components/HubList.js b/maps-frontend/src/components/HubList.js index d046e94..f5b1414 100644 --- a/maps-frontend/src/components/HubList.js +++ b/maps-frontend/src/components/HubList.js @@ -14,6 +14,7 @@ import '../css/UserCheckin.css'; function HubList(props) { const [hubItems, setHubItems] = useState([]); const [isSelected, setIsSelected] = useState(false); + const [name, setName] = useState(''); /** * Loads new the checkins into the current cache/map of hubs. @@ -30,20 +31,22 @@ function HubList(props) { } const getName = () => { - console.log(props.selected); props.data.forEach(hub => { if (hub.id == props.selected) { - return hub.name; + setName(hub.name); } }) - return ''; + setName(''); } // React hook that updates when the hubs are recalculated useEffect(() => updateHubItems(), [props.data]); //React hook to show data for an investor - useEffect(() => setIsSelected(true), [props.selected]); + useEffect(() => { + setIsSelected(true) + getName(); + }, [props.selected]); return (
    @@ -51,7 +54,7 @@ function HubList(props) {

    Suspicion Ranks

    - + ); } diff --git a/maps-frontend/src/components/InvestorInfo.js b/maps-frontend/src/components/InvestorInfo.js index 24994d0..d368984 100644 --- a/maps-frontend/src/components/InvestorInfo.js +++ b/maps-frontend/src/components/InvestorInfo.js @@ -14,15 +14,16 @@ function InvestorInfo(props) { const toEpochMilli = date => Date.parse(date); const getInfo = () => { - if (props.name === "") { - return; - } - console.log({ person: props.name, start: toEpochMilli(props.dates.start), end: toEpochMilli(props.dates.end) }); + + if (props.name === "") { + return; + } + fetch("http://localhost:4567/profit", { method: "POST", body: JSON.stringify({ @@ -53,13 +54,13 @@ function InvestorInfo(props) { );*/ - useEffect(() => getInfo(), [props.name]) + useEffect(() => getInfo(), [props.name, props.isSelected, props.personId]) -return ( -
    - hi -
    -); + return ( + + ); } export default InvestorInfo; \ No newline at end of file diff --git a/maps-frontend/src/components/Visualization.js b/maps-frontend/src/components/Visualization.js index c0e5811..91082e9 100644 --- a/maps-frontend/src/components/Visualization.js +++ b/maps-frontend/src/components/Visualization.js @@ -51,7 +51,7 @@ function Visualization(props) { } // Hooks to update graph state - useEffect(() => setGraphState({nodes: getNodes(), edges: getEdges()}), [props.data]); + useEffect(() => setGraphState({nodes: getNodes(), edges: getEdges()}), [JSON.stringify(props.data)]); return (
    -- cgit v1.2.3-70-g09d2