From afa043b0fc9f5e2d542e6707e955fd7fc48ea477 Mon Sep 17 00:00:00 2001 From: Peter Bull Hove Date: Thu, 4 Apr 2024 09:26:05 +0200 Subject: [PATCH] refactor: move logic up out of single-use components --- .../Components/Bridging/BridgeContainer.tsx | 18 ++++++++++---- .../Bridging/Graphs/CumulativeGraph.tsx | 24 ------------------- .../Bridging/Graphs/DistributionGraph.tsx | 18 -------------- 3 files changed, 14 insertions(+), 46 deletions(-) delete mode 100644 web/src/Components/Bridging/Graphs/CumulativeGraph.tsx delete mode 100644 web/src/Components/Bridging/Graphs/DistributionGraph.tsx diff --git a/web/src/Components/Bridging/BridgeContainer.tsx b/web/src/Components/Bridging/BridgeContainer.tsx index b9f3cc6..276c405 100644 --- a/web/src/Components/Bridging/BridgeContainer.tsx +++ b/web/src/Components/Bridging/BridgeContainer.tsx @@ -5,9 +5,9 @@ import { AuthContext } from 'react-oauth2-code-pkce' import { ErrorToast } from '../Common/Toast' import InputContainer from './InputContainer' import { findGraphData } from '../../Utils' -import CumulativeGraph from './Graphs/CumulativeGraph' -import DistributionGraph from './Graphs/DistributionGraph' import { Bridge } from '../../Types' +import BridgeGraph from './Graphs/BridgeGraph' +import { differentiateArrayObjects } from './utils' type BridgeContainerProps = { bridges: Bridge @@ -96,8 +96,18 @@ export default ({ bridges, mode, setMode, bridgeValue, setValue }: BridgeContain borderRadius: '0.5rem', }} > - - + + { - const newGraphData = findGraphData(sizeFractions, bridges) - setGraphData(newGraphData) - }, [bridges, sizeFractions]) - - return ( - - ) -} - -export default CumulativeGraph diff --git a/web/src/Components/Bridging/Graphs/DistributionGraph.tsx b/web/src/Components/Bridging/Graphs/DistributionGraph.tsx deleted file mode 100644 index 6109d77..0000000 --- a/web/src/Components/Bridging/Graphs/DistributionGraph.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { useEffect, useState } from 'react' -import { findGraphData } from '../../../Utils' -import { differentiateArrayObjects } from '../utils' -import BridgeGraph from './BridgeGraph' - -export function ParticleSizeDistributionGraph({ bridges, sizeFractions }) { - const [graphData, setGraphData] = useState([]) - - useEffect(() => { - const newGraphData = findGraphData(sizeFractions, bridges) - const diffentiated = differentiateArrayObjects(newGraphData) - setGraphData(diffentiated) - }, [bridges, sizeFractions]) - - return -} - -export default ParticleSizeDistributionGraph