Skip to content

Commit

Permalink
add total # of problems displayed to user
Browse files Browse the repository at this point in the history
  • Loading branch information
uxdxdev committed Nov 29, 2023
1 parent 13328ae commit 20d2677
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ function Home({ day }: { day: number }) {
const [boxes, setBoxes] = useState<Boxes | null>(null);
const [done, setDone] = useState<boolean>(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);
}
}, []);
Expand Down Expand Up @@ -126,7 +132,9 @@ function Home({ day }: { day: number }) {
Try again tomorrow
</button>
</div>
<div className="my-2">Prolems remaining {currentProblemSet?.length || 0}</div>
<div className="my-2">
Problems remaining {currentProblemSet?.length || 0}/{totalNumberOfProblems}
</div>

<div className="text-xs">
Found an issue? report it on{" "}
Expand Down

0 comments on commit 20d2677

Please sign in to comment.