From 20d267799038166c935533b838c2da4939534bac Mon Sep 17 00:00:00 2001 From: David Morton Date: Wed, 29 Nov 2023 13:34:34 +0000 Subject: [PATCH] add total # of problems displayed to user --- src/pages/Home.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index c3cff93..6737c31 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -17,12 +17,18 @@ function Home({ day }: { day: number }) { const [boxes, setBoxes] = useState(null); const [done, setDone] = useState(false); const [isLoading, setIsLoading] = useState(true); + const [totalNumberOfProblems, setTotalNumberOfProblems] = useState(0); // init useEffect(() => { const storedData = LocalStorage.getData(); if (storedData) { setBoxes(storedData.boxes); + setTotalNumberOfProblems( + Object.values(storedData.boxes) + .map((arr) => arr.length) + .reduce((acc, cur) => acc + cur, 0) + ); setDone(storedData.done); } }, []); @@ -126,7 +132,9 @@ function Home({ day }: { day: number }) { Try again tomorrow -
Prolems remaining {currentProblemSet?.length || 0}
+
+ Problems remaining {currentProblemSet?.length || 0}/{totalNumberOfProblems} +
Found an issue? report it on{" "}