From 174eb6a13723df2ed76bdc29801846542a480600 Mon Sep 17 00:00:00 2001 From: Steven Zhou Date: Wed, 20 Sep 2023 00:54:18 -0700 Subject: [PATCH] added live stats in about page --- src/components/AboutPage/AboutPage.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/AboutPage/AboutPage.jsx b/src/components/AboutPage/AboutPage.jsx index ba94a3d..f10cfec 100644 --- a/src/components/AboutPage/AboutPage.jsx +++ b/src/components/AboutPage/AboutPage.jsx @@ -15,6 +15,9 @@ export default function AboutPage() { const navigate = useNavigate(); const [screenWidth, setScreenWidth] = useState(window.screen.width); const [data, setData] = useState([]); + const [leaderboard, setLeaderboard] = useState([]); + console.log("leaderboard", leaderboard); + console.log("data", data); window.onresize = () => { setScreenWidth(window.screen.width); @@ -27,9 +30,14 @@ export default function AboutPage() { useEffect(() => { const getData = async () => { axios - .get("http://localhost:3001/items") + .get(`${process.env.REACT_APP_AWS_BACKEND_URL}/items/`) .then((data) => setData(data.data)) .catch((err) => console.log(err)); + + axios + .get(`${process.env.REACT_APP_AWS_BACKEND_URL}/leaderboard/`) + .then((leaderboardData) => setLeaderboard(leaderboardData.data)) + .catch((err) => console.log(err)); }; getData(); }, []); @@ -97,7 +105,7 @@ export default function AboutPage() { - 0 + {data.filter((item) => item.isresolved).length} Successful Returns @@ -105,7 +113,7 @@ export default function AboutPage() { - {data.length} + {leaderboard.length} Active Users