From 9d9273b70211c0c27c6d74b7b4eb9ec351be2042 Mon Sep 17 00:00:00 2001 From: Vincent550102 <5020559@gmail.com> Date: Wed, 6 Mar 2024 22:07:17 +0800 Subject: [PATCH] Update player info pretty show --- src/app/(booth)/booth/page.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/(booth)/booth/page.tsx b/src/app/(booth)/booth/page.tsx index 8ab19c0..3fc05b0 100644 --- a/src/app/(booth)/booth/page.tsx +++ b/src/app/(booth)/booth/page.tsx @@ -7,6 +7,7 @@ import "react-toastify/dist/ReactToastify.css"; import { sendPuzzle2Player } from "@/lib/sendPuzzle2Player"; import { invalidToken, puzzleSuccess, puzzleTaken } from "@/lib/const"; import { getBoothName } from "@/lib/getBoothName"; +import { getPlayerPuzzle } from "@/lib/getPlayerPuzzle"; export default function Page() { const [playerToken, setPlayerToken] = useState(null); const [boothToken, setBoothToken] = useState(""); @@ -25,13 +26,14 @@ export default function Page() { } if (typeof playerToken !== "string") return; const result = await sendPuzzle2Player(playerToken, boothToken); + const playerInfo = await getPlayerPuzzle(playerToken); setPlayerToken(null); if (result === puzzleSuccess) { - toast(`已為 ${playerToken} 增加拼圖`, { type: "success" }); + toast(`已為 ${playerInfo.user_id} 增加拼圖`, { type: "success" }); } else if (result === puzzleTaken) { - toast(`${playerToken} 已存在這張拼圖`, { type: "warning" }); + toast(`${playerInfo.user_id} 已存在這張拼圖`, { type: "warning" }); } else if (result === invalidToken) { - toast(`${playerToken} 尚未報到`, { + toast(`${playerInfo.user_id} 尚未報到`, { type: "error", }); }