Skip to content

Commit

Permalink
Update player info pretty show
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent550102 committed Mar 6, 2024
1 parent fbeb325 commit 9d9273b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/(booth)/booth/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | null>(null);
const [boothToken, setBoothToken] = useState("");
Expand All @@ -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",
});
}
Expand Down

0 comments on commit 9d9273b

Please sign in to comment.