diff --git a/client/src/components/TestAreaComponent.js b/client/src/components/TestAreaComponent.js new file mode 100644 index 00000000..9ecbb758 --- /dev/null +++ b/client/src/components/TestAreaComponent.js @@ -0,0 +1,38 @@ +import {useContext, useEffect, useState} from "react"; +import Speedtest from "./SpeedtestComponent"; +import {getIconBySpeed} from "../HelperFunctions"; +import {ConfigContext} from "../context/ConfigContext"; + +function TestArea() { + const config = useContext(ConfigContext); + const [tests, setTests] = useState([]); + + useEffect(() => { + let passwordHeaders = localStorage.getItem("password") ? {password: localStorage.getItem("password")} : {} + fetch("/api/speedtests", {headers: passwordHeaders}) + .then(res => res.json()) + .then(tests => setTests(tests)); + }, [setTests]); + + if (Object.entries(config).length === 0) return (<>>) + + return ( +