diff --git a/app/play/[level]/page.tsx b/app/play/[level]/page.tsx index 0341094..cdb183f 100644 --- a/app/play/[level]/page.tsx +++ b/app/play/[level]/page.tsx @@ -10,6 +10,7 @@ import Link from "next/link"; import { ChevronLeftIcon } from "@radix-ui/react-icons"; import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import TestMode from "./test-mode"; +import { useRouter } from "next/navigation"; export default function PlayLevelPage({ params, @@ -42,6 +43,9 @@ export default function PlayLevelPage({ mapId: map?._id, }); + const lastLevel = useQuery(api.maps.lastLevel); + const router = useRouter(); + if (!map) { return (
@@ -242,9 +246,27 @@ export default function PlayLevelPage({ ) : ( - +
+ + {gameResult && gameResult === "WON" ? ( + + ) : null} +
)}
diff --git a/convex/maps.ts b/convex/maps.ts index 199d982..4fbc4d3 100644 --- a/convex/maps.ts +++ b/convex/maps.ts @@ -363,3 +363,14 @@ export const testAIModel = action({ }; }, }); + +export const lastLevel = query({ + handler: async (ctx) => { + const lastMap = await ctx.db + .query("maps") + .withIndex("by_level") + .order("desc") + .first(); + return lastMap?.level ?? 0; + }, +});