diff --git a/apps/client/src/app.tsx b/apps/client/src/app.tsx index e4393d1..df5cec0 100644 --- a/apps/client/src/app.tsx +++ b/apps/client/src/app.tsx @@ -24,7 +24,7 @@ // レンダリング分岐 if (gameState === "title") { - return socketClient.joinRoom(roomId, playerName)} />; + return socketClient.joinRoom(payload.roomId, payload.playerName)} />; } if (gameState === "lobby") { diff --git a/apps/client/src/scenes/TitleScene.tsx b/apps/client/src/scenes/TitleScene.tsx index a559685..1c8e8b0 100644 --- a/apps/client/src/scenes/TitleScene.tsx +++ b/apps/client/src/scenes/TitleScene.tsx @@ -1,13 +1,25 @@ import { useState } from "react"; +// sharedからのインポート(パスは環境に合わせて調整してください) +import type { JoinRoomPayload } from "@repo/shared/src/types/room"; type Props = { - onJoin: (roomId: string, playerName: string) => void; + // バラバラの引数から、共通のペイロード型に変更 + onJoin: (payload: JoinRoomPayload) => void; }; export const TitleScene = ({ onJoin }: Props) => { const [playerName, setPlayerName] = useState(""); const [roomIdInput, setRoomIdInput] = useState(""); + // 元の条件を維持(両方入力されていればOK) + const canJoin = playerName !== "" && roomIdInput !== ""; + + const handleJoin = () => { + if (canJoin) { + onJoin({ roomId: roomIdInput, playerName }); + } + }; + return (

Pixel Paint War

@@ -28,13 +40,13 @@