diff --git a/src/app/(game)/scanner/page.tsx b/src/app/(game)/scanner/page.tsx index 1d5e4fc..143d486 100644 --- a/src/app/(game)/scanner/page.tsx +++ b/src/app/(game)/scanner/page.tsx @@ -7,12 +7,36 @@ import { getBoothToken } from "@/lib/getBoothToken"; import { sendPuzzle2Player } from "@/lib/sendPuzzle2Player"; import { useReadLocalStorage } from "usehooks-ts"; import { invalidToken, puzzleSuccess, puzzleTaken } from "@/lib/const"; +import { getPlayerPuzzle } from "@/lib/getPlayerPuzzle"; export default function Page() { + const playerToken: string | null = useReadLocalStorage("token"); + const [taken, setTaken] = useState(false); + + useEffect(() => { + if (!playerToken) return; + getPlayerPuzzle(playerToken) + .then((player) => { + if (typeof player.coupon === "number") setTaken(true); + }) + .catch(console.error); + }, [playerToken]); + + if (taken) { + return ( +