From 939526015d97dc60001013cdcd5b59062be0e54f Mon Sep 17 00:00:00 2001 From: CyferShepard Date: Mon, 14 Oct 2024 23:43:04 +0200 Subject: [PATCH] test code for hiding certain global stats, need to add ui to specify --- .../components/user-info/globalStats.jsx | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/pages/components/user-info/globalStats.jsx b/src/pages/components/user-info/globalStats.jsx index 3e06cbe..e98d137 100644 --- a/src/pages/components/user-info/globalStats.jsx +++ b/src/pages/components/user-info/globalStats.jsx @@ -14,6 +14,10 @@ function GlobalStats(props) { const [allStats, setAllStats] = useState({}); const token = localStorage.getItem("token"); + const [prefs, setPrefs] = useState( + localStorage.getItem("PREF_GLOBAL_STATS") != undefined ? JSON.parse(localStorage.getItem("PREF_GLOBAL_STATS")) : [] + ); + function fetchStats(hours = 24, setMethod = setDayStats) { axios .post( @@ -37,12 +41,12 @@ function GlobalStats(props) { useEffect(() => { const fetchData = async () => { try { - fetchStats(24, setDayStats); - fetchStats(24 * 7, setWeekStats); - fetchStats(24 * 30, setMonthStats); - fetchStats(24 * 180, setd180Stats); - fetchStats(24 * 365, setd365Stats); - fetchStats(24 * 999, setAllStats); + if (!prefs.includes("1")) fetchStats(24, setDayStats); + if (!prefs.includes("7")) fetchStats(24 * 7, setWeekStats); + if (!prefs.includes("30")) fetchStats(24 * 30, setMonthStats); + if (!prefs.includes("180")) fetchStats(24 * 180, setd180Stats); + if (!prefs.includes("365")) fetchStats(24 * 365, setd365Stats); + if (!prefs.includes("ALL")) fetchStats(24 * 999, setAllStats); } catch (error) { console.log(error); } @@ -59,12 +63,12 @@ function GlobalStats(props) {
- } /> - } /> - } /> - } /> - } /> - } /> + {!prefs.includes("1") && } />} + {!prefs.includes("7") && } />} + {!prefs.includes("30") && } />} + {!prefs.includes("180") && } />} + {!prefs.includes("365") && } />} + {!prefs.includes("ALL") && } />}
);