feat(web): add multiplayer layout route and landing page
- multiplayer.tsx: layout route wrapping all multiplayer children
with WsProvider, auth guard via beforeLoad
- multiplayer/index.tsx: create/join landing page
- POST /api/v1/lobbies to create, navigates to lobby waiting room
- POST /api/v1/lobbies/:code/join to join, normalizes code to
uppercase before sending
- loading states per action, error display, Enter key on join input
- imports Lobby type from @lila/shared (single source of truth)
This commit is contained in:
parent
9affe339c6
commit
4d4715b4ee
5 changed files with 292 additions and 3 deletions
21
apps/web/src/routes/multiplayer.tsx
Normal file
21
apps/web/src/routes/multiplayer.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
|
||||
import { WsProvider } from "../lib/ws-provider.js";
|
||||
import { authClient } from "../lib/auth-client.js";
|
||||
|
||||
export const Route = createFileRoute("/multiplayer")({
|
||||
component: MultiplayerLayout,
|
||||
beforeLoad: async () => {
|
||||
const { data: session } = await authClient.getSession();
|
||||
if (!session) {
|
||||
throw redirect({ to: "/login" });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
function MultiplayerLayout() {
|
||||
return (
|
||||
<WsProvider>
|
||||
<Outlet />
|
||||
</WsProvider>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue