diff --git a/app/play/page.tsx b/app/play/page.tsx index 842ed57..b1f1fa5 100644 --- a/app/play/page.tsx +++ b/app/play/page.tsx @@ -14,6 +14,7 @@ import { } from "@/components/ui/card"; import { useEffect, useState } from "react"; import { Skeleton } from "@/components/ui/skeleton"; +import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import { cn } from "@/lib/utils"; import { StarFilledIcon } from "@radix-ui/react-icons"; @@ -24,6 +25,7 @@ export default function PlayPage() { const [resMap, setResMap] = useState(new Map()); const [countMap, setCountMap] = useState(new Map()); + const [filter, setFilter] = useState("all"); useEffect(() => { if (userMapResults && mapCountResults) { @@ -49,11 +51,32 @@ export default function PlayPage() { } }, [userMapResults, mapCountResults]); - if (!maps) { + const filteredMaps = maps?.filter((map) => { + if (filter === "all") return true; + if (filter === "beaten") return resMap.get(map._id); + if (filter === "unbeaten") return !resMap.get(map._id); + return true; + }); + + if (!filteredMaps) { return (

Choose a Night

+ + setFilter(value)} + > + All + Beaten + Unbeaten + + +
{Array.from({ length: 6 }).map((_, index) => ( @@ -67,8 +90,23 @@ export default function PlayPage() {

Choose a Night

+ + setFilter(value)} + > + All + Beaten + Unbeaten + + +
- {maps.map((map) => ( + {filteredMaps.map((map) => ( + Won by {countMap.has(map._id) ? countMap.get(map._id) : 0}{" "} - Players + Player{countMap.get(map._id) !== 1 ? "s" : ""}
@@ -115,7 +153,7 @@ export default function PlayPage() {
Won by {countMap.has(map._id) ? countMap.get(map._id) : 0}{" "} - Players + Player{countMap.get(map._id) !== 1 ? "s" : ""}